[Home] [Help]
PACKAGE BODY: APPS.OKL_ASD_PVT
Source
1 PACKAGE BODY OKL_ASD_PVT AS
2 /* $Header: OKLSASDB.pls 115.13 2004/05/20 22:07:28 avsingh noship $ */
3 -- Badrinath Kuchibholta
4 /************************ HAND-CODED *********************************/
5 G_TABLE_TOKEN CONSTANT VARCHAR2(200) := OKC_API.G_CHILD_TABLE_TOKEN;
6 G_UNEXPECTED_ERROR CONSTANT VARCHAR2(200) := 'OKC_CONTRACTS_UNEXPECTED_ERROR';
7 G_SQLERRM_TOKEN CONSTANT VARCHAR2(200) := 'SQLerrm';
8 G_SQLCODE_TOKEN CONSTANT VARCHAR2(200) := 'SQLcode';
9 G_EXCEPTION_HALT_VALIDATION EXCEPTION;
10 G_EXCEPTION_STOP_VALIDATION EXCEPTION;
11 G_REQUIRED_VALUE CONSTANT VARCHAR2(200) := 'OKL_REQUIRED_VALUE';
12 G_INVALID_VALUE CONSTANT VARCHAR2(200) := 'OKL_INVALID_VALUE';
13 G_NO_MATCHING_RECORD CONSTANT VARCHAR2(200) := 'OKL_LLA_NO_MATCHING_RECORD';
14 -- List validation procedures for quick reference
15 --1. validate_tal_id -- Attribute Validation
16 --2. validate_asset_number -- Attribute Validation
17 --3. validate_quantity -- Attribute Validation
18 --4. validate_life_in_months_tax -- Attribute Validation
19 --5. validate_target_kle_id -- Attribute Validation
20 --7. Validate_INVENTORY_ITEM_ID -- Attribute Validation
21 --6. validate_qcs -- Tuple Record Validation
22 ----------------------------------7---------------------------------------------
23 -- Start of Commnets
24 -- chenkuang.lee
25 -- Procedure Name : Validate_INVENTORY_ITEM_ID
26 -- Description : FK validation with okx_system_items_v
27 -- Business Rules :
28 -- Parameters : OUT Return Status, IN Rec Info
29 -- Version : 1.0
30 -- End of Commnets
31
32 PROCEDURE Validate_INVENTORY_ITEM_ID(x_return_status OUT NOCOPY VARCHAR2,
33 p_asdv_rec IN asdv_rec_type) IS
34 ln_dummy number := 0;
35 CURSOR c_INVENTORY_ITEM_ID_validate(p_id number) is
36 SELECT 1
37 FROM okx_system_items_v
38 WHERE id1 = p_id;
39 --AND ID2=OKL_CONTEXT.get_okc_organization_id; -- multi-org enable
40
41 BEGIN
42 -- initialize return status
43 x_return_status := OKC_API.G_RET_STS_SUCCESS;
44 -- data is not required
45 IF (p_asdv_rec.INVENTORY_ITEM_ID <> OKC_API.G_MISS_NUM) AND
46 (p_asdv_rec.INVENTORY_ITEM_ID IS NOT NULL) THEN
47
48 -- Enforce Foreign Key
49 OPEN c_INVENTORY_ITEM_ID_validate(p_asdv_rec.INVENTORY_ITEM_ID);
50 FETCH c_INVENTORY_ITEM_ID_validate into ln_dummy;
51 CLOSE c_INVENTORY_ITEM_ID_validate;
52 IF (ln_dummy = 0) then
53 -- halt validation as it has no parent record
54 RAISE G_EXCEPTION_HALT_VALIDATION;
55 END IF;
56
57 END IF;
58
59 EXCEPTION
60 WHEN G_EXCEPTION_STOP_VALIDATION then
61 OKC_API.set_message(p_app_name => G_APP_NAME,
62 p_msg_name => G_REQUIRED_VALUE,
63 p_token1 => G_COL_NAME_TOKEN,
64 p_token1_value => 'INVENTORY_ITEM_ID');
65 -- Notify Error
66 x_return_status := OKC_API.G_RET_STS_ERROR;
67 WHEN G_EXCEPTION_HALT_VALIDATION then
68 -- We are here b'cause we have no parent record
69 -- store SQL error message on message stack
70 OKC_API.set_message(p_app_name => G_APP_NAME,
71 p_msg_name => G_NO_MATCHING_RECORD,
72 p_token1 => G_COL_NAME_TOKEN,
73 p_token1_value => 'INVENTORY_ITEM_ID');
74 -- If the cursor is open then it has to be closed
75 IF c_INVENTORY_ITEM_ID_validate%ISOPEN THEN
76 CLOSE c_INVENTORY_ITEM_ID_validate;
77 END IF;
78 -- notify caller of an error
79 x_return_status := OKC_API.G_RET_STS_ERROR;
80 WHEN OTHERS THEN
81 -- store SQL error message on message stack
82 OKC_API.SET_MESSAGE(p_app_name => G_APP_NAME,
83 p_msg_name => G_UNEXPECTED_ERROR,
84 p_token1 => G_SQLCODE_TOKEN,
85 p_token1_value => SQLCODE,
86 p_token2 => G_SQLERRM_TOKEN,
87 p_token2_value => SQLERRM);
88 -- If the cursor is open then it has to be closed
89 IF c_INVENTORY_ITEM_ID_validate%ISOPEN THEN
90 CLOSE c_INVENTORY_ITEM_ID_validate;
91 END IF;
92 -- notify caller of an error as UNEXPETED error
93 x_return_status := OKC_API.G_RET_STS_UNEXP_ERROR;
94 END Validate_INVENTORY_ITEM_ID;
95
96 --------------------------------------1-----------------------------------------
97 -- Start of Commnets
98 -- Badrinath Kuchibholta
99 -- Procedure Name : Validate_Tal_Id
100 -- Description : FK validation with OKL_TRX_ASSET_LINES_B
101 -- Business Rules :
102 -- Parameters : OUT Return Status, IN Rec Info
103 -- Version : 1.0
104 -- End of Commnets
105
106 PROCEDURE validate_tal_id(x_return_status OUT NOCOPY VARCHAR2,
107 p_asdv_rec IN asdv_rec_type) IS
108 ln_dummy number := 0;
109 CURSOR c_tal_id_validate(p_id number) is
110 SELECT 1
111 FROM DUAL
112 WHERE EXISTS (SELECT '1'
113 FROM OKL_TXL_ASSETS_V
114 WHERE id = p_id);
115
116 BEGIN
117 -- initialize return status
118 x_return_status := OKC_API.G_RET_STS_SUCCESS;
119 -- data is required
120 IF (p_asdv_rec.tal_id = OKC_API.G_MISS_NUM) OR
121 (p_asdv_rec.tal_id IS NULL) THEN
122 -- halt validation as it is a required field
123 RAISE G_EXCEPTION_STOP_VALIDATION;
124 END IF;
125 -- Enforce Foreign Key
126 OPEN c_tal_id_validate(p_asdv_rec.tal_id);
127 IF c_tal_id_validate%NOTFOUND THEN
128 -- halt validation as it has no parent record
129 RAISE G_EXCEPTION_HALT_VALIDATION;
130 END IF;
131 FETCH c_tal_id_validate into ln_dummy;
132 CLOSE c_tal_id_validate;
133 IF (ln_dummy = 0) then
134 -- halt validation as it has no parent record
135 RAISE G_EXCEPTION_HALT_VALIDATION;
136 END IF;
137 EXCEPTION
138 WHEN G_EXCEPTION_STOP_VALIDATION then
139 -- We are here since the field is required
140 -- store SQL error message on message stack
141 OKC_API.set_message(p_app_name => G_APP_NAME,
142 p_msg_name => G_REQUIRED_VALUE,
143 p_token1 => G_COL_NAME_TOKEN,
144 p_token1_value => 'tal_id');
145 -- Notify Error
146 x_return_status := OKC_API.G_RET_STS_ERROR;
147 WHEN G_EXCEPTION_HALT_VALIDATION then
148 -- We are here b'cause we have no parent record
149 -- store SQL error message on message stack
150 OKC_API.set_message(p_app_name => G_APP_NAME,
151 p_msg_name => G_NO_MATCHING_RECORD,
152 p_token1 => G_COL_NAME_TOKEN,
153 p_token1_value => 'tal_id');
154 -- If the cursor is open then it has to be closed
155 IF c_tal_id_validate%ISOPEN THEN
156 CLOSE c_tal_id_validate;
157 END IF;
158 -- notify caller of an error
159 x_return_status := OKC_API.G_RET_STS_ERROR;
160 WHEN OTHERS THEN
161 -- store SQL error message on message stack
162 OKC_API.SET_MESSAGE(p_app_name => G_APP_NAME,
163 p_msg_name => G_UNEXPECTED_ERROR,
164 p_token1 => G_SQLCODE_TOKEN,
165 p_token1_value => SQLCODE,
166 p_token2 => G_SQLERRM_TOKEN,
167 p_token2_value => SQLERRM);
168 -- If the cursor is open then it has to be closed
169 IF c_tal_id_validate%ISOPEN THEN
170 CLOSE c_tal_id_validate;
171 END IF;
172 -- notify caller of an error as UNEXPETED error
173 x_return_status := OKC_API.G_RET_STS_UNEXP_ERROR;
174 END validate_tal_id;
175 ------------------------------------3--------------------------------------------
176 -- Start of Commnets
177 -- Badrinath Kuchibholta
178 -- Procedure Name : Validate_quantity
179 -- Description : See that is more than 0
180 -- Business Rules :
181 -- Parameters : OUT Return Status, IN Rec Info
182 -- Version : 1.0
183 -- End of Commnets
184
185 PROCEDURE validate_quantity(x_return_status OUT NOCOPY VARCHAR2,
186 p_asdv_rec IN asdv_rec_type) IS
187
188 BEGIN
189 -- initialize return status
190 x_return_status := OKC_API.G_RET_STS_SUCCESS;
191 -- data is required
192 IF (p_asdv_rec.quantity = OKC_API.G_MISS_NUM) OR
193 (p_asdv_rec.quantity IS NULL) THEN
194 -- halt validation as it is a required field
195 RAISE G_EXCEPTION_STOP_VALIDATION;
196 END IF;
197 -- See that is more than 0
198 IF p_asdv_rec.quantity <= 0 THEN
199 -- halt validation
200 RAISE G_EXCEPTION_HALT_VALIDATION;
201 END IF;
202 EXCEPTION
203 WHEN G_EXCEPTION_STOP_VALIDATION then
204 -- We are here since the field is optional
205 null;
206 WHEN G_EXCEPTION_HALT_VALIDATION then
207 -- We are here b'cause not greater than zero
208 -- store SQL error message on message stack
209 OKC_API.set_message(p_app_name => G_APP_NAME,
210 p_msg_name => G_INVALID_VALUE,
211 p_token1 => G_COL_NAME_TOKEN,
212 p_token1_value => 'quantity');
213 -- notify caller of an error
214 x_return_status := OKC_API.G_RET_STS_ERROR;
215 WHEN OTHERS THEN
216 -- store SQL error message on message stack
217 OKC_API.SET_MESSAGE(p_app_name => G_APP_NAME,
218 p_msg_name => G_UNEXPECTED_ERROR,
219 p_token1 => G_SQLCODE_TOKEN,
220 p_token1_value => SQLCODE,
221 p_token2 => G_SQLERRM_TOKEN,
222 p_token2_value => SQLERRM);
223 -- notify caller of an error as UNEXPETED error
224 x_return_status := OKC_API.G_RET_STS_UNEXP_ERROR;
225 END validate_quantity;
226
227 -------------------------------------4-------------------------------------------
228 -- Start of Commnets
229 -- Badrinath Kuchibholta
230 -- Procedure Name : Validate_life_in_months_tax
231 -- Description : See that is more than 0
232 -- Business Rules :
233 -- Parameters : OUT Return Status, IN Rec Info
234 -- Version : 1.0
235 -- End of Commnets
236
237 PROCEDURE validate_life_in_months_tax(x_return_status OUT NOCOPY VARCHAR2,
238 p_asdv_rec IN asdv_rec_type) IS
239 BEGIN
240 -- initialize return status
241 x_return_status := OKC_API.G_RET_STS_SUCCESS;
242 -- data is required
243 IF (p_asdv_rec.life_in_months_tax = OKC_API.G_MISS_NUM) OR
244 (p_asdv_rec.life_in_months_tax IS NULL) THEN
245 -- halt validation as it is a required field
246 RAISE G_EXCEPTION_STOP_VALIDATION;
247 END IF;
248 -- See that is more than 0
249 IF p_asdv_rec.life_in_months_tax <= 0 THEN
250 -- halt validation
251 RAISE G_EXCEPTION_HALT_VALIDATION;
252 END IF;
253 EXCEPTION
254 WHEN G_EXCEPTION_STOP_VALIDATION then
255 -- We are here since the field is optional
256 null;
257 WHEN G_EXCEPTION_HALT_VALIDATION then
258 -- We are here b'cause not greater than zero
259 -- store SQL error message on message stack
260 OKC_API.set_message(p_app_name => G_APP_NAME,
261 p_msg_name => G_INVALID_VALUE,
262 p_token1 => G_COL_NAME_TOKEN,
263 p_token1_value => 'life_in_months_tax');
264 -- notify caller of an error
265 x_return_status := OKC_API.G_RET_STS_ERROR;
266 WHEN OTHERS THEN
267 -- store SQL error message on message stack
268 OKC_API.SET_MESSAGE(p_app_name => G_APP_NAME,
269 p_msg_name => G_UNEXPECTED_ERROR,
270 p_token1 => G_SQLCODE_TOKEN,
271 p_token1_value => SQLCODE,
272 p_token2 => G_SQLERRM_TOKEN,
273 p_token2_value => SQLERRM);
274 -- notify caller of an error as UNEXPETED error
275 x_return_status := OKC_API.G_RET_STS_UNEXP_ERROR;
276 END validate_life_in_months_tax;
277 --------------------------------------5-------------------------------------------
278 -- Start of Commnets
279 -- Badrinath Kuchibholta
280 -- Procedure Name : Validate_target_kle_id
281 -- Description : FK validation with OKL_K_LINES_V
282 -- Business Rules :
283 -- Parameters : OUT Return Status, IN Rec Info
284 -- Version : 1.0
285 -- End of Commnets
286
287 PROCEDURE validate_target_kle_id(x_return_status OUT NOCOPY VARCHAR2,
288 p_asdv_rec IN asdv_rec_type) IS
289 ln_dummy number := 0;
290 CURSOR c_target_kle_id_validate(p_id OKL_TXD_ASSETS_V.TARGET_KLE_ID%TYPE) is
291 SELECT 1
292 FROM DUAL
293 WHERE EXISTS (SELECT '1'
294 FROM OKL_K_LINES_V kle
295 WHERE kle.id = p_id);
296
297 BEGIN
298 -- initialize return status
299 x_return_status := OKC_API.G_RET_STS_SUCCESS;
300 -- data is required
301 IF (p_asdv_rec.target_kle_id = OKC_API.G_MISS_NUM) OR
302 (p_asdv_rec.target_kle_id IS NULL) THEN
303 -- halt validation as it is a required field
304 RAISE G_EXCEPTION_STOP_VALIDATION;
305 END IF;
306 -- Enforce Foreign Key
307 OPEN c_target_kle_id_validate(p_asdv_rec.target_kle_id);
308 IF c_target_kle_id_validate%NOTFOUND THEN
309 -- halt validation as it has no parent record
310 RAISE G_EXCEPTION_HALT_VALIDATION;
311 END IF;
312 FETCH c_target_kle_id_validate into ln_dummy;
313 CLOSE c_target_kle_id_validate;
314 IF (ln_dummy = 0) then
315 -- halt validation as it has no parent record
316 RAISE G_EXCEPTION_HALT_VALIDATION;
317 END IF;
318 EXCEPTION
319 WHEN G_EXCEPTION_STOP_VALIDATION then
320 -- We are here since the field is optional
321 null;
322 WHEN G_EXCEPTION_HALT_VALIDATION then
323 -- We are here b'cause we have no parent record
324 -- store SQL error message on message stack
325 OKC_API.set_message(p_app_name => G_APP_NAME,
326 p_msg_name => G_NO_MATCHING_RECORD,
327 p_token1 => G_COL_NAME_TOKEN,
328 p_token1_value => 'target_kle_id');
329 -- If the cursor is open then it has to be closed
330 IF c_target_kle_id_validate%ISOPEN THEN
331 CLOSE c_target_kle_id_validate;
332 END IF;
333 -- notify caller of an error
334 x_return_status := OKC_API.G_RET_STS_ERROR;
335 WHEN OTHERS THEN
336 -- store SQL error message on message stack
337 OKC_API.SET_MESSAGE(p_app_name => G_APP_NAME,
338 p_msg_name => G_UNEXPECTED_ERROR,
339 p_token1 => G_SQLCODE_TOKEN,
340 p_token1_value => SQLCODE,
341 p_token2 => G_SQLERRM_TOKEN,
342 p_token2_value => SQLERRM);
343 -- If the cursor is open then it has to be closed
344 IF c_target_kle_id_validate%ISOPEN THEN
345 CLOSE c_target_kle_id_validate;
346 END IF;
347 -- notify caller of an error as UNEXPETED error
348 x_return_status := OKC_API.G_RET_STS_UNEXP_ERROR;
349 END validate_target_kle_id;
350 ------------------------------19----------------------------------------------
351 -- Start of Commnets
352 -- Badrinath Kuchibholta
353 -- Procedure Name : validate_tax_book
354 -- Description : FK validation with OKX_ASST_BK_CONTROLS_V
355 -- Business Rules :
356 -- Parameters : OUT Return Status, IN Rec Info
357 -- Version : 1.0
358 -- End of Commnets
359
360 PROCEDURE validate_tax_book(x_return_status OUT NOCOPY VARCHAR2,
361 p_asdv_rec IN asdv_rec_type) IS
362
363 ln_dummy number := 0;
364 CURSOR c_tax_book_validate(p_name OKX_ASST_BK_CONTROLS_V.NAME%TYPE) is
365 SELECT 1
366 FROM DUAL
367 WHERE EXISTS (SELECT id1
368 FROM OKX_ASST_BK_CONTROLS_V
369 WHERE name = p_name
370 AND book_class = 'TAX');
371
372 BEGIN
373 -- initialize return status
374 x_return_status := OKC_API.G_RET_STS_SUCCESS;
375 -- data is required
376 IF (p_asdv_rec.tax_book = OKC_API.G_MISS_CHAR) OR
377 (p_asdv_rec.tax_book IS NULL) THEN
378 -- halt validation as it is a required field
379 RAISE G_EXCEPTION_STOP_VALIDATION;
380 END IF;
381 -- Enforce Foreign Key
382 OPEN c_tax_book_validate(p_asdv_rec.tax_book);
383 IF c_tax_book_validate%NOTFOUND THEN
384 -- halt validation as it has no parent record
385 RAISE G_EXCEPTION_HALT_VALIDATION;
386 END IF;
387 FETCH c_tax_book_validate into ln_dummy;
388 CLOSE c_tax_book_validate;
389 IF (ln_dummy = 0) then
390 -- halt validation as it has no parent record
391 RAISE G_EXCEPTION_HALT_VALIDATION;
392 END IF;
393 EXCEPTION
394 WHEN G_EXCEPTION_STOP_VALIDATION then
395 -- We are here since the field is optional
396 null;
397 WHEN G_EXCEPTION_HALT_VALIDATION then
398 -- We are here b'cause we have no parent record
399 -- store SQL error message on message stack
400 OKC_API.set_message(p_app_name => G_APP_NAME,
401 p_msg_name => G_NO_MATCHING_RECORD,
402 p_token1 => G_COL_NAME_TOKEN,
403 p_token1_value => 'tax_book');
404 IF c_tax_book_validate%ISOPEN THEN
405 CLOSE c_tax_book_validate;
406 END IF;
407 -- notify caller of an error
408 x_return_status := OKC_API.G_RET_STS_ERROR;
409 WHEN OTHERS THEN
410 -- store SQL error message on message stack
411 OKC_API.SET_MESSAGE(p_app_name => G_APP_NAME,
412 p_msg_name => G_UNEXPECTED_ERROR,
413 p_token1 => G_SQLCODE_TOKEN,
414 p_token1_value => SQLCODE,
415 p_token2 => G_SQLERRM_TOKEN,
416 p_token2_value => SQLERRM);
417 -- If the cursor is open then it has to be closed
418 IF c_tax_book_validate%ISOPEN THEN
419 CLOSE c_tax_book_validate;
420 END IF;
421 -- notify caller of an error as UNEXPETED error
422 x_return_status := OKC_API.G_RET_STS_UNEXP_ERROR;
423 END validate_tax_book;
424 --------------------------------20-------------------------------------------------
425 -- Start of Commnets
426 -- Badrinath Kuchibholta
427 -- Procedure Name : validate_dprn_mtd_tax
428 -- Description : FK validation with OKX_ASST_DEP_METHODS_V
429 -- Business Rules :
430 -- Parameters : OUT Return Status, IN Rec Info
431 -- Version : 1.0
432 -- End of Commnets
433
434 PROCEDURE validate_dprn_mtd_tax(x_return_status OUT NOCOPY VARCHAR2,
435 p_asdv_rec IN asdv_rec_type) IS
436
437 ln_dummy number := 0;
438 CURSOR c_dprn_mtd_tax_validate(p_deprn_method OKX_ASST_DEP_METHODS_V.METHOD_CODE%TYPE) is
439 SELECT 1
440 FROM DUAL
441 WHERE EXISTS (SELECT method_code
442 FROM OKX_ASST_DEP_METHODS_V
443 WHERE method_code = p_deprn_method);
444
445 BEGIN
446 -- initialize return status
447 x_return_status := OKC_API.G_RET_STS_SUCCESS;
448 -- data is required
449 IF (p_asdv_rec.deprn_method_tax = OKC_API.G_MISS_CHAR) OR
450 (p_asdv_rec.deprn_method_tax IS NULL) THEN
451 -- halt validation as it is a optional field
452 RAISE G_EXCEPTION_STOP_VALIDATION;
453 END IF;
454 -- Enforce Foreign Key
455 OPEN c_dprn_mtd_tax_validate(p_asdv_rec.deprn_method_tax);
456 IF c_dprn_mtd_tax_validate%NOTFOUND THEN
457 -- halt validation as it has no parent record
458 RAISE G_EXCEPTION_HALT_VALIDATION;
459 END IF;
460 FETCH c_dprn_mtd_tax_validate into ln_dummy;
461 CLOSE c_dprn_mtd_tax_validate;
462 IF (ln_dummy = 0) then
463 -- halt validation as it has no parent record
464 RAISE G_EXCEPTION_HALT_VALIDATION;
465 END IF;
466 EXCEPTION
467 WHEN G_EXCEPTION_STOP_VALIDATION then
468 -- We are here since the field is optional
469 null;
470 WHEN G_EXCEPTION_HALT_VALIDATION then
471 -- We are here b'cause we have no parent record
472 -- store SQL error message on message stack
473 OKC_API.set_message(p_app_name => G_APP_NAME,
474 p_msg_name => G_NO_MATCHING_RECORD,
475 p_token1 => G_COL_NAME_TOKEN,
476 p_token1_value => 'deprn_method_tax');
477 IF c_dprn_mtd_tax_validate%ISOPEN THEN
478 CLOSE c_dprn_mtd_tax_validate;
479 END IF;
480 -- notify caller of an error
481 x_return_status := OKC_API.G_RET_STS_ERROR;
482 WHEN OTHERS THEN
483 -- store SQL error message on message stack
484 OKC_API.SET_MESSAGE(p_app_name => G_APP_NAME,
485 p_msg_name => G_UNEXPECTED_ERROR,
486 p_token1 => G_SQLCODE_TOKEN,
487 p_token1_value => SQLCODE,
488 p_token2 => G_SQLERRM_TOKEN,
489 p_token2_value => SQLERRM);
490 -- If the cursor is open then it has to be closed
491 IF c_dprn_mtd_tax_validate%ISOPEN THEN
492 CLOSE c_dprn_mtd_tax_validate;
493 END IF;
494 -- notify caller of an error as UNEXPETED error
495 x_return_status := OKC_API.G_RET_STS_UNEXP_ERROR;
496 END validate_dprn_mtd_tax;
497
498 /************************ HAND-CODED *********************************/
499
500 --
501 -- Fix Bug# 2737014
502 --
503 -- Procedure Name : roundoff_line_amount
504 -- Description : Round off NOT NULL Asset Transaction line amounts
505 -- Business Rules :
506 -- Parameters :
507 -- Version : 1.0
508 -- End of comments
509
510 PROCEDURE roundoff_line_amount(
511 x_return_status OUT NOCOPY VARCHAR2,
512 x_msg_count OUT NOCOPY NUMBER,
513 x_msg_data OUT NOCOPY VARCHAR2,
514 p_asdv_rec IN asdv_rec_type,
515 x_asdv_rec OUT NOCOPY asdv_rec_type
516 ) IS
517
518 l_conv_amount NUMBER;
519 l_currency_code OKC_K_LINES_B.CURRENCY_CODE%TYPE;
520
521 roundoff_error EXCEPTION;
522
523 BEGIN
524
525 x_return_status := OKL_API.G_RET_STS_SUCCESS;
526
527 -- Take original record values
528 x_asdv_rec := p_asdv_rec;
529
530 l_currency_code := p_asdv_rec.currency_code;
531
532 IF (l_currency_code IS NULL) THEN -- Fatal error, Not a valid currency_code
533 RAISE roundoff_error;
534 END IF;
535
536 --dbms_output.put_line('Round off start '||l_currency_code);
537 -- Round off all Asset Transaction Line Amounts
538 IF (p_asdv_rec.cost IS NOT NULL
539 AND
540 p_asdv_rec.cost <> OKL_API.G_MISS_NUM) THEN
541
542 l_conv_amount := NULL;
543 l_conv_amount := okl_accounting_util.cross_currency_round_amount(
544 p_amount => p_asdv_rec.cost,
545 p_currency_code => l_currency_code
546 );
547
548 x_asdv_rec.cost := l_conv_amount;
549 END IF;
550
551 IF (p_asdv_rec.salvage_value IS NOT NULL
552 AND
553 p_asdv_rec.salvage_value <> OKL_API.G_MISS_NUM) THEN
554
555 l_conv_amount := NULL;
556 l_conv_amount := okl_accounting_util.cross_currency_round_amount(
557 p_amount => p_asdv_rec.salvage_value,
558 p_currency_code => l_currency_code
559 );
560
561 x_asdv_rec.salvage_value := l_conv_amount;
562 END IF;
563
564 --dbms_output.put_line('Round off complete');
565
566 EXCEPTION
567 WHEN roundoff_error THEN
568 x_return_status := OKL_API.G_RET_STS_ERROR;
569 END roundoff_line_amount;
570
571 -- Multi-Currency Change
572 --
573 -- PROCEDURE validate_currency
574 -- Decription: This procedure validates currency_code during insert and update operation
575 -- Logic:
576 -- 1. If transaction currency is NULL, take functional currency and
577 -- make rate, date and type as NULL
578 -- 2. If transaction currency is NOT NULL and
579 -- transaction currency <> functional currency and
580 -- type <> 'User' then
581 -- get conversion rate from GL and change rate column with new rate
582 -- 3. If transaction currency is NOT NULL and
583 -- transaction currency <> functional currency and
584 -- type = 'User' then
585 -- take all values as it is
586 -- 4. If transaction currency = functional currency
587 -- make rate, date and type as NULL
588 --
589 PROCEDURE validate_currency(
590 x_return_status OUT NOCOPY VARCHAR2,
591 p_asdv_rec IN asdv_rec_type,
592 x_asdv_rec OUT NOCOPY asdv_rec_type
593 ) IS
594
595 l_func_currency GL_CURRENCIES.CURRENCY_CODE%TYPE;
596 currency_validation_failed EXCEPTION;
597 l_ok VARCHAR2(1);
598
599 CURSOR conv_type_csr (p_conv_type gl_daily_conversion_types.conversion_type%TYPE) IS
600 SELECT 'Y'
601 FROM gl_daily_conversion_types
602 WHERE conversion_type = p_conv_type;
603
604 CURSOR curr_csr (p_curr_code gl_currencies.currency_code%TYPE) IS
605 SELECT 'Y'
606 FROM gl_currencies
607 WHERE currency_code = p_curr_code
608 AND TRUNC(SYSDATE) BETWEEN NVL(TRUNC(start_date_active), TRUNC(SYSDATE)) AND
609 NVL(TRUNC(end_date_active), TRUNC(SYSDATE));
610
611 BEGIN
612
613 x_asdv_rec := p_asdv_rec;
614 l_func_currency := okl_accounting_util.get_func_curr_code();
615
616 --dbms_output.put_line('Func Curr: '||l_func_currency);
617 --dbms_output.put_line('Trans Curr Code: '|| p_asdv_rec.currency_code);
618 --dbms_output.put_line('Trans Curr Rate: '|| p_asdv_rec.currency_conversion_rate);
619 --dbms_output.put_line('Trans Curr Date: '|| p_asdv_rec.currency_conversion_date);
620 --dbms_output.put_line('Trans Curr Type: '|| p_asdv_rec.currency_conversion_type);
621
622 IF (p_asdv_rec.currency_code IS NULL
623 OR
624 p_asdv_rec.currency_code = OKC_API.G_MISS_CHAR) THEN -- take functional currency
625 x_asdv_rec.currency_code := l_func_currency;
626 x_asdv_rec.currency_conversion_type := NULL;
627 x_asdv_rec.currency_conversion_rate := NULL;
628 x_asdv_rec.currency_conversion_date := NULL;
629 ELSE
630
631 l_ok := '?';
632 OPEN curr_csr(p_asdv_rec.currency_code);
633 FETCH curr_csr INTO l_ok;
634 CLOSE curr_csr;
635
636 IF (l_ok <> 'Y') THEN
637 OKC_API.set_message(p_app_name => G_APP_NAME,
638 p_msg_name => G_NO_MATCHING_RECORD,
639 p_token1 => G_COL_NAME_TOKEN,
640 p_token1_value => 'currency_code');
641 x_return_status := OKC_API.G_RET_STS_ERROR;
642 RAISE currency_validation_failed;
643 END IF;
644
645 IF (p_asdv_rec.currency_code = l_func_currency) THEN -- both are same
646 x_asdv_rec.currency_conversion_type := NULL;
647 x_asdv_rec.currency_conversion_rate := NULL;
648 x_asdv_rec.currency_conversion_date := NULL;
649 ELSE -- transactional and functional currency are different
650
651 -- Conversion type, date and rate mandetory
652 IF (p_asdv_rec.currency_conversion_type IS NULL
653 OR
654 p_asdv_rec.currency_conversion_type = OKC_API.G_MISS_CHAR) THEN
655 OKC_API.set_message(
656 p_app_name => G_APP_NAME,
657 p_msg_name => G_REQUIRED_VALUE,
658 p_token1 => G_COL_NAME_TOKEN,
659 p_token1_value => 'currency_conversion_type');
660 x_return_status := OKC_API.G_RET_STS_ERROR;
661 RAISE currency_validation_failed;
662 END IF;
663
664 l_ok := '?';
665 OPEN conv_type_csr (p_asdv_rec.currency_conversion_type);
666 FETCH conv_type_csr INTO l_ok;
667 CLOSE conv_type_csr;
668
669 IF (l_ok <> 'Y') THEN
670 OKC_API.set_message(p_app_name => G_APP_NAME,
671 p_msg_name => G_NO_MATCHING_RECORD,
672 p_token1 => G_COL_NAME_TOKEN,
673 p_token1_value => 'currency_conversion_type');
674 x_return_status := OKC_API.G_RET_STS_ERROR;
675 RAISE currency_validation_failed;
676 END IF;
677
678 IF (p_asdv_rec.currency_conversion_date IS NULL
679 OR
680 p_asdv_rec.currency_conversion_date = OKC_API.G_MISS_DATE) THEN
681 OKC_API.set_message(
682 p_app_name => G_APP_NAME,
683 p_msg_name => G_REQUIRED_VALUE,
684 p_token1 => G_COL_NAME_TOKEN,
685 p_token1_value => 'currency_conversion_date');
686 x_return_status := OKC_API.G_RET_STS_ERROR;
687 RAISE currency_validation_failed;
688 END IF;
689
690 IF (p_asdv_rec.currency_conversion_type = 'User') THEN
691
692 IF (p_asdv_rec.currency_conversion_rate IS NULL
693 OR
694 p_asdv_rec.currency_conversion_rate = OKC_API.G_MISS_NUM) THEN
695 OKC_API.set_message(
696 p_app_name => G_APP_NAME,
697 p_msg_name => G_REQUIRED_VALUE,
698 p_token1 => G_COL_NAME_TOKEN,
699 p_token1_value => 'currency_conversion_rate');
700 x_return_status := OKC_API.G_RET_STS_ERROR;
701 RAISE currency_validation_failed;
702 END IF;
703
704 x_asdv_rec.currency_conversion_type := p_asdv_rec.currency_conversion_type;
705 x_asdv_rec.currency_conversion_rate := p_asdv_rec.currency_conversion_rate;
706 x_asdv_rec.currency_conversion_date := p_asdv_rec.currency_conversion_date;
707
708 ELSE -- conversion_type <> 'User'
709
710 x_asdv_rec.currency_conversion_rate := okl_accounting_util.get_curr_con_rate(
711 p_from_curr_code => p_asdv_rec.currency_code,
712 p_to_curr_code => l_func_currency,
713 p_con_date => p_asdv_rec.currency_conversion_date,
714 p_con_type => p_asdv_rec.currency_conversion_type
715 );
716
717 x_asdv_rec.currency_conversion_type := p_asdv_rec.currency_conversion_type;
718 x_asdv_rec.currency_conversion_date := p_asdv_rec.currency_conversion_date;
719
720 END IF; -- conversion_type
721 END IF; -- currency_code check
722 END IF; -- currency_code NULL
723
724 EXCEPTION
725 WHEN currency_validation_failed THEN
726 RETURN;
727 END validate_currency;
728 -- Multi-Currency Change
729 ---------------------------------------------------------------------------
730 -- FUNCTION get_seq_id
731 ---------------------------------------------------------------------------
732 FUNCTION get_seq_id RETURN NUMBER IS
733 BEGIN
734 RETURN(okc_p_util.raw_to_number(sys_guid()));
735 END get_seq_id;
736
737 ---------------------------------------------------------------------------
738 -- PROCEDURE qc
739 ---------------------------------------------------------------------------
740 PROCEDURE qc IS
741 BEGIN
742 null;
743 END qc;
744
745 ---------------------------------------------------------------------------
746 -- PROCEDURE change_version
747 ---------------------------------------------------------------------------
748 PROCEDURE change_version IS
749 BEGIN
750 null;
751 END change_version;
752
753 ---------------------------------------------------------------------------
754 -- PROCEDURE api_copy
755 ---------------------------------------------------------------------------
756 PROCEDURE api_copy IS
757 BEGIN
758 null;
759 END api_copy;
760 ---------------------------------------------------------------------------
761 -- PROCEDURE add_language
762 ---------------------------------------------------------------------------
763 PROCEDURE add_language IS
764 BEGIN
765 DELETE FROM OKL_TXD_ASSETS_TL T
766 WHERE NOT EXISTS (
767 SELECT NULL
768 FROM OKL_TXD_ASSETS_B B --fixed bug 3321017 by kmotepal
769 WHERE B.ID = T.ID
770 );
771
772 UPDATE OKL_TXD_ASSETS_TL T SET (
773 DESCRIPTION) = (SELECT
774 B.DESCRIPTION
775 FROM OKL_TXD_ASSETS_TL B
776 WHERE B.ID = T.ID
777 AND B.LANGUAGE = T.SOURCE_LANG)
778 WHERE (
779 T.ID,
780 T.LANGUAGE)
781 IN (SELECT
782 SUBT.ID,
783 SUBT.LANGUAGE
784 FROM OKL_TXD_ASSETS_TL SUBB, OKL_TXD_ASSETS_TL SUBT
785 WHERE SUBB.ID = SUBT.ID
786 AND SUBB.LANGUAGE = SUBT.SOURCE_LANG
787 AND (SUBB.DESCRIPTION <> SUBT.DESCRIPTION
788 OR (SUBB.DESCRIPTION IS NULL AND SUBT.DESCRIPTION IS NOT NULL)
789 OR (SUBB.DESCRIPTION IS NOT NULL AND SUBT.DESCRIPTION IS NULL)
790 ));
791
792 INSERT INTO OKL_TXD_ASSETS_TL (
793 ID,
794 LANGUAGE,
795 SOURCE_LANG,
796 SFWT_FLAG,
797 DESCRIPTION,
798 CREATED_BY,
799 CREATION_DATE,
800 LAST_UPDATED_BY,
801 LAST_UPDATE_DATE,
802 LAST_UPDATE_LOGIN)
803 SELECT
804 B.ID,
805 L.LANGUAGE_CODE,
806 B.SOURCE_LANG,
807 B.SFWT_FLAG,
808 B.DESCRIPTION,
809 B.CREATED_BY,
810 B.CREATION_DATE,
811 B.LAST_UPDATED_BY,
812 B.LAST_UPDATE_DATE,
813 B.LAST_UPDATE_LOGIN
814 FROM OKL_TXD_ASSETS_TL B, FND_LANGUAGES L
815 WHERE L.INSTALLED_FLAG IN ('I', 'B')
816 AND B.LANGUAGE = USERENV('LANG')
817 AND NOT EXISTS(
818 SELECT NULL
819 FROM OKL_TXD_ASSETS_TL T
820 WHERE T.ID = B.ID
821 AND T.LANGUAGE = L.LANGUAGE_CODE
822 );
823
824 END add_language;
825
826 ---------------------------------------------------------------------------
827 -- FUNCTION get_rec for: OKL_TXD_ASSETS
828 ---------------------------------------------------------------------------
829 FUNCTION get_rec (
830 p_asd_rec IN asd_rec_type,
831 x_no_data_found OUT NOCOPY BOOLEAN
832 ) RETURN asd_rec_type IS
833 CURSOR asd_pk_csr (p_id IN NUMBER) IS
834 SELECT
835 ID,
836 OBJECT_VERSION_NUMBER,
837 TAL_ID,
838 TARGET_KLE_ID,
839 LINE_DETAIL_NUMBER,
840 ASSET_NUMBER,
841 QUANTITY,
842 COST,
843 TAX_BOOK,
844 LIFE_IN_MONTHS_TAX,
845 DEPRN_METHOD_TAX,
846 DEPRN_RATE_TAX,
847 SALVAGE_VALUE,
848 -- added new columns for split asset component
849 SPLIT_PERCENT,
850 INVENTORY_ITEM_ID,
851 -- end of added new columns for split asset component
852 ATTRIBUTE_CATEGORY,
853 ATTRIBUTE1,
854 ATTRIBUTE2,
855 ATTRIBUTE3,
856 ATTRIBUTE4,
857 ATTRIBUTE5,
858 ATTRIBUTE6,
859 ATTRIBUTE7,
860 ATTRIBUTE8,
861 ATTRIBUTE9,
862 ATTRIBUTE10,
863 ATTRIBUTE11,
864 ATTRIBUTE12,
865 ATTRIBUTE13,
866 ATTRIBUTE14,
867 ATTRIBUTE15,
868 CREATED_BY,
869 CREATION_DATE,
870 LAST_UPDATED_BY,
871 LAST_UPDATE_DATE,
872 LAST_UPDATE_LOGIN,
873 -- Multi-Currency changes
874 CURRENCY_CODE,
875 CURRENCY_CONVERSION_TYPE,
876 CURRENCY_CONVERSION_RATE,
877 CURRENCY_CONVERSION_DATE
878 -- Multi-Currency changes
879 FROM Okl_Txd_Assets_b txd
880 WHERE txd.id = p_id;
881 l_asd_pk asd_pk_csr%ROWTYPE;
882 l_asd_rec asd_rec_type;
883 BEGIN
884 x_no_data_found := TRUE;
885 -- Get current database values
886 OPEN asd_pk_csr (p_asd_rec.id);
887 FETCH asd_pk_csr INTO
888 l_asd_rec.ID,
889 l_asd_rec.OBJECT_VERSION_NUMBER,
890 l_asd_rec.TAL_ID,
891 l_asd_rec.TARGET_KLE_ID,
892 l_asd_rec.LINE_DETAIL_NUMBER,
893 l_asd_rec.ASSET_NUMBER,
894 l_asd_rec.QUANTITY,
895 l_asd_rec.COST,
896 l_asd_rec.TAX_BOOK,
897 l_asd_rec.LIFE_IN_MONTHS_TAX,
898 l_asd_rec.DEPRN_METHOD_TAX,
899 l_asd_rec.DEPRN_RATE_TAX,
900 l_asd_rec.SALVAGE_VALUE,
901 -- added new columns for split asset component
902 l_asd_rec.SPLIT_PERCENT,
903 l_asd_rec.INVENTORY_ITEM_ID,
904 -- end of added new columns for split asset component
905 l_asd_rec.ATTRIBUTE_CATEGORY,
906 l_asd_rec.ATTRIBUTE1,
907 l_asd_rec.ATTRIBUTE2,
908 l_asd_rec.ATTRIBUTE3,
909 l_asd_rec.ATTRIBUTE4,
910 l_asd_rec.ATTRIBUTE5,
911 l_asd_rec.ATTRIBUTE6,
912 l_asd_rec.ATTRIBUTE7,
913 l_asd_rec.ATTRIBUTE8,
914 l_asd_rec.ATTRIBUTE9,
915 l_asd_rec.ATTRIBUTE10,
916 l_asd_rec.ATTRIBUTE11,
917 l_asd_rec.ATTRIBUTE12,
918 l_asd_rec.ATTRIBUTE13,
919 l_asd_rec.ATTRIBUTE14,
920 l_asd_rec.ATTRIBUTE15,
921 l_asd_rec.CREATED_BY,
922 l_asd_rec.CREATION_DATE,
923 l_asd_rec.LAST_UPDATED_BY,
924 l_asd_rec.LAST_UPDATE_DATE,
925 l_asd_rec.LAST_UPDATE_LOGIN,
926 -- Multi-Currency changes
927 l_asd_rec.CURRENCY_CODE,
928 l_asd_rec.CURRENCY_CONVERSION_TYPE,
929 l_asd_rec.CURRENCY_CONVERSION_RATE,
930 l_asd_rec.CURRENCY_CONVERSION_DATE;
931 -- Multi-Currency changes
932 x_no_data_found := asd_pk_csr%NOTFOUND;
933 CLOSE asd_pk_csr;
934 RETURN(l_asd_rec);
935 END get_rec;
936
937 FUNCTION get_rec (
938 p_asd_rec IN asd_rec_type
939 ) RETURN asd_rec_type IS
940 l_row_notfound BOOLEAN := TRUE;
941 BEGIN
942 RETURN(get_rec(p_asd_rec, l_row_notfound));
943 END get_rec;
944 ---------------------------------------------------------------------------
945 -- FUNCTION get_rec for: OKL_TXD_ASSETS_TL
946 ---------------------------------------------------------------------------
947 FUNCTION get_rec (
948 p_okl_txd_assets_tl_rec IN okl_txd_assets_tl_rec_type,
949 x_no_data_found OUT NOCOPY BOOLEAN
950 ) RETURN okl_txd_assets_tl_rec_type IS
951 CURSOR okl_txd_asset_tl_pk_csr (p_id IN NUMBER,
952 p_language IN VARCHAR2) IS
953 SELECT
954 ID,
955 LANGUAGE,
956 SOURCE_LANG,
957 SFWT_FLAG,
958 DESCRIPTION,
959 CREATED_BY,
960 CREATION_DATE,
961 LAST_UPDATED_BY,
962 LAST_UPDATE_DATE,
963 LAST_UPDATE_LOGIN
964 FROM okl_txd_assets_tl
965 WHERE okl_txd_assets_tl.id = p_id
966 AND okl_txd_assets_tl.language = p_language;
967 l_okl_txd_asset_tl_pk okl_txd_asset_tl_pk_csr%ROWTYPE;
968 l_okl_txd_assets_tl_rec okl_txd_assets_tl_rec_type;
969 BEGIN
970 x_no_data_found := TRUE;
971 -- Get current database values
972 OPEN okl_txd_asset_tl_pk_csr (p_okl_txd_assets_tl_rec.id,
973 p_okl_txd_assets_tl_rec.language);
974 FETCH okl_txd_asset_tl_pk_csr INTO
975 l_okl_txd_assets_tl_rec.ID,
976 l_okl_txd_assets_tl_rec.LANGUAGE,
977 l_okl_txd_assets_tl_rec.SOURCE_LANG,
978 l_okl_txd_assets_tl_rec.SFWT_FLAG,
979 l_okl_txd_assets_tl_rec.DESCRIPTION,
980 l_okl_txd_assets_tl_rec.CREATED_BY,
981 l_okl_txd_assets_tl_rec.CREATION_DATE,
982 l_okl_txd_assets_tl_rec.LAST_UPDATED_BY,
983 l_okl_txd_assets_tl_rec.LAST_UPDATE_DATE,
984 l_okl_txd_assets_tl_rec.LAST_UPDATE_LOGIN;
985 x_no_data_found := okl_txd_asset_tl_pk_csr%NOTFOUND;
986 CLOSE okl_txd_asset_tl_pk_csr;
987 RETURN(l_okl_txd_assets_tl_rec);
988 END get_rec;
989
990 FUNCTION get_rec (
991 p_okl_txd_assets_tl_rec IN okl_txd_assets_tl_rec_type
992 ) RETURN okl_txd_assets_tl_rec_type IS
993 l_row_notfound BOOLEAN := TRUE;
994 BEGIN
995 RETURN(get_rec(p_okl_txd_assets_tl_rec, l_row_notfound));
996 END get_rec;
997 ---------------------------------------------------------------------------
998 -- FUNCTION get_rec for: OKL_TXD_ASSETS_V
999 ---------------------------------------------------------------------------
1000 FUNCTION get_rec (
1001 p_asdv_rec IN asdv_rec_type,
1002 x_no_data_found OUT NOCOPY BOOLEAN
1003 ) RETURN asdv_rec_type IS
1004 CURSOR okl_asdv_pk_csr (p_id IN NUMBER) IS
1005 SELECT id,
1006 object_version_number,
1007 sfwt_flag,
1008 tal_id,
1009 target_kle_id,
1010 line_detail_number,
1011 asset_number,
1012 description,
1013 quantity,
1014 cost,
1015 tax_book,
1016 life_in_months_tax,
1017 deprn_method_tax,
1018 deprn_rate_tax,
1019 salvage_value,
1020 -- added new columns for split asset component
1021 SPLIT_PERCENT,
1022 INVENTORY_ITEM_ID,
1023 -- end of added new columns for split asset component
1024 attribute_category,
1025 attribute1,
1026 attribute2,
1027 attribute3,
1028 attribute4,
1029 attribute5,
1030 attribute6,
1031 attribute7,
1032 attribute8,
1033 attribute9,
1034 attribute10,
1035 attribute11,
1036 attribute12,
1037 attribute13,
1038 attribute14,
1039 attribute15,
1040 created_by,
1041 creation_date,
1042 last_updated_by,
1043 last_update_date,
1044 last_update_login
1045 FROM Okl_Txd_Assets_V txd
1046 WHERE txd.id = p_id;
1047 l_okl_asdv_pk okl_asdv_pk_csr%ROWTYPE;
1048 l_asdv_rec asdv_rec_type;
1049 BEGIN
1050 x_no_data_found := TRUE;
1051 -- Get current database values
1052 OPEN okl_asdv_pk_csr (p_asdv_rec.id);
1053 FETCH okl_asdv_pk_csr INTO
1054 l_asdv_rec.ID,
1055 l_asdv_rec.OBJECT_VERSION_NUMBER,
1056 l_asdv_rec.SFWT_FLAG,
1057 l_asdv_rec.TAL_ID,
1058 l_asdv_rec.TARGET_KLE_ID,
1059 l_asdv_rec.LINE_DETAIL_NUMBER,
1060 l_asdv_rec.ASSET_NUMBER,
1061 l_asdv_rec.DESCRIPTION,
1062 l_asdv_rec.QUANTITY,
1063 l_asdv_rec.COST,
1064 l_asdv_rec.TAX_BOOK,
1065 l_asdv_rec.LIFE_IN_MONTHS_TAX,
1066 l_asdv_rec.DEPRN_METHOD_TAX,
1067 l_asdv_rec.DEPRN_RATE_TAX,
1068 l_asdv_rec.SALVAGE_VALUE,
1069 -- added new columns for split asset component
1070 l_asdv_rec.SPLIT_PERCENT,
1071 l_asdv_rec.INVENTORY_ITEM_ID,
1072 -- end of added new columns for split asset component
1073 l_asdv_rec.ATTRIBUTE_CATEGORY,
1074 l_asdv_rec.ATTRIBUTE1,
1075 l_asdv_rec.ATTRIBUTE2,
1076 l_asdv_rec.ATTRIBUTE3,
1077 l_asdv_rec.ATTRIBUTE4,
1078 l_asdv_rec.ATTRIBUTE5,
1079 l_asdv_rec.ATTRIBUTE6,
1080 l_asdv_rec.ATTRIBUTE7,
1081 l_asdv_rec.ATTRIBUTE8,
1082 l_asdv_rec.ATTRIBUTE9,
1083 l_asdv_rec.ATTRIBUTE10,
1084 l_asdv_rec.ATTRIBUTE11,
1085 l_asdv_rec.ATTRIBUTE12,
1086 l_asdv_rec.ATTRIBUTE13,
1087 l_asdv_rec.ATTRIBUTE14,
1088 l_asdv_rec.ATTRIBUTE15,
1089 l_asdv_rec.CREATED_BY,
1090 l_asdv_rec.CREATION_DATE,
1091 l_asdv_rec.LAST_UPDATED_BY,
1092 l_asdv_rec.LAST_UPDATE_DATE,
1093 l_asdv_rec.LAST_UPDATE_LOGIN;
1094 x_no_data_found := okl_asdv_pk_csr%NOTFOUND;
1095 CLOSE okl_asdv_pk_csr;
1096 RETURN(l_asdv_rec);
1097 END get_rec;
1098
1099 FUNCTION get_rec (
1100 p_asdv_rec IN asdv_rec_type
1101 ) RETURN asdv_rec_type IS
1102 l_row_notfound BOOLEAN := TRUE;
1103 BEGIN
1104 RETURN(get_rec(p_asdv_rec, l_row_notfound));
1105 END get_rec;
1106
1107 ------------------------------------------------------
1108 -- FUNCTION null_out_defaults for: OKL_TXD_ASSETS_V --
1109 ------------------------------------------------------
1110 FUNCTION null_out_defaults (
1111 p_asdv_rec IN asdv_rec_type
1112 ) RETURN asdv_rec_type IS
1113 l_asdv_rec asdv_rec_type := p_asdv_rec;
1114 BEGIN
1115 IF (l_asdv_rec.object_version_number = OKC_API.G_MISS_NUM) THEN
1116 l_asdv_rec.object_version_number := NULL;
1117 END IF;
1118 IF (l_asdv_rec.tal_id = OKC_API.G_MISS_NUM) THEN
1119 l_asdv_rec.tal_id := NULL;
1120 END IF;
1121 IF (l_asdv_rec.target_kle_id = OKC_API.G_MISS_NUM) THEN
1122 l_asdv_rec.target_kle_id := NULL;
1123 END IF;
1124 IF (l_asdv_rec.line_detail_number = OKC_API.G_MISS_NUM) THEN
1125 l_asdv_rec.line_detail_number := NULL;
1126 END IF;
1127 IF (l_asdv_rec.asset_number = OKC_API.G_MISS_CHAR) THEN
1128 l_asdv_rec.asset_number := NULL;
1129 END IF;
1130 IF (l_asdv_rec.description = OKC_API.G_MISS_CHAR) THEN
1131 l_asdv_rec.description := NULL;
1132 END IF;
1133 IF (l_asdv_rec.quantity = OKC_API.G_MISS_NUM) THEN
1134 l_asdv_rec.quantity := NULL;
1135 END IF;
1136 IF (l_asdv_rec.cost = OKC_API.G_MISS_NUM) THEN
1137 l_asdv_rec.cost := NULL;
1138 END IF;
1139 IF (l_asdv_rec.tax_book = OKC_API.G_MISS_CHAR) THEN
1140 l_asdv_rec.tax_book := NULL;
1141 END IF;
1142 IF (l_asdv_rec.life_in_months_tax = OKC_API.G_MISS_NUM) THEN
1143 l_asdv_rec.life_in_months_tax := NULL;
1144 END IF;
1145 IF (l_asdv_rec.deprn_method_tax = OKC_API.G_MISS_CHAR) THEN
1146 l_asdv_rec.deprn_method_tax := NULL;
1147 END IF;
1148 IF (l_asdv_rec.deprn_rate_tax = OKC_API.G_MISS_NUM) THEN
1149 l_asdv_rec.deprn_rate_tax := NULL;
1150 END IF;
1151 IF (l_asdv_rec.salvage_value = OKC_API.G_MISS_NUM) THEN
1152 l_asdv_rec.salvage_value := NULL;
1153 END IF;
1154
1155 -- added new columns for split asset component
1156 IF (l_asdv_rec.SPLIT_PERCENT = OKC_API.G_MISS_NUM) THEN
1157 l_asdv_rec.SPLIT_PERCENT := NULL;
1158 END IF;
1159 IF (l_asdv_rec.INVENTORY_ITEM_ID = OKC_API.G_MISS_NUM) THEN
1160 l_asdv_rec.INVENTORY_ITEM_ID := NULL;
1161 END IF;
1162 -- end of added new columns for split asset component
1163
1164 IF (l_asdv_rec.attribute_category = OKC_API.G_MISS_CHAR) THEN
1165 l_asdv_rec.attribute_category := NULL;
1166 END IF;
1167 IF (l_asdv_rec.attribute1 = OKC_API.G_MISS_CHAR) THEN
1168 l_asdv_rec.attribute1 := NULL;
1169 END IF;
1170 IF (l_asdv_rec.attribute2 = OKC_API.G_MISS_CHAR) THEN
1171 l_asdv_rec.attribute2 := NULL;
1172 END IF;
1173 IF (l_asdv_rec.attribute3 = OKC_API.G_MISS_CHAR) THEN
1174 l_asdv_rec.attribute3 := NULL;
1175 END IF;
1176 IF (l_asdv_rec.attribute4 = OKC_API.G_MISS_CHAR) THEN
1177 l_asdv_rec.attribute4 := NULL;
1178 END IF;
1179 IF (l_asdv_rec.attribute5 = OKC_API.G_MISS_CHAR) THEN
1180 l_asdv_rec.attribute5 := NULL;
1181 END IF;
1182 IF (l_asdv_rec.attribute6 = OKC_API.G_MISS_CHAR) THEN
1183 l_asdv_rec.attribute6 := NULL;
1184 END IF;
1185 IF (l_asdv_rec.attribute7 = OKC_API.G_MISS_CHAR) THEN
1186 l_asdv_rec.attribute7 := NULL;
1187 END IF;
1188 IF (l_asdv_rec.attribute8 = OKC_API.G_MISS_CHAR) THEN
1189 l_asdv_rec.attribute8 := NULL;
1190 END IF;
1191 IF (l_asdv_rec.attribute9 = OKC_API.G_MISS_CHAR) THEN
1192 l_asdv_rec.attribute9 := NULL;
1193 END IF;
1194 IF (l_asdv_rec.attribute10 = OKC_API.G_MISS_CHAR) THEN
1195 l_asdv_rec.attribute10 := NULL;
1196 END IF;
1197 IF (l_asdv_rec.attribute11 = OKC_API.G_MISS_CHAR) THEN
1198 l_asdv_rec.attribute11 := NULL;
1199 END IF;
1200 IF (l_asdv_rec.attribute12 = OKC_API.G_MISS_CHAR) THEN
1201 l_asdv_rec.attribute12 := NULL;
1202 END IF;
1203 IF (l_asdv_rec.attribute13 = OKC_API.G_MISS_CHAR) THEN
1204 l_asdv_rec.attribute13 := NULL;
1205 END IF;
1206 IF (l_asdv_rec.attribute14 = OKC_API.G_MISS_CHAR) THEN
1207 l_asdv_rec.attribute14 := NULL;
1208 END IF;
1209 IF (l_asdv_rec.attribute15 = OKC_API.G_MISS_CHAR) THEN
1210 l_asdv_rec.attribute15 := NULL;
1211 END IF;
1212 IF (l_asdv_rec.created_by = OKC_API.G_MISS_NUM) THEN
1213 l_asdv_rec.created_by := NULL;
1214 END IF;
1215 IF (l_asdv_rec.creation_date = OKC_API.G_MISS_DATE) THEN
1216 l_asdv_rec.creation_date := NULL;
1217 END IF;
1218 IF (l_asdv_rec.last_updated_by = OKC_API.G_MISS_NUM) THEN
1219 l_asdv_rec.last_updated_by := NULL;
1220 END IF;
1221 IF (l_asdv_rec.last_update_date = OKC_API.G_MISS_DATE) THEN
1222 l_asdv_rec.last_update_date := NULL;
1223 END IF;
1224 IF (l_asdv_rec.last_update_login = OKC_API.G_MISS_NUM) THEN
1225 l_asdv_rec.last_update_login := NULL;
1226 END IF;
1227 RETURN(l_asdv_rec);
1228 END null_out_defaults;
1229 ---------------------------------------------------------------------------
1230 -- PROCEDURE Validate_Attributes
1231 ---------------------------------------------------------------------------
1232 ----------------------------------------------
1233 -- Validate_Attributes for:OKL_TXD_ASSETS_V --
1234 ----------------------------------------------
1235 FUNCTION Validate_Attributes (
1236 p_asdv_rec IN asdv_rec_type
1237 ) RETURN VARCHAR2 IS
1238 l_return_status VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
1239 x_return_status VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
1240 BEGIN
1241 IF p_asdv_rec.id = OKC_API.G_MISS_NUM OR
1242 p_asdv_rec.id IS NULL THEN
1243 OKC_API.set_message(G_APP_NAME, G_REQUIRED_VALUE,G_COL_NAME_TOKEN,'id');
1244 x_return_status := OKC_API.G_RET_STS_ERROR;
1245 ELSIF p_asdv_rec.object_version_number = OKC_API.G_MISS_NUM OR
1246 p_asdv_rec.object_version_number IS NULL THEN
1247 OKC_API.set_message(G_APP_NAME, G_REQUIRED_VALUE,G_COL_NAME_TOKEN,'object_version_number');
1248 x_return_status := OKC_API.G_RET_STS_ERROR;
1249 ELSIF p_asdv_rec.asset_number = OKC_API.G_MISS_CHAR OR
1250 p_asdv_rec.asset_number IS NULL THEN
1251 OKC_API.set_message(G_APP_NAME, G_REQUIRED_VALUE,G_COL_NAME_TOKEN,'Asset_number');
1252 x_return_status := OKC_API.G_RET_STS_ERROR;
1253 END IF;
1254 /************************ HAND-CODED *********************************/
1255 -- Calling the Validate Procedure to validate Individual Attributes
1256 validate_tal_id(x_return_status => l_return_status,
1257 p_asdv_rec => p_asdv_rec);
1258 -- Store the Highest Degree of Error
1259 IF (l_return_status <> OKC_API.G_RET_STS_SUCCESS) THEN
1260 IF (x_return_status <> OKC_API.G_RET_STS_UNEXP_ERROR) THEN
1261 x_return_status := l_return_status;
1262 END IF;
1263 END IF;
1264 l_return_status := x_return_status;
1265 validate_quantity(x_return_status => l_return_status,
1266 p_asdv_rec => p_asdv_rec);
1267 -- Store the Highest Degree of Error
1268 IF (l_return_status <> OKC_API.G_RET_STS_SUCCESS) THEN
1269 IF (x_return_status <> OKC_API.G_RET_STS_UNEXP_ERROR) THEN
1270 x_return_status := l_return_status;
1271 END IF;
1272 END IF;
1273 l_return_status := x_return_status;
1274 validate_life_in_months_tax(x_return_status => l_return_status,
1275 p_asdv_rec => p_asdv_rec);
1276 -- Store the Highest Degree of Error
1277 IF (l_return_status <> OKC_API.G_RET_STS_SUCCESS) THEN
1278 IF (x_return_status <> OKC_API.G_RET_STS_UNEXP_ERROR) THEN
1279 x_return_status := l_return_status;
1280 END IF;
1281 END IF;
1282 l_return_status := x_return_status;
1283 validate_target_kle_id(x_return_status => l_return_status,
1284 p_asdv_rec => p_asdv_rec);
1285 -- Store the Highest Degree of Error
1286 IF (l_return_status <> OKC_API.G_RET_STS_SUCCESS) THEN
1287 IF (x_return_status <> OKC_API.G_RET_STS_UNEXP_ERROR) THEN
1288 x_return_status := l_return_status;
1289 END IF;
1290 END IF;
1291 l_return_status := x_return_status;
1292 validate_tax_book(x_return_status => l_return_status,
1293 p_asdv_rec => p_asdv_rec);
1294 -- Store the Highest Degree of Error
1295 IF (l_return_status <> OKC_API.G_RET_STS_SUCCESS) THEN
1296 IF (x_return_status <> OKC_API.G_RET_STS_UNEXP_ERROR) THEN
1297 x_return_status := l_return_status;
1298 END IF;
1299 END IF;
1300 l_return_status := x_return_status;
1301 validate_dprn_mtd_tax(x_return_status => l_return_status,
1302 p_asdv_rec => p_asdv_rec);
1303 -- Store the Highest Degree of Error
1304 IF (l_return_status <> OKC_API.G_RET_STS_SUCCESS) THEN
1305 IF (x_return_status <> OKC_API.G_RET_STS_UNEXP_ERROR) THEN
1306 x_return_status := l_return_status;
1307 END IF;
1308 END IF;
1309 l_return_status := x_return_status;
1310 --
1311 Validate_INVENTORY_ITEM_ID(x_return_status => l_return_status,
1312 p_asdv_rec => p_asdv_rec);
1313 -- Store the Highest Degree of Error
1314 IF (l_return_status <> OKC_API.G_RET_STS_SUCCESS) THEN
1315 IF (x_return_status <> OKC_API.G_RET_STS_UNEXP_ERROR) THEN
1316 x_return_status := l_return_status;
1317 END IF;
1318 END IF;
1319 l_return_status := x_return_status;
1320 --
1321
1322 RETURN(l_return_status);
1323 EXCEPTION
1324 WHEN OTHERS THEN
1325 -- store SQL error message on message stack
1326 OKC_API.SET_MESSAGE(p_app_name => G_APP_NAME,
1327 p_msg_name => G_UNEXPECTED_ERROR,
1328 p_token1 => G_SQLCODE_TOKEN,
1329 p_token1_value => SQLCODE,
1330 p_token2 => G_SQLERRM_TOKEN,
1331 p_token2_value => SQLERRM);
1332 -- notify caller of an error as UNEXPETED error
1333 x_return_status := OKC_API.G_RET_STS_UNEXP_ERROR;
1334 -- Return status to caller
1335 RETURN(x_return_status);
1336 /************************ HAND-CODED *********************************/
1337 END Validate_Attributes;
1338
1339 ---------------------------------------------------------------------------
1340 -- PROCEDURE Validate_Record
1341 ---------------------------------------------------------------------------
1342 ------------------------------------------
1343 -- Validate_Record for:OKL_TXD_ASSETS_V --
1344 ------------------------------------------
1345 FUNCTION Validate_Record (
1346 p_asdv_rec IN asdv_rec_type
1347 ) RETURN VARCHAR2 IS
1348 l_return_status VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
1349 x_return_status VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
1350 BEGIN
1351 RETURN (l_return_status);
1352 EXCEPTION
1353 WHEN OTHERS THEN
1354 -- store SQL error message on message stack
1355 OKC_API.SET_MESSAGE(p_app_name => G_APP_NAME,
1356 p_msg_name => G_UNEXPECTED_ERROR,
1357 p_token1 => G_SQLCODE_TOKEN,
1358 p_token1_value => SQLCODE,
1359 p_token2 => G_SQLERRM_TOKEN,
1360 p_token2_value => SQLERRM);
1361 -- notify caller of an error as UNEXPETED error
1362 x_return_status := OKC_API.G_RET_STS_UNEXP_ERROR;
1363 -- Return status to caller
1364 RETURN(l_return_status);
1365 END Validate_Record;
1366 ---------------------------------------------------------------------------
1367 -- PROCEDURE Migrate
1368 ---------------------------------------------------------------------------
1369 PROCEDURE migrate (
1370 p_from IN asdv_rec_type,
1371 p_to IN OUT NOCOPY asd_rec_type
1372 ) IS
1373 BEGIN
1374 p_to.id := p_from.id;
1375 p_to.object_version_number := p_from.object_version_number;
1376 p_to.tal_id := p_from.tal_id;
1377 p_to.target_kle_id := p_from.target_kle_id;
1378 p_to.line_detail_number := p_from.line_detail_number;
1379 p_to.asset_number := p_from.asset_number;
1380 p_to.quantity := p_from.quantity;
1381 p_to.cost := p_from.cost;
1382 p_to.tax_book := p_from.tax_book;
1383 p_to.life_in_months_tax := p_from.life_in_months_tax;
1384 p_to.deprn_method_tax := p_from.deprn_method_tax;
1385 p_to.deprn_rate_tax := p_from.deprn_rate_tax;
1386 p_to.salvage_value := p_from.salvage_value;
1387 --
1388 p_to.SPLIT_PERCENT := p_from.SPLIT_PERCENT;
1389 p_to.INVENTORY_ITEM_ID := p_from.INVENTORY_ITEM_ID;
1390 --
1391 p_to.attribute_category := p_from.attribute_category;
1392 p_to.attribute1 := p_from.attribute1;
1393 p_to.attribute2 := p_from.attribute2;
1394 p_to.attribute3 := p_from.attribute3;
1395 p_to.attribute4 := p_from.attribute4;
1396 p_to.attribute5 := p_from.attribute5;
1397 p_to.attribute6 := p_from.attribute6;
1398 p_to.attribute7 := p_from.attribute7;
1399 p_to.attribute8 := p_from.attribute8;
1400 p_to.attribute9 := p_from.attribute9;
1401 p_to.attribute10 := p_from.attribute10;
1402 p_to.attribute11 := p_from.attribute11;
1403 p_to.attribute12 := p_from.attribute12;
1404 p_to.attribute13 := p_from.attribute13;
1405 p_to.attribute14 := p_from.attribute14;
1406 p_to.attribute15 := p_from.attribute15;
1407 p_to.created_by := p_from.created_by;
1408 p_to.creation_date := p_from.creation_date;
1409 p_to.last_updated_by := p_from.last_updated_by;
1410 p_to.last_update_date := p_from.last_update_date;
1411 p_to.last_update_login := p_from.last_update_login;
1412 -- Multi-Currency Change
1413 p_to.currency_code := p_from.currency_code;
1414 p_to.currency_conversion_type := p_from.currency_conversion_type;
1415 p_to.currency_conversion_rate := p_from.currency_conversion_rate;
1416 p_to.currency_conversion_date := p_from.currency_conversion_date;
1417 -- Multi-Currency Change
1418 END migrate;
1419 PROCEDURE migrate (
1420 p_from IN asd_rec_type,
1421 p_to IN OUT NOCOPY asdv_rec_type
1422 ) IS
1423 BEGIN
1424 p_to.id := p_from.id;
1425 p_to.object_version_number := p_from.object_version_number;
1426 p_to.tal_id := p_from.tal_id;
1427 p_to.target_kle_id := p_from.target_kle_id;
1428 p_to.line_detail_number := p_from.line_detail_number;
1429 p_to.asset_number := p_from.asset_number;
1430 p_to.quantity := p_from.quantity;
1431 p_to.cost := p_from.cost;
1432 p_to.tax_book := p_from.tax_book;
1433 p_to.life_in_months_tax := p_from.life_in_months_tax;
1434 p_to.deprn_method_tax := p_from.deprn_method_tax;
1435 p_to.deprn_rate_tax := p_from.deprn_rate_tax;
1436 p_to.salvage_value := p_from.salvage_value;
1437 --
1438 p_to.SPLIT_PERCENT := p_from.SPLIT_PERCENT;
1439 p_to.INVENTORY_ITEM_ID := p_from.INVENTORY_ITEM_ID;
1440 --
1441 p_to.attribute_category := p_from.attribute_category;
1442 p_to.attribute1 := p_from.attribute1;
1443 p_to.attribute2 := p_from.attribute2;
1444 p_to.attribute3 := p_from.attribute3;
1445 p_to.attribute4 := p_from.attribute4;
1446 p_to.attribute5 := p_from.attribute5;
1447 p_to.attribute6 := p_from.attribute6;
1448 p_to.attribute7 := p_from.attribute7;
1449 p_to.attribute8 := p_from.attribute8;
1450 p_to.attribute9 := p_from.attribute9;
1451 p_to.attribute10 := p_from.attribute10;
1452 p_to.attribute11 := p_from.attribute11;
1453 p_to.attribute12 := p_from.attribute12;
1454 p_to.attribute13 := p_from.attribute13;
1455 p_to.attribute14 := p_from.attribute14;
1456 p_to.attribute15 := p_from.attribute15;
1457 p_to.created_by := p_from.created_by;
1458 p_to.creation_date := p_from.creation_date;
1459 p_to.last_updated_by := p_from.last_updated_by;
1460 p_to.last_update_date := p_from.last_update_date;
1461 p_to.last_update_login := p_from.last_update_login;
1462 -- Multi-Currency Change
1463 p_to.currency_code := p_from.currency_code;
1464 p_to.currency_conversion_type := p_from.currency_conversion_type;
1465 p_to.currency_conversion_rate := p_from.currency_conversion_rate;
1466 p_to.currency_conversion_date := p_from.currency_conversion_date;
1467 -- Multi-Currency Change
1468 END migrate;
1469 PROCEDURE migrate (
1470 p_from IN asdv_rec_type,
1471 p_to IN OUT NOCOPY okl_txd_assets_tl_rec_type
1472 ) IS
1473 BEGIN
1474 p_to.id := p_from.id;
1475 p_to.sfwt_flag := p_from.sfwt_flag;
1476 p_to.description := p_from.description;
1477 p_to.created_by := p_from.created_by;
1478 p_to.creation_date := p_from.creation_date;
1479 p_to.last_updated_by := p_from.last_updated_by;
1480 p_to.last_update_date := p_from.last_update_date;
1481 p_to.last_update_login := p_from.last_update_login;
1482 END migrate;
1483 PROCEDURE migrate (
1484 p_from IN okl_txd_assets_tl_rec_type,
1485 p_to IN OUT NOCOPY asdv_rec_type
1486 ) IS
1487 BEGIN
1488 p_to.id := p_from.id;
1489 p_to.sfwt_flag := p_from.sfwt_flag;
1490 p_to.description := p_from.description;
1491 p_to.created_by := p_from.created_by;
1492 p_to.creation_date := p_from.creation_date;
1493 p_to.last_updated_by := p_from.last_updated_by;
1494 p_to.last_update_date := p_from.last_update_date;
1495 p_to.last_update_login := p_from.last_update_login;
1496 END migrate;
1497
1498 ---------------------------------------------------------------------------
1499 -- PROCEDURE validate_row
1500 ---------------------------------------------------------------------------
1501 ---------------------------------------
1502 -- validate_row for:OKL_TXD_ASSETS_V --
1503 ---------------------------------------
1504 PROCEDURE validate_row(
1505 p_api_version IN NUMBER,
1506 p_init_msg_list IN VARCHAR2 DEFAULT OKC_API.G_FALSE,
1507 x_return_status OUT NOCOPY VARCHAR2,
1508 x_msg_count OUT NOCOPY NUMBER,
1509 x_msg_data OUT NOCOPY VARCHAR2,
1510 p_asdv_rec IN asdv_rec_type) IS
1511
1512 l_api_version CONSTANT NUMBER := 1;
1513 l_api_name CONSTANT VARCHAR2(30) := 'V_validate_row';
1514 l_return_status VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
1515 l_asdv_rec asdv_rec_type := p_asdv_rec;
1516 l_asd_rec asd_rec_type;
1517 l_okl_txd_assets_tl_rec okl_txd_assets_tl_rec_type;
1518 BEGIN
1519 l_return_status := OKC_API.START_ACTIVITY(l_api_name,
1520 G_PKG_NAME,
1521 p_init_msg_list,
1522 l_api_version,
1523 p_api_version,
1524 '_PVT',
1525 x_return_status);
1526 IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
1527 RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
1528 ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
1529 RAISE OKC_API.G_EXCEPTION_ERROR;
1530 END IF;
1531
1532 --- Validate all non-missing attributes (Item Level Validation)
1533 l_return_status := Validate_Attributes(l_asdv_rec);
1534 --- If any errors happen abort API
1535 IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
1536 RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
1537 ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
1538 RAISE OKC_API.G_EXCEPTION_ERROR;
1539 END IF;
1540 l_return_status := Validate_Record(l_asdv_rec);
1541 IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
1542 RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
1543 ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
1544 RAISE OKC_API.G_EXCEPTION_ERROR;
1545 END IF;
1546 OKC_API.END_ACTIVITY(x_msg_count, x_msg_data);
1547 EXCEPTION
1548 WHEN OKC_API.G_EXCEPTION_ERROR THEN
1549 x_return_status := OKC_API.HANDLE_EXCEPTIONS
1550 (
1551 l_api_name,
1552 G_PKG_NAME,
1553 'OKC_API.G_RET_STS_ERROR',
1554 x_msg_count,
1555 x_msg_data,
1556 '_PVT'
1557 );
1558 WHEN OKC_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
1559 x_return_status :=OKC_API.HANDLE_EXCEPTIONS
1560 (
1561 l_api_name,
1562 G_PKG_NAME,
1563 'OKC_API.G_RET_STS_UNEXP_ERROR',
1564 x_msg_count,
1565 x_msg_data,
1566 '_PVT'
1567 );
1568 WHEN OTHERS THEN
1569 x_return_status :=OKC_API.HANDLE_EXCEPTIONS
1570 (
1571 l_api_name,
1572 G_PKG_NAME,
1573 'OTHERS',
1574 x_msg_count,
1575 x_msg_data,
1576 '_PVT'
1577 );
1578 END validate_row;
1579 ------------------------------------------
1580 -- PL/SQL TBL validate_row for:ASDV_TBL --
1581 ------------------------------------------
1582 PROCEDURE validate_row(
1583 p_api_version IN NUMBER,
1584 p_init_msg_list IN VARCHAR2 DEFAULT OKC_API.G_FALSE,
1585 x_return_status OUT NOCOPY VARCHAR2,
1586 x_msg_count OUT NOCOPY NUMBER,
1587 x_msg_data OUT NOCOPY VARCHAR2,
1588 p_asdv_tbl IN asdv_tbl_type) IS
1589
1590 l_api_version CONSTANT NUMBER := 1;
1591 l_api_name CONSTANT VARCHAR2(30) := 'V_tbl_validate_row';
1592 l_return_status VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
1593 i NUMBER := 0;
1594 BEGIN
1595 OKC_API.init_msg_list(p_init_msg_list);
1596 -- Make sure PL/SQL table has records in it before passing
1597 IF (p_asdv_tbl.COUNT > 0) THEN
1598 i := p_asdv_tbl.FIRST;
1599 LOOP
1600 validate_row (
1601 p_api_version => p_api_version,
1602 p_init_msg_list => OKC_API.G_FALSE,
1603 x_return_status => x_return_status,
1604 x_msg_count => x_msg_count,
1605 x_msg_data => x_msg_data,
1606 p_asdv_rec => p_asdv_tbl(i));
1607 EXIT WHEN (i = p_asdv_tbl.LAST);
1608 i := p_asdv_tbl.NEXT(i);
1609 END LOOP;
1610 END IF;
1611 EXCEPTION
1612 WHEN OKC_API.G_EXCEPTION_ERROR THEN
1613 x_return_status := OKC_API.HANDLE_EXCEPTIONS
1614 (
1615 l_api_name,
1616 G_PKG_NAME,
1617 'OKC_API.G_RET_STS_ERROR',
1618 x_msg_count,
1619 x_msg_data,
1620 '_PVT'
1621 );
1622 WHEN OKC_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
1623 x_return_status :=OKC_API.HANDLE_EXCEPTIONS
1624 (
1625 l_api_name,
1626 G_PKG_NAME,
1627 'OKC_API.G_RET_STS_UNEXP_ERROR',
1628 x_msg_count,
1629 x_msg_data,
1630 '_PVT'
1631 );
1632 WHEN OTHERS THEN
1633 x_return_status :=OKC_API.HANDLE_EXCEPTIONS
1634 (
1635 l_api_name,
1636 G_PKG_NAME,
1637 'OTHERS',
1638 x_msg_count,
1639 x_msg_data,
1640 '_PVT'
1641 );
1642 END validate_row;
1643
1644 ---------------------------------------------------------------------------
1645 -- PROCEDURE insert_row
1646 ---------------------------------------------------------------------------
1647 -----------------------------------
1648 -- insert_row for:OKL_TXD_ASSETS_B --
1649 -----------------------------------
1650 PROCEDURE insert_row(
1651 p_init_msg_list IN VARCHAR2 DEFAULT OKC_API.G_FALSE,
1652 x_return_status OUT NOCOPY VARCHAR2,
1653 x_msg_count OUT NOCOPY NUMBER,
1654 x_msg_data OUT NOCOPY VARCHAR2,
1655 p_asd_rec IN asd_rec_type,
1656 x_asd_rec OUT NOCOPY asd_rec_type) IS
1657
1658 l_api_version CONSTANT NUMBER := 1;
1659 l_api_name CONSTANT VARCHAR2(30) := 'ASSETS_insert_row';
1660 l_return_status VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
1661 l_asd_rec asd_rec_type := p_asd_rec;
1662 l_def_asd_rec asd_rec_type;
1663 ---------------------------------------
1664 -- Set_Attributes for:OKL_TXD_ASSETS_B --
1665 ---------------------------------------
1666 FUNCTION Set_Attributes (
1667 p_asd_rec IN asd_rec_type,
1668 x_asd_rec OUT NOCOPY asd_rec_type
1669 ) RETURN VARCHAR2 IS
1670 l_return_status VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
1671 BEGIN
1672 x_asd_rec := p_asd_rec;
1673 RETURN(l_return_status);
1674 END Set_Attributes;
1675 BEGIN
1676 l_return_status := OKC_API.START_ACTIVITY(l_api_name,
1677 p_init_msg_list,
1678 '_PVT',
1679 x_return_status);
1680 IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
1681 RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
1682 ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
1683 RAISE OKC_API.G_EXCEPTION_ERROR;
1684 END IF;
1685 --- Setting item attributes
1686 l_return_status := Set_Attributes(
1687 p_asd_rec, -- IN
1688 l_asd_rec); -- OUT
1689 --- If any errors happen abort API
1690 IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
1691 RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
1692 ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
1693 RAISE OKC_API.G_EXCEPTION_ERROR;
1694 END IF;
1695 INSERT INTO OKL_TXD_ASSETS_B(
1696 id,
1697 object_version_number,
1698 tal_id,
1699 target_kle_id,
1700 line_detail_number,
1701 asset_number,
1702 quantity,
1703 cost,
1704 tax_book,
1705 life_in_months_tax,
1706 deprn_method_tax,
1707 deprn_rate_tax,
1708 salvage_value,
1709
1710 -- added new columns for split asset component
1711 SPLIT_PERCENT,
1712 INVENTORY_ITEM_ID,
1713 -- end of added new columns for split asset component
1714
1715 attribute_category,
1716 attribute1,
1717 attribute2,
1718 attribute3,
1719 attribute4,
1720 attribute5,
1721 attribute6,
1722 attribute7,
1723 attribute8,
1724 attribute9,
1725 attribute10,
1726 attribute11,
1727 attribute12,
1728 attribute13,
1729 attribute14,
1730 attribute15,
1731 created_by,
1732 creation_date,
1733 last_updated_by,
1734 last_update_date,
1735 last_update_login,
1736 -- Multi-Currency changes
1737 currency_code,
1738 currency_conversion_type,
1739 currency_conversion_rate,
1740 currency_conversion_date)
1741 -- Multi-Currency changes
1742 VALUES (
1743 l_asd_rec.id,
1744 l_asd_rec.object_version_number,
1745 l_asd_rec.tal_id,
1746 l_asd_rec.target_kle_id,
1747 l_asd_rec.line_detail_number,
1748 l_asd_rec.asset_number,
1749 l_asd_rec.quantity,
1750 l_asd_rec.cost,
1751 l_asd_rec.tax_book,
1752 l_asd_rec.life_in_months_tax,
1753 l_asd_rec.deprn_method_tax,
1754 l_asd_rec.deprn_rate_tax,
1755 l_asd_rec.salvage_value,
1756
1757 -- added new columns for split asset component
1758 l_asd_rec.SPLIT_PERCENT,
1759 l_asd_rec.INVENTORY_ITEM_ID,
1760 -- end of added new columns for split asset component
1761
1762 l_asd_rec.attribute_category,
1763 l_asd_rec.attribute1,
1764 l_asd_rec.attribute2,
1765 l_asd_rec.attribute3,
1766 l_asd_rec.attribute4,
1767 l_asd_rec.attribute5,
1768 l_asd_rec.attribute6,
1769 l_asd_rec.attribute7,
1770 l_asd_rec.attribute8,
1771 l_asd_rec.attribute9,
1772 l_asd_rec.attribute10,
1773 l_asd_rec.attribute11,
1774 l_asd_rec.attribute12,
1775 l_asd_rec.attribute13,
1776 l_asd_rec.attribute14,
1777 l_asd_rec.attribute15,
1778 l_asd_rec.created_by,
1779 l_asd_rec.creation_date,
1780 l_asd_rec.last_updated_by,
1781 l_asd_rec.last_update_date,
1782 l_asd_rec.last_update_login,
1783 -- Multi-Currency Change
1784 l_asd_rec.currency_code,
1785 l_asd_rec.currency_conversion_type,
1786 l_asd_rec.currency_conversion_rate,
1787 l_asd_rec.currency_conversion_date);
1788 -- Multi-Currency Change
1789 -- Set OUT values
1790 x_asd_rec := l_asd_rec;
1791 OKC_API.END_ACTIVITY(x_msg_count, x_msg_data);
1792 EXCEPTION
1793 WHEN OKC_API.G_EXCEPTION_ERROR THEN
1794 x_return_status := OKC_API.HANDLE_EXCEPTIONS
1795 (
1796 l_api_name,
1797 G_PKG_NAME,
1798 'OKC_API.G_RET_STS_ERROR',
1799 x_msg_count,
1800 x_msg_data,
1801 '_PVT'
1802 );
1803 WHEN OKC_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
1804 x_return_status :=OKC_API.HANDLE_EXCEPTIONS
1805 (
1806 l_api_name,
1807 G_PKG_NAME,
1808 'OKC_API.G_RET_STS_UNEXP_ERROR',
1809 x_msg_count,
1810 x_msg_data,
1811 '_PVT'
1812 );
1813 WHEN OTHERS THEN
1814 x_return_status :=OKC_API.HANDLE_EXCEPTIONS
1815 (
1816 l_api_name,
1817 G_PKG_NAME,
1818 'OTHERS',
1819 x_msg_count,
1820 x_msg_data,
1821 '_PVT'
1822 );
1823 END insert_row;
1824 --------------------------------------
1825 -- insert_row for:OKL_TXD_ASSETS_TL --
1826 --------------------------------------
1827 PROCEDURE insert_row(
1828 p_init_msg_list IN VARCHAR2 DEFAULT OKC_API.G_FALSE,
1829 x_return_status OUT NOCOPY VARCHAR2,
1830 x_msg_count OUT NOCOPY NUMBER,
1831 x_msg_data OUT NOCOPY VARCHAR2,
1832 p_okl_txd_assets_tl_rec IN okl_txd_assets_tl_rec_type,
1833 x_okl_txd_assets_tl_rec OUT NOCOPY okl_txd_assets_tl_rec_type) IS
1834
1835 l_api_version CONSTANT NUMBER := 1;
1836 l_api_name CONSTANT VARCHAR2(30) := 'TL_insert_row';
1837 l_return_status VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
1838 l_okl_txd_assets_tl_rec okl_txd_assets_tl_rec_type := p_okl_txd_assets_tl_rec;
1839 l_def_okl_txd_assets_tl_rec okl_txd_assets_tl_rec_type;
1840 CURSOR get_languages IS
1841 SELECT *
1842 FROM FND_LANGUAGES
1843 WHERE INSTALLED_FLAG IN ('I', 'B');
1844 ------------------------------------------
1845 -- Set_Attributes for:OKL_TXD_ASSETS_TL --
1846 ------------------------------------------
1847 FUNCTION Set_Attributes (
1848 p_okl_txd_assets_tl_rec IN okl_txd_assets_tl_rec_type,
1849 x_okl_txd_assets_tl_rec OUT NOCOPY okl_txd_assets_tl_rec_type
1850 ) RETURN VARCHAR2 IS
1851 l_return_status VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
1852 BEGIN
1853 x_okl_txd_assets_tl_rec := p_okl_txd_assets_tl_rec;
1854 x_okl_txd_assets_tl_rec.LANGUAGE := USERENV('LANG');
1855 x_okl_txd_assets_tl_rec.SOURCE_LANG := USERENV('LANG');
1856 RETURN(l_return_status);
1857 END Set_Attributes;
1858 BEGIN
1859 l_return_status := OKC_API.START_ACTIVITY(l_api_name,
1860 p_init_msg_list,
1861 '_PVT',
1862 x_return_status);
1863 IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
1864 RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
1865 ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
1866 RAISE OKC_API.G_EXCEPTION_ERROR;
1867 END IF;
1868 --- Setting item attributes
1869 l_return_status := Set_Attributes(
1870 p_okl_txd_assets_tl_rec, -- IN
1871 l_okl_txd_assets_tl_rec); -- OUT
1872 --- If any errors happen abort API
1873 IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
1874 RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
1875 ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
1876 RAISE OKC_API.G_EXCEPTION_ERROR;
1877 END IF;
1878 FOR l_lang_rec IN get_languages LOOP
1879 l_okl_txd_assets_tl_rec.language := l_lang_rec.language_code;
1880 INSERT INTO OKL_TXD_ASSETS_TL(
1881 id,
1882 language,
1883 source_lang,
1884 sfwt_flag,
1885 description,
1886 created_by,
1887 creation_date,
1888 last_updated_by,
1889 last_update_date,
1890 last_update_login)
1891 VALUES (
1892 l_okl_txd_assets_tl_rec.id,
1893 l_okl_txd_assets_tl_rec.language,
1894 l_okl_txd_assets_tl_rec.source_lang,
1895 l_okl_txd_assets_tl_rec.sfwt_flag,
1896 l_okl_txd_assets_tl_rec.description,
1897 l_okl_txd_assets_tl_rec.created_by,
1898 l_okl_txd_assets_tl_rec.creation_date,
1899 l_okl_txd_assets_tl_rec.last_updated_by,
1900 l_okl_txd_assets_tl_rec.last_update_date,
1901 l_okl_txd_assets_tl_rec.last_update_login);
1902 END LOOP;
1903 -- Set OUT values
1904 x_okl_txd_assets_tl_rec := l_okl_txd_assets_tl_rec;
1905 OKC_API.END_ACTIVITY(x_msg_count, x_msg_data);
1906 EXCEPTION
1907 WHEN OKC_API.G_EXCEPTION_ERROR THEN
1908 x_return_status := OKC_API.HANDLE_EXCEPTIONS
1909 (
1910 l_api_name,
1911 G_PKG_NAME,
1912 'OKC_API.G_RET_STS_ERROR',
1913 x_msg_count,
1914 x_msg_data,
1915 '_PVT'
1916 );
1917 WHEN OKC_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
1918 x_return_status :=OKC_API.HANDLE_EXCEPTIONS
1919 (
1920 l_api_name,
1921 G_PKG_NAME,
1922 'OKC_API.G_RET_STS_UNEXP_ERROR',
1923 x_msg_count,
1924 x_msg_data,
1925 '_PVT'
1926 );
1927 WHEN OTHERS THEN
1928 x_return_status :=OKC_API.HANDLE_EXCEPTIONS
1929 (
1930 l_api_name,
1931 G_PKG_NAME,
1932 'OTHERS',
1933 x_msg_count,
1934 x_msg_data,
1935 '_PVT'
1936 );
1937 END insert_row;
1938 -------------------------------------
1939 -- insert_row for:OKL_TXD_ASSETS_V --
1940 -------------------------------------
1941 PROCEDURE insert_row(
1942 p_api_version IN NUMBER,
1943 p_init_msg_list IN VARCHAR2 DEFAULT OKC_API.G_FALSE,
1944 x_return_status OUT NOCOPY VARCHAR2,
1945 x_msg_count OUT NOCOPY NUMBER,
1946 x_msg_data OUT NOCOPY VARCHAR2,
1947 p_asdv_rec IN asdv_rec_type,
1948 x_asdv_rec OUT NOCOPY asdv_rec_type) IS
1949
1950 l_api_version CONSTANT NUMBER := 1;
1951 l_api_name CONSTANT VARCHAR2(30) := 'V_insert_row';
1952 l_return_status VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
1953 l_asdv_rec asdv_rec_type;
1954 l_def_asdv_rec asdv_rec_type;
1955 l_asd_rec asd_rec_type;
1956 lx_asd_rec asd_rec_type;
1957 l_okl_txd_assets_tl_rec okl_txd_assets_tl_rec_type;
1958 lx_okl_txd_assets_tl_rec okl_txd_assets_tl_rec_type;
1959 lx_temp_asdv_rec asdv_rec_type;
1960 -------------------------------
1961 -- FUNCTION fill_who_columns --
1962 -------------------------------
1963 FUNCTION fill_who_columns (
1964 p_asdv_rec IN asdv_rec_type
1965 ) RETURN asdv_rec_type IS
1966 l_asdv_rec asdv_rec_type := p_asdv_rec;
1967 BEGIN
1968 l_asdv_rec.CREATION_DATE := SYSDATE;
1969 l_asdv_rec.CREATED_BY := FND_GLOBAL.USER_ID;
1970 l_asdv_rec.LAST_UPDATE_DATE := SYSDATE;
1971 l_asdv_rec.LAST_UPDATED_BY := FND_GLOBAL.USER_ID;
1972 l_asdv_rec.LAST_UPDATE_LOGIN := FND_GLOBAL.LOGIN_ID;
1973 RETURN(l_asdv_rec);
1974 END fill_who_columns;
1975 -----------------------------------------
1976 -- Set_Attributes for:OKL_TXD_ASSETS_V --
1977 -----------------------------------------
1978 FUNCTION Set_Attributes (
1979 p_asdv_rec IN asdv_rec_type,
1980 x_asdv_rec OUT NOCOPY asdv_rec_type
1981 ) RETURN VARCHAR2 IS
1982 l_return_status VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
1983 BEGIN
1984 x_asdv_rec := p_asdv_rec;
1985 x_asdv_rec.OBJECT_VERSION_NUMBER := 1;
1986 x_asdv_rec.SFWT_FLAG := 'N';
1987 RETURN(l_return_status);
1988 END Set_Attributes;
1989 BEGIN
1990 l_return_status := OKC_API.START_ACTIVITY(l_api_name,
1991 G_PKG_NAME,
1992 p_init_msg_list,
1993 l_api_version,
1994 p_api_version,
1995 '_PVT',
1996 x_return_status);
1997 IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
1998 RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
1999 ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
2000 RAISE OKC_API.G_EXCEPTION_ERROR;
2001 END IF;
2002 l_asdv_rec := null_out_defaults(p_asdv_rec);
2003 -- Set primary key value
2004 l_asdv_rec.ID := get_seq_id;
2005 --- Setting item attributes
2006 l_return_status := Set_Attributes(
2007 l_asdv_rec, -- IN
2008 l_def_asdv_rec); -- OUT
2009 --- If any errors happen abort API
2010 IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
2011 RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
2012 ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
2013 RAISE OKC_API.G_EXCEPTION_ERROR;
2014 END IF;
2015 l_def_asdv_rec := fill_who_columns(l_def_asdv_rec);
2016 --- Validate all non-missing attributes (Item Level Validation)
2017 l_return_status := Validate_Attributes(l_def_asdv_rec);
2018 --- If any errors happen abort API
2019 IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
2020 RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
2021 ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
2022 RAISE OKC_API.G_EXCEPTION_ERROR;
2023 END IF;
2024 l_return_status := Validate_Record(l_def_asdv_rec);
2025 IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
2026 RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
2027 ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
2028 RAISE OKC_API.G_EXCEPTION_ERROR;
2029 END IF;
2030
2031 --
2032 -- Multi-Currency Change, dedey, 12/04/2002
2033 --
2034 validate_currency(
2035 x_return_status => l_return_status,
2036 p_asdv_rec => l_def_asdv_rec,
2037 x_asdv_rec => lx_temp_asdv_rec
2038 );
2039
2040 IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
2041 RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
2042 ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
2043 RAISE OKC_API.G_EXCEPTION_ERROR;
2044 END IF;
2045 l_def_asdv_rec := lx_temp_asdv_rec;
2046
2047 --dbms_output.put_line('After Change: '||lx_temp_asdv_rec.currency_code);
2048 --dbms_output.put_line('After Change: '||l_def_asdv_rec.currency_code);
2049 --
2050 -- Multi-Currency Change
2051 --
2052
2053 -- Fix Bug# 2737014
2054 --
2055 -- Round off amounts
2056 --
2057 roundoff_line_amount(
2058 x_return_status => l_return_status,
2059 x_msg_count => x_msg_count,
2060 x_msg_data => x_msg_data,
2061 p_asdv_rec => l_def_asdv_rec,
2062 x_asdv_rec => lx_temp_asdv_rec
2063 );
2064
2065 IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
2066 RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
2067 ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
2068 RAISE OKC_API.G_EXCEPTION_ERROR;
2069 END IF;
2070 l_def_asdv_rec := lx_temp_asdv_rec;
2071
2072 --------------------------------------
2073 -- Move VIEW record to "Child" records
2074 --------------------------------------
2075 migrate(l_def_asdv_rec, l_asd_rec);
2076 migrate(l_def_asdv_rec, l_okl_txd_assets_tl_rec);
2077 --------------------------------------------
2078 -- Call the INSERT_ROW for each child record
2079 --------------------------------------------
2080 insert_row(
2081 p_init_msg_list,
2082 x_return_status,
2083 x_msg_count,
2084 x_msg_data,
2085 l_asd_rec,
2086 lx_asd_rec
2087 );
2088 IF (x_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
2089 RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
2090 ELSIF (x_return_status = OKC_API.G_RET_STS_ERROR) THEN
2091 RAISE OKC_API.G_EXCEPTION_ERROR;
2092 END IF;
2093 migrate(lx_asd_rec, l_def_asdv_rec);
2094 insert_row(
2095 p_init_msg_list,
2096 x_return_status,
2097 x_msg_count,
2098 x_msg_data,
2099 l_okl_txd_assets_tl_rec,
2100 lx_okl_txd_assets_tl_rec
2101 );
2102 IF (x_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
2103 RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
2104 ELSIF (x_return_status = OKC_API.G_RET_STS_ERROR) THEN
2105 RAISE OKC_API.G_EXCEPTION_ERROR;
2106 END IF;
2107 migrate(lx_okl_txd_assets_tl_rec, l_def_asdv_rec);
2108 -- Set OUT values
2109 x_asdv_rec := l_def_asdv_rec;
2110 OKC_API.END_ACTIVITY(x_msg_count, x_msg_data);
2111 EXCEPTION
2112 WHEN OKC_API.G_EXCEPTION_ERROR THEN
2113 x_return_status := OKC_API.HANDLE_EXCEPTIONS
2114 (
2115 l_api_name,
2116 G_PKG_NAME,
2117 'OKC_API.G_RET_STS_ERROR',
2118 x_msg_count,
2119 x_msg_data,
2120 '_PVT'
2121 );
2122 WHEN OKC_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
2123 x_return_status :=OKC_API.HANDLE_EXCEPTIONS
2124 (
2125 l_api_name,
2126 G_PKG_NAME,
2127 'OKC_API.G_RET_STS_UNEXP_ERROR',
2128 x_msg_count,
2129 x_msg_data,
2130 '_PVT'
2131 );
2132 WHEN OTHERS THEN
2133 x_return_status :=OKC_API.HANDLE_EXCEPTIONS
2134 (
2135 l_api_name,
2136 G_PKG_NAME,
2137 'OTHERS',
2138 x_msg_count,
2139 x_msg_data,
2140 '_PVT'
2141 );
2142 END insert_row;
2143 ----------------------------------------
2144 -- PL/SQL TBL insert_row for:ASDV_TBL --
2145 ----------------------------------------
2146 PROCEDURE insert_row(
2147 p_api_version IN NUMBER,
2148 p_init_msg_list IN VARCHAR2 DEFAULT OKC_API.G_FALSE,
2149 x_return_status OUT NOCOPY VARCHAR2,
2150 x_msg_count OUT NOCOPY NUMBER,
2151 x_msg_data OUT NOCOPY VARCHAR2,
2152 p_asdv_tbl IN asdv_tbl_type,
2153 x_asdv_tbl OUT NOCOPY asdv_tbl_type) IS
2154
2155 l_api_version CONSTANT NUMBER := 1;
2156 l_api_name CONSTANT VARCHAR2(30) := 'V_tbl_insert_row';
2157 l_return_status VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
2158 i NUMBER := 0;
2159 BEGIN
2160 OKC_API.init_msg_list(p_init_msg_list);
2161 -- Make sure PL/SQL table has records in it before passing
2162 IF (p_asdv_tbl.COUNT > 0) THEN
2163 i := p_asdv_tbl.FIRST;
2164 LOOP
2165 insert_row (
2166 p_api_version => p_api_version,
2167 p_init_msg_list => OKC_API.G_FALSE,
2168 x_return_status => x_return_status,
2169 x_msg_count => x_msg_count,
2170 x_msg_data => x_msg_data,
2171 p_asdv_rec => p_asdv_tbl(i),
2172 x_asdv_rec => x_asdv_tbl(i));
2173 EXIT WHEN (i = p_asdv_tbl.LAST);
2174 i := p_asdv_tbl.NEXT(i);
2175 END LOOP;
2176 END IF;
2177 EXCEPTION
2178 WHEN OKC_API.G_EXCEPTION_ERROR THEN
2179 x_return_status := OKC_API.HANDLE_EXCEPTIONS
2180 (
2181 l_api_name,
2182 G_PKG_NAME,
2183 'OKC_API.G_RET_STS_ERROR',
2184 x_msg_count,
2185 x_msg_data,
2186 '_PVT'
2187 );
2188 WHEN OKC_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
2189 x_return_status :=OKC_API.HANDLE_EXCEPTIONS
2190 (
2191 l_api_name,
2192 G_PKG_NAME,
2193 'OKC_API.G_RET_STS_UNEXP_ERROR',
2194 x_msg_count,
2195 x_msg_data,
2196 '_PVT'
2197 );
2198 WHEN OTHERS THEN
2199 x_return_status :=OKC_API.HANDLE_EXCEPTIONS
2200 (
2201 l_api_name,
2202 G_PKG_NAME,
2203 'OTHERS',
2204 x_msg_count,
2205 x_msg_data,
2206 '_PVT'
2207 );
2208 END insert_row;
2209
2210 ---------------------------------------------------------------------------
2211 -- PROCEDURE lock_row
2212 ---------------------------------------------------------------------------
2213 ---------------------------------
2214 -- lock_row for:OKL_TXD_ASSETS_B --
2215 ---------------------------------
2216 PROCEDURE lock_row(
2217 p_init_msg_list IN VARCHAR2 DEFAULT OKC_API.G_FALSE,
2218 x_return_status OUT NOCOPY VARCHAR2,
2219 x_msg_count OUT NOCOPY NUMBER,
2220 x_msg_data OUT NOCOPY VARCHAR2,
2221 p_asd_rec IN asd_rec_type) IS
2222
2223 E_Resource_Busy EXCEPTION;
2224 PRAGMA EXCEPTION_INIT(E_Resource_Busy, -00054);
2225 CURSOR lock_csr (p_asd_rec IN asd_rec_type) IS
2226 SELECT OBJECT_VERSION_NUMBER
2227 FROM OKL_TXD_ASSETS_B
2228 WHERE ID = p_asd_rec.id
2229 AND OBJECT_VERSION_NUMBER = p_asd_rec.object_version_number
2230 FOR UPDATE OF OBJECT_VERSION_NUMBER NOWAIT;
2231
2232 CURSOR lchk_csr (p_asd_rec IN asd_rec_type) IS
2233 SELECT OBJECT_VERSION_NUMBER
2234 FROM OKL_TXD_ASSETS_B
2235 WHERE ID = p_asd_rec.id;
2236 l_api_version CONSTANT NUMBER := 1;
2237 l_api_name CONSTANT VARCHAR2(30) := 'ASSETS_lock_row';
2238 l_return_status VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
2239 l_object_version_number OKL_TXD_ASSETS_B.OBJECT_VERSION_NUMBER%TYPE;
2240 lc_object_version_number OKL_TXD_ASSETS_B.OBJECT_VERSION_NUMBER%TYPE;
2241 l_row_notfound BOOLEAN := FALSE;
2242 lc_row_notfound BOOLEAN := FALSE;
2243 BEGIN
2244 l_return_status := OKC_API.START_ACTIVITY(l_api_name,
2245 p_init_msg_list,
2246 '_PVT',
2247 x_return_status);
2248 IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
2249 RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
2250 ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
2251 RAISE OKC_API.G_EXCEPTION_ERROR;
2252 END IF;
2253 BEGIN
2254 OPEN lock_csr(p_asd_rec);
2255 FETCH lock_csr INTO l_object_version_number;
2256 l_row_notfound := lock_csr%NOTFOUND;
2257 CLOSE lock_csr;
2258 EXCEPTION
2259 WHEN E_Resource_Busy THEN
2260 IF (lock_csr%ISOPEN) THEN
2261 CLOSE lock_csr;
2262 END IF;
2263 OKC_API.set_message(G_FND_APP,G_FORM_UNABLE_TO_RESERVE_REC);
2264 RAISE APP_EXCEPTIONS.RECORD_LOCK_EXCEPTION;
2265 END;
2266
2267 IF ( l_row_notfound ) THEN
2268 OPEN lchk_csr(p_asd_rec);
2269 FETCH lchk_csr INTO lc_object_version_number;
2270 lc_row_notfound := lchk_csr%NOTFOUND;
2271 CLOSE lchk_csr;
2272 END IF;
2273 IF (lc_row_notfound) THEN
2274 OKC_API.set_message(G_FND_APP,G_FORM_RECORD_DELETED);
2275 RAISE OKC_API.G_EXCEPTION_ERROR;
2276 ELSIF lc_object_version_number > p_asd_rec.object_version_number THEN
2277 OKC_API.set_message(G_FND_APP,G_FORM_RECORD_CHANGED);
2278 RAISE OKC_API.G_EXCEPTION_ERROR;
2279 ELSIF lc_object_version_number <> p_asd_rec.object_version_number THEN
2280 OKC_API.set_message(G_FND_APP,G_FORM_RECORD_CHANGED);
2281 RAISE OKC_API.G_EXCEPTION_ERROR;
2282 ELSIF lc_object_version_number = -1 THEN
2283 OKC_API.set_message(G_APP_NAME,G_RECORD_LOGICALLY_DELETED);
2284 RAISE OKC_API.G_EXCEPTION_ERROR;
2285 END IF;
2286 OKC_API.END_ACTIVITY(x_msg_count, x_msg_data);
2287 EXCEPTION
2288 WHEN OKC_API.G_EXCEPTION_ERROR THEN
2289 x_return_status := OKC_API.HANDLE_EXCEPTIONS
2290 (
2291 l_api_name,
2292 G_PKG_NAME,
2293 'OKC_API.G_RET_STS_ERROR',
2294 x_msg_count,
2295 x_msg_data,
2296 '_PVT'
2297 );
2298 WHEN OKC_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
2299 x_return_status :=OKC_API.HANDLE_EXCEPTIONS
2300 (
2301 l_api_name,
2302 G_PKG_NAME,
2303 'OKC_API.G_RET_STS_UNEXP_ERROR',
2304 x_msg_count,
2305 x_msg_data,
2306 '_PVT'
2307 );
2308 WHEN OTHERS THEN
2309 x_return_status :=OKC_API.HANDLE_EXCEPTIONS
2310 (
2311 l_api_name,
2312 G_PKG_NAME,
2313 'OTHERS',
2314 x_msg_count,
2315 x_msg_data,
2316 '_PVT'
2317 );
2318 END lock_row;
2319 ------------------------------------
2320 -- lock_row for:OKL_TXD_ASSETS_TL --
2321 ------------------------------------
2322 PROCEDURE lock_row(
2323 p_init_msg_list IN VARCHAR2 DEFAULT OKC_API.G_FALSE,
2324 x_return_status OUT NOCOPY VARCHAR2,
2325 x_msg_count OUT NOCOPY NUMBER,
2326 x_msg_data OUT NOCOPY VARCHAR2,
2327 p_okl_txd_assets_tl_rec IN okl_txd_assets_tl_rec_type) IS
2328
2329 E_Resource_Busy EXCEPTION;
2330 PRAGMA EXCEPTION_INIT(E_Resource_Busy, -00054);
2331 CURSOR lock_csr (p_okl_txd_assets_tl_rec IN okl_txd_assets_tl_rec_type) IS
2332 SELECT *
2333 FROM OKL_TXD_ASSETS_TL
2334 WHERE ID = p_okl_txd_assets_tl_rec.id
2335 FOR UPDATE NOWAIT;
2336
2337 l_api_version CONSTANT NUMBER := 1;
2338 l_api_name CONSTANT VARCHAR2(30) := 'TL_lock_row';
2339 l_return_status VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
2340 l_lock_var lock_csr%ROWTYPE;
2341 l_row_notfound BOOLEAN := FALSE;
2342 lc_row_notfound BOOLEAN := FALSE;
2343 BEGIN
2344 l_return_status := OKC_API.START_ACTIVITY(l_api_name,
2345 p_init_msg_list,
2346 '_PVT',
2347 x_return_status);
2348 IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
2349 RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
2350 ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
2351 RAISE OKC_API.G_EXCEPTION_ERROR;
2352 END IF;
2353 BEGIN
2354 OPEN lock_csr(p_okl_txd_assets_tl_rec);
2355 FETCH lock_csr INTO l_lock_var;
2356 l_row_notfound := lock_csr%NOTFOUND;
2357 CLOSE lock_csr;
2358 EXCEPTION
2359 WHEN E_Resource_Busy THEN
2360 IF (lock_csr%ISOPEN) THEN
2361 CLOSE lock_csr;
2362 END IF;
2363 OKC_API.set_message(G_FND_APP,G_FORM_UNABLE_TO_RESERVE_REC);
2364 RAISE APP_EXCEPTIONS.RECORD_LOCK_EXCEPTION;
2365 END;
2366
2367 IF ( l_row_notfound ) THEN
2368 OKC_API.set_message(G_FND_APP,G_FORM_RECORD_DELETED);
2369 RAISE OKC_API.G_EXCEPTION_ERROR;
2370 END IF;
2371 OKC_API.END_ACTIVITY(x_msg_count, x_msg_data);
2372 EXCEPTION
2373 WHEN OKC_API.G_EXCEPTION_ERROR THEN
2374 x_return_status := OKC_API.HANDLE_EXCEPTIONS
2375 (
2376 l_api_name,
2377 G_PKG_NAME,
2378 'OKC_API.G_RET_STS_ERROR',
2379 x_msg_count,
2380 x_msg_data,
2381 '_PVT'
2382 );
2383 WHEN OKC_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
2384 x_return_status :=OKC_API.HANDLE_EXCEPTIONS
2385 (
2386 l_api_name,
2387 G_PKG_NAME,
2388 'OKC_API.G_RET_STS_UNEXP_ERROR',
2389 x_msg_count,
2390 x_msg_data,
2391 '_PVT'
2392 );
2393 WHEN OTHERS THEN
2394 x_return_status :=OKC_API.HANDLE_EXCEPTIONS
2395 (
2396 l_api_name,
2397 G_PKG_NAME,
2398 'OTHERS',
2399 x_msg_count,
2400 x_msg_data,
2401 '_PVT'
2402 );
2403 END lock_row;
2404 -----------------------------------
2405 -- lock_row for:OKL_TXD_ASSETS_V --
2406 -----------------------------------
2407 PROCEDURE lock_row(
2408 p_api_version IN NUMBER,
2409 p_init_msg_list IN VARCHAR2 DEFAULT OKC_API.G_FALSE,
2410 x_return_status OUT NOCOPY VARCHAR2,
2411 x_msg_count OUT NOCOPY NUMBER,
2412 x_msg_data OUT NOCOPY VARCHAR2,
2413 p_asdv_rec IN asdv_rec_type) IS
2414
2415 l_api_version CONSTANT NUMBER := 1;
2416 l_api_name CONSTANT VARCHAR2(30) := 'V_lock_row';
2417 l_return_status VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
2418 l_asd_rec asd_rec_type;
2419 l_okl_txd_assets_tl_rec okl_txd_assets_tl_rec_type;
2420 BEGIN
2421 l_return_status := OKC_API.START_ACTIVITY(l_api_name,
2422 G_PKG_NAME,
2423 p_init_msg_list,
2424 l_api_version,
2425 p_api_version,
2426 '_PVT',
2427 x_return_status);
2428 IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
2429 RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
2430 ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
2431 RAISE OKC_API.G_EXCEPTION_ERROR;
2432 END IF;
2433 --------------------------------------
2434 -- Move VIEW record to "Child" records
2435 --------------------------------------
2436 migrate(p_asdv_rec, l_asd_rec);
2437 migrate(p_asdv_rec, l_okl_txd_assets_tl_rec);
2438 --------------------------------------------
2439 -- Call the LOCK_ROW for each child record
2440 --------------------------------------------
2441 lock_row(
2442 p_init_msg_list,
2443 x_return_status,
2444 x_msg_count,
2445 x_msg_data,
2446 l_asd_rec
2447 );
2448 IF (x_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
2449 RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
2450 ELSIF (x_return_status = OKC_API.G_RET_STS_ERROR) THEN
2451 RAISE OKC_API.G_EXCEPTION_ERROR;
2452 END IF;
2453 lock_row(
2454 p_init_msg_list,
2455 x_return_status,
2456 x_msg_count,
2457 x_msg_data,
2458 l_okl_txd_assets_tl_rec
2459 );
2460 IF (x_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
2461 RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
2462 ELSIF (x_return_status = OKC_API.G_RET_STS_ERROR) THEN
2463 RAISE OKC_API.G_EXCEPTION_ERROR;
2464 END IF;
2465 OKC_API.END_ACTIVITY(x_msg_count, x_msg_data);
2466 EXCEPTION
2467 WHEN OKC_API.G_EXCEPTION_ERROR THEN
2468 x_return_status := OKC_API.HANDLE_EXCEPTIONS
2469 (
2470 l_api_name,
2471 G_PKG_NAME,
2472 'OKC_API.G_RET_STS_ERROR',
2473 x_msg_count,
2474 x_msg_data,
2475 '_PVT'
2476 );
2477 WHEN OKC_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
2478 x_return_status :=OKC_API.HANDLE_EXCEPTIONS
2479 (
2480 l_api_name,
2481 G_PKG_NAME,
2482 'OKC_API.G_RET_STS_UNEXP_ERROR',
2483 x_msg_count,
2484 x_msg_data,
2485 '_PVT'
2486 );
2487 WHEN OTHERS THEN
2488 x_return_status :=OKC_API.HANDLE_EXCEPTIONS
2489 (
2490 l_api_name,
2491 G_PKG_NAME,
2492 'OTHERS',
2493 x_msg_count,
2494 x_msg_data,
2495 '_PVT'
2496 );
2497 END lock_row;
2498 --------------------------------------
2499 -- PL/SQL TBL lock_row for:ASDV_TBL --
2500 --------------------------------------
2501 PROCEDURE lock_row(
2502 p_api_version IN NUMBER,
2503 p_init_msg_list IN VARCHAR2 DEFAULT OKC_API.G_FALSE,
2504 x_return_status OUT NOCOPY VARCHAR2,
2505 x_msg_count OUT NOCOPY NUMBER,
2506 x_msg_data OUT NOCOPY VARCHAR2,
2507 p_asdv_tbl IN asdv_tbl_type) IS
2508
2509 l_api_version CONSTANT NUMBER := 1;
2510 l_api_name CONSTANT VARCHAR2(30) := 'V_tbl_lock_row';
2511 l_return_status VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
2512 i NUMBER := 0;
2513 BEGIN
2514 OKC_API.init_msg_list(p_init_msg_list);
2515 -- Make sure PL/SQL table has records in it before passing
2516 IF (p_asdv_tbl.COUNT > 0) THEN
2517 i := p_asdv_tbl.FIRST;
2518 LOOP
2519 lock_row (
2520 p_api_version => p_api_version,
2521 p_init_msg_list => OKC_API.G_FALSE,
2522 x_return_status => x_return_status,
2523 x_msg_count => x_msg_count,
2524 x_msg_data => x_msg_data,
2525 p_asdv_rec => p_asdv_tbl(i));
2526 EXIT WHEN (i = p_asdv_tbl.LAST);
2527 i := p_asdv_tbl.NEXT(i);
2528 END LOOP;
2529 END IF;
2530 EXCEPTION
2531 WHEN OKC_API.G_EXCEPTION_ERROR THEN
2532 x_return_status := OKC_API.HANDLE_EXCEPTIONS
2533 (
2534 l_api_name,
2535 G_PKG_NAME,
2536 'OKC_API.G_RET_STS_ERROR',
2537 x_msg_count,
2538 x_msg_data,
2539 '_PVT'
2540 );
2541 WHEN OKC_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
2542 x_return_status :=OKC_API.HANDLE_EXCEPTIONS
2543 (
2544 l_api_name,
2545 G_PKG_NAME,
2546 'OKC_API.G_RET_STS_UNEXP_ERROR',
2547 x_msg_count,
2548 x_msg_data,
2549 '_PVT'
2550 );
2551 WHEN OTHERS THEN
2552 x_return_status :=OKC_API.HANDLE_EXCEPTIONS
2553 (
2554 l_api_name,
2555 G_PKG_NAME,
2556 'OTHERS',
2557 x_msg_count,
2558 x_msg_data,
2559 '_PVT'
2560 );
2561 END lock_row;
2562
2563 ---------------------------------------------------------------------------
2564 -- PROCEDURE update_row
2565 ---------------------------------------------------------------------------
2566 -----------------------------------
2567 -- update_row for:OKL_TXD_ASSETS_B --
2568 -----------------------------------
2569 PROCEDURE update_row(
2570 p_init_msg_list IN VARCHAR2 DEFAULT OKC_API.G_FALSE,
2571 x_return_status OUT NOCOPY VARCHAR2,
2572 x_msg_count OUT NOCOPY NUMBER,
2573 x_msg_data OUT NOCOPY VARCHAR2,
2574 p_asd_rec IN asd_rec_type,
2575 x_asd_rec OUT NOCOPY asd_rec_type) IS
2576
2577 l_api_version CONSTANT NUMBER := 1;
2578 l_api_name CONSTANT VARCHAR2(30) := 'ASSETS_update_row';
2579 l_return_status VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
2580 l_asd_rec asd_rec_type := p_asd_rec;
2581 l_def_asd_rec asd_rec_type;
2582 l_row_notfound BOOLEAN := TRUE;
2583 ----------------------------------
2584 -- FUNCTION populate_new_record --
2585 ----------------------------------
2586 FUNCTION populate_new_record (
2587 p_asd_rec IN asd_rec_type,
2588 x_asd_rec OUT NOCOPY asd_rec_type
2589 ) RETURN VARCHAR2 IS
2590 l_asd_rec asd_rec_type;
2591 l_row_notfound BOOLEAN := TRUE;
2592 l_return_status VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
2593 BEGIN
2594 x_asd_rec := p_asd_rec;
2595 -- Get current database values
2596 l_asd_rec := get_rec(p_asd_rec, l_row_notfound);
2597 IF (l_row_notfound) THEN
2598 l_return_status := OKC_API.G_RET_STS_UNEXP_ERROR;
2599 END IF;
2600 IF (x_asd_rec.id = OKC_API.G_MISS_NUM)
2601 THEN
2602 x_asd_rec.id := l_asd_rec.id;
2603 END IF;
2604 IF (x_asd_rec.object_version_number = OKC_API.G_MISS_NUM)
2605 THEN
2606 x_asd_rec.object_version_number := l_asd_rec.object_version_number;
2607 END IF;
2608 IF (x_asd_rec.tal_id = OKC_API.G_MISS_NUM)
2609 THEN
2610 x_asd_rec.tal_id := l_asd_rec.tal_id;
2611 END IF;
2612 IF (x_asd_rec.target_kle_id = OKC_API.G_MISS_NUM)
2613 THEN
2614 x_asd_rec.target_kle_id := l_asd_rec.target_kle_id;
2615 END IF;
2616 IF (x_asd_rec.line_detail_number = OKC_API.G_MISS_NUM)
2617 THEN
2618 x_asd_rec.line_detail_number := l_asd_rec.line_detail_number;
2619 END IF;
2620 IF (x_asd_rec.asset_number = OKC_API.G_MISS_CHAR)
2621 THEN
2622 x_asd_rec.asset_number := l_asd_rec.asset_number;
2623 END IF;
2624 IF (x_asd_rec.quantity = OKC_API.G_MISS_NUM)
2625 THEN
2626 x_asd_rec.quantity := l_asd_rec.quantity;
2627 END IF;
2628 IF (x_asd_rec.cost = OKC_API.G_MISS_NUM)
2629 THEN
2630 x_asd_rec.cost := l_asd_rec.cost;
2631 END IF;
2632 IF (x_asd_rec.tax_book = OKC_API.G_MISS_CHAR)
2633 THEN
2634 x_asd_rec.tax_book := l_asd_rec.tax_book;
2635 END IF;
2636 IF (x_asd_rec.life_in_months_tax = OKC_API.G_MISS_NUM)
2637 THEN
2638 x_asd_rec.life_in_months_tax := l_asd_rec.life_in_months_tax;
2639 END IF;
2640 IF (x_asd_rec.deprn_method_tax = OKC_API.G_MISS_CHAR)
2641 THEN
2642 x_asd_rec.deprn_method_tax := l_asd_rec.deprn_method_tax;
2643 END IF;
2644 IF (x_asd_rec.deprn_rate_tax = OKC_API.G_MISS_NUM)
2645 THEN
2646 x_asd_rec.deprn_rate_tax := l_asd_rec.deprn_rate_tax;
2647 END IF;
2648 IF (x_asd_rec.salvage_value = OKC_API.G_MISS_NUM)
2649 THEN
2650 x_asd_rec.salvage_value := l_asd_rec.salvage_value;
2651 END IF;
2652
2653 -- added new columns for split asset component
2654 IF (x_asd_rec.SPLIT_PERCENT = OKC_API.G_MISS_NUM)
2655 THEN
2656 x_asd_rec.SPLIT_PERCENT := l_asd_rec.SPLIT_PERCENT;
2657 END IF;
2658 IF (x_asd_rec.INVENTORY_ITEM_ID = OKC_API.G_MISS_NUM)
2659 THEN
2660 x_asd_rec.INVENTORY_ITEM_ID := l_asd_rec.INVENTORY_ITEM_ID;
2661 END IF;
2662 -- end of added new columns for split asset component
2663
2664 IF (x_asd_rec.attribute_category = OKC_API.G_MISS_CHAR)
2665 THEN
2666 x_asd_rec.attribute_category := l_asd_rec.attribute_category;
2667 END IF;
2668 IF (x_asd_rec.attribute1 = OKC_API.G_MISS_CHAR)
2669 THEN
2670 x_asd_rec.attribute1 := l_asd_rec.attribute1;
2671 END IF;
2672 IF (x_asd_rec.attribute2 = OKC_API.G_MISS_CHAR)
2673 THEN
2674 x_asd_rec.attribute2 := l_asd_rec.attribute2;
2675 END IF;
2676 IF (x_asd_rec.attribute3 = OKC_API.G_MISS_CHAR)
2677 THEN
2678 x_asd_rec.attribute3 := l_asd_rec.attribute3;
2679 END IF;
2680 IF (x_asd_rec.attribute4 = OKC_API.G_MISS_CHAR)
2681 THEN
2682 x_asd_rec.attribute4 := l_asd_rec.attribute4;
2683 END IF;
2684 IF (x_asd_rec.attribute5 = OKC_API.G_MISS_CHAR)
2685 THEN
2686 x_asd_rec.attribute5 := l_asd_rec.attribute5;
2687 END IF;
2688 IF (x_asd_rec.attribute6 = OKC_API.G_MISS_CHAR)
2689 THEN
2690 x_asd_rec.attribute6 := l_asd_rec.attribute6;
2691 END IF;
2692 IF (x_asd_rec.attribute7 = OKC_API.G_MISS_CHAR)
2693 THEN
2694 x_asd_rec.attribute7 := l_asd_rec.attribute7;
2695 END IF;
2696 IF (x_asd_rec.attribute8 = OKC_API.G_MISS_CHAR)
2697 THEN
2698 x_asd_rec.attribute8 := l_asd_rec.attribute8;
2699 END IF;
2700 IF (x_asd_rec.attribute9 = OKC_API.G_MISS_CHAR)
2701 THEN
2702 x_asd_rec.attribute9 := l_asd_rec.attribute9;
2703 END IF;
2704 IF (x_asd_rec.attribute10 = OKC_API.G_MISS_CHAR)
2705 THEN
2706 x_asd_rec.attribute10 := l_asd_rec.attribute10;
2707 END IF;
2708 IF (x_asd_rec.attribute11 = OKC_API.G_MISS_CHAR)
2709 THEN
2710 x_asd_rec.attribute11 := l_asd_rec.attribute11;
2711 END IF;
2712 IF (x_asd_rec.attribute12 = OKC_API.G_MISS_CHAR)
2713 THEN
2714 x_asd_rec.attribute12 := l_asd_rec.attribute12;
2715 END IF;
2716 IF (x_asd_rec.attribute13 = OKC_API.G_MISS_CHAR)
2717 THEN
2718 x_asd_rec.attribute13 := l_asd_rec.attribute13;
2719 END IF;
2720 IF (x_asd_rec.attribute14 = OKC_API.G_MISS_CHAR)
2721 THEN
2722 x_asd_rec.attribute14 := l_asd_rec.attribute14;
2723 END IF;
2724 IF (x_asd_rec.attribute15 = OKC_API.G_MISS_CHAR)
2725 THEN
2726 x_asd_rec.attribute15 := l_asd_rec.attribute15;
2727 END IF;
2728 IF (x_asd_rec.created_by = OKC_API.G_MISS_NUM)
2729 THEN
2730 x_asd_rec.created_by := l_asd_rec.created_by;
2731 END IF;
2732 IF (x_asd_rec.creation_date = OKC_API.G_MISS_DATE)
2733 THEN
2734 x_asd_rec.creation_date := l_asd_rec.creation_date;
2735 END IF;
2736 IF (x_asd_rec.last_updated_by = OKC_API.G_MISS_NUM)
2737 THEN
2738 x_asd_rec.last_updated_by := l_asd_rec.last_updated_by;
2739 END IF;
2740 IF (x_asd_rec.last_update_date = OKC_API.G_MISS_DATE)
2741 THEN
2742 x_asd_rec.last_update_date := l_asd_rec.last_update_date;
2743 END IF;
2744 IF (x_asd_rec.last_update_login = OKC_API.G_MISS_NUM)
2745 THEN
2746 x_asd_rec.last_update_login := l_asd_rec.last_update_login;
2747 END IF;
2748 -- Multi Currency Change
2749 IF (x_asd_rec.currency_code = OKC_API.G_MISS_CHAR)
2750 THEN
2751 x_asd_rec.currency_code := l_asd_rec.currency_code;
2752 END IF;
2753 IF (x_asd_rec.currency_conversion_type = OKC_API.G_MISS_CHAR)
2754 THEN
2755 x_asd_rec.currency_conversion_type := l_asd_rec.currency_conversion_type;
2756 END IF;
2757 IF (x_asd_rec.currency_conversion_rate = OKC_API.G_MISS_NUM)
2758 THEN
2759 x_asd_rec.currency_conversion_rate := l_asd_rec.currency_conversion_rate;
2760 END IF;
2761 IF (x_asd_rec.currency_conversion_date = OKC_API.G_MISS_DATE)
2762 THEN
2763 x_asd_rec.currency_conversion_date := l_asd_rec.currency_conversion_date;
2764 END IF;
2765 -- Multi Currency Change
2766 RETURN(l_return_status);
2767 END populate_new_record;
2768 ---------------------------------------
2769 -- Set_Attributes for:OKL_TXD_ASSETS_B --
2770 ---------------------------------------
2771 FUNCTION Set_Attributes (
2772 p_asd_rec IN asd_rec_type,
2773 x_asd_rec OUT NOCOPY asd_rec_type
2774 ) RETURN VARCHAR2 IS
2775 l_return_status VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
2776 BEGIN
2777 x_asd_rec := p_asd_rec;
2778 RETURN(l_return_status);
2779 END Set_Attributes;
2780 BEGIN
2781 l_return_status := OKC_API.START_ACTIVITY(l_api_name,
2782 p_init_msg_list,
2783 '_PVT',
2784 x_return_status);
2785 IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
2786 RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
2787 ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
2788 RAISE OKC_API.G_EXCEPTION_ERROR;
2789 END IF;
2790 --- Setting item attributes
2791 l_return_status := Set_Attributes(
2792 p_asd_rec, -- IN
2793 l_asd_rec); -- OUT
2794 --- If any errors happen abort API
2795 IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
2796 RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
2797 ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
2798 RAISE OKC_API.G_EXCEPTION_ERROR;
2799 END IF;
2800 l_return_status := populate_new_record(l_asd_rec, l_def_asd_rec);
2801 IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
2802 RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
2803 ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
2804 RAISE OKC_API.G_EXCEPTION_ERROR;
2805 END IF;
2806 UPDATE OKL_TXD_ASSETS_B
2807 SET OBJECT_VERSION_NUMBER = l_def_asd_rec.object_version_number,
2808 TAL_ID = l_def_asd_rec.tal_id,
2809 TARGET_KLE_ID = l_def_asd_rec.target_kle_id,
2810 LINE_DETAIL_NUMBER = l_def_asd_rec.line_detail_number,
2811 ASSET_NUMBER = l_def_asd_rec.asset_number,
2812 QUANTITY = l_def_asd_rec.quantity,
2813 COST = l_def_asd_rec.cost,
2814 TAX_BOOK = l_def_asd_rec.tax_book,
2815 LIFE_IN_MONTHS_TAX = l_def_asd_rec.life_in_months_tax,
2816 DEPRN_METHOD_TAX = l_def_asd_rec.deprn_method_tax,
2817 DEPRN_RATE_TAX = l_def_asd_rec.deprn_rate_tax,
2818 SALVAGE_VALUE = l_def_asd_rec.salvage_value,
2819
2820 -- added new columns for split asset component
2821 SPLIT_PERCENT = l_def_asd_rec.SPLIT_PERCENT,
2822 INVENTORY_ITEM_ID = l_def_asd_rec.INVENTORY_ITEM_ID,
2823 -- end of added new columns for split asset component
2824
2825 ATTRIBUTE_CATEGORY = l_def_asd_rec.attribute_category,
2826 ATTRIBUTE1 = l_def_asd_rec.attribute1,
2827 ATTRIBUTE2 = l_def_asd_rec.attribute2,
2828 ATTRIBUTE3 = l_def_asd_rec.attribute3,
2829 ATTRIBUTE4 = l_def_asd_rec.attribute4,
2830 ATTRIBUTE5 = l_def_asd_rec.attribute5,
2831 ATTRIBUTE6 = l_def_asd_rec.attribute6,
2832 ATTRIBUTE7 = l_def_asd_rec.attribute7,
2833 ATTRIBUTE8 = l_def_asd_rec.attribute8,
2834 ATTRIBUTE9 = l_def_asd_rec.attribute9,
2835 ATTRIBUTE10 = l_def_asd_rec.attribute10,
2836 ATTRIBUTE11 = l_def_asd_rec.attribute11,
2837 ATTRIBUTE12 = l_def_asd_rec.attribute12,
2838 ATTRIBUTE13 = l_def_asd_rec.attribute13,
2839 ATTRIBUTE14 = l_def_asd_rec.attribute14,
2840 ATTRIBUTE15 = l_def_asd_rec.attribute15,
2841 CREATED_BY = l_def_asd_rec.created_by,
2842 CREATION_DATE = l_def_asd_rec.creation_date,
2843 LAST_UPDATED_BY = l_def_asd_rec.last_updated_by,
2844 LAST_UPDATE_DATE = l_def_asd_rec.last_update_date,
2845 LAST_UPDATE_LOGIN = l_def_asd_rec.last_update_login,
2846 CURRENCY_CODE = l_def_asd_rec.currency_code,
2847 CURRENCY_CONVERSION_TYPE = l_def_asd_rec.currency_conversion_type,
2848 CURRENCY_CONVERSION_RATE = l_def_asd_rec.currency_conversion_rate,
2849 CURRENCY_CONVERSION_DATE = l_def_asd_rec.currency_conversion_date
2850 WHERE ID = l_def_asd_rec.id;
2851
2852 x_asd_rec := l_def_asd_rec;
2853 OKC_API.END_ACTIVITY(x_msg_count, x_msg_data);
2854 EXCEPTION
2855 WHEN OKC_API.G_EXCEPTION_ERROR THEN
2856 x_return_status := OKC_API.HANDLE_EXCEPTIONS
2857 (
2858 l_api_name,
2859 G_PKG_NAME,
2860 'OKC_API.G_RET_STS_ERROR',
2861 x_msg_count,
2862 x_msg_data,
2863 '_PVT'
2864 );
2865 WHEN OKC_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
2866 x_return_status :=OKC_API.HANDLE_EXCEPTIONS
2867 (
2868 l_api_name,
2869 G_PKG_NAME,
2870 'OKC_API.G_RET_STS_UNEXP_ERROR',
2871 x_msg_count,
2872 x_msg_data,
2873 '_PVT'
2874 );
2875 WHEN OTHERS THEN
2876 x_return_status :=OKC_API.HANDLE_EXCEPTIONS
2877 (
2878 l_api_name,
2879 G_PKG_NAME,
2880 'OTHERS',
2881 x_msg_count,
2882 x_msg_data,
2883 '_PVT'
2884 );
2885 END update_row;
2886 --------------------------------------
2887 -- update_row for:OKL_TXD_ASSETS_TL --
2888 --------------------------------------
2889 PROCEDURE update_row(
2890 p_init_msg_list IN VARCHAR2 DEFAULT OKC_API.G_FALSE,
2891 x_return_status OUT NOCOPY VARCHAR2,
2892 x_msg_count OUT NOCOPY NUMBER,
2893 x_msg_data OUT NOCOPY VARCHAR2,
2894 p_okl_txd_assets_tl_rec IN okl_txd_assets_tl_rec_type,
2895 x_okl_txd_assets_tl_rec OUT NOCOPY okl_txd_assets_tl_rec_type) IS
2896
2897 l_api_version CONSTANT NUMBER := 1;
2898 l_api_name CONSTANT VARCHAR2(30) := 'TL_update_row';
2899 l_return_status VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
2900 l_okl_txd_assets_tl_rec okl_txd_assets_tl_rec_type := p_okl_txd_assets_tl_rec;
2901 l_def_okl_txd_assets_tl_rec okl_txd_assets_tl_rec_type;
2902 l_row_notfound BOOLEAN := TRUE;
2903 ----------------------------------
2904 -- FUNCTION populate_new_record --
2905 ----------------------------------
2906 FUNCTION populate_new_record (
2907 p_okl_txd_assets_tl_rec IN okl_txd_assets_tl_rec_type,
2908 x_okl_txd_assets_tl_rec OUT NOCOPY okl_txd_assets_tl_rec_type
2909 ) RETURN VARCHAR2 IS
2910 l_okl_txd_assets_tl_rec okl_txd_assets_tl_rec_type;
2911 l_row_notfound BOOLEAN := TRUE;
2912 l_return_status VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
2913 BEGIN
2914 x_okl_txd_assets_tl_rec := p_okl_txd_assets_tl_rec;
2915 -- Get current database values
2916 l_okl_txd_assets_tl_rec := get_rec(p_okl_txd_assets_tl_rec, l_row_notfound);
2917 IF (l_row_notfound) THEN
2918 l_return_status := OKC_API.G_RET_STS_UNEXP_ERROR;
2919 END IF;
2920 IF (x_okl_txd_assets_tl_rec.id = OKC_API.G_MISS_NUM)
2921 THEN
2922 x_okl_txd_assets_tl_rec.id := l_okl_txd_assets_tl_rec.id;
2923 END IF;
2924 IF (x_okl_txd_assets_tl_rec.language = OKC_API.G_MISS_CHAR)
2925 THEN
2926 x_okl_txd_assets_tl_rec.language := l_okl_txd_assets_tl_rec.language;
2927 END IF;
2928 IF (x_okl_txd_assets_tl_rec.source_lang = OKC_API.G_MISS_CHAR)
2929 THEN
2930 x_okl_txd_assets_tl_rec.source_lang := l_okl_txd_assets_tl_rec.source_lang;
2931 END IF;
2932 IF (x_okl_txd_assets_tl_rec.sfwt_flag = OKC_API.G_MISS_CHAR)
2933 THEN
2934 x_okl_txd_assets_tl_rec.sfwt_flag := l_okl_txd_assets_tl_rec.sfwt_flag;
2935 END IF;
2936 IF (x_okl_txd_assets_tl_rec.description = OKC_API.G_MISS_CHAR)
2937 THEN
2938 x_okl_txd_assets_tl_rec.description := l_okl_txd_assets_tl_rec.description;
2939 END IF;
2940 IF (x_okl_txd_assets_tl_rec.created_by = OKC_API.G_MISS_NUM)
2941 THEN
2942 x_okl_txd_assets_tl_rec.created_by := l_okl_txd_assets_tl_rec.created_by;
2943 END IF;
2944 IF (x_okl_txd_assets_tl_rec.creation_date = OKC_API.G_MISS_DATE)
2945 THEN
2946 x_okl_txd_assets_tl_rec.creation_date := l_okl_txd_assets_tl_rec.creation_date;
2947 END IF;
2948 IF (x_okl_txd_assets_tl_rec.last_updated_by = OKC_API.G_MISS_NUM)
2949 THEN
2950 x_okl_txd_assets_tl_rec.last_updated_by := l_okl_txd_assets_tl_rec.last_updated_by;
2951 END IF;
2952 IF (x_okl_txd_assets_tl_rec.last_update_date = OKC_API.G_MISS_DATE)
2953 THEN
2954 x_okl_txd_assets_tl_rec.last_update_date := l_okl_txd_assets_tl_rec.last_update_date;
2955 END IF;
2956 IF (x_okl_txd_assets_tl_rec.last_update_login = OKC_API.G_MISS_NUM)
2957 THEN
2958 x_okl_txd_assets_tl_rec.last_update_login := l_okl_txd_assets_tl_rec.last_update_login;
2959 END IF;
2960 /*
2961 -- Multi Currency Change
2962 IF (x_okl_txd_assets_tl_rec.currency_code = OKC_API.G_MISS_CHAR)
2963 THEN
2964 x_okl_txd_assets_tl_rec.currency_code := l_okl_txd_assets_tl_rec.currency_code;
2965 END IF;
2966 IF (x_okl_txd_assets_tl_rec.currency_conversion_type = OKC_API.G_MISS_CHAR)
2967 THEN
2968 x_okl_txd_assets_tl_rec.currency_conversion_type := l_okl_txd_assets_tl_rec.currency_conversion_type;
2969 END IF;
2970 IF (x_okl_txd_assets_tl_rec.currency_conversion_rate = OKC_API.G_MISS_NUM)
2971 THEN
2972 x_okl_txd_assets_tl_rec.currency_conversion_rate := l_okl_txd_assets_tl_rec.currency_conversion_rate;
2973 END IF;
2974 IF (x_okl_txd_assets_tl_rec.currency_conversion_date = OKC_API.G_MISS_DATE)
2975 THEN
2976 x_okl_txd_assets_tl_rec.currency_conversion_date := l_okl_txd_assets_tl_rec.currency_conversion_date;
2977 END IF;
2978 -- Multi Currency Change
2979 */
2980 RETURN(l_return_status);
2981 END populate_new_record;
2982 ------------------------------------------
2983 -- Set_Attributes for:OKL_TXD_ASSETS_TL --
2984 ------------------------------------------
2985 FUNCTION Set_Attributes (
2986 p_okl_txd_assets_tl_rec IN okl_txd_assets_tl_rec_type,
2987 x_okl_txd_assets_tl_rec OUT NOCOPY okl_txd_assets_tl_rec_type
2988 ) RETURN VARCHAR2 IS
2989 l_return_status VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
2990 BEGIN
2991 x_okl_txd_assets_tl_rec := p_okl_txd_assets_tl_rec;
2992 x_okl_txd_assets_tl_rec.LANGUAGE := USERENV('LANG');
2993 x_okl_txd_assets_tl_rec.SOURCE_LANG := USERENV('LANG');
2994 RETURN(l_return_status);
2995 END Set_Attributes;
2996 BEGIN
2997 l_return_status := OKC_API.START_ACTIVITY(l_api_name,
2998 p_init_msg_list,
2999 '_PVT',
3000 x_return_status);
3001 IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
3002 RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
3003 ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
3004 RAISE OKC_API.G_EXCEPTION_ERROR;
3005 END IF;
3006 --- Setting item attributes
3007 l_return_status := Set_Attributes(
3008 p_okl_txd_assets_tl_rec, -- IN
3009 l_okl_txd_assets_tl_rec); -- OUT
3010 --- If any errors happen abort API
3011 IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
3012 RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
3013 ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
3014 RAISE OKC_API.G_EXCEPTION_ERROR;
3015 END IF;
3016 l_return_status := populate_new_record(l_okl_txd_assets_tl_rec, l_def_okl_txd_assets_tl_rec);
3017 IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
3018 RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
3019 ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
3020 RAISE OKC_API.G_EXCEPTION_ERROR;
3021 END IF;
3022 UPDATE OKL_TXD_ASSETS_TL
3023 SET DESCRIPTION = l_def_okl_txd_assets_tl_rec.description,
3024 --Bug# 3641933 :
3025 SOURCE_LANG = l_def_okl_txd_assets_tl_rec.source_lang,
3026 CREATED_BY = l_def_okl_txd_assets_tl_rec.created_by,
3027 CREATION_DATE = l_def_okl_txd_assets_tl_rec.creation_date,
3028 LAST_UPDATED_BY = l_def_okl_txd_assets_tl_rec.last_updated_by,
3029 LAST_UPDATE_DATE = l_def_okl_txd_assets_tl_rec.last_update_date,
3030 LAST_UPDATE_LOGIN = l_def_okl_txd_assets_tl_rec.last_update_login
3031 WHERE ID = l_def_okl_txd_assets_tl_rec.id
3032 --Bug# 3641933 :
3033 AND USERENV('LANG') in (SOURCE_LANG,LANGUAGE);
3034 --AND SOURCE_LANG = USERENV('LANG');
3035
3036 UPDATE OKL_TXD_ASSETS_TL
3037 SET SFWT_FLAG = 'Y'
3038 WHERE ID = l_def_okl_txd_assets_tl_rec.id
3039 AND SOURCE_LANG <> USERENV('LANG');
3040
3041 x_okl_txd_assets_tl_rec := l_def_okl_txd_assets_tl_rec;
3042 OKC_API.END_ACTIVITY(x_msg_count, x_msg_data);
3043 EXCEPTION
3044 WHEN OKC_API.G_EXCEPTION_ERROR THEN
3045 x_return_status := OKC_API.HANDLE_EXCEPTIONS
3046 (
3047 l_api_name,
3048 G_PKG_NAME,
3049 'OKC_API.G_RET_STS_ERROR',
3050 x_msg_count,
3051 x_msg_data,
3052 '_PVT'
3053 );
3054 WHEN OKC_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
3055 x_return_status :=OKC_API.HANDLE_EXCEPTIONS
3056 (
3057 l_api_name,
3058 G_PKG_NAME,
3059 'OKC_API.G_RET_STS_UNEXP_ERROR',
3060 x_msg_count,
3061 x_msg_data,
3062 '_PVT'
3063 );
3064 WHEN OTHERS THEN
3065 x_return_status :=OKC_API.HANDLE_EXCEPTIONS
3066 (
3067 l_api_name,
3068 G_PKG_NAME,
3069 'OTHERS',
3070 x_msg_count,
3071 x_msg_data,
3072 '_PVT'
3073 );
3074 END update_row;
3075 -------------------------------------
3076 -- update_row for:OKL_TXD_ASSETS_V --
3077 -------------------------------------
3078 PROCEDURE update_row(
3079 p_api_version IN NUMBER,
3080 p_init_msg_list IN VARCHAR2 DEFAULT OKC_API.G_FALSE,
3081 x_return_status OUT NOCOPY VARCHAR2,
3082 x_msg_count OUT NOCOPY NUMBER,
3083 x_msg_data OUT NOCOPY VARCHAR2,
3084 p_asdv_rec IN asdv_rec_type,
3085 x_asdv_rec OUT NOCOPY asdv_rec_type) IS
3086
3087 l_api_version CONSTANT NUMBER := 1;
3088 l_api_name CONSTANT VARCHAR2(30) := 'V_update_row';
3089 l_return_status VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
3090 l_asdv_rec asdv_rec_type := p_asdv_rec;
3091 l_def_asdv_rec asdv_rec_type;
3092 l_okl_txd_assets_tl_rec okl_txd_assets_tl_rec_type;
3093 lx_okl_txd_assets_tl_rec okl_txd_assets_tl_rec_type;
3094 l_asd_rec asd_rec_type;
3095 lx_asd_rec asd_rec_type;
3096 lx_temp_asdv_rec asdv_rec_type;
3097 -------------------------------
3098 -- FUNCTION fill_who_columns --
3099 -------------------------------
3100 FUNCTION fill_who_columns (
3101 p_asdv_rec IN asdv_rec_type
3102 ) RETURN asdv_rec_type IS
3103 l_asdv_rec asdv_rec_type := p_asdv_rec;
3104 BEGIN
3105 l_asdv_rec.LAST_UPDATE_DATE := SYSDATE;
3106 l_asdv_rec.LAST_UPDATED_BY := FND_GLOBAL.USER_ID;
3107 l_asdv_rec.LAST_UPDATE_LOGIN := FND_GLOBAL.LOGIN_ID;
3108 RETURN(l_asdv_rec);
3109 END fill_who_columns;
3110 ----------------------------------
3111 -- FUNCTION populate_new_record --
3112 ----------------------------------
3113 FUNCTION populate_new_record (
3114 p_asdv_rec IN asdv_rec_type,
3115 x_asdv_rec OUT NOCOPY asdv_rec_type
3116 ) RETURN VARCHAR2 IS
3117 l_asdv_rec asdv_rec_type;
3118 l_row_notfound BOOLEAN := TRUE;
3119 l_return_status VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
3120 BEGIN
3121 x_asdv_rec := p_asdv_rec;
3122 -- Get current database values
3123 l_asdv_rec := get_rec(p_asdv_rec, l_row_notfound);
3124 IF (l_row_notfound) THEN
3125 l_return_status := OKC_API.G_RET_STS_UNEXP_ERROR;
3126 END IF;
3127 IF (x_asdv_rec.id = OKC_API.G_MISS_NUM)
3128 THEN
3129 x_asdv_rec.id := l_asdv_rec.id;
3130 END IF;
3131 IF (x_asdv_rec.object_version_number = OKC_API.G_MISS_NUM)
3132 THEN
3133 x_asdv_rec.object_version_number := l_asdv_rec.object_version_number;
3134 END IF;
3135 IF (x_asdv_rec.sfwt_flag = OKC_API.G_MISS_CHAR)
3136 THEN
3137 x_asdv_rec.sfwt_flag := l_asdv_rec.sfwt_flag;
3138 END IF;
3139 IF (x_asdv_rec.tal_id = OKC_API.G_MISS_NUM)
3140 THEN
3141 x_asdv_rec.tal_id := l_asdv_rec.tal_id;
3142 END IF;
3143 IF (x_asdv_rec.target_kle_id = OKC_API.G_MISS_NUM)
3144 THEN
3145 x_asdv_rec.target_kle_id := l_asdv_rec.target_kle_id;
3146 END IF;
3147 IF (x_asdv_rec.line_detail_number = OKC_API.G_MISS_NUM)
3148 THEN
3149 x_asdv_rec.line_detail_number := l_asdv_rec.line_detail_number;
3150 END IF;
3151 IF (x_asdv_rec.asset_number = OKC_API.G_MISS_CHAR)
3152 THEN
3153 x_asdv_rec.asset_number := l_asdv_rec.asset_number;
3154 END IF;
3155 IF (x_asdv_rec.description = OKC_API.G_MISS_CHAR)
3156 THEN
3157 x_asdv_rec.description := l_asdv_rec.description;
3158 END IF;
3159 IF (x_asdv_rec.quantity = OKC_API.G_MISS_NUM)
3160 THEN
3161 x_asdv_rec.quantity := l_asdv_rec.quantity;
3162 END IF;
3163 IF (x_asdv_rec.cost = OKC_API.G_MISS_NUM)
3164 THEN
3165 x_asdv_rec.cost := l_asdv_rec.cost;
3166 END IF;
3167 IF (x_asdv_rec.tax_book = OKC_API.G_MISS_CHAR)
3168 THEN
3169 x_asdv_rec.tax_book := l_asdv_rec.tax_book;
3170 END IF;
3171 IF (x_asdv_rec.life_in_months_tax = OKC_API.G_MISS_NUM)
3172 THEN
3173 x_asdv_rec.life_in_months_tax := l_asdv_rec.life_in_months_tax;
3174 END IF;
3175 IF (x_asdv_rec.deprn_method_tax = OKC_API.G_MISS_CHAR)
3176 THEN
3177 x_asdv_rec.deprn_method_tax := l_asdv_rec.deprn_method_tax;
3178 END IF;
3179 IF (x_asdv_rec.deprn_rate_tax = OKC_API.G_MISS_NUM)
3180 THEN
3181 x_asdv_rec.deprn_rate_tax := l_asdv_rec.deprn_rate_tax;
3182 END IF;
3183 IF (x_asdv_rec.salvage_value = OKC_API.G_MISS_NUM)
3184 THEN
3185 x_asdv_rec.salvage_value := l_asdv_rec.salvage_value;
3186 END IF;
3187
3188 -- added new columns for split asset component
3189 IF (x_asdv_rec.SPLIT_PERCENT = OKC_API.G_MISS_NUM)
3190 THEN
3191 x_asdv_rec.SPLIT_PERCENT := l_asdv_rec.SPLIT_PERCENT;
3192 END IF;
3193 IF (x_asdv_rec.INVENTORY_ITEM_ID = OKC_API.G_MISS_NUM)
3194 THEN
3195 x_asdv_rec.INVENTORY_ITEM_ID := l_asdv_rec.INVENTORY_ITEM_ID;
3196 END IF;
3197 -- end of added new columns for split asset component
3198
3199 IF (x_asdv_rec.attribute_category = OKC_API.G_MISS_CHAR)
3200 THEN
3201 x_asdv_rec.attribute_category := l_asdv_rec.attribute_category;
3202 END IF;
3203 IF (x_asdv_rec.attribute1 = OKC_API.G_MISS_CHAR)
3204 THEN
3205 x_asdv_rec.attribute1 := l_asdv_rec.attribute1;
3206 END IF;
3207 IF (x_asdv_rec.attribute2 = OKC_API.G_MISS_CHAR)
3208 THEN
3209 x_asdv_rec.attribute2 := l_asdv_rec.attribute2;
3210 END IF;
3211 IF (x_asdv_rec.attribute3 = OKC_API.G_MISS_CHAR)
3212 THEN
3213 x_asdv_rec.attribute3 := l_asdv_rec.attribute3;
3214 END IF;
3215 IF (x_asdv_rec.attribute4 = OKC_API.G_MISS_CHAR)
3216 THEN
3217 x_asdv_rec.attribute4 := l_asdv_rec.attribute4;
3218 END IF;
3219 IF (x_asdv_rec.attribute5 = OKC_API.G_MISS_CHAR)
3220 THEN
3221 x_asdv_rec.attribute5 := l_asdv_rec.attribute5;
3222 END IF;
3223 IF (x_asdv_rec.attribute6 = OKC_API.G_MISS_CHAR)
3224 THEN
3225 x_asdv_rec.attribute6 := l_asdv_rec.attribute6;
3226 END IF;
3227 IF (x_asdv_rec.attribute7 = OKC_API.G_MISS_CHAR)
3228 THEN
3229 x_asdv_rec.attribute7 := l_asdv_rec.attribute7;
3230 END IF;
3231 IF (x_asdv_rec.attribute8 = OKC_API.G_MISS_CHAR)
3232 THEN
3233 x_asdv_rec.attribute8 := l_asdv_rec.attribute8;
3234 END IF;
3235 IF (x_asdv_rec.attribute9 = OKC_API.G_MISS_CHAR)
3236 THEN
3237 x_asdv_rec.attribute9 := l_asdv_rec.attribute9;
3238 END IF;
3239 IF (x_asdv_rec.attribute10 = OKC_API.G_MISS_CHAR)
3240 THEN
3241 x_asdv_rec.attribute10 := l_asdv_rec.attribute10;
3242 END IF;
3243 IF (x_asdv_rec.attribute11 = OKC_API.G_MISS_CHAR)
3244 THEN
3245 x_asdv_rec.attribute11 := l_asdv_rec.attribute11;
3246 END IF;
3247 IF (x_asdv_rec.attribute12 = OKC_API.G_MISS_CHAR)
3248 THEN
3249 x_asdv_rec.attribute12 := l_asdv_rec.attribute12;
3250 END IF;
3251 IF (x_asdv_rec.attribute13 = OKC_API.G_MISS_CHAR)
3252 THEN
3253 x_asdv_rec.attribute13 := l_asdv_rec.attribute13;
3254 END IF;
3255 IF (x_asdv_rec.attribute14 = OKC_API.G_MISS_CHAR)
3256 THEN
3257 x_asdv_rec.attribute14 := l_asdv_rec.attribute14;
3258 END IF;
3259 IF (x_asdv_rec.attribute15 = OKC_API.G_MISS_CHAR)
3260 THEN
3261 x_asdv_rec.attribute15 := l_asdv_rec.attribute15;
3262 END IF;
3263 IF (x_asdv_rec.created_by = OKC_API.G_MISS_NUM)
3264 THEN
3265 x_asdv_rec.created_by := l_asdv_rec.created_by;
3266 END IF;
3267 IF (x_asdv_rec.creation_date = OKC_API.G_MISS_DATE)
3268 THEN
3269 x_asdv_rec.creation_date := l_asdv_rec.creation_date;
3270 END IF;
3271 IF (x_asdv_rec.last_updated_by = OKC_API.G_MISS_NUM)
3272 THEN
3273 x_asdv_rec.last_updated_by := l_asdv_rec.last_updated_by;
3274 END IF;
3275 IF (x_asdv_rec.last_update_date = OKC_API.G_MISS_DATE)
3276 THEN
3277 x_asdv_rec.last_update_date := l_asdv_rec.last_update_date;
3278 END IF;
3279 IF (x_asdv_rec.last_update_login = OKC_API.G_MISS_NUM)
3280 THEN
3281 x_asdv_rec.last_update_login := l_asdv_rec.last_update_login;
3282 END IF;
3283 -- Multi Currency Change
3284 IF (x_asdv_rec.currency_code = OKC_API.G_MISS_CHAR)
3285 THEN
3286 x_asdv_rec.currency_code := l_asdv_rec.currency_code;
3287 END IF;
3288 IF (x_asdv_rec.currency_conversion_type = OKC_API.G_MISS_CHAR)
3289 THEN
3290 x_asdv_rec.currency_conversion_type := l_asdv_rec.currency_conversion_type;
3291 END IF;
3292 IF (x_asdv_rec.currency_conversion_rate = OKC_API.G_MISS_NUM)
3293 THEN
3294 x_asdv_rec.currency_conversion_rate := l_asdv_rec.currency_conversion_rate;
3295 END IF;
3296 IF (x_asdv_rec.currency_conversion_date = OKC_API.G_MISS_DATE)
3297 THEN
3298 x_asdv_rec.currency_conversion_date := l_asdv_rec.currency_conversion_date;
3299 END IF;
3300 -- Multi Currency Change
3301 RETURN(l_return_status);
3302 END populate_new_record;
3303 -----------------------------------------
3304 -- Set_Attributes for:OKL_TXD_ASSETS_V --
3305 -----------------------------------------
3306 FUNCTION Set_Attributes (
3307 p_asdv_rec IN asdv_rec_type,
3308 x_asdv_rec OUT NOCOPY asdv_rec_type
3309 ) RETURN VARCHAR2 IS
3310 l_return_status VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
3311 BEGIN
3312 x_asdv_rec := p_asdv_rec;
3313 x_asdv_rec.OBJECT_VERSION_NUMBER := NVL(x_asdv_rec.OBJECT_VERSION_NUMBER, 0) + 1;
3314 RETURN(l_return_status);
3315 END Set_Attributes;
3316 BEGIN
3317 l_return_status := OKC_API.START_ACTIVITY(l_api_name,
3318 G_PKG_NAME,
3319 p_init_msg_list,
3320 l_api_version,
3321 p_api_version,
3322 '_PVT',
3323 x_return_status);
3324 IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
3325 RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
3326 ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
3327 RAISE OKC_API.G_EXCEPTION_ERROR;
3328 END IF;
3329 --- Setting item attributes
3330 l_return_status := Set_Attributes(
3331 p_asdv_rec, -- IN
3332 l_asdv_rec); -- OUT
3333 --- If any errors happen abort API
3334 IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
3335 RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
3336 ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
3337 RAISE OKC_API.G_EXCEPTION_ERROR;
3338 END IF;
3339 l_return_status := populate_new_record(l_asdv_rec, l_def_asdv_rec);
3340 IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
3341 RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
3342 ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
3343 RAISE OKC_API.G_EXCEPTION_ERROR;
3344 END IF;
3345 l_def_asdv_rec := fill_who_columns(l_def_asdv_rec);
3346 --- Validate all non-missing attributes (Item Level Validation)
3347 l_return_status := Validate_Attributes(l_def_asdv_rec);
3348 --- If any errors happen abort API
3349 IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
3350 RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
3351 ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
3352 RAISE OKC_API.G_EXCEPTION_ERROR;
3353 END IF;
3354 l_return_status := Validate_Record(l_def_asdv_rec);
3355 IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
3356 RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
3357 ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
3358 RAISE OKC_API.G_EXCEPTION_ERROR;
3359 END IF;
3360
3361 --
3362 -- Multi-Currency Change, dedey, 12/04/2002
3363 --
3364 validate_currency(
3365 x_return_status => l_return_status,
3366 p_asdv_rec => l_def_asdv_rec,
3367 x_asdv_rec => lx_temp_asdv_rec
3368 );
3369
3370 IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
3371 RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
3372 ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
3373 RAISE OKC_API.G_EXCEPTION_ERROR;
3374 END IF;
3375 l_def_asdv_rec := lx_temp_asdv_rec;
3376
3377 --dbms_output.put_line('After Change: '||lx_temp_asdv_rec.currency_code);
3378 --dbms_output.put_line('After Change: '||l_def_asdv_rec.currency_code);
3379 --
3380 -- Multi-Currency Change
3381 --
3382
3383 -- Fix Bug# 2737014
3384 --
3385 -- Round off amounts
3386 --
3387 roundoff_line_amount(
3388 x_return_status => l_return_status,
3389 x_msg_count => x_msg_count,
3390 x_msg_data => x_msg_data,
3391 p_asdv_rec => l_def_asdv_rec,
3392 x_asdv_rec => lx_temp_asdv_rec
3393 );
3394
3395 IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
3396 RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
3397 ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
3398 RAISE OKC_API.G_EXCEPTION_ERROR;
3399 END IF;
3400 l_def_asdv_rec := lx_temp_asdv_rec;
3401
3402 --------------------------------------
3403 -- Move VIEW record to "Child" records
3404 --------------------------------------
3405 migrate(l_def_asdv_rec, l_okl_txd_assets_tl_rec);
3406 migrate(l_def_asdv_rec, l_asd_rec);
3407 --------------------------------------------
3408 -- Call the UPDATE_ROW for each child record
3409 --------------------------------------------
3410 update_row(
3411 p_init_msg_list,
3412 x_return_status,
3413 x_msg_count,
3414 x_msg_data,
3415 l_okl_txd_assets_tl_rec,
3416 lx_okl_txd_assets_tl_rec
3417 );
3418 IF (x_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
3419 RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
3420 ELSIF (x_return_status = OKC_API.G_RET_STS_ERROR) THEN
3421 RAISE OKC_API.G_EXCEPTION_ERROR;
3422 END IF;
3423 migrate(lx_okl_txd_assets_tl_rec, l_def_asdv_rec);
3424 --------------------------------------------
3425 -- Call the UPDATE_ROW for each child record
3426 --------------------------------------------
3427 update_row(
3428 p_init_msg_list,
3429 x_return_status,
3430 x_msg_count,
3431 x_msg_data,
3432 l_asd_rec,
3433 lx_asd_rec
3434 );
3435 IF (x_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
3436 RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
3437 ELSIF (x_return_status = OKC_API.G_RET_STS_ERROR) THEN
3438 RAISE OKC_API.G_EXCEPTION_ERROR;
3439 END IF;
3440 migrate(lx_asd_rec, l_def_asdv_rec);
3441 x_asdv_rec := l_def_asdv_rec;
3442 OKC_API.END_ACTIVITY(x_msg_count, x_msg_data);
3443 EXCEPTION
3444 WHEN OKC_API.G_EXCEPTION_ERROR THEN
3445 x_return_status := OKC_API.HANDLE_EXCEPTIONS
3446 (
3447 l_api_name,
3448 G_PKG_NAME,
3449 'OKC_API.G_RET_STS_ERROR',
3450 x_msg_count,
3451 x_msg_data,
3452 '_PVT'
3453 );
3454 WHEN OKC_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
3455 x_return_status :=OKC_API.HANDLE_EXCEPTIONS
3456 (
3457 l_api_name,
3458 G_PKG_NAME,
3459 'OKC_API.G_RET_STS_UNEXP_ERROR',
3460 x_msg_count,
3461 x_msg_data,
3462 '_PVT'
3463 );
3464 WHEN OTHERS THEN
3465 x_return_status :=OKC_API.HANDLE_EXCEPTIONS
3466 (
3467 l_api_name,
3468 G_PKG_NAME,
3469 'OTHERS',
3470 x_msg_count,
3471 x_msg_data,
3472 '_PVT'
3473 );
3474 END update_row;
3475 ----------------------------------------
3476 -- PL/SQL TBL update_row for:ASDV_TBL --
3477 ----------------------------------------
3478 PROCEDURE update_row(
3479 p_api_version IN NUMBER,
3480 p_init_msg_list IN VARCHAR2 DEFAULT OKC_API.G_FALSE,
3481 x_return_status OUT NOCOPY VARCHAR2,
3482 x_msg_count OUT NOCOPY NUMBER,
3483 x_msg_data OUT NOCOPY VARCHAR2,
3484 p_asdv_tbl IN asdv_tbl_type,
3485 x_asdv_tbl OUT NOCOPY asdv_tbl_type) IS
3486
3487 l_api_version CONSTANT NUMBER := 1;
3488 l_api_name CONSTANT VARCHAR2(30) := 'V_tbl_update_row';
3489 l_return_status VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
3490 i NUMBER := 0;
3491 BEGIN
3492 OKC_API.init_msg_list(p_init_msg_list);
3493 -- Make sure PL/SQL table has records in it before passing
3494 IF (p_asdv_tbl.COUNT > 0) THEN
3495 i := p_asdv_tbl.FIRST;
3496 LOOP
3497 update_row (
3498 p_api_version => p_api_version,
3499 p_init_msg_list => OKC_API.G_FALSE,
3500 x_return_status => x_return_status,
3501 x_msg_count => x_msg_count,
3502 x_msg_data => x_msg_data,
3503 p_asdv_rec => p_asdv_tbl(i),
3504 x_asdv_rec => x_asdv_tbl(i));
3505 EXIT WHEN (i = p_asdv_tbl.LAST);
3506 i := p_asdv_tbl.NEXT(i);
3507 END LOOP;
3508 END IF;
3509 EXCEPTION
3510 WHEN OKC_API.G_EXCEPTION_ERROR THEN
3511 x_return_status := OKC_API.HANDLE_EXCEPTIONS
3512 (
3513 l_api_name,
3514 G_PKG_NAME,
3515 'OKC_API.G_RET_STS_ERROR',
3516 x_msg_count,
3517 x_msg_data,
3518 '_PVT'
3519 );
3520 WHEN OKC_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
3521 x_return_status :=OKC_API.HANDLE_EXCEPTIONS
3522 (
3523 l_api_name,
3524 G_PKG_NAME,
3525 'OKC_API.G_RET_STS_UNEXP_ERROR',
3526 x_msg_count,
3527 x_msg_data,
3528 '_PVT'
3529 );
3530 WHEN OTHERS THEN
3531 x_return_status :=OKC_API.HANDLE_EXCEPTIONS
3532 (
3533 l_api_name,
3534 G_PKG_NAME,
3535 'OTHERS',
3536 x_msg_count,
3537 x_msg_data,
3538 '_PVT'
3539 );
3540 END update_row;
3541
3542 ---------------------------------------------------------------------------
3543 -- PROCEDURE delete_row
3544 ---------------------------------------------------------------------------
3545 -----------------------------------
3546 -- delete_row for:OKL_TXD_ASSETS_B --
3547 -----------------------------------
3548 PROCEDURE delete_row(
3549 p_init_msg_list IN VARCHAR2 DEFAULT OKC_API.G_FALSE,
3550 x_return_status OUT NOCOPY VARCHAR2,
3551 x_msg_count OUT NOCOPY NUMBER,
3552 x_msg_data OUT NOCOPY VARCHAR2,
3553 p_asd_rec IN asd_rec_type) IS
3554
3555 l_api_version CONSTANT NUMBER := 1;
3556 l_api_name CONSTANT VARCHAR2(30) := 'ASSETS_delete_row';
3557 l_return_status VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
3558 l_asd_rec asd_rec_type:= p_asd_rec;
3559 l_row_notfound BOOLEAN := TRUE;
3560 BEGIN
3561 l_return_status := OKC_API.START_ACTIVITY(l_api_name,
3562 p_init_msg_list,
3563 '_PVT',
3564 x_return_status);
3565 IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
3566 RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
3567 ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
3568 RAISE OKC_API.G_EXCEPTION_ERROR;
3569 END IF;
3570 DELETE FROM OKL_TXD_ASSETS_B
3571 WHERE ID = l_asd_rec.id;
3572
3573 OKC_API.END_ACTIVITY(x_msg_count, x_msg_data);
3574 EXCEPTION
3575 WHEN OKC_API.G_EXCEPTION_ERROR THEN
3576 x_return_status := OKC_API.HANDLE_EXCEPTIONS
3577 (
3578 l_api_name,
3579 G_PKG_NAME,
3580 'OKC_API.G_RET_STS_ERROR',
3581 x_msg_count,
3582 x_msg_data,
3583 '_PVT'
3584 );
3585 WHEN OKC_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
3586 x_return_status :=OKC_API.HANDLE_EXCEPTIONS
3587 (
3588 l_api_name,
3589 G_PKG_NAME,
3590 'OKC_API.G_RET_STS_UNEXP_ERROR',
3591 x_msg_count,
3592 x_msg_data,
3593 '_PVT'
3594 );
3595 WHEN OTHERS THEN
3596 x_return_status :=OKC_API.HANDLE_EXCEPTIONS
3597 (
3598 l_api_name,
3599 G_PKG_NAME,
3600 'OTHERS',
3601 x_msg_count,
3602 x_msg_data,
3603 '_PVT'
3604 );
3605 END delete_row;
3606 --------------------------------------
3607 -- delete_row for:OKL_TXD_ASSETS_TL --
3608 --------------------------------------
3609 PROCEDURE delete_row(
3610 p_init_msg_list IN VARCHAR2 DEFAULT OKC_API.G_FALSE,
3611 x_return_status OUT NOCOPY VARCHAR2,
3612 x_msg_count OUT NOCOPY NUMBER,
3613 x_msg_data OUT NOCOPY VARCHAR2,
3614 p_okl_txd_assets_tl_rec IN okl_txd_assets_tl_rec_type) IS
3615
3616 l_api_version CONSTANT NUMBER := 1;
3617 l_api_name CONSTANT VARCHAR2(30) := 'TL_delete_row';
3618 l_return_status VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
3619 l_okl_txd_assets_tl_rec okl_txd_assets_tl_rec_type:= p_okl_txd_assets_tl_rec;
3620 l_row_notfound BOOLEAN := TRUE;
3621 ------------------------------------------
3622 -- Set_Attributes for:OKL_TXD_ASSETS_TL --
3623 ------------------------------------------
3624 FUNCTION Set_Attributes (
3625 p_okl_txd_assets_tl_rec IN okl_txd_assets_tl_rec_type,
3626 x_okl_txd_assets_tl_rec OUT NOCOPY okl_txd_assets_tl_rec_type
3627 ) RETURN VARCHAR2 IS
3628 l_return_status VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
3629 BEGIN
3630 x_okl_txd_assets_tl_rec := p_okl_txd_assets_tl_rec;
3631 x_okl_txd_assets_tl_rec.LANGUAGE := USERENV('LANG');
3632 RETURN(l_return_status);
3633 END Set_Attributes;
3634 BEGIN
3635 l_return_status := OKC_API.START_ACTIVITY(l_api_name,
3636 p_init_msg_list,
3637 '_PVT',
3638 x_return_status);
3639 IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
3640 RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
3641 ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
3642 RAISE OKC_API.G_EXCEPTION_ERROR;
3643 END IF;
3644 --- Setting item attributes
3645 l_return_status := Set_Attributes(
3646 p_okl_txd_assets_tl_rec, -- IN
3647 l_okl_txd_assets_tl_rec); -- OUT
3648 --- If any errors happen abort API
3649 IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
3650 RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
3651 ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
3652 RAISE OKC_API.G_EXCEPTION_ERROR;
3653 END IF;
3654 DELETE FROM OKL_TXD_ASSETS_TL
3655 WHERE ID = l_okl_txd_assets_tl_rec.id;
3656
3657 OKC_API.END_ACTIVITY(x_msg_count, x_msg_data);
3658 EXCEPTION
3659 WHEN OKC_API.G_EXCEPTION_ERROR THEN
3660 x_return_status := OKC_API.HANDLE_EXCEPTIONS
3661 (
3662 l_api_name,
3663 G_PKG_NAME,
3664 'OKC_API.G_RET_STS_ERROR',
3665 x_msg_count,
3666 x_msg_data,
3667 '_PVT'
3668 );
3669 WHEN OKC_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
3670 x_return_status :=OKC_API.HANDLE_EXCEPTIONS
3671 (
3672 l_api_name,
3673 G_PKG_NAME,
3674 'OKC_API.G_RET_STS_UNEXP_ERROR',
3675 x_msg_count,
3676 x_msg_data,
3677 '_PVT'
3678 );
3679 WHEN OTHERS THEN
3680 x_return_status :=OKC_API.HANDLE_EXCEPTIONS
3681 (
3682 l_api_name,
3683 G_PKG_NAME,
3684 'OTHERS',
3685 x_msg_count,
3686 x_msg_data,
3687 '_PVT'
3688 );
3689 END delete_row;
3690 -------------------------------------
3691 -- delete_row for:OKL_TXD_ASSETS_V --
3692 -------------------------------------
3693 PROCEDURE delete_row(
3694 p_api_version IN NUMBER,
3695 p_init_msg_list IN VARCHAR2 DEFAULT OKC_API.G_FALSE,
3696 x_return_status OUT NOCOPY VARCHAR2,
3697 x_msg_count OUT NOCOPY NUMBER,
3698 x_msg_data OUT NOCOPY VARCHAR2,
3699 p_asdv_rec IN asdv_rec_type) IS
3700
3701 l_api_version CONSTANT NUMBER := 1;
3702 l_api_name CONSTANT VARCHAR2(30) := 'V_delete_row';
3703 l_return_status VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
3704 l_asdv_rec asdv_rec_type := p_asdv_rec;
3705 l_okl_txd_assets_tl_rec okl_txd_assets_tl_rec_type;
3706 l_asd_rec asd_rec_type;
3707 BEGIN
3708 l_return_status := OKC_API.START_ACTIVITY(l_api_name,
3709 G_PKG_NAME,
3710 p_init_msg_list,
3711 l_api_version,
3712 p_api_version,
3713 '_PVT',
3714 x_return_status);
3715 IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
3716 RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
3717 ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
3718 RAISE OKC_API.G_EXCEPTION_ERROR;
3719 END IF;
3720 --------------------------------------
3721 -- Move VIEW record to "Child" records
3722 --------------------------------------
3723 migrate(l_asdv_rec, l_okl_txd_assets_tl_rec);
3724 migrate(l_asdv_rec, l_asd_rec);
3725 --------------------------------------------
3726 -- Call the DELETE_ROW for each child record
3727 --------------------------------------------
3728 delete_row(
3729 p_init_msg_list,
3730 x_return_status,
3731 x_msg_count,
3732 x_msg_data,
3733 l_okl_txd_assets_tl_rec
3734 );
3735 IF (x_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
3736 RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
3737 ELSIF (x_return_status = OKC_API.G_RET_STS_ERROR) THEN
3738 RAISE OKC_API.G_EXCEPTION_ERROR;
3739 END IF;
3740 --------------------------------------------
3741 -- Call the DELETE_ROW for each child record
3742 --------------------------------------------
3743 delete_row(
3744 p_init_msg_list,
3745 x_return_status,
3746 x_msg_count,
3747 x_msg_data,
3748 l_asd_rec
3749 );
3750 IF (x_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
3751 RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
3752 ELSIF (x_return_status = OKC_API.G_RET_STS_ERROR) THEN
3753 RAISE OKC_API.G_EXCEPTION_ERROR;
3754 END IF;
3755 OKC_API.END_ACTIVITY(x_msg_count, x_msg_data);
3756 EXCEPTION
3757 WHEN OKC_API.G_EXCEPTION_ERROR THEN
3758 x_return_status := OKC_API.HANDLE_EXCEPTIONS
3759 (
3760 l_api_name,
3761 G_PKG_NAME,
3762 'OKC_API.G_RET_STS_ERROR',
3763 x_msg_count,
3764 x_msg_data,
3765 '_PVT'
3766 );
3767 WHEN OKC_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
3768 x_return_status :=OKC_API.HANDLE_EXCEPTIONS
3769 (
3770 l_api_name,
3771 G_PKG_NAME,
3772 'OKC_API.G_RET_STS_UNEXP_ERROR',
3773 x_msg_count,
3774 x_msg_data,
3775 '_PVT'
3776 );
3777 WHEN OTHERS THEN
3778 x_return_status :=OKC_API.HANDLE_EXCEPTIONS
3779 (
3780 l_api_name,
3781 G_PKG_NAME,
3782 'OTHERS',
3783 x_msg_count,
3784 x_msg_data,
3785 '_PVT'
3786 );
3787 END delete_row;
3788 ----------------------------------------
3789 -- PL/SQL TBL delete_row for:ASDV_TBL --
3790 ----------------------------------------
3791 PROCEDURE delete_row(
3792 p_api_version IN NUMBER,
3793 p_init_msg_list IN VARCHAR2 DEFAULT OKC_API.G_FALSE,
3794 x_return_status OUT NOCOPY VARCHAR2,
3795 x_msg_count OUT NOCOPY NUMBER,
3796 x_msg_data OUT NOCOPY VARCHAR2,
3797 p_asdv_tbl IN asdv_tbl_type) IS
3798
3799 l_api_version CONSTANT NUMBER := 1;
3800 l_api_name CONSTANT VARCHAR2(30) := 'V_tbl_delete_row';
3801 l_return_status VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
3802 i NUMBER := 0;
3803 BEGIN
3804 OKC_API.init_msg_list(p_init_msg_list);
3805 -- Make sure PL/SQL table has records in it before passing
3806 IF (p_asdv_tbl.COUNT > 0) THEN
3807 i := p_asdv_tbl.FIRST;
3808 LOOP
3809 delete_row (
3810 p_api_version => p_api_version,
3811 p_init_msg_list => OKC_API.G_FALSE,
3812 x_return_status => x_return_status,
3813 x_msg_count => x_msg_count,
3814 x_msg_data => x_msg_data,
3815 p_asdv_rec => p_asdv_tbl(i));
3816 EXIT WHEN (i = p_asdv_tbl.LAST);
3817 i := p_asdv_tbl.NEXT(i);
3818 END LOOP;
3819 END IF;
3820 EXCEPTION
3821 WHEN OKC_API.G_EXCEPTION_ERROR THEN
3822 x_return_status := OKC_API.HANDLE_EXCEPTIONS
3823 (
3824 l_api_name,
3825 G_PKG_NAME,
3826 'OKC_API.G_RET_STS_ERROR',
3827 x_msg_count,
3828 x_msg_data,
3829 '_PVT'
3830 );
3831 WHEN OKC_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
3832 x_return_status :=OKC_API.HANDLE_EXCEPTIONS
3833 (
3834 l_api_name,
3835 G_PKG_NAME,
3836 'OKC_API.G_RET_STS_UNEXP_ERROR',
3837 x_msg_count,
3838 x_msg_data,
3839 '_PVT'
3840 );
3841 WHEN OTHERS THEN
3842 x_return_status :=OKC_API.HANDLE_EXCEPTIONS
3843 (
3844 l_api_name,
3845 G_PKG_NAME,
3846 'OTHERS',
3847 x_msg_count,
3848 x_msg_data,
3849 '_PVT'
3850 );
3851 END delete_row;
3852 END OKL_ASD_PVT;