[Home] [Help]
PACKAGE BODY: APPS.OKL_SLA_ACC_SOURCES_PVT
Source
1 PACKAGE BODY okl_sla_acc_sources_pvt AS
2 /*$Header: OKLRSLAB.pls 120.37.12010000.5 2008/09/02 06:04:34 racheruv ship $*/
3
4 -- Package level variables
5 G_MODULE CONSTANT VARCHAR2(255):= 'LEASE.ACCOUNTING.SOURCES.OKL_SLA_ACC_SOURCES_PVT';
6 G_DEBUG_ENABLED CONSTANT VARCHAR2(10) := OKL_DEBUG_PUB.CHECK_LOG_ENABLED;
7 G_IS_DEBUG_STATEMENT_ON BOOLEAN;
8 G_REPRESENTATION_TYPE VARCHAR2(20);
9 --------------------------------------------------------------------------------
10 -- Common Cursor definitions.
11 --------------------------------------------------------------------------------
12 -- Cursor to fetch the Ledger Language
13 CURSOR c_ledger_lang_csr(p_ledger_id NUMBER)
14 IS
15 SELECT DISTINCT NVL(led.sla_description_language, USERENV('LANG')) language_code
16 FROM gl_ledgers led
17 ,xla_ledger_options lopt
18 ,gl_ledger_relationships led_rel
19 WHERE led.ledger_category_code in ('PRIMARY', 'SECONDARY')
20 AND led_rel.target_ledger_category_code in ('PRIMARY', 'SECONDARY')
21 AND led.ledger_id = lopt.ledger_id
22 AND lopt.enabled_flag = 'Y'
23 AND lopt.application_id = 540
24 AND led.ledger_id = led_rel.target_ledger_id
25 AND led_rel.primary_ledger_id = p_ledger_id;
26
27 CURSOR c_org_name_csr( p_org_id NUMBER, p_ledger_lang VARCHAR2 )
28 IS
29 SELECT htl.NAME org_name
30 FROM HR_ALL_ORGANIZATION_UNITS_TL htl
31 WHERE htl.organization_id = p_org_id
32 AND htl.LANGUAGE = p_ledger_lang;
33 CURSOR c_org_name_code_csr( p_org_id NUMBER )
34 IS
35 SELECT ht.NAME org_name
36 FROM hr_all_organization_units ht
37 WHERE ht.organization_id = p_org_id;
38
39 -- Cursor to fetch basic Contract Attributes
40 CURSOR c_khr_attributes_csr (l_khr_id NUMBER)
41 IS
42 SELECT khr.khr_id khr_khr_id
43 ,chr.cust_acct_id cust_acct_id
44 ,chr.contract_number contract_number
45 ,chr.currency_code currency_code
46 ,chr.START_DATE start_date
47 ,chr.bill_to_site_use_id bill_to_site_use_id
48 ,chr.orig_system_reference1 orig_system_reference1
49 ,khr.assignable_yn assignable_yn
50 ,chr.authoring_org_id authoring_org_id
51 ,khr.converted_account_yn converted_account_yn
52 ,khr.generate_accrual_override_yn generate_accrual_override_yn
53 ,chr.cust_po_number cust_po_number
54 ,chr.sts_code sts_code
55 ,hr_org.NAME hr_org_name
56 ,khr.pdt_id pdt_id
57 ,chr.scs_code scs_code
58 FROM okc_k_headers_all_b chr
59 ,okl_k_headers khr
60 ,hr_all_organization_units hr_org
61 WHERE khr.id = l_khr_id
62 AND chr.id = khr.id
63 AND hr_org.organization_id = chr.authoring_org_id;
64
65 -- Use this cursor to fetch the Lesses DFF Information.
66 CURSOR c_kpl_attributes_csr (l_khr_id NUMBER)
67 IS
68 SELECT kpl.attribute_category
69 ,kpl.attribute1
70 ,kpl.attribute2
71 ,kpl.attribute3
72 ,kpl.attribute4
73 ,kpl.attribute5
74 ,kpl.attribute6
75 ,kpl.attribute7
76 ,kpl.attribute8
77 ,kpl.attribute9
78 ,kpl.attribute10
79 ,kpl.attribute11
80 ,kpl.attribute12
81 ,kpl.attribute13
82 ,kpl.attribute14
83 ,kpl.attribute15
84 FROM okl_k_party_roles kpl
85 ,okc_k_party_roles_b cplb
86 WHERE cplb.chr_id = l_khr_id
87 AND cplb.dnz_chr_id = cplb.chr_id
88 AND kpl.id = cplb.id
89 AND cplb.rle_code = 'LESSEE';
90
91 -- Use this cursor to fetch the RRB and ICM values of a particular product
92 CURSOR c_rev_rec_int_calc_methods_csr (l_pdt_id NUMBER)
93 IS
94 SELECT rrb_qve.value rev_rec_method_code
95 ,icm_qve.value int_calc_method_code
96 FROM okl_pdt_qualitys icm_pqy
97 ,okl_pdt_pqy_vals icm_pqv
98 ,okl_pqy_values icm_qve
99 ,okl_pdt_qualitys rrb_pqy
100 ,okl_pdt_pqy_vals rrb_pqv
101 ,okl_pqy_values rrb_qve
102 WHERE icm_pqv.pdt_id = l_pdt_id
103 AND icm_pqv.qve_id = icm_qve.id
104 AND icm_qve.pqy_id = icm_pqy.id
105 AND icm_pqy.name = 'INTEREST_CALCULATION_BASIS'
106 AND rrb_pqv.pdt_id = l_pdt_id
107 AND rrb_pqv.qve_id = rrb_qve.id
108 AND rrb_qve.pqy_id = rrb_pqy.id
109 AND rrb_pqy.name = 'REVENUE_RECOGNITION_METHOD';
110
111 -- Cursor to fetch the Investor Agreement Details provided the
112 -- Contract ID and RENT/RESIDUAL stream type
113 CURSOR c_investor_agreement_main_csr(p_khr_id NUMBER, p_sty_type VARCHAR2)
114 IS
115 SELECT
116 ia_chr.id ia_chr_id
117 ,ia_chr.contract_number ia_contract_number
118 ,ia_chr.START_DATE ia_start_date
119 ,ia_pdt.NAME ia_product_name
120 FROM okl_pool_contents ia_pool_c
121 ,okc_k_headers_all_b ia_chr
122 ,okl_k_headers ia_khr
123 ,okl_products ia_pdt
124 ,okl_pools_all ia_pool
125 WHERE ia_pool_c.sty_code = p_sty_type
126 AND ia_pool_c.pol_id = ia_pool.id
127 AND ia_pool.khr_id = ia_chr.id
128 AND ia_chr.scs_code = G_INVESTOR
129 AND ia_chr.id = ia_khr.id
130 AND ia_pdt.id = ia_khr.pdt_id
131 AND ia_chr.id = ia_khr.id
132 AND ia_pool_c.khr_id = p_khr_id
133 AND ia_pool_c.status_code <> Okl_Pool_Pvt.G_POC_STS_PENDING ; --Added by VARANGAN -Pool Contents Impact(Bug#6658065)
134 -- Cursor to fetch IA Accounting Code setup in Terms and Conditions..
135 CURSOR c_investor_agree_acc_code_csr (l_rent_ia_chr_id NUMBER, l_res_ia_chr_id NUMBER)
136 IS
137 SELECT
138 DECODE(ia_rule.dnz_chr_id,l_rent_ia_chr_id, ia_rule.rule_information1,NULL) rent_ia_accounting_code
139 ,DECODE(ia_rule.dnz_chr_id,l_res_ia_chr_id,ia_rule.rule_information1,NULL) res_ia_accounting_code
140 FROM okc_rules_b ia_rule
141 ,okc_rule_groups_b ia_rule_groups
142 WHERE ia_rule.rgp_id = ia_rule_groups.id
143 AND ia_rule.dnz_chr_id IN (l_rent_ia_chr_id, l_res_ia_chr_id)
144 AND ia_rule_groups.rgd_code = 'LASEAC'
145 AND ia_rule.rule_information_category = 'LASEAC';
146
147 -- Cursor to fetch the Customer Name and Account Number details
148 -- Modifed by zrehman Bug#6707320 for Party Merge impact on transaction sources tables
149 CURSOR c_cust_name_account_csr (l_khr_id NUMBER,l_cust_acct_id NUMBER )
150 IS
151 SELECT cust_party.party_name
152 ,cust_party.party_id
153 ,cust_accounts.account_number
154 FROM okc_k_party_roles_b cust_party_roles
155 ,hz_parties cust_party
156 ,hz_cust_accounts cust_accounts
157 WHERE cust_party.party_type in ( 'PERSON','ORGANIZATION')
158 AND cust_party.party_id = cust_party_roles.object1_id1
159 AND '#' = cust_party_roles.object1_id2
160 AND cust_party_roles.jtot_object1_code = 'OKX_PARTY'
161 AND cust_party_roles.rle_code = 'LESSEE'
162 AND cust_party_roles.chr_id = l_khr_id
163 AND cust_party_roles.dnz_chr_id = l_khr_id
164 AND cust_accounts.cust_account_id = l_cust_acct_id;
165
166 -- Cursor to fetch the Active Insurance policy details
167 CURSOR c_insurance_csr (l_khr_id NUMBER)
168 IS
169 SELECT ins.policy_number
170 ,ins.ipe_code
171 FROM okl_ins_policies_all_b ins
172 WHERE ins.khr_id = l_khr_id
173 AND ins.ipy_type = 'LEASE_POLICY'
174 AND ins.quote_yn = 'N'
175 AND ins.iss_code = 'ACTIVE';
176
177 -- Cursor to fetch the Sales Representative Name using the AGS PK ...
178 CURSOR c_sales_rep_acc_sources_csr (p_jtf_sales_rep_pk NUMBER)
179 IS
180 SELECT rep.name
181 FROM jtf_rs_salesreps_mo_v rep
182 WHERE salesrep_id = p_jtf_sales_rep_pk;
183
184 -- Cursor to fetch the Sales Representative Details
185 CURSOR c_sales_rep_csr (l_khr_id NUMBER)
186 IS
187 SELECT rep.name
188 FROM okc_contacts contact
189 ,okx_salesreps_v rep
190 WHERE contact.DNZ_CHR_ID = l_khr_id
191 AND rep.id1 = contact.object1_id1
192 AND rep.id2 = contact.object1_id2;
193
194 -- Cursor to fetch the Credit Line and Master Lease Details
195 CURSOR c_creditline_master_lease_csr (l_khr_id NUMBER)
196 IS
197 SELECT chr_cr_master.scs_code CHR_TYPE
198 ,decode(chr_cr_master.scs_code,'CREDITLINE_CONTRACT'
199 ,chr_cr_master.contract_number, NULL) credit_line_number
200 ,decode(chr_cr_master.scs_code,'MASTER_LEASE'
201 ,chr_cr_master.contract_number, NULL) master_lease_number
202 ,decode(chr_cr_master.scs_code,'MASTER_LEASE'
203 ,chr_cr_master.id, TO_NUMBER(NULL)) master_lease_id
204 FROM okc_k_headers_all_b chr_cr_master
205 ,okc_governances governances
206 WHERE governances.dnz_chr_id = l_khr_id
207 AND governances.chr_id_referred = chr_cr_master.ID
208 AND chr_cr_master.scs_code in ('CREDITLINE_CONTRACT', 'MASTER_LEASE');
209
210 -- Sometimes credit line may be associated with Master Lease instead with a contract
211 CURSOR c_creditline_sub_csr (l_mla_chr_id NUMBER)
212 IS
213 SELECT crline_sub_chr.contract_number
214 FROM okc_k_headers_all_b crline_sub_chr
215 ,okc_governances crline_gov
216 WHERE crline_gov.dnz_chr_id = l_mla_chr_id
217 AND crline_gov.chr_id_referred = crline_sub_chr.id
218 AND crline_sub_chr.scs_code = 'CREDITLINE_CONTRACT';
219
220 -- Cursor to fetch the Vendor Program Agreement Number
221 CURSOR c_vendor_program_number_csr (p_khr_id NUMBER)
222 IS
223 SELECT vp_chr.contract_number
224 FROM okc_k_headers_all_b vp_chr
225 ,okl_k_headers khr
226 WHERE vp_chr.id = khr.khr_id
227 AND vp_chr.scs_code = 'PROGRAM'
228 AND khr.id = p_khr_id;
229
230 -- Use this cursor to fetch the meaning of the of the Contract Status
231 CURSOR c_get_status_meaning_csr( p_sts_code VARCHAR2, p_led_lang VARCHAR2)
232 IS
233 SELECT status.meaning status_meaning
234 FROM okc_statuses_tl status
235 WHERE status.code = p_sts_code
236 AND status.language = p_led_lang;
237
238 -- Cursor to fetch the Transaction type in the ledger language.
239 CURSOR c_trx_type_name_csr( p_try_id NUMBER, p_led_lang VARCHAR2 )
240 IS
241 SELECT try_tl.NAME transaction_type_name
242 ,try_b.trx_type_class trx_type_class_code
243 FROM okl_trx_types_tl try_tl
244 ,okl_trx_types_b try_b
245 WHERE try_tl.id = p_try_id
246 AND TRY_B.ID = try_tl.id
247 AND try_tl.language = p_led_lang;
248
249 -- Cursor to fetch the Contract Id from the OKL_TXL_ASSETS table.
250 CURSOR c_tas_khr_id_csr( p_source_id okl_trx_assets.id%TYPE )
251 IS
252 SELECT DISTINCT tal.dnz_khr_id khr_id
253 ,kle_id kle_id
254 FROM okl_trx_assets tas
255 ,okl_txl_assets_b tal
256 WHERE tal.tas_id = tas.id
257 AND tas.id = p_source_id;
258
259 -- Cursor to fetch the Contract Id from the OKL_TXL_ASSETS table.
260 CURSOR c_tal_khr_id_csr( p_source_id okl_txl_assets_b.id%TYPE )
261 IS
262 SELECT tal.dnz_khr_id khr_id
263 ,tal.kle_id kle_id
264 FROM okl_txl_assets_b tal
265 WHERE tal.id = p_source_id;
266
267 -- Cursor to fetch the Contract Line Information
268 CURSOR c_k_lines_csr (p_kle_id NUMBER)
269 IS
270 SELECT cleb.line_number
271 ,kle.fee_type
272 ,DECODE(cleb.lse_id,
273 33, clet.name, -- For FREE_FORM1 Asset
274 NULL) asset_number
275 ,kle.date_delivery_expected
276 ,decode(cleb.lse_id,
277 33, 'FREE_FORM1', -- Asset
278 1, 'SERVICE', -- Service
279 48, 'SERVICE',
280 52, 'FEE', -- Fee
281 NULL) contract_line_type
282 FROM okc_k_lines_b cleb
283 ,okl_k_lines kle
284 ,okc_k_lines_tl clet
285 WHERE cleb.id = p_kle_id
286 AND kle.id = cleb.id
287 AND cleb.id = clet.id
288 AND clet.language = USERENV('LANG');
289
290
291 -- Cursor to fetch the vendor details along with the Line Number
292 CURSOR c_vendor_name_csr (p_kle_id NUMBER, p_khr_id NUMBER)
293 IS
294 SELECT pov.vendor_id
295 ,pov.vendor_name
296 FROM okc_k_lines_b cleb_vendor
297 ,po_vendors pov
298 ,okc_k_party_roles_b pty
299 WHERE cleb_vendor.cle_id = p_kle_id
300 AND cleb_vendor.dnz_chr_id = p_khr_id
301 AND cleb_vendor.lse_id = 34
302 AND pty.cle_id = cleb_vendor.id
303 AND pty.rle_code = 'OKL_VENDOR'
304 AND pty.dnz_chr_id = p_khr_id
305 AND pov.vendor_id = pty.object1_id1;
306
307 -- Cursor to fetch the Asset Installed Site
308 CURSOR c_installed_site_csr (p_kle_id NUMBER, p_khr_id NUMBER)
309 IS
310 SELECT hl.location_id installed_site_id
311 FROM hz_locations hl,
312 hz_party_sites hps,
313 csi_item_instances csi,
314 okc_k_items cim_ib,
315 okc_k_lines_b cle_ib,
316 okc_k_lines_b cle_inst,
317 okc_k_lines_b cle_fin
318 WHERE cle_fin.cle_id is null
319 AND cle_fin.chr_id = cle_fin.dnz_chr_id
320 AND cle_fin.lse_id = 33
321 AND cle_inst.cle_id = cle_fin.id
322 AND cle_inst.dnz_chr_id = cle_fin.dnz_chr_id
323 AND cle_inst.lse_id = 43
324 AND cle_ib.cle_id = cle_inst.id
325 AND cle_ib.dnz_chr_id = cle_inst.dnz_chr_id
326 AND cle_ib.lse_id = 45
327 AND cim_ib.cle_id = cle_ib.id
328 AND cim_ib.dnz_chr_id = cle_ib.dnz_chr_id
329 AND cim_ib.object1_id1 = csi.instance_id
330 AND cim_ib.object1_id2 = '#'
331 AND cim_ib.jtot_object1_code = 'OKX_IB_ITEM'
332 AND csi.install_location_id = hps.party_site_id
333 AND csi.install_location_type_code = 'HZ_PARTY_SITES'
334 AND hps.location_id = hl.location_id
335 AND cle_fin.dnz_chr_id = p_khr_id
336 AND cle_fin.id = p_kle_id;
337
338 -- Cursor to fetch the Inventory Item Name
339 CURSOR c_inventory_item_name_csr (p_inventory_item_id_pk1 VARCHAR2
340 ,p_inventory_org_id_pk2 VARCHAR2
341 ,p_ledger_language VARCHAR2)
342 IS
343 SELECT msitl.description description
344 ,msitb.description b_description
345 FROM mtl_system_items_tl msitl
346 ,mtl_system_items_b msitb
347 WHERE msitl.inventory_item_id = p_inventory_item_id_pk1
348 AND msitl.organization_id = p_inventory_org_id_pk2
349 AND msitl.inventory_item_id = msitb.inventory_item_id
350 AND msitl.organization_id = msitb.organization_id
351 AND msitl.LANGUAGE = p_ledger_language;
352
353 CURSOR c_inventory_org_id_csr( p_khr_id NUMBER )
354 IS
355 SELECT khr.inv_organization_id inv_organization_id
356 ,hrb.NAME hrb_name
357 FROM okc_k_headers_all_b khr
358 ,hr_all_organization_units hrb
359 WHERE khr.id = p_khr_id
360 AND hrb.organization_id = khr.inv_organization_id;
361
362 CURSOR c_khr_to_ledger_id_csr( p_khr_id NUMBER )
363 IS
364 SELECT set_of_books_id ledger_id
365 FROM okl_sys_acct_opts_all sysop
366 ,okc_k_headers_all_b cntrct
367 WHERE cntrct.id = p_khr_id
368 AND cntrct.authoring_org_id = sysop.org_id;
369
370 -- for khr category and attributes
371 CURSOR c_khr_category_attributes_csr (l_khr_id NUMBER)
372 IS
373 SELECT khr.attribute_category
374 ,khr.attribute1
375 ,khr.attribute2
376 ,khr.attribute3
377 ,khr.attribute4
378 ,khr.attribute5
379 ,khr.attribute6
380 ,khr.attribute7
381 ,khr.attribute8
382 ,khr.attribute9
383 ,khr.attribute10
384 ,khr.attribute11
385 ,khr.attribute12
386 ,khr.attribute13
387 ,khr.attribute14
388 ,khr.attribute15
389 FROM okl_k_headers khr
390 WHERE khr.id = l_khr_id;
391
392 -- for book classification code and tax owner code
393 CURSOR c_pdt_bc_to_icm_rrb_csr(p_pdt_id NUMBER)
394 IS
395 SELECT pdt.name pdt_name
396 ,aes.name aes_name
397 ,gts.name sgt_name
398 ,gts.deal_type deal_type
399 ,gts.tax_owner tax_owner
400 ,gts.interest_calc_meth_code interest_calc_meth_code
401 ,gts.revenue_recog_meth_code revenue_recog_meth_code
402 FROM okl_products pdt
403 ,okl_ae_tmpt_sets_all aes
404 ,okl_st_gen_tmpt_sets_all gts
405 WHERE pdt.aes_id = aes.id
406 AND aes.gts_id = gts.id
407 AND pdt.id = p_pdt_id;
408
409 --for line attribute category and line attributes
410 CURSOR c_line_attributes_csr (l_kle_id NUMBER)
411 IS
412 SELECT kle.attribute_category
413 ,kle.attribute1
414 ,kle.attribute2
415 ,kle.attribute3
416 ,kle.attribute4
417 ,kle.attribute5
418 ,kle.attribute6
419 ,kle.attribute7
420 ,kle.attribute8
421 ,kle.attribute9
422 ,kle.attribute10
423 ,kle.attribute11
424 ,kle.attribute12
425 ,kle.attribute13
426 ,kle.attribute14
427 ,kle.attribute15
428 FROM okl_k_lines kle
429 WHERE kle.id = l_kle_id;
430
431 -- Cursor to fetch the Asset Manufacturer Name, Model Number and Category Name
432 CURSOR c_manufacture_model_csr (p_kle_id NUMBER, p_khr_id NUMBER)
433 IS
434 SELECT fac.category_id category_id
435 ,fab.manufacturer_name manufacturer_name
436 ,fab.model_number model_number
437 ,fac.SEGMENT1 || '-' || fac.SEGMENT2 asset_category_name
438 FROM okc_k_lines_b cleb_fa
439 ,fa_additions_b fab
440 ,okc_k_items cim
441 ,fa_categories fac
442 WHERE cleb_fa.cle_id = p_kle_id
443 AND cleb_fa.dnz_chr_id = p_khr_id
444 AND cleb_fa.lse_id = 42
445 AND cim.cle_id = cleb_fa.id
446 AND cim.dnz_chr_id = p_khr_id
447 AND cim.jtot_object1_code = 'OKX_ASSET'
448 AND fab.asset_id = cim.object1_id1
449 AND fac.category_id = fab.asset_category_id;
450
451 -- Cursor to fetch the Asset Location Id
452 CURSOR c_location_id_csr (p_kle_id NUMBER, p_khr_id NUMBER )
453 IS
454 SELECT fdh.location_id
455 FROM okc_k_lines_b cleb_loc
456 ,fa_distribution_history fdh
457 ,okc_k_items cim
458 WHERE cleb_loc.cle_id = p_kle_id
459 AND cleb_loc.dnz_chr_id = p_khr_id
460 AND cleb_loc.lse_id = 42
461 AND cim.cle_id = cleb_loc.id
462 AND cim.dnz_chr_id = p_khr_id
463 AND fdh.asset_id = cim.object1_id1
464 AND cim.jtot_object1_code = 'OKX_ASSET'
465 AND fdh.transaction_header_id_out IS NULL;
466
467 -- Cursor to fetch the Asset Location Name
468 CURSOR c_asset_location_name_csr (p_fdh_location_id NUMBER)
469 IS
470 SELECT location_id location_id
471 ,loc.concatenated_segments asset_location_name
472 FROM fa_locations_kfv loc
473 WHERE loc.location_id = p_fdh_location_id;
474
475 -- Cursor to fetch the transaction number
476 -- source table : okl_txl_assets_b
477 CURSOR c_txl_trans_number_csr (p_source_id NUMBER)
478 IS
479 SELECT tas.trans_number trans_number
480 ,txl.id txl_id
481 ,tas.id tas_id
482 FROM okl_trx_assets tas
483 ,okl_txl_assets_b txl
484 WHERE tas.id = txl.tas_id and
485 txl.id = p_source_id;
486
487 -- Cursor to fetch the transaction number
488 -- source table : okl_txd_assets_b
489 CURSOR c_txd_trans_number_csr (p_source_id NUMBER)
490 IS
491 SELECT tas.trans_number trans_number
492 ,txl.id txl_id
493 ,tas.id tas_id
494 FROM okl_trx_assets tas
495 ,okl_txl_assets_b txl
496 ,okl_txd_assets_b txd
497 WHERE tas.id = txl.tas_id and
498 txl.id = txd.tal_id and
499 txd.id = p_source_id;
500
501 -- Cursor to fetch the Transaction Line Description
502 CURSOR get_txl_line_desc_csr( p_txl_id NUMBER, p_ledger_lang VARCHAR2 )
503 IS
504 SELECT txl_tl.description trans_line_description
505 FROM okl_txl_assets_tl txl_tl
506 WHERE txl_tl.id = p_txl_id
507 AND txl_tl.language = p_ledger_lang;
508
509 -- Cursor to fetch the Asset Year Manufactured
510 CURSOR c_asset_year_manufactured_csr (p_kle_id NUMBER, p_khr_id NUMBER)
511 IS
512 SELECT kle.Year_built year_of_manufacture
513 FROM okl_k_lines kle,
514 okc_k_lines_b cleb_year
515 WHERE kle.id = cleb_year.id
516 AND cleb_year.cle_id = p_kle_id
517 AND cleb_year.dnz_chr_id = p_khr_id
518 AND cleb_year.lse_id = 42;
519
520 -- Cursor to fetch the Aging Bucket Name
521 CURSOR c_aging_bucket_name_csr (p_bkt_id NUMBER)
522 IS
523 SELECT ARB.BUCKET_NAME BUCKET_NAME
524 FROM OKL_BUCKETS OBKT
525 ,AR_AGING_BUCKET_LINES_B ARBL
526 ,AR_AGING_BUCKETS ARB
527 WHERE OBKT.IBC_ID = ARBL.AGING_BUCKET_LINE_ID
528 AND ARBL.AGING_BUCKET_ID = ARB.AGING_BUCKET_ID
529 AND OBKT.ID = p_bkt_id;
530
531 -- Cursor to fetch the Receivables Transaction Type using AGS ID
532 CURSOR c_cust_trx_type_csr( p_trx_id NUMBER)
533 IS
534 SELECT ctt.name trx_name
535 FROM ra_cust_trx_types ctt
536 WHERE ctt.cust_trx_type_id = p_trx_id;
537
538 -- Cursor to fetch termination quote attr
539 CURSOR c_termination_qte_csr (l_qte_id NUMBER)
540 IS
541 SELECT date_effective_from
542 ,quote_number
543 ,qtp_code
544 FROM okl_trx_quotes_all_b
545 WHERE id = l_qte_id;
546
547 -- Cursor to fetch contingency code and stream type name
548 -- applicable only for AR.
549 CURSOR c_contingency_strm_b_csr (p_sty_id NUMBER )
550 IS
551 SELECT styb.code stream_type_code
552 ,styb.stream_type_purpose stream_type_purpose
553 -- changed to contingency_name from styb.contingency
554 -- for bug fix 6744584. racheruv
555 ,adr.contingency_name contingency_code
556 FROM okl_strm_type_b styb, ar_deferral_reasons adr
557 WHERE styb.id = p_sty_id
558 AND styb.contingency_id = adr.contingency_id(+);
559
560 CURSOR c_strm_name_tl_csr (p_sty_id NUMBER, p_lang VARCHAR2)
561 IS
562 SELECT stytl.NAME stream_type_name
563 FROM okl_strm_type_tl stytl
564 WHERE stytl.id = p_sty_id
565 AND stytl.language = p_lang;
566
567 -- Cursor to fetch Investor Related Information
568 CURSOR c_inv_agrmnt_details_csr( p_inv_agrmnt_id NUMBER)
569 IS
570 SELECT invc.contract_number inv_agrmnt_number
571 ,DECODE(invk.securitization_type,
572 'SALE', 'SECURITIZATION',
573 'LOAN', 'SYNDICATION',
574 'SECURITIZATION','SECURITIZATION',
575 'SYNDICATION', 'SYNDICATION') inv_agrmnt_synd_code
576 ,pol.pool_number inv_agrmnt_pool_number
577 ,invc.currency_code inv_agrmnt_currency_code
578 ,invc.START_DATE inv_agrmnt_effective_from
579 ,invc.sts_code inv_agrmnt_status_code
580 FROM okc_k_headers_all_b invc
581 ,okl_k_headers invk
582 ,okl_pools_all pol
583 WHERE invc.id = invk.id
584 AND invc.scs_code = G_INVESTOR
585 AND pol.khr_id = invk.id
586 AND invc.id = p_inv_agrmnt_id;
587
588 -- Cursor to fetch the Accounting Distributions
589 -- Note: This cursor is used in AR and AP Populate Sources alone
590 CURSOR c_account_dist_csr (
591 p_source_id NUMBER
592 ,p_source_table VARCHAR2)
593 IS
594 SELECT DISTINCT template_id
595 FROM okl_trns_acc_dstrs_all dist
596 WHERE source_table = p_source_table
597 AND source_id = p_source_id;
598
599 -- Cursor to fetch the template information
600 -- Note: This cursor is used in AR and AP Populate Sources alone
601 CURSOR c_ae_templates_csr (p_template_id NUMBER)
602 IS
603 SELECT name
604 ,memo_yn
605 FROM okl_ae_templates_all
606 WHERE id = p_template_id;
607
608 -- This cursor is used to fetch the Subsidy Details like
609 -- Subsidy Name and Subsidy Party Name. Used only by AR Populate Sources
610 -- Modified by zrehman Bug#6707320 for Party Merge Impact on Transaction Sources tables
611 CURSOR get_subsidy_details_csr( p_kle_id NUMBER)
612 IS
613 SELECT sub.NAME subsidy_name
614 ,party.vendor_name subsidy_party_name
615 ,party.vendor_id subsidy_vendor_id
616 FROM okl_subsidies_b sub
617 ,okl_k_lines subsidy_line
618 ,okc_k_party_roles_b role
619 ,po_vendors party
620 WHERE sub.id = subsidy_line.subsidy_id
621 AND role.cle_id = subsidy_line.id
622 AND role.object1_id1 = party.vendor_id
623 AND subsidy_line.id = p_kle_id;
624
625 -- Cursor to fetch the product name
626 CURSOR c_get_pdt_name_csr( p_pdt_id NUMBER)
627 IS
628 SELECT pdt.name pdt_name
629 FROM okl_products pdt
630 WHERE pdt.id = p_pdt_id;
631
632 -- Cursor to fetch the Line Style of the given Line ID
633 -- Used by FA Populate sources for validation Purposes
634 -- Used by AR Populate sources for getting parent_line_id
635 CURSOR get_line_style_csr(p_kle_id IN NUMBER)
636 IS
637 SELECT lse.lty_code line_style
638 ,cle.cle_id parent_line_id
639 FROM okc_k_lines_b cle
640 ,okc_line_styles_b lse
641 WHERE cle.lse_id = lse.id
642 AND cle.id = p_kle_id;
643
644 -- Cursor to fetch the Transaction Line Description for AR TXD
645 CURSOR c_tld_line_description (p_tld_tl_id NUMBER, p_lang VARCHAR2)
646 IS
647 SELECT tldl.id tldl_id
648 ,tldl.description trans_line_description
649 FROM okl_txd_ar_ln_dtls_tl tldl
650 WHERE tldl.id = p_tld_tl_id
651 AND tldl.language = p_lang;
652
653 -- Cursor to fetch the AP Invoice Invoice Transaction Line Description
654 CURSOR c_txl_ap_inv_desc_csr (p_tpld_id NUMBER, p_lang VARCHAR2)
655 IS
656 SELECT tpld.id tpld_id
657 ,tpld.description trans_line_description
658 FROM okl_txl_ap_inv_lns_tl tpld
659 WHERE tpld.id = p_tpld_id
660 AND tpld.LANGUAGE = p_lang;
661
662 -- Cursors to fetch the Termination Quote Related Sources for FA Transactions
663 -- For Offlease Amortization Transaction
664 CURSOR c_tq_dtls_offlease( p_kle_id NUMBER)
665 IS
666 SELECT qte.quote_number quote_number
667 ,qte.date_accepted quote_accepted_date
668 ,qte.qtp_code quote_type
669 FROM okl_trx_quotes_all_b qte
670 ,okl_txl_quote_lines_b tql
671 WHERE qte.id = tql.qte_id
672 AND qte.qst_code in ('ACCEPTED', 'COMPLETE')
673 AND qte.accepted_yn = 'Y'
674 AND tql.qlt_code = 'AMCFIA'
675 AND tql.kle_id = p_kle_id;
676
677 -- For Split Asset Transaction
678 CURSOR c_tq_dtls_split_ast( p_kle_id NUMBER
679 ,p_split_asset_trx_id NUMBER )
680 IS
681 SELECT qte.quote_number quote_number
682 ,qte.date_accepted quote_accepted_date
683 ,qte.qtp_code quote_type
684 FROM okl_trx_quotes_all_b qte
685 ,okl_txl_quote_lines_b tql
686 WHERE qte.id = tql.qte_id
687 AND qte.qst_code in ('ACCEPTED', 'COMPLETE')
688 AND qte.accepted_yn = 'Y'
689 AND tql.qlt_code = 'AMCFIA'
690 AND tql.kle_id = p_kle_id
691 AND EXISTS
692 (
693 SELECT 1
694 FROM okl_trx_assets tas
695 ,okl_txl_assets_b tal
696 ,okc_k_lines_b cleb
697 WHERE cleb.id = tql.kle_id
698 AND cleb.cle_id = tal.kle_id
699 AND tal.tas_id = tas.id
700 AND tas.id = p_split_asset_trx_id
701 );
702
703 -- For Release Transaction
704 CURSOR c_tq_dtls_release( p_khr_id NUMBER )
705 IS
706 SELECT qte.quote_number quote_number
707 ,qte.date_accepted quote_accepted_date
708 ,qte.qtp_code quote_type
709 FROM okl_trx_types_b trx_b
710 ,okl_trx_contracts_all rel_trx
711 ,okl_trx_quotes_all_b qte
712 WHERE trx_b.trx_type_class = 'RE_LEASE'
713 AND trx_b.id = rel_trx.try_id
714 AND rel_trx.khr_id_new = p_khr_id
715 AND rel_trx.tsu_code <> 'PROCESSED'
716 AND qte.id = rel_trx.qte_id;
717
718 -- get the representations. MG uptake
719 CURSOR get_rep_type_csr(p_book_type_name varchar2) IS
720 SELECT o.ledger_id,
721 o.representation_code,
722 o.representation_name,
723 o.representation_type
724 FROM okl_representations_v o,
725 fa_book_controls f
726 WHERE o.ledger_id = f.set_of_books_id
727 AND f.book_type_name = p_book_type_name;
728
729 -- get the representations based on book_type_code .. MG uptake
730 CURSOR get_reps_csr(p_book_type_code varchar2) IS
731 SELECT o.ledger_id,
732 o.representation_code,
733 o.representation_name,
734 o.representation_type
735 FROM okl_representations_v o,
736 fa_book_controls f
737 WHERE o.ledger_id = f.set_of_books_id
738 AND f.book_type_code = p_book_type_code;
739
740 -- get the reporting product based on the contract product .. MG uptake
741 CURSOR c_rep_pdt_csr(p_pdt_id number) IS
742 SELECT reporting_pdt_id
743 FROM okl_products p
744 WHERE p.id = p_pdt_id;
745
746 -- get the book_type_name for asset book type code .. MG uptake
747 CURSOR get_book_type_name(p_book_type_code varchar2) IS
748 SELECT book_type_name
749 FROM fa_book_controls
750 WHERE book_type_code = p_book_type_code;
751
752 PROCEDURE write_to_log(
753 p_level IN VARCHAR2,
754 p_module IN fnd_log_messages.module%TYPE,
755 msg IN VARCHAR2 )
756 AS
757 -- l_level: S - Statement, P- Procedure, B - Both
758 BEGIN
759 okl_debug_pub.log_debug(
760 p_level,
761 p_module,
762 msg);
763 END;
764
765 PROCEDURE put_in_log(
766 p_debug_enabled IN VARCHAR2,
767 is_debug_procedure_on IN BOOLEAN,
768 is_debug_statement_on IN BOOLEAN,
769 p_module IN fnd_log_messages.module%TYPE,
770 p_level IN VARCHAR2,
771 msg IN VARCHAR2 )
772 AS
773 -- l_level: S - Statement, P- Procedure, B - Both
774 BEGIN
775 IF(p_debug_enabled='Y' AND is_debug_procedure_on AND p_level = 'P')
776 THEN
777 write_to_log(
778 p_level => FND_LOG.LEVEL_PROCEDURE,
779 p_module => p_module,
780 msg => msg);
781 ELSIF (p_debug_enabled='Y' AND is_debug_statement_on AND
782 (p_level = 'S' OR p_level = 'B' ))
783 THEN
784 write_to_log(
785 p_level => FND_LOG.LEVEL_STATEMENT,
786 p_module => p_module,
787 msg => msg);
788 END IF;
789 END put_in_log;
790
791 PROCEDURE write_ext_hdr_to_log(
792 p_teh_rec IN okl_teh_pvt.teh_rec_type
793 ,p_tehl_tbl IN okl_teh_pvt.tehl_tbl_type
794 ,p_module IN fnd_log_messages.module%TYPE)
795 AS
796 tl_index NUMBER;
797 BEGIN
798 -- Print the Sources captured at extension Header Level
799 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'HEADER_EXTENSION_ID =' || p_teh_rec.HEADER_EXTENSION_ID );
800 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'SOURCE_ID =' || p_teh_rec.SOURCE_ID );
801 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'SOURCE_TABLE =' || p_teh_rec.SOURCE_TABLE );
802 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'OBJECT_VERSION_NUMBER =' || p_teh_rec.OBJECT_VERSION_NUMBER );
803 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'CONTRACT_NUMBER =' || p_teh_rec.CONTRACT_NUMBER );
804 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'INV_AGRMNT_NUMBER =' || p_teh_rec.INV_AGRMNT_NUMBER );
805 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'CONTRACT_CURRENCY_CODE =' || p_teh_rec.CONTRACT_CURRENCY_CODE );
806 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'INV_AGRMNT_CURRENCY_CODE =' || p_teh_rec.INV_AGRMNT_CURRENCY_CODE );
807 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'CONTRACT_EFFECTIVE_FROM =' || p_teh_rec.CONTRACT_EFFECTIVE_FROM );
808 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'INV_AGRMNT_EFFECTIVE_FROM =' || p_teh_rec.INV_AGRMNT_EFFECTIVE_FROM );
809 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'CUSTOMER_NAME =' || p_teh_rec.CUSTOMER_NAME );
810 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'SALES_REP_NAME =' || p_teh_rec.SALES_REP_NAME );
811 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'CUSTOMER_ACCOUNT_NUMBER =' || p_teh_rec.CUSTOMER_ACCOUNT_NUMBER );
812 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'BILL_TO_ADDRESS_NUM =' || p_teh_rec.BILL_TO_ADDRESS_NUM );
813 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'INT_CALC_METHOD_CODE =' || p_teh_rec.INT_CALC_METHOD_CODE );
814 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'REV_REC_METHOD_CODE =' || p_teh_rec.REV_REC_METHOD_CODE );
815 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'CONVERTED_NUMBER =' || p_teh_rec.CONVERTED_NUMBER );
816 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'ASSIGNABLE_FLAG =' || p_teh_rec.ASSIGNABLE_FLAG );
817 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'CREDIT_LINE_NUMBER =' || p_teh_rec.CREDIT_LINE_NUMBER );
818 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'MASTER_LEASE_NUMBER =' || p_teh_rec.MASTER_LEASE_NUMBER );
819 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'PO_ORDER_NUMBER =' || p_teh_rec.PO_ORDER_NUMBER );
820 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'VENDOR_PROGRAM_NUMBER =' || p_teh_rec.VENDOR_PROGRAM_NUMBER );
821 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'INS_POLICY_TYPE_CODE =' || p_teh_rec.INS_POLICY_TYPE_CODE );
822 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'INS_POLICY_NUMBER =' || p_teh_rec.INS_POLICY_NUMBER );
823 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'TERM_QUOTE_ACCEPT_DATE =' || p_teh_rec.TERM_QUOTE_ACCEPT_DATE );
824 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'TERM_QUOTE_NUM =' || p_teh_rec.TERM_QUOTE_NUM );
825 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'TERM_QUOTE_TYPE_CODE =' || p_teh_rec.TERM_QUOTE_TYPE_CODE );
826 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'CONVERTED_ACCOUNT_FLAG =' || p_teh_rec.CONVERTED_ACCOUNT_FLAG );
827 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'ACCRUAL_OVERRIDE_FLAG =' || p_teh_rec.ACCRUAL_OVERRIDE_FLAG );
828 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'CUST_ATTRIBUTE_CATEGORY =' || p_teh_rec.CUST_ATTRIBUTE_CATEGORY );
829 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'CUST_ATTRIBUTE1 =' || p_teh_rec.CUST_ATTRIBUTE1 );
830 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'CUST_ATTRIBUTE2 =' || p_teh_rec.CUST_ATTRIBUTE2 );
831 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'CUST_ATTRIBUTE3 =' || p_teh_rec.CUST_ATTRIBUTE3 );
832 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'CUST_ATTRIBUTE4 =' || p_teh_rec.CUST_ATTRIBUTE4 );
833 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'CUST_ATTRIBUTE5 =' || p_teh_rec.CUST_ATTRIBUTE5 );
834 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'CUST_ATTRIBUTE6 =' || p_teh_rec.CUST_ATTRIBUTE6 );
835 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'CUST_ATTRIBUTE7 =' || p_teh_rec.CUST_ATTRIBUTE7 );
836 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'CUST_ATTRIBUTE8 =' || p_teh_rec.CUST_ATTRIBUTE8 );
837 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'CUST_ATTRIBUTE9 =' || p_teh_rec.CUST_ATTRIBUTE9 );
838 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'CUST_ATTRIBUTE10 =' || p_teh_rec.CUST_ATTRIBUTE10 );
839 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'CUST_ATTRIBUTE11 =' || p_teh_rec.CUST_ATTRIBUTE11 );
840 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'CUST_ATTRIBUTE12 =' || p_teh_rec.CUST_ATTRIBUTE12 );
841 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'CUST_ATTRIBUTE13 =' || p_teh_rec.CUST_ATTRIBUTE13 );
842 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'CUST_ATTRIBUTE14 =' || p_teh_rec.CUST_ATTRIBUTE14 );
843 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'CUST_ATTRIBUTE15 =' || p_teh_rec.CUST_ATTRIBUTE15 );
844 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'RENT_IA_CONTRACT_NUMBER =' || p_teh_rec.RENT_IA_CONTRACT_NUMBER );
845 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'RES_IA_CONTRACT_NUMBER =' || p_teh_rec.RES_IA_CONTRACT_NUMBER );
846 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'INV_AGRMNT_POOL_NUMBER =' || p_teh_rec.INV_AGRMNT_POOL_NUMBER );
847 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'RENT_IA_PRODUCT_NAME =' || p_teh_rec.RENT_IA_PRODUCT_NAME );
848 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'RES_IA_PRODUCT_NAME =' || p_teh_rec.RES_IA_PRODUCT_NAME );
849 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'RENT_IA_ACCOUNTING_CODE =' || p_teh_rec.RENT_IA_ACCOUNTING_CODE );
850 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'RES_IA_ACCOUNTING_CODE =' || p_teh_rec.RES_IA_ACCOUNTING_CODE );
851 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'INV_AGRMNT_SYND_CODE =' || p_teh_rec.INV_AGRMNT_SYND_CODE );
852 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'CONTRACT_STATUS_CODE =' || p_teh_rec.CONTRACT_STATUS_CODE );
853 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'INV_AGRMNT_STATUS_CODE =' || p_teh_rec.INV_AGRMNT_STATUS_CODE );
854 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'TRX_TYPE_CLASS_CODE =' || p_teh_rec.TRX_TYPE_CLASS_CODE );
855 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'CHR_OPERATING_UNIT_CODE =' || p_teh_rec.CHR_OPERATING_UNIT_CODE );
856 -- Print translatable sources
857 FOR tl_index IN p_tehl_tbl.FIRST .. p_tehl_tbl.LAST
858 LOOP
859 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'LANGUAGE =' || p_tehl_tbl(tl_index).LANGUAGE );
860 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'CONTRACT_STATUS =' || p_tehl_tbl(tl_index).CONTRACT_STATUS );
861 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'INV_AGRMNT_STATUS =' || p_tehl_tbl(tl_index).INV_AGRMNT_STATUS );
862 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'CHR_OPERATING_UNIT_NAME =' || p_tehl_tbl(tl_index).CHR_OPERATING_UNIT_NAME );
863 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'TRANSACTION_TYPE_NAME =' || p_tehl_tbl(tl_index).TRANSACTION_TYPE_NAME );
864 END LOOP;
865 END;
866
867 PROCEDURE write_ext_line_to_log(
868 p_tel_rec IN tel_rec_type
869 ,p_tell_tbl IN tell_tbl_type
870 ,p_module IN fnd_log_messages.module%TYPE)
871 AS
872 tl_index NUMBER;
873 BEGIN
874 -- Print the Sources captured at Extension Line Level
875 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'LINE_EXTENSION_ID =' || p_tel_rec.LINE_EXTENSION_ID );
876 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'SOURCE_ID =' || p_tel_rec.SOURCE_ID );
877 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'SOURCE_TABLE =' || p_tel_rec.SOURCE_TABLE );
878 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'TEH_ID =' || p_tel_rec.TEH_ID );
879 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'CONTRACT_LINE_NUMBER =' || p_tel_rec.CONTRACT_LINE_NUMBER );
880 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'FEE_TYPE_CODE =' || p_tel_rec.FEE_TYPE_CODE );
881 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'ASSET_NUMBER =' || p_tel_rec.ASSET_NUMBER );
882 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'ASSET_CATEGORY_NAME =' || p_tel_rec.ASSET_CATEGORY_NAME );
883 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'ASSET_VENDOR_NAME =' || p_tel_rec.ASSET_VENDOR_NAME );
884 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'ASSET_MANUFACTURER_NAME =' || p_tel_rec.ASSET_MANUFACTURER_NAME );
885 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'ASSET_YEAR_MANUFACTURED =' || p_tel_rec.ASSET_YEAR_MANUFACTURED );
886 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'ASSET_MODEL_NUMBER =' || p_tel_rec.ASSET_MODEL_NUMBER );
887 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'ASSET_DELIVERED_DATE =' || p_tel_rec.ASSET_DELIVERED_DATE );
888 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'INSTALLED_SITE_ID =' || p_tel_rec.INSTALLED_SITE_ID );
889 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'FIXED_ASSET_LOCATION_NAME =' || p_tel_rec.FIXED_ASSET_LOCATION_NAME );
890 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'CONTINGENCY_CODE =' || p_tel_rec.CONTINGENCY_CODE );
891 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'SUBSIDY_NAME =' || p_tel_rec.SUBSIDY_NAME );
892 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'SUBSIDY_PARTY_NAME =' || p_tel_rec.SUBSIDY_PARTY_NAME );
893 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'MEMO_FLAG =' || p_tel_rec.MEMO_FLAG );
894 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'RECIEVABLES_TRX_TYPE_NAME =' || p_tel_rec.RECIEVABLES_TRX_TYPE_NAME );
895 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'AGING_BUCKET_NAME =' || p_tel_rec.AGING_BUCKET_NAME );
896 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'CONTRACT_LINE_TYPE =' || p_tel_rec.CONTRACT_LINE_TYPE );
897 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'PAY_SUPPLIER_SITE_NAME =' || p_tel_rec.PAY_SUPPLIER_SITE_NAME );
898 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'INVENTORY_ITEM_NAME_CODE =' || p_tel_rec.INVENTORY_ITEM_NAME_CODE );
899 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'INVENTORY_ORG_CODE =' || p_tel_rec.INVENTORY_ORG_CODE );
900 -- Print translatable sources
901 FOR tl_index IN p_tell_tbl.FIRST .. p_tell_tbl.LAST
902 LOOP
903 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'LANGUAGE =' || p_tell_tbl(tl_index).LANGUAGE );
904 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'INVENTORY_ITEM_NAME =' || p_tell_tbl(tl_index).INVENTORY_ITEM_NAME );
905 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'INVENTORY_ORG_NAMES =' || p_tell_tbl(tl_index).INVENTORY_ORG_NAME );
906 END LOOP;
907 END;
908
909 ---------------------------------------------------------------------------
910 -- Start of comments
911 -- API name : populate_tcn_sources
912 -- Pre-reqs : None
913 -- Function : Creates records for OKL_TRX_EXTENSION_V
914 -- Parameters :
915 -- IN : p_source_id IN NUMBER Required
916 -- Corresponds to the column ID
917 -- in the table OKL_TRX_CONTRACTS.
918 -- p_source_table IN VARCHAR2 Required
919 -- Value G_TRX_CONTRACTS
920 -- Version : 1.0
921 -- History : Ravi Gooty created
922 -- End of comments
923 ---------------------------------------------------------------------------
924 PROCEDURE populate_tcn_sources(
925 p_api_version IN NUMBER
926 ,p_init_msg_list IN VARCHAR2
927 ,px_trans_hdr_rec IN OUT NOCOPY tehv_rec_type
928 ,p_acc_sources_rec IN asev_rec_type
929 ,x_return_status OUT NOCOPY VARCHAR2
930 ,x_msg_count OUT NOCOPY NUMBER
931 ,x_msg_data OUT NOCOPY VARCHAR2
932 )
933 IS
934 -----------------------------------------------------------------
935 -- Declare Process Variable
936 -----------------------------------------------------------------
937 l_api_version CONSTANT NUMBER := 1;
938 l_api_name CONSTANT VARCHAR2(30) := 'POPULATE_TCN_SOURCES';
939 l_return_status VARCHAR2(1) := OKL_API.G_RET_STS_SUCCESS;
940 -----------------------------------------------------------------
941 -- Declare records: Extension Headers
942 -----------------------------------------------------------------
943 l_teh_rec_in okl_teh_pvt.teh_rec_type;
944 l_teh_rec_out okl_teh_pvt.teh_rec_type;
945 l_tehl_tbl_in okl_teh_pvt.tehl_tbl_type;
946 l_tehl_tbl_out okl_teh_pvt.tehl_tbl_type;
947
948 -- To fetch khr_id, Termination Quote_id, Event Class
949 CURSOR c_tcn_basic_csr (p_source_id NUMBER)
950 IS
951 SELECT tcn.khr_id khr_id
952 ,tcn.qte_id qte_id
953 ,tcn.pdt_id pdt_id
954 ,tcn.set_of_books_id ledger_id
955 ,try.accounting_event_class_code accounting_event_class_code
956 ,try.id try_id
957 ,tcn_type tcn_type
958 FROM okl_trx_contracts_all tcn
959 ,okl_trx_types_b try
960 WHERE tcn.id = p_source_id
961 AND tcn.try_id = try.id
962 AND try.accounting_event_class_code IS NOT NULL;
963 l_tcn_basic_csr_rec c_tcn_basic_csr%ROWTYPE;
964
965 -- Record structures based on the cursor variables.
966 l_ledger_lang_rec c_ledger_lang_csr%ROWTYPE;
967 l_get_status_meaning_rec c_get_status_meaning_csr%ROWTYPE;
968 l_khr_attributes_csr_rec c_khr_attributes_csr%ROWTYPE;
969 l_kpl_attributes_csr_rec c_kpl_attributes_csr%ROWTYPE;
970 l_rev_rec_int_calc_mtd_csr_rec c_rev_rec_int_calc_methods_csr%ROWTYPE;
971 l_investor_agree_main_csr_rec c_investor_agreement_main_csr%ROWTYPE;
972 l_inv_agree_acc_code_csr_rec c_investor_agree_acc_code_csr%ROWTYPE;
973 l_cust_name_account_csr_rec c_cust_name_account_csr%ROWTYPE;
974 l_insurance_csr_rec c_insurance_csr%ROWTYPE;
975 l_sales_rep_acc_sources_csr c_sales_rep_acc_sources_csr%ROWTYPE;
976 l_crline_master_lease_csr_rec c_creditline_master_lease_csr%ROWTYPE;
977 l_creditline_sub_csr_rec c_creditline_sub_csr%ROWTYPE;
978 l_vendor_program_number_csr c_vendor_program_number_csr%ROWTYPE;
979 l_trx_type_name_rec c_trx_type_name_csr%ROWTYPE;
980 l_termination_qte_csr_rec c_termination_qte_csr%ROWTYPE;
981 l_inv_agrmnt_details_rec c_inv_agrmnt_details_csr%ROWTYPE;
982 -- Local Variables
983 l_khr_id okl_trx_contracts_all.khr_id%TYPE;
984 l_qte_id okl_trx_contracts_all.qte_id%TYPE;
985 l_pdt_id okl_trx_contracts_all.pdt_id%TYPE;
986 l_ledger_id okl_trx_contracts_all.set_of_books_id%TYPE;
987 l_accounting_event_class_code okl_trx_types_b.accounting_event_class_code%TYPE;
988 l_cust_acct_id okc_k_headers_all_b.cust_acct_id%TYPE;
989 l_rent_ia_chr_id okc_k_headers_all_b.id%TYPE;
990 l_res_ia_chr_id okc_k_headers_all_b.id%TYPE;
991 l_master_lease_id okc_k_headers_all_b.id%TYPE;
992 l_acc_sources_rec asev_rec_type;
993 -- Local Variables for enabling the Debug Statements
994 l_module CONSTANT fnd_log_messages.module%TYPE := G_MODULE || l_api_name;
995 l_debug_enabled VARCHAR2(10);
996 is_debug_procedure_on BOOLEAN;
997 is_debug_statement_on BOOLEAN;
998 tl_sources_in NUMBER := 1;
999 BEGIN
1000 l_debug_enabled := okl_debug_pub.check_log_enabled;
1001 -- check for logging on PROCEDURE level
1002 is_debug_procedure_on := okl_debug_pub.check_log_on(l_module,FND_LOG.LEVEL_PROCEDURE);
1003 -- check for logging on STATEMENT level
1004 is_debug_statement_on := okl_debug_pub.check_log_on(l_module,FND_LOG.LEVEL_STATEMENT);
1005 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
1006 'begin debug OKLRSLAB.pls call ' || l_api_name);
1007 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
1008 'BEGIN API OKL_SLA_ACC_SOURCES_PVT.POPULATE_TCN_SOURCES');
1009 l_return_status := OKL_API.G_RET_STS_SUCCESS;
1010 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
1011 'Calling OKL_API.START_ACTIVITY');
1012 l_return_status := OKL_API.START_ACTIVITY(
1013 p_api_name => l_api_name
1014 ,p_pkg_name => g_pkg_name
1015 ,p_init_msg_list => p_init_msg_list
1016 ,l_api_version => l_api_version
1017 ,p_api_version => p_api_version
1018 ,p_api_type => '_PVT'
1019 ,x_return_status => l_return_status);
1020 IF (l_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
1021 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
1022 ELSIF (l_return_status = OKL_API.G_RET_STS_ERROR) THEN
1023 RAISE OKL_API.G_EXCEPTION_ERROR;
1024 END IF;
1025 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
1026 'Return status from OKL_API.START_ACTIVITY :'||l_return_status);
1027 -- Store the source id and source table in the rec to be passed to the Insert API
1028 l_teh_rec_in.source_id := px_trans_hdr_rec.source_id;
1029 l_teh_rec_in.source_table := px_trans_hdr_rec.source_table;
1030 -- Validations ..
1031 IF px_trans_hdr_rec.source_table NOT LIKE G_TRX_CONTRACTS
1032 THEN
1033 OKL_API.set_message(
1034 p_app_name => G_APP_NAME
1035 ,p_msg_name => G_INVALID_VALUE
1036 ,p_token1 => G_COL_NAME_TOKEN
1037 ,p_token1_value => 'HEADER.SOURCE_TABLE');
1038 l_return_status := OKL_API.G_RET_STS_UNEXP_ERROR;
1039 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
1040 END IF;
1041 -- Assign the AGS Record to the Local Record Structure
1042 l_acc_sources_rec := p_acc_sources_rec;
1043 -- Validation on the AGS Record
1044 IF l_acc_sources_rec.source_id IS NULL
1045 THEN
1046 OKL_API.set_message(
1047 p_app_name => G_APP_NAME
1048 ,p_msg_name => G_INVALID_VALUE
1049 ,p_token1 => G_COL_NAME_TOKEN
1050 ,p_token1_value => 'ACCT_SOURCES.SOURCE_ID');
1051 l_return_status := OKL_API.G_RET_STS_UNEXP_ERROR;
1052 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
1053 END IF;
1054
1055 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
1056 'Executing Cursor c_tcn_basic_csr: Source ID: ' || px_trans_hdr_rec.source_id);
1057 FOR t_rec IN c_tcn_basic_csr (p_source_id => px_trans_hdr_rec.source_id)
1058 LOOP
1059 l_tcn_basic_csr_rec := t_rec;
1060 IF l_tcn_basic_csr_rec.accounting_event_class_code IS NULL
1061 THEN
1062 -- accounting_event_class_code is missing
1063 OKL_API.set_message(
1064 p_app_name => G_APP_NAME
1065 ,p_msg_name => G_INVALID_VALUE
1066 ,p_token1 => G_COL_NAME_TOKEN
1067 ,p_token1_value => 'ACCOUNTING_EVENT_CLASS_CODE');
1068 l_return_status := OKL_API.G_RET_STS_UNEXP_ERROR;
1069 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
1070 END IF;
1071 l_khr_id := l_tcn_basic_csr_rec.khr_id;
1072 l_qte_id := l_tcn_basic_csr_rec.qte_id;
1073 l_pdt_id := l_tcn_basic_csr_rec.pdt_id;
1074 l_ledger_id := l_tcn_basic_csr_rec.ledger_id;
1075 l_accounting_event_class_code := l_tcn_basic_csr_rec.accounting_event_class_code;
1076 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
1077 ' l_khr_id : ' || l_khr_id ||
1078 ' l_qte_id : ' || l_qte_id ||
1079 ' l_pdt_id : ' || l_pdt_id ||
1080 ' l_accounting_event_class_code : ' || l_accounting_event_class_code ||
1081 ' ledger_id ' || TO_CHAR( l_tcn_basic_csr_rec.ledger_id));
1082 END LOOP; -- c_tcn_basic_csr;
1083
1084 -- Fetch the Ledger language in order to populate the MLS Sources at header level.
1085 -- Store the Ledger Language so that its passed to the TAPI
1086 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
1087 'Picked Language | Ledger Language | USERENV Language p_ledger_id=' || TO_CHAR(l_ledger_id));
1088 FOR t_rec IN c_ledger_lang_csr( p_ledger_id => l_ledger_id )
1089 LOOP
1090 l_tehl_tbl_in(tl_sources_in).language := t_rec.language_code;
1091 tl_sources_in := tl_sources_in + 1;
1092 END LOOP;
1093
1094 FOR tl_sources_in in l_tehl_tbl_in.FIRST .. l_tehl_tbl_in.LAST
1095 LOOP
1096 -- Fetch the Transaction Type in Ledger language
1097 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
1098 'Executing the Cursor c_trx_type_name_csr. p_try_id=' || TO_CHAR(l_tcn_basic_csr_rec.try_id)
1099 || 'p_led_lang= ' || l_tehl_tbl_in(tl_sources_in).language );
1100 FOR t_rec IN c_trx_type_name_csr(
1101 p_try_id => l_tcn_basic_csr_rec.try_id
1102 ,p_led_lang => l_tehl_tbl_in(tl_sources_in).language )
1103 LOOP
1104 l_trx_type_name_rec := t_rec;
1105 l_tehl_tbl_in(tl_sources_in).transaction_type_name := l_trx_type_name_rec.transaction_type_name;
1106 l_teh_rec_in.trx_type_class_code := l_trx_type_name_rec.trx_type_class_code;
1107 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
1108 'Fetched Transaction Type ' || l_tehl_tbl_in(tl_sources_in).transaction_type_name );
1109 END LOOP;
1110 END LOOP;
1111
1112 IF l_accounting_event_class_code NOT IN ( G_INVESTOR )
1113 THEN
1114 --------------------------------------------------------------------------------
1115 -- Populating Common Header Sources
1116 --------------------------------------------------------------------------------
1117 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
1118 'Executing Cursor c_khr_attributes_csr : l_khr_id = ' ||to_char(l_khr_id));
1119 FOR t_rec IN c_khr_attributes_csr (l_khr_id)
1120 LOOP
1121 l_khr_attributes_csr_rec := t_rec;
1122 l_teh_rec_in.source_id := px_trans_hdr_rec.source_id;
1123 l_teh_rec_in.source_table := px_trans_hdr_rec.source_table;
1124 l_cust_acct_id := l_khr_attributes_csr_rec.cust_acct_id;
1125 l_teh_rec_in.contract_number := l_khr_attributes_csr_rec.contract_number;
1126 l_teh_rec_in.contract_currency_code := l_khr_attributes_csr_rec.currency_code;
1127 l_teh_rec_in.contract_effective_from := l_khr_attributes_csr_rec.start_date;
1128 l_teh_rec_in.bill_to_address_num := l_khr_attributes_csr_rec.bill_to_site_use_id;
1129 -- added by zrehman Bug#6707320 for Party Merge impact on Accounting sources tables start
1130 l_teh_rec_in.cust_site_use_id := l_khr_attributes_csr_rec.bill_to_site_use_id;
1131 -- added by zrehman Bug#6707320 for Party Merge impact on Accounting sources tables end
1132 l_teh_rec_in.converted_number := l_khr_attributes_csr_rec.orig_system_reference1;
1133 l_teh_rec_in.assignable_flag := l_khr_attributes_csr_rec.assignable_yn;
1134 l_teh_rec_in.converted_account_flag := l_khr_attributes_csr_rec.converted_account_yn;
1135 l_teh_rec_in.po_order_number := l_khr_attributes_csr_rec.cust_po_number;
1136 l_teh_rec_in.accrual_override_flag := l_khr_attributes_csr_rec.generate_accrual_override_yn;
1137 l_teh_rec_in.chr_operating_unit_code := l_khr_attributes_csr_rec.hr_org_name;
1138 l_teh_rec_in.contract_status_code := l_khr_attributes_csr_rec.sts_code;
1139 IF l_accounting_event_class_code IN ( G_BOOKING, G_REBOOK, G_RE_LEASE )
1140 THEN
1141 l_teh_rec_in.contract_status_code := 'BOOKED';
1142 ELSIF l_accounting_event_class_code = G_TERMINATION AND
1143 l_tcn_basic_csr_rec.tcn_type = 'TMT'
1144 THEN
1145 -- Full Termination Transaction
1146 l_teh_rec_in.contract_status_code := 'TERMINATED';
1147 ELSIF l_accounting_event_class_code = G_EVERGREEN
1148 THEN
1149 l_teh_rec_in.contract_status_code := 'EVERGREEN';
1150 END IF;
1151 END LOOP; -- c_khr_attributes_csr
1152
1153 FOR tl_sources_in in l_tehl_tbl_in.FIRST .. l_tehl_tbl_in.LAST
1154 LOOP
1155 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
1156 'Executing the Cursor c_get_status_meaning_csr. p_sts_code=' ||
1157 l_khr_attributes_csr_rec.sts_code || 'p_led_lang= ' || l_tehl_tbl_in(tl_sources_in).language );
1158 FOR t_rec IN c_get_status_meaning_csr(
1159 p_sts_code => l_teh_rec_in.contract_status_code
1160 ,p_led_lang => l_tehl_tbl_in(tl_sources_in).language )
1161 LOOP
1162 l_get_status_meaning_rec := t_rec;
1163 l_tehl_tbl_in(tl_sources_in).contract_status := l_get_status_meaning_rec.status_meaning;
1164 END LOOP; -- End for c_get_status_meaning_csr
1165
1166 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
1167 'Executing the Cursor c_org_name_csr. p_org_id= ' || to_char(l_khr_attributes_csr_rec.authoring_org_id) ||
1168 ' ledger_language=' || l_tehl_tbl_in(tl_sources_in).language );
1169 FOR t_rec IN c_org_name_csr(
1170 p_org_id => l_khr_attributes_csr_rec.authoring_org_id
1171 ,p_ledger_lang => l_tehl_tbl_in(tl_sources_in).language )
1172 LOOP
1173 l_tehl_tbl_in(tl_sources_in).chr_operating_unit_name := t_rec.org_name;
1174 END LOOP;
1175 END LOOP;
1176
1177 IF l_accounting_event_class_code NOT IN ( G_BOOKING )
1178 THEN
1179 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
1180 'RENT: Executing the Cursor c_investor_agreement_main_csr l_khr_id = : ' || TO_CHAR(l_khr_id));
1181 FOR t_rec IN c_investor_agreement_main_csr(
1182 p_khr_id => l_khr_id
1183 ,p_sty_type => 'RENT')
1184 LOOP
1185 l_rent_ia_chr_id := t_rec.ia_chr_id;
1186 l_teh_rec_in.rent_ia_contract_number := t_rec.ia_contract_number;
1187 l_teh_rec_in.rent_ia_product_name := t_rec.ia_product_name;
1188 END LOOP; -- c_investor_agreement_main_csr
1189
1190 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
1191 'RESIDUAL VALUE: Executing the Cursor c_investor_agreement_main_csr l_khr_id = : ' || TO_CHAR(l_khr_id));
1192 FOR t_rec IN c_investor_agreement_main_csr(
1193 p_khr_id => l_khr_id
1194 ,p_sty_type => 'RESIDUAL VALUE')
1195 LOOP
1196 l_res_ia_chr_id := t_rec.ia_chr_id;
1197 l_teh_rec_in.res_ia_contract_number := t_rec.ia_contract_number;
1198 l_teh_rec_in.res_ia_product_name := t_rec.ia_product_name;
1199 END LOOP; -- c_investor_agreement_main_csr
1200 END IF; -- IF l_accounting_event_class_code NOT IN ( G_BOOKING )
1201
1202 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
1203 'Executing the Cursor c_kpl_attributes_csr l_khr_id = ' || TO_CHAR(l_khr_id) );
1204 FOR t_rec IN c_kpl_attributes_csr (l_khr_id)
1205 LOOP
1206 l_kpl_attributes_csr_rec := t_rec;
1207 l_teh_rec_in.cust_attribute_category := l_kpl_attributes_csr_rec.attribute_category;
1208 l_teh_rec_in.cust_attribute1 := l_kpl_attributes_csr_rec.attribute1;
1209 l_teh_rec_in.cust_attribute2 := l_kpl_attributes_csr_rec.attribute2;
1210 l_teh_rec_in.cust_attribute3 := l_kpl_attributes_csr_rec.attribute3;
1211 l_teh_rec_in.cust_attribute4 := l_kpl_attributes_csr_rec.attribute4;
1212 l_teh_rec_in.cust_attribute5 := l_kpl_attributes_csr_rec.attribute5;
1213 l_teh_rec_in.cust_attribute6 := l_kpl_attributes_csr_rec.attribute6;
1214 l_teh_rec_in.cust_attribute7 := l_kpl_attributes_csr_rec.attribute7;
1215 l_teh_rec_in.cust_attribute8 := l_kpl_attributes_csr_rec.attribute8;
1216 l_teh_rec_in.cust_attribute9 := l_kpl_attributes_csr_rec.attribute9;
1217 l_teh_rec_in.cust_attribute10 := l_kpl_attributes_csr_rec.attribute10;
1218 l_teh_rec_in.cust_attribute11 := l_kpl_attributes_csr_rec.attribute11;
1219 l_teh_rec_in.cust_attribute12 := l_kpl_attributes_csr_rec.attribute12;
1220 l_teh_rec_in.cust_attribute13 := l_kpl_attributes_csr_rec.attribute13;
1221 l_teh_rec_in.cust_attribute14 := l_kpl_attributes_csr_rec.attribute14;
1222 l_teh_rec_in.cust_attribute15 := l_kpl_attributes_csr_rec.attribute15;
1223 END LOOP; -- c_kpl_attributes_csr_attributes_csr_attributes_csr
1224
1225 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
1226 'Executing the Cursor c_vendor_program_number_csr p_khr_id = ' || TO_CHAR(l_khr_id) );
1227 FOR t_rec IN c_vendor_program_number_csr (p_khr_id => l_khr_id)
1228 LOOP
1229 l_teh_rec_in.vendor_program_number := t_rec.contract_number;
1230 END LOOP; -- c_vendor_program_number_csr
1231
1232 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
1233 'Executing the Cursor l_cust_name_account_csr. l_khr_id = ' || TO_CHAR(l_khr_id)
1234 || ' l_cust_acct_id = ' || TO_CHAR(l_cust_acct_id ) );
1235 FOR t_rec IN c_cust_name_account_csr (l_khr_id,l_cust_acct_id)
1236 LOOP
1237 l_cust_name_account_csr_rec := t_rec;
1238 l_teh_rec_in.customer_name := l_cust_name_account_csr_rec.party_name;
1239 l_teh_rec_in.customer_account_number := l_cust_name_account_csr_rec.account_number;
1240 -- added by zrehman Bug#6707320 for Party Merge Impact on Transaction Sources tables start
1241 l_teh_rec_in.cust_account_id := l_cust_acct_id;
1242 l_teh_rec_in.party_id := l_cust_name_account_csr_rec.party_id;
1243 -- added by zrehman Bug#6707320 for Party Merge Impact on Transaction Sources tables end
1244 END LOOP; -- c_cust_name_account_csr
1245
1246 IF l_accounting_event_class_code NOT IN ( G_BOOKING )
1247 THEN
1248 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
1249 'Executing the Cursor c_investor_agree_acc_code_csr. l_rent_ia_chr_id = '
1250 || TO_CHAR(l_rent_ia_chr_id) || ' l_res_ia_chr_id = ' || l_res_ia_chr_id);
1251 FOR t_rec in c_investor_agree_acc_code_csr (l_rent_ia_chr_id, l_res_ia_chr_id)
1252 LOOP
1253 l_inv_agree_acc_code_csr_rec := t_rec;
1254 l_teh_rec_in.rent_ia_accounting_code := l_inv_agree_acc_code_csr_rec.rent_ia_accounting_code;
1255 l_teh_rec_in.res_ia_accounting_code := l_inv_agree_acc_code_csr_rec.res_ia_accounting_code;
1256 END LOOP; -- c_investor_agree_acc_code_csr
1257 END IF; -- IF l_accounting_event_class_code NOT IN ( G_BOOKING )
1258
1259 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
1260 'Executing the Cursor c_rev_rec_int_calc_methods_csr. l_pdt_id = ' || TO_CHAR(l_pdt_id) );
1261 FOR t_rec IN c_rev_rec_int_calc_methods_csr(l_pdt_id)
1262 LOOP
1263 l_rev_rec_int_calc_mtd_csr_rec := t_rec;
1264 l_teh_rec_in.rev_rec_method_code := l_rev_rec_int_calc_mtd_csr_rec.rev_rec_method_code;
1265 l_teh_rec_in.int_calc_method_code := l_rev_rec_int_calc_mtd_csr_rec.int_calc_method_code;
1266 END LOOP;
1267
1268 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
1269 'Executing the Cursor c_creditline_master_lease_csr. l_khr_id = ' || TO_CHAR(l_khr_id) );
1270 FOR t_rec IN c_creditline_master_lease_csr (l_khr_id)
1271 LOOP
1272 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
1273 ' Line Type ' || t_rec.chr_type );
1274 IF t_rec.chr_type = 'CREDITLINE_CONTRACT'
1275 THEN
1276 l_teh_rec_in.credit_line_number := t_rec.credit_line_number;
1277 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
1278 'Credit Line Number ' || l_teh_rec_in.credit_line_number );
1279 END IF;
1280 IF t_rec.chr_type = 'MASTER_LEASE'
1281 THEN
1282 l_master_lease_id := t_rec.master_lease_id;
1283 l_teh_rec_in.master_lease_number := t_rec.master_lease_number;
1284 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
1285 'Master Lease Number ' || l_teh_rec_in.master_lease_number );
1286 END IF;
1287 END LOOP;
1288 IF (l_teh_rec_in.credit_line_number IS NULL AND
1289 l_master_lease_id IS NOT NULL)
1290 THEN
1291 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
1292 'Executing the Cursor c_creditline_sub_csr. l_master_lease_id = ' || TO_CHAR(l_master_lease_id) );
1293 FOR t_rec IN c_creditline_sub_csr (l_master_lease_id)
1294 LOOP
1295 l_creditline_sub_csr_rec := t_rec;
1296 l_teh_rec_in.credit_line_number := l_creditline_sub_csr_rec.contract_number;
1297 END LOOP;
1298 END IF;
1299 END IF; -- NOT LIKE G_INVESTOR
1300 --------------------------------------------------------------------------------
1301 -- Populating Sources specific to Event Classe(s)
1302 --------------------------------------------------------------------------------
1303 IF (l_accounting_event_class_code IN (G_TERMINATION, G_ASSET_DISPOSITION, G_SPLIT_ASSET))
1304 THEN
1305 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
1306 'Executing the Cursor c_termination_qte_csr. l_qte_id = ' || TO_CHAR(l_qte_id) );
1307 FOR t_rec IN c_termination_qte_csr (l_qte_id)
1308 LOOP
1309 l_termination_qte_csr_rec := t_rec;
1310 l_teh_rec_in.term_quote_accept_date := l_termination_qte_csr_rec.date_effective_from;
1311 l_teh_rec_in.term_quote_num := l_termination_qte_csr_rec.quote_number;
1312 l_teh_rec_in.term_quote_type_code := l_termination_qte_csr_rec.qtp_code;
1313 END LOOP; -- c_termination_qte_csr
1314 END IF; -- TERMINATION/ ASSET_DISPOSITION Specific.
1315
1316 IF l_accounting_event_class_code IN (G_ACCRUAL)
1317 THEN
1318 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
1319 'Executing the Cursor c_insurance_csr. l_khr_id = ' || TO_CHAR(l_khr_id) );
1320 FOR t_rec IN c_insurance_csr (l_khr_id)
1321 LOOP
1322 l_insurance_csr_rec := t_rec;
1323 l_teh_rec_in.ins_policy_type_code := l_insurance_csr_rec.ipe_code;
1324 l_teh_rec_in.ins_policy_number := l_insurance_csr_rec.policy_number;
1325 END LOOP; -- c_insurance_csr
1326 END IF; -- ACCRUAL SPECIFIC
1327
1328 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
1329 '** Sales Representative ID passed = ' || TO_CHAR(l_acc_sources_rec.jtf_sales_reps_pk) );
1330 IF ( l_accounting_event_class_code NOT IN
1331 (G_RECEIPT_APPLICATION, G_INVESTOR) ) AND
1332 l_acc_sources_rec.jtf_sales_reps_pk IS NOT NULL -- Account Generator Source should not be NULL
1333 THEN
1334 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
1335 'Executing the Cursor c_sales_rep_acc_sources_csr. l_sales_rep_id = ' || TO_CHAR(l_acc_sources_rec.jtf_sales_reps_pk) );
1336 FOR t_rec IN c_sales_rep_acc_sources_csr (p_jtf_sales_rep_pk => l_acc_sources_rec.jtf_sales_reps_pk)
1337 LOOP
1338 l_sales_rep_acc_sources_csr := t_rec;
1339 l_teh_rec_in.sales_rep_name := l_sales_rep_acc_sources_csr.name;
1340 END LOOP; -- c_sales_rep_acc_sources_csr
1341 END IF;
1342 --------------------------------------------------------------------------------
1343 -- Populating Investor Specfic Sources
1344 --------------------------------------------------------------------------------
1345 IF l_accounting_event_class_code IN (G_INVESTOR)
1346 THEN
1347 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
1348 ' POPULATING INVESTOR SPECIFIC Sources ' );
1349 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
1350 'Executing the Cursor c_inv_agrmnt_details_csr. l_khr_id = ' || TO_CHAR(l_khr_id) );
1351 FOR t_rec IN c_inv_agrmnt_details_csr( p_inv_agrmnt_id => l_khr_id )
1352 LOOP
1353 l_inv_agrmnt_details_rec := t_rec;
1354 l_teh_rec_in.inv_agrmnt_number := l_inv_agrmnt_details_rec.inv_agrmnt_number;
1355 l_teh_rec_in.inv_agrmnt_synd_code := l_inv_agrmnt_details_rec.inv_agrmnt_synd_code;
1356 l_teh_rec_in.inv_agrmnt_pool_number := l_inv_agrmnt_details_rec.inv_agrmnt_pool_number;
1357 l_teh_rec_in.inv_agrmnt_currency_code := l_inv_agrmnt_details_rec.inv_agrmnt_currency_code;
1358 l_teh_rec_in.inv_agrmnt_effective_from := l_inv_agrmnt_details_rec.inv_agrmnt_effective_from;
1359 -- Hard Code the Investor Agreement Status always to ACTIVE
1360 l_teh_rec_in.inv_agrmnt_status_code := 'ACTIVE';
1361
1362 FOR tl_sources_in in l_tehl_tbl_in.FIRST .. l_tehl_tbl_in.LAST
1363 LOOP
1364 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
1365 'INV_AGRMNT_STATUS: Executing the Cursor c_get_status_meaning_csr. p_sts_code=' ||
1366 l_inv_agrmnt_details_rec.inv_agrmnt_status_code || 'p_led_lang= ' || l_tehl_tbl_in(tl_sources_in).language );
1367 FOR t_meaning_rec IN c_get_status_meaning_csr(
1368 p_sts_code => l_inv_agrmnt_details_rec.inv_agrmnt_status_code
1369 ,p_led_lang => l_tehl_tbl_in(tl_sources_in).language )
1370 LOOP
1371 l_get_status_meaning_rec := t_meaning_rec;
1372 l_tehl_tbl_in(tl_sources_in).inv_agrmnt_status := l_get_status_meaning_rec.status_meaning;
1373 END LOOP; -- End for c_get_status_meaning_csr
1374 END LOOP;
1375 END LOOP; --
1376 END IF; -- G_INVESTOR SPECIFIC
1377 -- If Log is enabled, print all the sources fetched.
1378 IF (l_debug_enabled='Y' AND is_debug_statement_on)
1379 THEN
1380 write_ext_hdr_to_log(
1381 p_teh_rec => l_teh_rec_in
1382 ,p_tehl_tbl => l_tehl_tbl_in
1383 ,p_module => l_module);
1384 END IF;
1385 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
1386 'Calling OKL_TRX_EXTENSION_PVT.create_trx_extension API. ' || l_tehl_tbl_in.COUNT);
1387 okl_trx_extension_pvt.create_trx_extension(
1388 p_api_version => p_api_version
1389 ,p_init_msg_list => p_init_msg_list
1390 ,x_return_status => l_return_status
1391 ,x_msg_count => x_msg_count
1392 ,x_msg_data => x_msg_data
1393 ,p_teh_rec => l_teh_rec_in
1394 ,p_tehl_tbl => l_tehl_tbl_in
1395 ,x_teh_rec => l_teh_rec_out
1396 ,x_tehl_tbl => l_tehl_tbl_out
1397 );
1398 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
1399 'After execution of OKL_TRX_EXTENSION_PVT.create_trx_extension API. l_return_status ' || l_return_status);
1400 IF l_return_status = FND_API.G_RET_STS_ERROR
1401 THEN
1402 RAISE FND_API.G_EXC_ERROR;
1403 ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR
1404 THEN
1405 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1406 END IF;
1407 -- Returning back the record structure
1408 px_trans_hdr_rec.header_extension_id := l_teh_rec_out.header_extension_id;
1409 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
1410 'Calling okl_api.end_activity');
1411 okl_api.end_activity(
1412 x_msg_count => x_msg_count
1413 ,x_msg_data => x_msg_data);
1414 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
1415 'END OKL_SLA_ACC_SOURCES_PVT.POPULATE_TCN_SOURCES');
1416 x_return_status := OKL_API.G_RET_STS_SUCCESS;
1417 EXCEPTION
1418 ------------------------------------------------------------
1419 -- Exception handling
1420 ------------------------------------------------------------
1421 WHEN OKL_API.G_EXCEPTION_ERROR
1422 THEN
1423 IF c_tcn_basic_csr%ISOPEN THEN
1424 CLOSE c_tcn_basic_csr;
1425 END IF;
1426 IF c_khr_attributes_csr%ISOPEN THEN
1427 CLOSE c_khr_attributes_csr;
1428 END IF;
1429 IF c_kpl_attributes_csr%ISOPEN THEN
1430 CLOSE c_kpl_attributes_csr;
1431 END IF;
1432 IF c_termination_qte_csr%ISOPEN THEN
1433 CLOSE c_termination_qte_csr;
1434 END IF;
1435 IF c_cust_name_account_csr%ISOPEN THEN
1436 CLOSE c_cust_name_account_csr;
1437 END IF;
1438 IF c_insurance_csr%ISOPEN THEN
1439 CLOSE c_insurance_csr;
1440 END IF;
1441 IF c_sales_rep_acc_sources_csr%ISOPEN THEN
1442 CLOSE c_sales_rep_acc_sources_csr;
1443 END IF;
1444 IF c_creditline_master_lease_csr%ISOPEN THEN
1445 CLOSE c_creditline_master_lease_csr;
1446 END IF;
1447 IF c_creditline_sub_csr%ISOPEN THEN
1448 CLOSE c_creditline_sub_csr;
1449 END IF;
1450 IF c_vendor_program_number_csr%ISOPEN THEN
1451 CLOSE c_vendor_program_number_csr;
1452 END IF;
1453 IF c_investor_agreement_main_csr%ISOPEN THEN
1454 CLOSE c_investor_agreement_main_csr;
1455 END IF;
1456 IF c_investor_agree_acc_code_csr%ISOPEN THEN
1457 CLOSE c_investor_agree_acc_code_csr;
1458 END IF;
1459 IF c_rev_rec_int_calc_methods_csr%ISOPEN THEN
1460 CLOSE c_rev_rec_int_calc_methods_csr;
1461 END IF;
1462 x_return_status := OKL_API.HANDLE_EXCEPTIONS (
1463 p_api_name => l_api_name
1464 ,p_pkg_name => G_PKG_NAME
1465 ,p_exc_name => OKL_API.G_RET_STS_ERROR
1466 ,x_msg_count => x_msg_count
1467 ,x_msg_data => x_msg_data
1468 ,p_api_type => '_PVT');
1469 WHEN OKL_API.G_EXCEPTION_UNEXPECTED_ERROR
1470 THEN
1471 IF c_tcn_basic_csr%ISOPEN THEN
1472 CLOSE c_tcn_basic_csr;
1473 END IF;
1474 IF c_khr_attributes_csr%ISOPEN THEN
1475 CLOSE c_khr_attributes_csr;
1476 END IF;
1477 IF c_kpl_attributes_csr%ISOPEN THEN
1478 CLOSE c_kpl_attributes_csr;
1479 END IF;
1480 IF c_termination_qte_csr%ISOPEN THEN
1481 CLOSE c_termination_qte_csr;
1482 END IF;
1483 IF c_cust_name_account_csr%ISOPEN THEN
1484 CLOSE c_cust_name_account_csr;
1485 END IF;
1486 IF c_insurance_csr%ISOPEN THEN
1487 CLOSE c_insurance_csr;
1488 END IF;
1489 IF c_sales_rep_acc_sources_csr%ISOPEN THEN
1490 CLOSE c_sales_rep_acc_sources_csr;
1491 END IF;
1492 IF c_creditline_master_lease_csr%ISOPEN THEN
1493 CLOSE c_creditline_master_lease_csr;
1494 END IF;
1495 IF c_creditline_sub_csr%ISOPEN THEN
1496 CLOSE c_creditline_sub_csr;
1497 END IF;
1498 IF c_vendor_program_number_csr%ISOPEN THEN
1499 CLOSE c_vendor_program_number_csr;
1500 END IF;
1501 IF c_investor_agreement_main_csr%ISOPEN THEN
1502 CLOSE c_investor_agreement_main_csr;
1503 END IF;
1504 IF c_investor_agree_acc_code_csr%ISOPEN THEN
1505 CLOSE c_investor_agree_acc_code_csr;
1506 END IF;
1507 IF c_rev_rec_int_calc_methods_csr%ISOPEN THEN
1508 CLOSE c_rev_rec_int_calc_methods_csr;
1509 END IF;
1510 x_return_status := OKL_API.HANDLE_EXCEPTIONS (
1511 p_api_name => l_api_name
1512 ,p_pkg_name => G_PKG_NAME
1513 ,p_exc_name => OKL_API.G_RET_STS_UNEXP_ERROR
1514 ,x_msg_count => x_msg_count
1515 ,x_msg_data => x_msg_data
1516 ,p_api_type => '_PVT');
1517 WHEN OTHERS
1518 THEN
1519 IF c_tcn_basic_csr%ISOPEN THEN
1520 CLOSE c_tcn_basic_csr;
1521 END IF;
1522 IF c_khr_attributes_csr%ISOPEN THEN
1523 CLOSE c_khr_attributes_csr;
1524 END IF;
1525 IF c_kpl_attributes_csr%ISOPEN THEN
1526 CLOSE c_kpl_attributes_csr;
1527 END IF;
1528 IF c_termination_qte_csr%ISOPEN THEN
1529 CLOSE c_termination_qte_csr;
1530 END IF;
1531 IF c_cust_name_account_csr%ISOPEN THEN
1532 CLOSE c_cust_name_account_csr;
1533 END IF;
1534 IF c_insurance_csr%ISOPEN THEN
1535 CLOSE c_insurance_csr;
1536 END IF;
1537 IF c_sales_rep_acc_sources_csr%ISOPEN THEN
1538 CLOSE c_sales_rep_acc_sources_csr;
1539 END IF;
1540 IF c_creditline_master_lease_csr%ISOPEN THEN
1541 CLOSE c_creditline_master_lease_csr;
1542 END IF;
1543 IF c_creditline_sub_csr%ISOPEN THEN
1544 CLOSE c_creditline_sub_csr;
1545 END IF;
1546 IF c_vendor_program_number_csr%ISOPEN THEN
1547 CLOSE c_vendor_program_number_csr;
1548 END IF;
1549 IF c_investor_agreement_main_csr%ISOPEN THEN
1550 CLOSE c_investor_agreement_main_csr;
1551 END IF;
1552 IF c_investor_agree_acc_code_csr%ISOPEN THEN
1553 CLOSE c_investor_agree_acc_code_csr;
1554 END IF;
1555 IF c_rev_rec_int_calc_methods_csr%ISOPEN THEN
1556 CLOSE c_rev_rec_int_calc_methods_csr;
1557 END IF;
1558 x_return_status := OKL_API.HANDLE_EXCEPTIONS (
1559 p_api_name => l_api_name
1560 ,p_pkg_name => G_PKG_NAME
1561 ,p_exc_name => 'OTHERS'
1562 ,x_msg_count => x_msg_count
1563 ,x_msg_data => x_msg_data
1564 ,p_api_type => '_PVT');
1565 END populate_tcn_sources;
1566
1567 ---------------------------------------------------------------------------
1568 -- Start of comments
1569 -- API name : populate_tcl_sources
1570 -- Pre-reqs : None
1571 -- Function : Creates records for OKL_TXL_EXTENSION_V
1572 -- Parameters :
1573 -- IN : px_trans_line_rec.source_id IN NUMBER Required
1574 -- Corresponds to the column ID
1575 -- in the table OKL_TXL_CNTRCT_LNS.
1576 -- px_trans_line_rec.source_table IN VARCHAR2 Required
1577 -- Value G_TXL_CONTRACTS
1578 -- Version : 1.0
1579 -- History : Ravi Gooty created
1580 -- End of comments
1581 ---------------------------------------------------------------------------
1582 PROCEDURE populate_tcl_sources(
1583 p_api_version IN NUMBER
1584 ,p_init_msg_list IN VARCHAR2
1585 ,px_trans_line_rec IN OUT NOCOPY telv_rec_type
1586 ,p_acc_sources_rec IN asev_rec_type
1587 ,x_return_status OUT NOCOPY VARCHAR2
1588 ,x_msg_count OUT NOCOPY NUMBER
1589 ,x_msg_data OUT NOCOPY VARCHAR2
1590 )
1591 IS
1592 -----------------------------------------------------------------
1593 -- Declare Process Variable
1594 -----------------------------------------------------------------
1595 l_api_version CONSTANT NUMBER := 1;
1596 l_api_name CONSTANT VARCHAR2(30) := 'POPULATE_TCL_SOURCES';
1597 l_return_status VARCHAR2(1) := OKL_API.G_RET_STS_SUCCESS;
1598 ------------------------------------------------------------
1599 -- Declare records: Extension Headers, Extension Lines
1600 ------------------------------------------------------------
1601 l_tel_rec_in tel_rec_type;
1602 l_tel_rec_out tel_rec_type;
1603 l_tell_tbl_in tell_tbl_type;
1604 l_tell_tbl_out tell_tbl_type;
1605
1606 -- to fetch kle_id, event_class
1607 CURSOR c_tcl_basic_csr (p_source_id NUMBER)
1608 IS
1609 SELECT tcl.kle_id
1610 ,tcl.khr_id
1611 ,tcl.id
1612 ,tcl.bkt_id
1613 ,tcl.sty_id
1614 ,tcn.set_of_books_id ledger_id
1615 ,try.accounting_event_class_code
1616 FROM okl_txl_cntrct_lns_all tcl
1617 ,okl_trx_contracts_all tcn
1618 ,okl_trx_types_b try
1619 WHERE tcl.id = p_source_id
1620 AND tcl.tcn_id = tcn.id
1621 AND try.id = tcn.try_id
1622 AND try.accounting_event_class_code IS NOT NULL;
1623 l_tcl_basic_csr_rec c_tcl_basic_csr%ROWTYPE;
1624
1625 -- Record structures based on Cursor Definitions
1626 l_ledger_lang_rec c_ledger_lang_csr%ROWTYPE;
1627 l_k_lines_rec c_k_lines_csr%ROWTYPE;
1628 l_vendor_name_csr_rec c_vendor_name_csr%ROWTYPE;
1629 l_installed_site_csr_rec c_installed_site_csr%ROWTYPE;
1630 l_inventory_item_name_csr_rec c_inventory_item_name_csr%ROWTYPE;
1631 l_manufacture_model_csr_rec c_manufacture_model_csr%ROWTYPE;
1632 l_location_id_csr_rec c_location_id_csr%ROWTYPE;
1633 l_asset_location_name_csr_rec c_asset_location_name_csr%ROWTYPE;
1634 l_asset_year_mfg_csr_rec c_asset_year_manufactured_csr%ROWTYPE;
1635 l_aging_bucket_name_csr_rec c_aging_bucket_name_csr%ROWTYPE;
1636 l_cust_trx_type_csr_rec c_cust_trx_type_csr%ROWTYPE;
1637 l_acc_sources_rec asev_rec_type;
1638 -- Local Variables
1639 i NUMBER := 0;
1640 tl_sources_in NUMBER := 1;
1641 -- Local Variables for enabling the Debug Statements
1642 l_module CONSTANT fnd_log_messages.module%TYPE := G_MODULE || l_api_name;
1643 l_debug_enabled VARCHAR2(10);
1644 is_debug_procedure_on BOOLEAN;
1645 is_debug_statement_on BOOLEAN;
1646 BEGIN
1647 l_debug_enabled := okl_debug_pub.check_log_enabled;
1648 -- check for logging on PROCEDURE level
1649 is_debug_procedure_on := okl_debug_pub.check_log_on(l_module,FND_LOG.LEVEL_PROCEDURE);
1650 -- check for logging on STATEMENT level
1651 is_debug_statement_on := okl_debug_pub.check_log_on(l_module,FND_LOG.LEVEL_STATEMENT);
1652 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
1653 'begin debug OKLRSLAB.pls call ' || l_api_name);
1654 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
1655 'BEGIN API OKL_SLA_ACC_SOURCES_PVT.POPULATE_TCL_SOURCES');
1656 l_return_status := OKL_API.G_RET_STS_SUCCESS;
1657 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
1658 'Calling OKL_API.START_ACTIVITY');
1659 l_return_status := OKL_API.START_ACTIVITY(
1660 p_api_name => l_api_name
1661 ,p_pkg_name => g_pkg_name
1662 ,p_init_msg_list => p_init_msg_list
1663 ,l_api_version => l_api_version
1664 ,p_api_version => p_api_version
1665 ,p_api_type => '_PVT'
1666 ,x_return_status => l_return_status);
1667 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
1668 'After Start Activity l_return_status ' || l_return_status );
1669 IF (l_return_status = OKL_API.G_RET_STS_UNEXP_ERROR)
1670 THEN
1671 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
1672 ELSIF (l_return_status = OKL_API.G_RET_STS_ERROR)
1673 THEN
1674 RAISE OKL_API.G_EXCEPTION_ERROR;
1675 END IF;
1676 -- Copy the input parameters to the local variables and start using them.
1677 l_tel_rec_in.source_id := px_trans_line_rec.source_id;
1678 l_tel_rec_in.source_table := px_trans_line_rec.source_table;
1679 l_tel_rec_in.teh_id := px_trans_line_rec.teh_id;
1680 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
1681 ' Input Parameters : p_api_version=' || TO_CHAR(p_api_version) ||
1682 ' p_init_msg_list=' || p_init_msg_list || 'line_id=' || to_char(l_tel_rec_in.source_id) ||
1683 ' line_table='|| l_tel_rec_in.source_table);
1684
1685 IF l_tel_rec_in.source_table <> G_TXL_CONTRACTS
1686 THEN
1687 OKL_API.set_message(
1688 p_app_name => G_APP_NAME
1689 ,p_msg_name => G_INVALID_VALUE
1690 ,p_token1 => G_COL_NAME_TOKEN
1691 ,p_token1_value => 'LINE.SOURCE_TABLE');
1692 l_return_status := OKL_API.G_RET_STS_UNEXP_ERROR;
1693 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
1694 END IF;
1695
1696 -- Assign the AGS Record to the Local Record Structure
1697 l_acc_sources_rec := p_acc_sources_rec;
1698 -- Validation on the AGS Record
1699 IF l_acc_sources_rec.source_id IS NULL
1700 THEN
1701 OKL_API.set_message(
1702 p_app_name => G_APP_NAME
1703 ,p_msg_name => G_INVALID_VALUE
1704 ,p_token1 => G_COL_NAME_TOKEN
1705 ,p_token1_value => 'ACCT_SOURCES.SOURCE_ID');
1706 l_return_status := OKL_API.G_RET_STS_UNEXP_ERROR;
1707 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
1708 END IF;
1709
1710 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
1711 'Executing the Cursor c_tcl_basic_csr. p_source_id = ' || TO_CHAR(l_tel_rec_in.source_id) );
1712 OPEN c_tcl_basic_csr (l_tel_rec_in.source_id);
1713 FETCH c_tcl_basic_csr INTO l_tcl_basic_csr_rec;
1714 CLOSE c_tcl_basic_csr;
1715 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
1716 'Closed Cursor c_tcl_basic_csr' );
1717
1718 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
1719 'input parameter l_tel_rec_in.line_id='|| to_char(l_tel_rec_in.source_id) ||
1720 ' l_tcl_basic_csr_rec.khr_id='|| to_char(l_tcl_basic_csr_rec.khr_id) ||
1721 ' l_tcl_basic_csr_rec.kle_id='|| to_char(l_tcl_basic_csr_rec.kle_id) ||
1722 ' l_tcl_basic_csr_rec.accounting_event_class_code=' || l_tcl_basic_csr_rec.accounting_event_class_code ||
1723 ' l_tcl_basic_csr_rec.bkt_id=' || to_char(l_tcl_basic_csr_rec.bkt_id) ||
1724 ' l_tcl_basic_csr_rec.sty_id=' || to_char(l_tcl_basic_csr_rec.sty_id) ||
1725 ' l_tcl_basic_csr_rec.ledger_id=' || to_char(l_tcl_basic_csr_rec.ledger_id) );
1726
1727 IF l_tcl_basic_csr_rec.accounting_event_class_code IS NULL
1728 THEN
1729 -- accounting_event_class_code is missing
1730 OKL_API.set_message(
1731 p_app_name => G_APP_NAME
1732 ,p_msg_name => G_INVALID_VALUE
1733 ,p_token1 => G_COL_NAME_TOKEN
1734 ,p_token1_value => 'ACCOUNTING_EVENT_CLASS_CODE');
1735 l_return_status := OKL_API.G_RET_STS_UNEXP_ERROR;
1736 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
1737 END IF;
1738
1739 -- Store the Ledger Language so that its passed to the TAPI
1740 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
1741 'Picked Language | Ledger Language | USERENV Language p_ledger_id=' || TO_CHAR(l_tcl_basic_csr_rec.ledger_id));
1742 FOR t_rec IN c_ledger_lang_csr( p_ledger_id => l_tcl_basic_csr_rec.ledger_id )
1743 LOOP
1744 l_tell_tbl_in(tl_sources_in).language := t_rec.language_code;
1745 END LOOP;
1746
1747 IF l_tcl_basic_csr_rec.kle_id IS NOT NULL
1748 THEN
1749 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
1750 'Executing the curosr c_k_lines_csr. kle_id= ' || to_char(l_tcl_basic_csr_rec.kle_id) );
1751 FOR t_rec IN c_k_lines_csr (l_tcl_basic_csr_rec.kle_id)
1752 LOOP
1753 l_k_lines_rec := t_rec;
1754 l_tel_rec_in.contract_line_type := l_k_lines_rec.contract_line_type;
1755 IF l_tcl_basic_csr_rec.accounting_event_class_code IN
1756 ( G_TERMINATION, G_EVERGREEN, G_ACCRUAL, G_PRINCIPAL_ADJUSTMENT )
1757 THEN
1758 l_tel_rec_in.fee_type_code := l_k_lines_rec.fee_type;
1759 END IF;
1760 IF l_tcl_basic_csr_rec.accounting_event_class_code IN
1761 ( G_TERMINATION, G_EVERGREEN, G_ACCRUAL, G_PRINCIPAL_ADJUSTMENT,
1762 G_MISCELLANEOUS, G_ASSET_DISPOSITION, G_UPFRONT_TAX, G_SPLIT_ASSET )
1763 THEN
1764 l_tel_rec_in.asset_number := l_k_lines_rec.asset_number;
1765 END IF;
1766 IF l_tcl_basic_csr_rec.accounting_event_class_code IN
1767 (G_TERMINATION, G_EVERGREEN, G_ACCRUAL, G_ASSET_DISPOSITION, G_UPFRONT_TAX, G_SPLIT_ASSET)
1768 THEN
1769 l_tel_rec_in.contract_line_number := l_k_lines_rec.line_number;
1770 END IF;
1771 IF l_tcl_basic_csr_rec.accounting_event_class_code IN
1772 ( G_TERMINATION, G_EVERGREEN, G_ACCRUAL, G_RECEIPT_APPLICATION,
1773 G_PRINCIPAL_ADJUSTMENT, G_ASSET_DISPOSITION, G_UPFRONT_TAX, G_SPLIT_ASSET )
1774 THEN
1775 l_tel_rec_in.asset_delivered_date := l_k_lines_rec.date_delivery_expected;
1776 END IF;
1777 END LOOP; -- c_k_lines_csr
1778
1779 IF l_tcl_basic_csr_rec.accounting_event_class_code IN
1780 (G_TERMINATION, G_EVERGREEN, G_ACCRUAL, G_PRINCIPAL_ADJUSTMENT,
1781 G_MISCELLANEOUS, G_ASSET_DISPOSITION, G_UPFRONT_TAX, G_SPLIT_ASSET)
1782 THEN
1783 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
1784 'Executing the Cursor c_location_id_csr. kle_id= ' || to_char(l_tcl_basic_csr_rec.kle_id) ||
1785 ' khr_id=' || to_char(l_tcl_basic_csr_rec.khr_id) );
1786 OPEN c_location_id_csr(l_tcl_basic_csr_rec.kle_id,l_tcl_basic_csr_rec.khr_id );
1787 FETCH c_location_id_csr into l_location_id_csr_rec;
1788 CLOSE c_location_id_csr;
1789 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
1790 'Executing the Cursor l_vendor_name_csr_rec. kle_id= ' || to_char(l_tcl_basic_csr_rec.kle_id) ||
1791 ' khr_id=' || to_char(l_tcl_basic_csr_rec.khr_id) );
1792 FOR t_rec IN c_vendor_name_csr(
1793 l_tcl_basic_csr_rec.kle_id
1794 ,l_tcl_basic_csr_rec.khr_id)
1795 LOOP
1796 l_vendor_name_csr_rec := t_rec;
1797 l_tel_rec_in.asset_vendor_name := l_vendor_name_csr_rec.vendor_name;
1798 -- added by zrehman Bug#6707320 for Party Merge impact on transaction sources tables start
1799 l_tel_rec_in.asset_vendor_id := l_vendor_name_csr_rec.vendor_id;
1800 -- added by zrehman Bug#6707320 for Party Merge impact on transaction sources tables end
1801 END LOOP; -- c_vendor_name_csr
1802 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
1803 'Executing the Cursor c_asset_location_name_csr. location_id=' ||
1804 TO_CHAR(l_location_id_csr_rec.location_id) );
1805 FOR t_rec IN c_asset_location_name_csr(l_location_id_csr_rec.location_id)
1806 LOOP
1807 l_asset_location_name_csr_rec := t_rec;
1808 l_tel_rec_in.fixed_asset_location_name := l_asset_location_name_csr_rec.asset_location_name;
1809 END LOOP; -- c_asset_location_name_csr
1810 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
1811 'Executing the Cursor l_installed_site_csr_rec. kle_id= ' || to_char(l_tcl_basic_csr_rec.kle_id) ||
1812 ' khr_id=' || to_char(l_tcl_basic_csr_rec.khr_id) );
1813 FOR t_rec IN c_installed_site_csr(
1814 l_tcl_basic_csr_rec.kle_id
1815 ,l_tcl_basic_csr_rec.khr_id)
1816 LOOP
1817 l_installed_site_csr_rec := t_rec;
1818 l_tel_rec_in.installed_site_id := l_installed_site_csr_rec.installed_site_id;
1819 END LOOP; -- c_installed_site_csr
1820 END IF; -- accounting_event_class_code for 7 events
1821
1822 IF l_tcl_basic_csr_rec.accounting_event_class_code IN
1823 ( G_TERMINATION, G_EVERGREEN, G_ACCRUAL, G_RECEIPT_APPLICATION,
1824 G_PRINCIPAL_ADJUSTMENT, G_ASSET_DISPOSITION, G_UPFRONT_TAX, G_SPLIT_ASSET )
1825 THEN
1826 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
1827 'Executing the Cursor c_manufacture_model_csr. kle_id= ' || to_char(l_tcl_basic_csr_rec.kle_id) ||
1828 ' khr_id=' || to_char(l_tcl_basic_csr_rec.khr_id) );
1829 FOR t_rec IN c_manufacture_model_csr (
1830 l_tcl_basic_csr_rec.kle_id
1831 ,l_tcl_basic_csr_rec.khr_ID)
1832 LOOP
1833 l_manufacture_model_csr_rec := t_rec;
1834 IF l_tcl_basic_csr_rec.accounting_event_class_code NOT LIKE G_ACCRUAL
1835 THEN
1836 l_tel_rec_in.asset_manufacturer_name := l_manufacture_model_csr_rec.manufacturer_name;
1837 END IF;
1838 l_tel_rec_in.asset_model_number := l_manufacture_model_csr_rec.model_number;
1839 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
1840 'Executing the Cursor c_asset_year_manufactured_csr. kle_id= ' || to_char(l_tcl_basic_csr_rec.kle_id) ||
1841 ' khr_id=' || to_char(l_tcl_basic_csr_rec.khr_id) );
1842 FOR t_year_man_rec IN c_asset_year_manufactured_csr (
1843 l_tcl_basic_csr_rec.kle_id
1844 ,l_tcl_basic_csr_rec.khr_id)
1845 LOOP
1846 l_asset_year_mfg_csr_rec := t_year_man_rec;
1847 l_tel_rec_in.asset_year_manufactured := l_asset_year_mfg_csr_rec.Year_of_manufacture;
1848 END LOOP; -- c_asset_year_manufactured_csr
1849 IF l_tcl_basic_csr_rec.accounting_event_class_code NOT IN
1850 ( G_RECEIPT_APPLICATION, G_PRINCIPAL_ADJUSTMENT, G_ACCRUAL, G_MISCELLANEOUS )
1851 THEN
1852 l_tel_rec_in.asset_category_name := l_manufacture_model_csr_rec.asset_category_name;
1853 END IF;
1854 END LOOP; -- c_manufacture_model_csr
1855 END IF; -- accounting_event_class_code for 5 events
1856
1857 END IF; -- IF l_tcl_basic_csr_rec.kle_id IS NOT NULL
1858
1859 IF l_tcl_basic_csr_rec.accounting_event_class_code IN
1860 (G_BOOKING, G_REBOOK, G_RE_LEASE, G_ACCRUAL, G_MISCELLANEOUS)
1861 THEN
1862 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
1863 'Executing the Cursor c_cust_trx_type_csr rec_trx_types_pk=' || to_char(l_acc_sources_rec.rec_trx_types_pk) );
1864 FOR t_rec IN c_cust_trx_type_csr( p_trx_id => l_acc_sources_rec.rec_trx_types_pk )
1865 LOOP
1866 l_cust_trx_type_csr_rec := t_rec;
1867 l_tel_rec_in.recievables_trx_type_name :=l_cust_trx_type_csr_rec.trx_name;
1868 END LOOP;
1869 END IF; -- c_cust_trx_type_csr
1870
1871 IF l_tcl_basic_csr_rec.accounting_event_class_code IN (G_GLP)
1872 THEN
1873 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
1874 'Executing cursor c_aging_bucket_name_csr bkt_id=' || l_tcl_basic_csr_rec.bkt_id );
1875 FOR t_rec IN c_aging_bucket_name_csr(l_tcl_basic_csr_rec.bkt_id)
1876 LOOP
1877 l_aging_bucket_name_csr_rec := t_rec;
1878 l_tel_rec_in.aging_bucket_name :=l_aging_bucket_name_csr_rec.bucket_name;
1879 END LOOP; -- c_aging_bucket_name_csr
1880 END IF;
1881
1882 -- Populating MLS Sources at Transaction Line Level
1883 IF l_tcl_basic_csr_rec.accounting_event_class_code IN (G_ACCRUAL,G_ASSET_DISPOSITION, G_SPLIT_ASSET)
1884 THEN
1885 FOR tl_sources_in IN l_tell_tbl_in.FIRST .. l_tell_tbl_in.LAST
1886 LOOP
1887 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
1888 'Executing the Cursor c_inventory_item_name_csr. p_inventory_item_id_pk1= ' ||
1889 to_char(l_acc_sources_rec.inventory_item_id_pk1) || ' p_inventory_org_id_pk2=' ||
1890 to_char(l_acc_sources_rec.inventory_org_id_pk2) || ' ledger_language=' ||
1891 l_tell_tbl_in(tl_sources_in).language );
1892 FOR t_rec IN c_inventory_item_name_csr(
1893 p_inventory_item_id_pk1 => l_acc_sources_rec.inventory_item_id_pk1
1894 ,p_inventory_org_id_pk2 => l_acc_sources_rec.inventory_org_id_pk2
1895 ,p_ledger_language => l_tell_tbl_in(tl_sources_in).language)
1896 LOOP
1897 l_inventory_item_name_csr_rec := t_rec;
1898 l_tell_tbl_in(tl_sources_in).inventory_item_name := l_inventory_item_name_csr_rec.description;
1899 l_tel_rec_in.inventory_item_name_code := l_inventory_item_name_csr_rec.b_description;
1900 END LOOP;
1901 END LOOP;
1902 END IF; -- IF l_tcn_basic_csr_rec.accounting_event_class_code IN (G_ACCRUAL,G_ASSET_DISPOSITION, G_SPLIT_ASSET)
1903
1904 -- Populating Common MLS Sources at Transaction Line Level
1905 IF l_tcl_basic_csr_rec.accounting_event_class_code NOT IN (G_UPFRONT_TAX)
1906 THEN
1907 -- Populate Inventory Organization Name
1908 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
1909 '*** AGS Inventory Org ID used to fetch teh Inventory Organization Code : Org ID=' ||
1910 l_acc_sources_rec.inventory_org_id_pk2 );
1911 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
1912 'Executing the Cursor c_org_name_code_csr. p_org_id= ' || to_char(l_acc_sources_rec.inventory_org_id_pk2) );
1913 FOR t_rec IN c_org_name_code_csr(
1914 p_org_id => l_acc_sources_rec.inventory_org_id_pk2 )
1915 LOOP
1916 l_tel_rec_in.inventory_org_code := t_rec.org_name;
1917 END LOOP;
1918
1919 FOR tl_sources_in IN l_tell_tbl_in.FIRST .. l_tell_tbl_in.LAST
1920 LOOP
1921 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
1922 'Executing the Cursor c_org_name_csr. p_org_id= ' || to_char(l_acc_sources_rec.inventory_org_id_pk2) ||
1923 ' ledger_language=' || l_tell_tbl_in(tl_sources_in).language );
1924 FOR t_rec IN c_org_name_csr(
1925 p_org_id => l_acc_sources_rec.inventory_org_id_pk2
1926 ,p_ledger_lang => l_tell_tbl_in(tl_sources_in).language )
1927 LOOP
1928 l_tell_tbl_in(tl_sources_in).inventory_org_name := t_rec.org_name;
1929 END LOOP;
1930 END LOOP;
1931 END IF; -- IF l_tcl_basic_csr_rec.accounting_event_class_code IN (G_UPFRONT_TAX)
1932
1933 -- Assigning the Memo Indicator to the Extension Line Record structure ..
1934 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
1935 '** AGS Memo Flag ' || l_acc_sources_rec.memo_yn );
1936 l_tel_rec_in.memo_flag := l_acc_sources_rec.memo_yn;
1937
1938 -- If Log is enabled, print all the sources fetched.
1939 IF (l_debug_enabled='Y' AND is_debug_statement_on)
1940 THEN
1941 write_ext_line_to_log(
1942 p_tel_rec => l_tel_rec_in
1943 ,p_tell_tbl => l_tell_tbl_in
1944 ,p_module => l_module);
1945 END IF;
1946 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
1947 'Calling OKL_TRX_EXTENSION_PVT.create_txl_extension API.' );
1948
1949 okl_trx_extension_pvt.create_txl_extension(
1950 p_api_version => p_api_version
1951 ,p_init_msg_list => p_init_msg_list
1952 ,x_return_status => l_return_status
1953 ,x_msg_count => x_msg_count
1954 ,x_msg_data => x_msg_data
1955 ,p_tel_rec => l_tel_rec_in
1956 ,p_tell_tbl => l_tell_tbl_in
1957 ,x_tel_rec => l_tel_rec_out
1958 ,x_tell_tbl => l_tell_tbl_out
1959 );
1960 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
1961 'After okl_trx_extension_pvt.create_txl_extension. l_return_status ' || l_return_status );
1962 IF l_return_status = FND_API.G_RET_STS_ERROR
1963 THEN
1964 RAISE FND_API.G_EXC_ERROR;
1965 ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR
1966 THEN
1967 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1968 END IF;
1969 -- Return the values
1970 px_trans_line_rec.line_extension_id := l_tel_rec_out.line_extension_id;
1971 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
1972 'Calling okl_api.end_activity');
1973 okl_api.end_activity(
1974 x_msg_count => x_msg_count
1975 ,x_msg_data => x_msg_data);
1976 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
1977 'END OKL_SLA_ACC_SOURCES_PVT.POPULATE_TCL_SOURCES');
1978 x_return_status := OKL_API.G_RET_STS_SUCCESS;
1979 EXCEPTION
1980 ------------------------------------------------------------
1981 -- Exception handling
1982 ------------------------------------------------------------
1983 WHEN OKL_API.G_EXCEPTION_ERROR
1984 THEN
1985 IF c_tcl_basic_csr%ISOPEN THEN
1986 CLOSE c_tcl_basic_csr;
1987 END IF;
1988 IF c_k_lines_csr%ISOPEN THEN
1989 CLOSE c_k_lines_csr;
1990 END IF;
1991 IF c_vendor_name_csr%ISOPEN THEN
1992 CLOSE c_vendor_name_csr;
1993 END IF;
1994 IF c_manufacture_model_csr%ISOPEN THEN
1995 CLOSE c_manufacture_model_csr;
1996 END IF;
1997 IF c_location_id_csr%ISOPEN THEN
1998 CLOSE c_location_id_csr;
1999 END IF;
2000 IF c_asset_location_name_csr%ISOPEN THEN
2001 CLOSE c_asset_location_name_csr;
2002 END IF;
2003 IF c_asset_year_manufactured_csr%ISOPEN THEN
2004 CLOSE c_asset_year_manufactured_csr;
2005 END IF;
2006 IF c_installed_site_csr%ISOPEN THEN
2007 CLOSE c_installed_site_csr;
2008 END IF;
2009 IF c_aging_bucket_name_csr%ISOPEN THEN
2010 CLOSE c_aging_bucket_name_csr;
2011 END IF;
2012 IF c_cust_trx_type_csr%ISOPEN THEN
2013 CLOSE c_cust_trx_type_csr;
2014 END IF;
2015 IF c_inventory_item_name_csr%ISOPEN THEN
2016 CLOSE c_inventory_item_name_csr;
2017 END IF;
2018 x_return_status := OKL_API.HANDLE_EXCEPTIONS (
2019 p_api_name => l_api_name
2020 ,p_pkg_name => G_PKG_NAME
2021 ,p_exc_name => OKL_API.G_RET_STS_ERROR
2022 ,x_msg_count => x_msg_count
2023 ,x_msg_data => x_msg_data
2024 ,p_api_type => '_PVT');
2025
2026 WHEN OKL_API.G_EXCEPTION_UNEXPECTED_ERROR
2027 THEN
2028 IF c_tcl_basic_csr%ISOPEN THEN
2029 CLOSE c_tcl_basic_csr;
2030 END IF;
2031 IF c_k_lines_csr%ISOPEN THEN
2032 CLOSE c_k_lines_csr;
2033 END IF;
2034 IF c_vendor_name_csr%ISOPEN THEN
2035 CLOSE c_vendor_name_csr;
2036 END IF;
2037 IF c_manufacture_model_csr%ISOPEN THEN
2038 CLOSE c_manufacture_model_csr;
2039 END IF;
2040 IF c_location_id_csr%ISOPEN THEN
2041 CLOSE c_location_id_csr;
2042 END IF;
2043 IF c_asset_location_name_csr%ISOPEN THEN
2044 CLOSE c_asset_location_name_csr;
2045 END IF;
2046 IF c_asset_year_manufactured_csr%ISOPEN THEN
2047 CLOSE c_asset_year_manufactured_csr;
2048 END IF;
2049 IF c_installed_site_csr%ISOPEN THEN
2050 CLOSE c_installed_site_csr;
2051 END IF;
2052 IF c_aging_bucket_name_csr%ISOPEN THEN
2053 CLOSE c_aging_bucket_name_csr;
2054 END IF;
2055 IF c_cust_trx_type_csr%ISOPEN THEN
2056 CLOSE c_cust_trx_type_csr;
2057 END IF;
2058 IF c_inventory_item_name_csr%ISOPEN THEN
2059 CLOSE c_inventory_item_name_csr;
2060 END IF;
2061 x_return_status := OKL_API.HANDLE_EXCEPTIONS (
2062 p_api_name => l_api_name
2063 ,p_pkg_name => G_PKG_NAME
2064 ,p_exc_name => OKL_API.G_RET_STS_UNEXP_ERROR
2065 ,x_msg_count => x_msg_count
2066 ,x_msg_data => x_msg_data
2067 ,p_api_type => '_PVT');
2068 WHEN OTHERS
2069 THEN
2070 IF c_tcl_basic_csr%ISOPEN THEN
2071 CLOSE c_tcl_basic_csr;
2072 END IF;
2073 IF c_k_lines_csr%ISOPEN THEN
2074 CLOSE c_k_lines_csr;
2075 END IF;
2076 IF c_vendor_name_csr%ISOPEN THEN
2077 CLOSE c_vendor_name_csr;
2078 END IF;
2079 IF c_manufacture_model_csr%ISOPEN THEN
2080 CLOSE c_manufacture_model_csr;
2081 END IF;
2082 IF c_location_id_csr%ISOPEN THEN
2083 CLOSE c_location_id_csr;
2084 END IF;
2085 IF c_asset_location_name_csr%ISOPEN THEN
2086 CLOSE c_asset_location_name_csr;
2087 END IF;
2088 IF c_asset_year_manufactured_csr%ISOPEN THEN
2089 CLOSE c_asset_year_manufactured_csr;
2090 END IF;
2091 IF c_installed_site_csr%ISOPEN THEN
2092 CLOSE c_installed_site_csr;
2093 END IF;
2094 IF c_aging_bucket_name_csr%ISOPEN THEN
2095 CLOSE c_aging_bucket_name_csr;
2096 END IF;
2097 IF c_cust_trx_type_csr%ISOPEN THEN
2098 CLOSE c_cust_trx_type_csr;
2099 END IF;
2100 IF c_inventory_item_name_csr%ISOPEN THEN
2101 CLOSE c_inventory_item_name_csr;
2102 END IF;
2103 x_return_status := OKL_API.HANDLE_EXCEPTIONS (
2104 p_api_name => l_api_name
2105 ,p_pkg_name => G_PKG_NAME
2106 ,p_exc_name => 'OTHERS'
2107 ,x_msg_count => x_msg_count
2108 ,x_msg_data => x_msg_data
2109 ,p_api_type => '_PVT');
2110 END populate_tcl_sources;
2111
2112
2113 ---------------------------------------------------------------------------
2114 -- Start of comments
2115 -- API name : populate_tcl_sources
2116 -- Pre-reqs : None
2117 -- Function : Creates records for OKL_TXL_EXTENSION_V
2118 -- This API will be called by Populate Sources
2119 -- to do the bulk INSERTs of the Extension Line Sources
2120 -- Parameters :
2121 -- IN : p_trans_hdr_rec.source_id Required
2122 -- p_trans_hdr_rec.source_table Required.
2123 -- Value G_TXL_CONTRACTS
2124 -- Version : 1.0
2125 -- History : Ravi Gooty created
2126 -- End of comments
2127 ---------------------------------------------------------------------------
2128 PROCEDURE populate_tcl_sources(
2129 p_api_version IN NUMBER
2130 ,p_init_msg_list IN VARCHAR2
2131 ,p_trans_hdr_rec IN tehv_rec_type
2132 ,p_acc_sources_tbl IN asev_tbl_type
2133 ,p_trans_line_tbl IN telv_tbl_type
2134 ,x_trans_line_tbl OUT NOCOPY telv_tbl_type
2135 ,x_return_status OUT NOCOPY VARCHAR2
2136 ,x_msg_count OUT NOCOPY NUMBER
2137 ,x_msg_data OUT NOCOPY VARCHAR2
2138 )
2139 IS
2140 -----------------------------------------------------------------
2141 -- Declare Process Variable
2142 -----------------------------------------------------------------
2143 l_api_version CONSTANT NUMBER := 1;
2144 l_api_name CONSTANT VARCHAR2(30) := 'POPULATE_TCL_SOURCES';
2145 l_return_status VARCHAR2(1) := OKL_API.G_RET_STS_SUCCESS;
2146 ------------------------------------------------------------
2147 -- Declare records: Extension Headers, Extension Lines
2148 ------------------------------------------------------------
2149 l_tel_tbl_tbl tel_tbl_tbl_type;
2150 l_tel_tbl_tbl_out tel_tbl_tbl_type;
2151 l_tell_tbl_in tell_tbl_type;
2152 l_tell_tbl_in_base tell_tbl_type;
2153 l_tel_tbl_in tel_tbl_type;
2154 l_tel_tbl_out tel_tbl_type;
2155
2156 -- Performant Cursor to fetch all the Kle_ids in Order
2157 CURSOR c_tcl_tbl_csr (p_tcn_id NUMBER)
2158 IS
2159 SELECT tcl.khr_id khr_id
2160 ,tcl.kle_id kle_id
2161 ,tcl.sty_id sty_id
2162 ,tcl.bkt_id bkt_id
2163 ,tcl.id tcl_id
2164 FROM okl_txl_cntrct_lns_all tcl
2165 WHERE tcl.tcn_id = p_tcn_id
2166 ORDER BY kle_id, sty_id, bkt_id;
2167 l_prev_tcl_rec c_tcl_tbl_csr%ROWTYPE;
2168 l_curr_tcl_rec c_tcl_tbl_csr%ROWTYPE;
2169
2170 TYPE tcl_tbl_type IS TABLE OF c_tcl_tbl_csr%ROWTYPE INDEX BY BINARY_INTEGER; -- Added by PRASJAIN Bug#6134235
2171 l_tcl_tbl tcl_tbl_type; -- Added by PRASJAIN Bug#6134235
2172
2173 CURSOR c_tcn_basic_csr ( p_tcn_id NUMBER)
2174 IS
2175 SELECT tcn.id tcn_id
2176 ,tcn.khr_id khr_id
2177 ,tcn.set_of_books_id ledger_id
2178 ,try.accounting_event_class_code accounting_event_class_code
2179 FROM okl_trx_contracts_all tcn
2180 ,okl_trx_types_b try
2181 WHERE tcn.id = p_tcn_id
2182 AND tcn.try_id = try.id
2183 AND try.accounting_event_class_code IS NOT NULL;
2184 l_tcn_basic_csr_rec c_tcn_basic_csr%ROWTYPE;
2185
2186 -- Record structures based on Cursor Definitions
2187 l_ledger_lang_rec c_ledger_lang_csr%ROWTYPE;
2188 l_k_lines_rec c_k_lines_csr%ROWTYPE;
2189 l_vendor_name_csr_rec c_vendor_name_csr%ROWTYPE;
2190 l_installed_site_csr_rec c_installed_site_csr%ROWTYPE;
2191 l_inventory_item_name_csr_rec c_inventory_item_name_csr%ROWTYPE;
2192 l_inventory_org_name_rec c_org_name_csr%ROWTYPE;
2193 l_cust_trx_type_csr_rec c_cust_trx_type_csr%ROWTYPE;
2194 l_location_id_csr_rec c_location_id_csr%ROWTYPE;
2195 l_manufacture_model_csr_rec c_manufacture_model_csr%ROWTYPE;
2196 l_asset_year_mfg_csr_rec c_asset_year_manufactured_csr%ROWTYPE;
2197 l_asset_location_name_csr_rec c_asset_location_name_csr%ROWTYPE;
2198 l_aging_bucket_name_csr_rec c_aging_bucket_name_csr%ROWTYPE;
2199 l_inv_org_name_code_csr c_org_name_code_csr%ROWTYPE;
2200 l_acc_sources_tbl asev_tbl_type;
2201 l_acc_sources_rec asev_rec_type;
2202 l_acc_sources_found BOOLEAN;
2203 ags_index NUMBER;
2204 -- Local Variables
2205 tel_index NUMBER := 0;
2206 tcl_count NUMBER := 0;
2207 idx NUMBER := 0;
2208 idx1 NUMBER := 0;
2209 tl_sources_in NUMBER := 1;
2210 l_capture_sources VARCHAR2(3); -- Flag to decide whether to Capture Sources or Not !
2211 l_trans_line_tbl telv_tbl_type;
2212 l_fetch_sources BOOLEAN := FALSE;
2213
2214 -- Local Variables for enabling the Debug Statements
2215 l_module CONSTANT fnd_log_messages.module%TYPE := G_MODULE || l_api_name;
2216 l_debug_enabled VARCHAR2(10);
2217 is_debug_procedure_on BOOLEAN;
2218 is_debug_statement_on BOOLEAN;
2219 BEGIN
2220 l_debug_enabled := okl_debug_pub.check_log_enabled;
2221 -- check for logging on PROCEDURE level
2222 is_debug_procedure_on := okl_debug_pub.check_log_on(l_module,FND_LOG.LEVEL_PROCEDURE);
2223 -- check for logging on STATEMENT level
2224 is_debug_statement_on := okl_debug_pub.check_log_on(l_module,FND_LOG.LEVEL_STATEMENT);
2225 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
2226 'begin debug APOKLRSLAB.pls call ' || l_api_name);
2227 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
2228 'BEGIN API okl_sla_acc_sources_pvt.POPULATE_TCL_SOURCES');
2229 l_return_status := OKL_API.G_RET_STS_SUCCESS;
2230 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
2231 'Calling OKL_API.START_ACTIVITY');
2232 l_return_status := OKL_API.START_ACTIVITY(
2233 p_api_name => l_api_name
2234 ,p_pkg_name => g_pkg_name
2235 ,p_init_msg_list => p_init_msg_list
2236 ,l_api_version => l_api_version
2237 ,p_api_version => p_api_version
2238 ,p_api_type => '_PVT'
2239 ,x_return_status => l_return_status);
2240 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
2241 'After Start Activity l_return_status ' || l_return_status );
2242 IF (l_return_status = OKL_API.G_RET_STS_UNEXP_ERROR)
2243 THEN
2244 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
2245 ELSIF (l_return_status = OKL_API.G_RET_STS_ERROR)
2246 THEN
2247 RAISE OKL_API.G_EXCEPTION_ERROR;
2248 END IF;
2249
2250 IF p_trans_hdr_rec.source_table <> G_TRX_CONTRACTS
2251 THEN
2252 OKL_API.set_message(
2253 p_app_name => G_APP_NAME
2254 ,p_msg_name => G_INVALID_VALUE
2255 ,p_token1 => G_COL_NAME_TOKEN
2256 ,p_token1_value => 'HEADER.SOURCE_TABLE');
2257 l_return_status := OKL_API.G_RET_STS_UNEXP_ERROR;
2258 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
2259 END IF;
2260
2261 IF p_trans_hdr_rec.header_extension_id IS NULL
2262 THEN
2263 OKL_API.set_message(
2264 p_app_name => G_APP_NAME
2265 ,p_msg_name => G_INVALID_VALUE
2266 ,p_token1 => G_COL_NAME_TOKEN
2267 ,p_token1_value => 'HEADER.HEADER_EXTENSION_ID');
2268 l_return_status := OKL_API.G_RET_STS_UNEXP_ERROR;
2269 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
2270 END IF;
2271
2272 -- Assign the AGS Record to the Local Record Structure
2273 l_acc_sources_tbl := p_acc_sources_tbl;
2274 l_trans_line_tbl := p_trans_line_tbl;
2275 -- Validation: Check whether the AGS Table is passed properly or not ..
2276 IF l_acc_sources_tbl.COUNT <= 0
2277 THEN
2278 OKL_API.set_message(
2279 p_app_name => G_APP_NAME
2280 ,p_msg_name => G_INVALID_VALUE
2281 ,p_token1 => G_COL_NAME_TOKEN
2282 ,p_token1_value => 'ACCT_SOURCES.COUNT');
2283 l_return_status := OKL_API.G_RET_STS_UNEXP_ERROR;
2284 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
2285 END IF;
2286 -- Assign the l_acc_sources_rec as the first one of the l_acc_sources_tbl
2287 -- so that we can reuse the Inventory Organization ID
2288 l_acc_sources_rec := l_acc_sources_tbl( l_acc_sources_tbl.FIRST );
2289
2290 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
2291 'Executing the Cursor c_tcn_basic_csr, tcn_id = ' || TO_CHAR( p_trans_hdr_rec.source_id) );
2292 FOR t_rec IN c_tcn_basic_csr (p_tcn_id => p_trans_hdr_rec.source_id )
2293 LOOP
2294 l_tcn_basic_csr_rec := t_rec;
2295 END LOOP;
2296
2297 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
2298 ' l_tcn_basic_csr_rec.accounting_event_class_code=' || l_tcn_basic_csr_rec.accounting_event_class_code ||
2299 ' l_tcn_basic_csr_rec.ledger_id=' || to_char(l_tcn_basic_csr_rec.ledger_id) );
2300
2301 IF l_tcn_basic_csr_rec.accounting_event_class_code IS NULL
2302 THEN
2303 -- accounting_event_class_code is missing
2304 OKL_API.set_message(
2305 p_app_name => G_APP_NAME
2306 ,p_msg_name => G_INVALID_VALUE
2307 ,p_token1 => G_COL_NAME_TOKEN
2308 ,p_token1_value => 'ACCOUNTING_EVENT_CLASS_CODE');
2309 l_return_status := OKL_API.G_RET_STS_UNEXP_ERROR;
2310 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
2311 END IF;
2312
2313 -- Fetch the Ledger Language
2314 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
2315 'Picked Language | Ledger Language | USERENV Language p_ledger_id=' || TO_CHAR(l_tcn_basic_csr_rec.ledger_id));
2316 FOR t_rec IN c_ledger_lang_csr( p_ledger_id => l_tcn_basic_csr_rec.ledger_id )
2317 LOOP
2318 l_tell_tbl_in_base(tl_sources_in).language := t_rec.language_code;
2319 tl_sources_in := tl_sources_in + 1;
2320 END LOOP;
2321
2322 -- Fetching Common Sources
2323 -- Populating MLS Sources at Transaction Line Level
2324 -- Populate Inventory Organization Name
2325 IF l_tcn_basic_csr_rec.accounting_event_class_code NOT IN (G_UPFRONT_TAX)
2326 THEN
2327 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
2328 '*** AGS Inventory Org ID used to fetch teh Inventory Organization Name: Org ID=' ||
2329 l_acc_sources_rec.inventory_org_id_pk2 );
2330 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
2331 '*** AGS Inventory Org ID used to fetch teh Inventory Organization Code : Org ID=' ||
2332 l_acc_sources_rec.inventory_org_id_pk2 );
2333 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
2334 'Executing the Cursor c_org_name_code_csr. p_org_id= ' || to_char(l_acc_sources_rec.inventory_org_id_pk2) );
2335 FOR t_rec IN c_org_name_code_csr(
2336 p_org_id => l_acc_sources_rec.inventory_org_id_pk2 )
2337 LOOP
2338 l_inv_org_name_code_csr := t_rec;
2339 END LOOP;
2340
2341 FOR tl_sources_in IN l_tell_tbl_in_base.FIRST .. l_tell_tbl_in_base.LAST
2342 LOOP
2343 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
2344 'Executing the Cursor c_org_name_csr. p_org_id= ' || to_char(l_acc_sources_rec.inventory_org_id_pk2) ||
2345 ' ledger_language=' || l_tell_tbl_in_base(tl_sources_in).language );
2346 FOR t_rec IN c_org_name_csr(
2347 p_org_id => l_acc_sources_rec.inventory_org_id_pk2
2348 ,p_ledger_lang => l_tell_tbl_in_base(tl_sources_in).language )
2349 LOOP
2350 l_tell_tbl_in_base(tl_sources_in).inventory_org_name := t_rec.org_name;
2351 END LOOP;
2352 END LOOP;
2353 END IF;
2354
2355 -- Fetch all the Transaction Lines for the given Transaction Header
2356 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
2357 'Executing the Cursor c_tcl_tbl_csr, tcn_id = ' || TO_CHAR( p_trans_hdr_rec.source_id) );
2358 -- Initialize the tel_index
2359 tel_index := 1;
2360 -- Initialize the tcl_count to ZERO
2361 tcl_count := 0;
2362 -- Start PRASJAIN Bug#6134235
2363 FOR t_rec IN c_tcl_tbl_csr( p_tcn_id => p_trans_hdr_rec.source_id )
2364 LOOP
2365 tcl_count := tcl_count + 1;
2366 l_tcl_tbl(tcl_count) := t_rec;
2367 END LOOP;
2368 -- End PRASJAIN Bug#6134235
2369
2370 -- Start PRASJAIN Bug#6134235
2371 FOR idx IN l_tcl_tbl.FIRST .. l_tcl_tbl.LAST
2372 LOOP
2373 -- Logic Explanation:
2374 -- 1. Check for the Count of the Trx. Lines fetched from DB
2375 -- 2. Compare this count with the count of Trx. Lines passed to this API
2376 -- 3. If the count is same, then, capture sources for every Trx. Line
2377 -- otherwise, capture sources for only those transaction line, which have
2378 -- been passed by the Accounting Engine
2379 l_capture_sources := 'N';
2380 IF tcl_count = l_trans_line_tbl.COUNT
2381 THEN
2382 -- If count is same, then capture sources for every Transaction Detail Line
2383 l_capture_sources := 'Y';
2384 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
2385 'Case 1: Transaction Line Count in DB = Transaction Detail Line Count of the Input Param Table !' );
2386 ELSE
2387 idx1 := l_trans_line_tbl.FIRST;
2388 LOOP
2389 IF l_tcl_tbl(idx).tcl_id = l_trans_line_tbl(idx1).source_id
2390 THEN
2391 l_capture_sources := 'Y';
2392 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
2393 'Case 2: Populate Sources has been asked to capture sources for the Current Transaction Detail by Accounting Engine ' ||
2394 ' TCL ID = ' || TO_CHAR( l_trans_line_tbl(idx1).source_id ) );
2395 END IF;
2396 -- Exit when this is the Last Record or the Transaction Details has been found
2397 EXIT WHEN ( idx1 = l_trans_line_tbl.LAST ) -- When reached End of the Table
2398 OR ( l_capture_sources = 'Y' ); -- Or When the TXD has been found
2399 -- Increment the rxl_index
2400 idx1 := l_trans_line_tbl.NEXT( idx1 );
2401 END LOOP; -- Loop on l_trans_line_tbl ..
2402 END IF; -- IF tcl_count = l_trans_line_tbl.COUNT ..
2403
2404 IF (l_capture_sources = 'Y')
2405 THEN
2406 -- Store the iterative recrod to the Local variable
2407 l_curr_tcl_rec := l_tcl_tbl(idx);
2408 -- End PRASJAIN Bug#6134235
2409
2410 -- Fetch the Sources using the cursors only if
2411 -- If this the First Transaction Line (Or)
2412 -- The previous Transation Line kle_id is different than the Current Transaction Line
2413 l_fetch_sources := FALSE;
2414 IF tel_index = 1
2415 THEN
2416 l_fetch_sources := TRUE;
2417 ELSE
2418 IF l_curr_tcl_rec.kle_id <> l_prev_tcl_rec.kle_id
2419 THEN
2420 l_fetch_sources := TRUE;
2421 END IF;
2422 END IF;
2423
2424 IF l_fetch_sources
2425 THEN
2426 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
2427 '**** Need to fetch the Sources Afresh ****** ' ||
2428 'Current Kle_id = ' || l_curr_tcl_rec.kle_id || '| Previous Kle_id = ' || l_prev_tcl_rec.kle_id );
2429 ELSE
2430 -- Store Previously Fetched Transaction Related Sources to the Current Transaction Line
2431 -- l_tel_tbl_tbl(tel_index) := l_tel_tbl_tbl(tel_index - 1);
2432 l_tel_tbl_in(tel_index) := l_tel_tbl_in(tel_index - 1);
2433 END IF;
2434 -- For a given transaction Line fetch the corresponding Account Generator Sources
2435 -- Logic:
2436 -- Loop on the l_acc_sources_tbl till we find that
2437 -- l_acc_sources_tbl.source_id = l_curr_tcl_rec.tcl_id
2438 -- If the AGS record has been found assign it to l_acc_sources_rec
2439 -- else raise an exception.
2440 l_acc_sources_found := FALSE;
2441 l_acc_sources_rec := NULL;
2442 ags_index := l_acc_sources_tbl.FIRST;
2443 LOOP
2444 IF l_acc_sources_tbl(ags_index).source_id = l_curr_tcl_rec.tcl_id
2445 THEN
2446 l_acc_sources_found := TRUE;
2447 l_acc_sources_rec := l_acc_sources_tbl(ags_index);
2448 END IF;
2449 EXIT WHEN l_acc_sources_found OR ( ags_index = l_acc_sources_tbl.LAST );
2450 ags_index := l_acc_sources_tbl.NEXT(ags_index);
2451 END LOOP;
2452 -- If the AGS Index is not found then return error
2453 IF l_acc_sources_found = FALSE
2454 THEN
2455 -- accounting_event_class_code is missing
2456 OKL_API.set_message(
2457 p_app_name => G_APP_NAME
2458 ,p_msg_name => G_INVALID_VALUE
2459 ,p_token1 => G_COL_NAME_TOKEN
2460 ,p_token1_value => 'AGS_SOURCES.SOURCE_ID');
2461 l_return_status := OKL_API.G_RET_STS_UNEXP_ERROR;
2462 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
2463 END IF; -- IF l_acc_sources_found = FALSE
2464 -- Override the Source ID, Table and other related sources
2465 l_tel_tbl_in(tel_index).source_id := l_curr_tcl_rec.tcl_id;
2466 l_tel_tbl_in(tel_index).source_table := G_TXL_CONTRACTS;
2467 l_tel_tbl_in(tel_index).teh_id := p_trans_hdr_rec.header_extension_id;
2468
2469 l_tell_tbl_in := l_tell_tbl_in_base;
2470
2471 IF l_tcn_basic_csr_rec.accounting_event_class_code IN
2472 (G_BOOKING, G_REBOOK, G_RE_LEASE, G_ACCRUAL, G_MISCELLANEOUS)
2473 THEN
2474 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
2475 'Executing the Cursor c_cust_trx_type_csr rec_trx_types_pk=' || to_char(l_acc_sources_rec.rec_trx_types_pk) );
2476 FOR t_rec IN c_cust_trx_type_csr( p_trx_id => l_acc_sources_rec.rec_trx_types_pk )
2477 LOOP
2478 l_cust_trx_type_csr_rec := t_rec;
2479 l_tel_tbl_in(tel_index).recievables_trx_type_name :=l_cust_trx_type_csr_rec.trx_name;
2480 END LOOP; -- c_cust_trx_type_csr
2481 END IF;
2482
2483 -- Store the Inventory Organization Code
2484 l_tel_tbl_in(tel_index).inventory_org_code := l_inv_org_name_code_csr.org_name;
2485
2486 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
2487 ' l_curr_tcl_rec.tcl_id=' || to_char(l_curr_tcl_rec.tcl_id) ||
2488 ' l_curr_tcl_rec.khr_id=' || to_char(l_curr_tcl_rec.khr_id) ||
2489 ' l_curr_tcl_rec.kle_id=' || to_char(l_curr_tcl_rec.kle_id) ||
2490 ' l_curr_tcl_rec.bkt_id=' || to_char(l_curr_tcl_rec.bkt_id) ||
2491 ' l_curr_tcl_rec.sty_id=' || to_char(l_curr_tcl_rec.sty_id) );
2492
2493 -- If kle_id IS NOT NULL and l_fetch_sources is TRUE then ..
2494 IF l_fetch_sources AND
2495 l_curr_tcl_rec.kle_id IS NOT NULL
2496 THEN
2497 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
2498 'Executing the curosr c_k_lines_csr. kle_id= ' || to_char(l_curr_tcl_rec.kle_id) );
2499 FOR t_rec IN c_k_lines_csr (l_curr_tcl_rec.kle_id)
2500 LOOP
2501 l_k_lines_rec := t_rec;
2502 l_tel_tbl_in(tel_index).contract_line_type := l_k_lines_rec.contract_line_type;
2503 IF l_tcn_basic_csr_rec.accounting_event_class_code IN
2504 ( G_TERMINATION, G_EVERGREEN, G_ACCRUAL, G_PRINCIPAL_ADJUSTMENT )
2505 THEN
2506 l_tel_tbl_in(tel_index).fee_type_code := l_k_lines_rec.fee_type;
2507 END IF;
2508 IF l_tcn_basic_csr_rec.accounting_event_class_code IN
2509 ( G_TERMINATION, G_EVERGREEN, G_ACCRUAL, G_PRINCIPAL_ADJUSTMENT,
2510 G_MISCELLANEOUS, G_ASSET_DISPOSITION, G_UPFRONT_TAX, G_SPLIT_ASSET )
2511 THEN
2512 l_tel_tbl_in(tel_index).asset_number := l_k_lines_rec.asset_number;
2513 END IF;
2514 IF l_tcn_basic_csr_rec.accounting_event_class_code IN
2515 (G_TERMINATION, G_EVERGREEN, G_ACCRUAL, G_ASSET_DISPOSITION, G_UPFRONT_TAX, G_SPLIT_ASSET)
2516 THEN
2517 l_tel_tbl_in(tel_index).contract_line_number := l_k_lines_rec.line_number;
2518 END IF;
2519 IF l_tcn_basic_csr_rec.accounting_event_class_code IN
2520 ( G_TERMINATION, G_EVERGREEN, G_ACCRUAL, G_RECEIPT_APPLICATION,
2521 G_PRINCIPAL_ADJUSTMENT, G_ASSET_DISPOSITION, G_UPFRONT_TAX, G_SPLIT_ASSET )
2522 THEN
2523 l_tel_tbl_in(tel_index).asset_delivered_date := l_k_lines_rec.date_delivery_expected;
2524 END IF;
2525 END LOOP; -- c_k_lines_csr
2526
2527 IF l_tcn_basic_csr_rec.accounting_event_class_code IN
2528 (G_TERMINATION, G_EVERGREEN, G_ACCRUAL, G_PRINCIPAL_ADJUSTMENT,
2529 G_MISCELLANEOUS, G_ASSET_DISPOSITION, G_UPFRONT_TAX, G_SPLIT_ASSET)
2530 THEN
2531 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
2532 'Executing the Cursor c_location_id_csr. kle_id= ' || to_char(l_curr_tcl_rec.kle_id) ||
2533 ' khr_id=' || to_char(l_tcn_basic_csr_rec.khr_id) );
2534 OPEN c_location_id_csr(l_curr_tcl_rec.kle_id,l_tcn_basic_csr_rec.khr_id );
2535 FETCH c_location_id_csr into l_location_id_csr_rec;
2536 CLOSE c_location_id_csr;
2537 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
2538 'Executing the Cursor l_vendor_name_csr_rec. kle_id= ' || to_char(l_curr_tcl_rec.kle_id) ||
2539 ' khr_id=' || to_char(l_tcn_basic_csr_rec.khr_id) );
2540 FOR t_rec IN c_vendor_name_csr(
2541 l_curr_tcl_rec.kle_id
2542 ,l_tcn_basic_csr_rec.khr_id)
2543 LOOP
2544 l_vendor_name_csr_rec := t_rec;
2545 l_tel_tbl_in(tel_index).asset_vendor_name := l_vendor_name_csr_rec.vendor_name;
2546 -- added by zrehman Bug#6707320 for Party Merge impact on Accounting sources tables start
2547 l_tel_tbl_in(tel_index).asset_vendor_id := l_vendor_name_csr_rec.vendor_id;
2548 -- added by zrehman Bug#6707320 for Party Merge impact on Accounting sources tables end
2549 END LOOP; -- c_vendor_name_csr
2550 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
2551 'Executing the Cursor c_asset_location_name_csr. location_id=' ||
2552 TO_CHAR(l_location_id_csr_rec.location_id) );
2553 FOR t_rec IN c_asset_location_name_csr(l_location_id_csr_rec.location_id)
2554 LOOP
2555 l_asset_location_name_csr_rec := t_rec;
2556 l_tel_tbl_in(tel_index).fixed_asset_location_name := l_asset_location_name_csr_rec.asset_location_name;
2557 END LOOP; -- c_asset_location_name_csr
2558 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
2559 'Executing the Cursor l_installed_site_csr_rec. kle_id= ' || to_char(l_curr_tcl_rec.kle_id) ||
2560 ' khr_id=' || to_char(l_tcn_basic_csr_rec.khr_id) );
2561 FOR t_rec IN c_installed_site_csr(
2562 l_curr_tcl_rec.kle_id
2563 ,l_tcn_basic_csr_rec.khr_id)
2564 LOOP
2565 l_installed_site_csr_rec := t_rec;
2566 l_tel_tbl_in(tel_index).installed_site_id := l_installed_site_csr_rec.installed_site_id;
2567 END LOOP; -- c_installed_site_csr
2568 END IF; -- accounting_event_class_code for 7 events
2569
2570 IF l_tcn_basic_csr_rec.accounting_event_class_code IN
2571 ( G_TERMINATION, G_EVERGREEN, G_ACCRUAL, G_RECEIPT_APPLICATION,
2572 G_PRINCIPAL_ADJUSTMENT, G_ASSET_DISPOSITION, G_UPFRONT_TAX, G_SPLIT_ASSET )
2573 THEN
2574 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
2575 'Executing the Cursor c_manufacture_model_csr. kle_id= ' || to_char(l_curr_tcl_rec.kle_id) ||
2576 ' khr_id=' || to_char(l_tcn_basic_csr_rec.khr_id) );
2577 FOR t_rec IN c_manufacture_model_csr (
2578 l_curr_tcl_rec.kle_id
2579 ,l_tcn_basic_csr_rec.khr_ID)
2580 LOOP
2581 l_manufacture_model_csr_rec := t_rec;
2582 IF l_tcn_basic_csr_rec.accounting_event_class_code NOT LIKE G_ACCRUAL
2583 THEN
2584 l_tel_tbl_in(tel_index).asset_manufacturer_name := l_manufacture_model_csr_rec.manufacturer_name;
2585 END IF;
2586 l_tel_tbl_in(tel_index).asset_model_number := l_manufacture_model_csr_rec.model_number;
2587 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
2588 'Executing the Cursor c_asset_year_manufactured_csr. kle_id= ' || to_char(l_curr_tcl_rec.kle_id) ||
2589 ' khr_id=' || to_char(l_tcn_basic_csr_rec.khr_id) );
2590 FOR t_year_man_rec IN c_asset_year_manufactured_csr (
2591 l_curr_tcl_rec.kle_id
2592 ,l_tcn_basic_csr_rec.khr_id)
2593 LOOP
2594 l_asset_year_mfg_csr_rec := t_year_man_rec;
2595 l_tel_tbl_in(tel_index).asset_year_manufactured := l_asset_year_mfg_csr_rec.Year_of_manufacture;
2596 END LOOP; -- c_asset_year_manufactured_csr
2597 IF l_tcn_basic_csr_rec.accounting_event_class_code NOT IN
2598 ( G_RECEIPT_APPLICATION, G_PRINCIPAL_ADJUSTMENT, G_ACCRUAL, G_MISCELLANEOUS )
2599 THEN
2600 l_tel_tbl_in(tel_index).asset_category_name := l_manufacture_model_csr_rec.asset_category_name;
2601 END IF;
2602 END LOOP; -- c_manufacture_model_csr
2603 END IF; -- accounting_event_class_code for 5 events
2604 END IF; -- IF l_tcn_basic_csr_rec.kle_id IS NOT NULL
2605
2606 IF l_tcn_basic_csr_rec.accounting_event_class_code IN (G_ACCRUAL,G_ASSET_DISPOSITION, G_SPLIT_ASSET)
2607 THEN
2608 FOR tl_sources_in IN l_tell_tbl_in.FIRST .. l_tell_tbl_in.LAST
2609 LOOP
2610 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
2611 'Executing the Cursor c_asset_year_manufactured_csr. p_inventory_item_id_pk1= ' ||
2612 to_char(l_acc_sources_rec.inventory_item_id_pk1) || ' p_inventory_org_id_pk2=' ||
2613 to_char(l_acc_sources_rec.inventory_org_id_pk2) || ' ledger_language=' ||
2614 l_tell_tbl_in(tl_sources_in).language );
2615 FOR t_rec IN c_inventory_item_name_csr(
2616 p_inventory_item_id_pk1 => l_acc_sources_rec.inventory_item_id_pk1
2617 ,p_inventory_org_id_pk2 => l_acc_sources_rec.inventory_org_id_pk2
2618 ,p_ledger_language => l_tell_tbl_in(tl_sources_in).language)
2619 LOOP
2620 l_inventory_item_name_csr_rec := t_rec;
2621 l_tell_tbl_in(tl_sources_in).inventory_item_name := l_inventory_item_name_csr_rec.description;
2622 l_tel_tbl_in(tel_index).inventory_item_name_code := l_inventory_item_name_csr_rec.b_description;
2623 END LOOP;
2624 END LOOP;
2625 END IF; -- IF l_tcn_basic_csr_rec.accounting_event_class_code IN (G_ACCRUAL,G_ASSET_DISPOSITION, G_SPLIT_ASSET)
2626
2627 IF l_tcn_basic_csr_rec.accounting_event_class_code IN (G_GLP)
2628 THEN
2629 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
2630 'Executing cursor c_aging_bucket_name_csr bkt_id=' || l_curr_tcl_rec.bkt_id );
2631 FOR t_rec IN c_aging_bucket_name_csr(l_curr_tcl_rec.bkt_id)
2632 LOOP
2633 l_aging_bucket_name_csr_rec := t_rec;
2634 l_tel_tbl_in(tel_index).aging_bucket_name :=l_aging_bucket_name_csr_rec.bucket_name;
2635 END LOOP; -- c_aging_bucket_name_csr
2636 END IF;
2637
2638 -- Assigning the Memo Indicator to the Extension Line Record structure ..
2639 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
2640 '** AGS Memo Flag ' || l_acc_sources_rec.memo_yn );
2641 l_tel_tbl_in(tel_index).memo_flag := l_acc_sources_rec.memo_yn;
2642
2643 -- If Log is enabled, print all the sources fetched.
2644 IF (l_debug_enabled='Y' AND is_debug_statement_on)
2645 THEN
2646 write_ext_line_to_log(
2647 p_tel_rec => l_tel_tbl_in(tel_index)
2648 ,p_tell_tbl => l_tell_tbl_in
2649 ,p_module => l_module);
2650 END IF;
2651
2652 -- Store khr_id, kle_id, sty_id, bkt_id of the current transaction line.
2653 -- This recrod will be used during comparision from next iteration onwards
2654 l_prev_tcl_rec := l_tcl_tbl(idx);
2655 -- Build the record strucutre now ..
2656 l_tel_tbl_tbl(tel_index).tel_rec := l_tel_tbl_in(tel_index);
2657 l_tel_tbl_tbl(tel_index).tell_tbl := l_tell_tbl_in; -- Translatable Table capturing sources
2658 -- Increment the tel_index
2659 tel_index := tel_index + 1;
2660 END IF;
2661 END LOOP;
2662
2663
2664 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
2665 'Calling OKL_TRX_EXTENSION_PVT.create_txl_extension API.' );
2666
2667 okl_trx_extension_pvt.create_txl_extension(
2668 p_api_version => p_api_version
2669 ,p_init_msg_list => p_init_msg_list
2670 ,x_return_status => l_return_status
2671 ,x_msg_count => x_msg_count
2672 ,x_msg_data => x_msg_data
2673 ,p_tel_tbl_tbl => l_tel_tbl_tbl
2674 ,x_tel_tbl_tbl => l_tel_tbl_tbl_out
2675 );
2676 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
2677 'After okl_trx_extension_pvt.create_txl_extension-tbl. l_return_status ' || l_return_status );
2678 IF l_return_status = FND_API.G_RET_STS_ERROR
2679 THEN
2680 RAISE FND_API.G_EXC_ERROR;
2681 ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR
2682 THEN
2683 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2684 END IF;
2685
2686 -- Return the values
2687 x_trans_line_tbl := p_trans_line_tbl; --Added PRASJAIN Bug#6134235
2688 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
2689 'Calling okl_api.end_activity');
2690 okl_api.end_activity(
2691 x_msg_count => x_msg_count
2692 ,x_msg_data => x_msg_data);
2693 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
2694 'END okl_sla_acc_sources_pvt.POPULATE_TCL_SOURCES');
2695 x_return_status := OKL_API.G_RET_STS_SUCCESS;
2696 EXCEPTION
2697 ------------------------------------------------------------
2698 -- Exception handling
2699 ------------------------------------------------------------
2700 WHEN OKL_API.G_EXCEPTION_ERROR
2701 THEN
2702 IF c_tcl_tbl_csr%ISOPEN THEN
2703 CLOSE c_tcl_tbl_csr;
2704 END IF;
2705 IF c_k_lines_csr%ISOPEN THEN
2706 CLOSE c_k_lines_csr;
2707 END IF;
2708 IF c_vendor_name_csr%ISOPEN THEN
2709 CLOSE c_vendor_name_csr;
2710 END IF;
2711 IF c_manufacture_model_csr%ISOPEN THEN
2712 CLOSE c_manufacture_model_csr;
2713 END IF;
2714 IF c_location_id_csr%ISOPEN THEN
2715 CLOSE c_location_id_csr;
2716 END IF;
2717 IF c_asset_location_name_csr%ISOPEN THEN
2718 CLOSE c_asset_location_name_csr;
2719 END IF;
2720 IF c_asset_year_manufactured_csr%ISOPEN THEN
2721 CLOSE c_asset_year_manufactured_csr;
2722 END IF;
2723 IF c_installed_site_csr%ISOPEN THEN
2724 CLOSE c_installed_site_csr;
2725 END IF;
2726 IF c_aging_bucket_name_csr%ISOPEN THEN
2727 CLOSE c_aging_bucket_name_csr;
2728 END IF;
2729 IF c_cust_trx_type_csr%ISOPEN THEN
2730 CLOSE c_cust_trx_type_csr;
2731 END IF;
2732 IF c_inventory_item_name_csr%ISOPEN THEN
2733 CLOSE c_inventory_item_name_csr;
2734 END IF;
2735 x_return_status := OKL_API.HANDLE_EXCEPTIONS (
2736 p_api_name => l_api_name
2737 ,p_pkg_name => G_PKG_NAME
2738 ,p_exc_name => OKL_API.G_RET_STS_ERROR
2739 ,x_msg_count => x_msg_count
2740 ,x_msg_data => x_msg_data
2741 ,p_api_type => '_PVT');
2742
2743 WHEN OKL_API.G_EXCEPTION_UNEXPECTED_ERROR
2744 THEN
2745 IF c_tcl_tbl_csr%ISOPEN THEN
2746 CLOSE c_tcl_tbl_csr;
2747 END IF;
2748 IF c_k_lines_csr%ISOPEN THEN
2749 CLOSE c_k_lines_csr;
2750 END IF;
2751 IF c_vendor_name_csr%ISOPEN THEN
2752 CLOSE c_vendor_name_csr;
2753 END IF;
2754 IF c_manufacture_model_csr%ISOPEN THEN
2755 CLOSE c_manufacture_model_csr;
2756 END IF;
2757 IF c_location_id_csr%ISOPEN THEN
2758 CLOSE c_location_id_csr;
2759 END IF;
2760 IF c_asset_location_name_csr%ISOPEN THEN
2761 CLOSE c_asset_location_name_csr;
2762 END IF;
2763 IF c_asset_year_manufactured_csr%ISOPEN THEN
2764 CLOSE c_asset_year_manufactured_csr;
2765 END IF;
2766 IF c_installed_site_csr%ISOPEN THEN
2767 CLOSE c_installed_site_csr;
2768 END IF;
2769 IF c_aging_bucket_name_csr%ISOPEN THEN
2770 CLOSE c_aging_bucket_name_csr;
2771 END IF;
2772 IF c_cust_trx_type_csr%ISOPEN THEN
2773 CLOSE c_cust_trx_type_csr;
2774 END IF;
2775 IF c_inventory_item_name_csr%ISOPEN THEN
2776 CLOSE c_inventory_item_name_csr;
2777 END IF;
2778 x_return_status := OKL_API.HANDLE_EXCEPTIONS (
2779 p_api_name => l_api_name
2780 ,p_pkg_name => G_PKG_NAME
2781 ,p_exc_name => OKL_API.G_RET_STS_UNEXP_ERROR
2782 ,x_msg_count => x_msg_count
2783 ,x_msg_data => x_msg_data
2784 ,p_api_type => '_PVT');
2785 WHEN OTHERS
2786 THEN
2787 IF c_tcl_tbl_csr%ISOPEN THEN
2788 CLOSE c_tcl_tbl_csr;
2789 END IF;
2790 IF c_k_lines_csr%ISOPEN THEN
2791 CLOSE c_k_lines_csr;
2792 END IF;
2793 IF c_vendor_name_csr%ISOPEN THEN
2794 CLOSE c_vendor_name_csr;
2795 END IF;
2796 IF c_manufacture_model_csr%ISOPEN THEN
2797 CLOSE c_manufacture_model_csr;
2798 END IF;
2799 IF c_location_id_csr%ISOPEN THEN
2800 CLOSE c_location_id_csr;
2801 END IF;
2802 IF c_asset_location_name_csr%ISOPEN THEN
2803 CLOSE c_asset_location_name_csr;
2804 END IF;
2805 IF c_asset_year_manufactured_csr%ISOPEN THEN
2806 CLOSE c_asset_year_manufactured_csr;
2807 END IF;
2808 IF c_installed_site_csr%ISOPEN THEN
2809 CLOSE c_installed_site_csr;
2810 END IF;
2811 IF c_aging_bucket_name_csr%ISOPEN THEN
2812 CLOSE c_aging_bucket_name_csr;
2813 END IF;
2814 IF c_cust_trx_type_csr%ISOPEN THEN
2815 CLOSE c_cust_trx_type_csr;
2816 END IF;
2817 IF c_inventory_item_name_csr%ISOPEN THEN
2818 CLOSE c_inventory_item_name_csr;
2819 END IF;
2820 x_return_status := OKL_API.HANDLE_EXCEPTIONS (
2821 p_api_name => l_api_name
2822 ,p_pkg_name => G_PKG_NAME
2823 ,p_exc_name => 'OTHERS'
2824 ,x_msg_count => x_msg_count
2825 ,x_msg_data => x_msg_data
2826 ,p_api_type => '_PVT');
2827 END populate_tcl_sources;
2828
2829 ---------------------------------------------------------------------------
2830 -- Start of comments
2831 -- API name : populate_sources
2832 -- Pre-reqs : None
2833 -- Function : Use this API to populate sources at the Transaction Header
2834 -- level and at the Transaction Line level too.
2835 -- Parameters :
2836 -- IN : p_source_id IN NUMBER Required
2837 -- Pass Transaction Header id.
2838 -- p_source_hdr_table IN VARCHAR2 Required
2839 -- Pass the table name of the Transaction Header.
2840 -- Eg. OKL_TRX_CONTRACTS, OKL_TRX_ASSETS ..
2841 -- p_trans_line_tbl trans_line_tbl_type Required.
2842 -- source_line_id NUMBER Required
2843 -- Pass the Transaction Line id
2844 -- source_line_table VARCHAR2(30) Required
2845 -- Pass the table name of the Transaction Table.
2846 -- Eg. OKL_TXL_CNTRCT_LNS ..
2847 -- Version : 1.0
2848 -- History : Ravindranath Gooty created
2849 -- End of comments
2850 ---------------------------------------------------------------------------
2851 PROCEDURE populate_sources(
2852 p_api_version IN NUMBER
2853 ,p_init_msg_list IN VARCHAR2
2854 ,p_trans_hdr_rec IN tehv_rec_type
2855 ,p_trans_line_tbl IN telv_tbl_type
2856 ,p_acc_sources_tbl IN asev_tbl_type
2857 ,x_return_status OUT NOCOPY VARCHAR2
2858 ,x_msg_count OUT NOCOPY NUMBER
2859 ,x_msg_data OUT NOCOPY VARCHAR2
2860 )
2861 IS
2862 -----------------------------------------------------------------
2863 -- Declare Process Variable
2864 -----------------------------------------------------------------
2865 l_api_version CONSTANT NUMBER := 1;
2866 l_api_name CONSTANT VARCHAR2(30) := 'POPULATE_SOURCES-OKL';
2867 l_return_status VARCHAR2(1) := OKL_API.G_RET_STS_SUCCESS;
2868 -- Local Variables for enabling the Debug Statements
2869 l_trans_hdr_rec tehv_rec_type;
2870 l_acc_sources_tbl asev_tbl_type;
2871 l_trans_line_tbl telv_tbl_type; -- Added by PRASJAIN Bug#6134235
2872 x_trans_line_tbl telv_tbl_type; -- Added by PRASJAIN Bug#6134235
2873
2874 l_module CONSTANT fnd_log_messages.module%TYPE := G_MODULE || l_api_name;
2875 l_debug_enabled VARCHAR2(10);
2876 is_debug_procedure_on BOOLEAN;
2877 is_debug_statement_on BOOLEAN;
2878 BEGIN
2879 l_debug_enabled := okl_debug_pub.check_log_enabled;
2880 -- check for logging on PROCEDURE level
2881 is_debug_procedure_on := okl_debug_pub.check_log_on(l_module,FND_LOG.LEVEL_PROCEDURE);
2882 -- check for logging on STATEMENT level
2883 is_debug_statement_on := okl_debug_pub.check_log_on(l_module,FND_LOG.LEVEL_STATEMENT);
2884 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
2885 'begin debug APOKLRSLAB.pls call ' || l_api_name);
2886 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
2887 'BEGIN API okl_sla_acc_sources_pvt.POPULATE_SOURCES');
2888 l_return_status := OKL_API.G_RET_STS_SUCCESS;
2889 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
2890 'Calling OKL_API.START_ACTIVITY');
2891 l_return_status := OKL_API.START_ACTIVITY(
2892 p_api_name => l_api_name
2893 ,p_pkg_name => g_pkg_name
2894 ,p_init_msg_list => p_init_msg_list
2895 ,l_api_version => l_api_version
2896 ,p_api_version => p_api_version
2897 ,p_api_type => '_PVT'
2898 ,x_return_status => l_return_status);
2899 IF (l_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
2900 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
2901 ELSIF (l_return_status = OKL_API.G_RET_STS_ERROR) THEN
2902 RAISE OKL_API.G_EXCEPTION_ERROR;
2903 END IF;
2904 -- Copy the input parameters to the local variables
2905 l_trans_hdr_rec := p_trans_hdr_rec;
2906 l_acc_sources_tbl := p_acc_sources_tbl;
2907 l_trans_line_tbl := p_trans_line_tbl; -- Added by PRASJAIN Bug#6134235
2908 IF l_acc_sources_tbl.COUNT <= 0
2909 THEN
2910 -- Raise an error message saying that the Sources should be passed !
2911 OKL_API.set_message(
2912 p_app_name => G_APP_NAME
2913 ,p_msg_name => G_INVALID_VALUE
2914 ,p_token1 => G_COL_NAME_TOKEN
2915 ,p_token1_value => 'P_ACC_SOURCES_TBL.COUNT');
2916 l_return_status := OKL_API.G_RET_STS_UNEXP_ERROR;
2917 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
2918 END IF;
2919
2920 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
2921 'Input Parameters p_source_hdr_id=' || to_char(l_trans_hdr_rec.source_id) || ' Header Table=' || l_trans_hdr_rec.source_table );
2922 IF l_trans_hdr_rec.source_table = G_TRX_CONTRACTS
2923 THEN
2924 -- Calling populate_tcn_sources for OKL Transactions..
2925 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
2926 'Calling the populate_tcn_sources' );
2927 populate_tcn_sources(
2928 p_api_version => l_api_version
2929 ,p_init_msg_list => p_init_msg_list
2930 ,px_trans_hdr_rec => l_trans_hdr_rec
2931 ,p_acc_sources_rec => l_acc_sources_tbl( l_acc_sources_tbl.FIRST )
2932 ,x_return_status => l_return_status
2933 ,x_msg_count => x_msg_count
2934 ,x_msg_data => x_msg_data );
2935 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
2936 'After populate_tcn_sources: l_return_status ' || l_return_status );
2937 ELSE
2938 -- Return with an error message
2939 OKL_API.set_message(
2940 p_app_name => G_APP_NAME
2941 ,p_msg_name => G_INVALID_VALUE
2942 ,p_token1 => G_COL_NAME_TOKEN
2943 ,p_token1_value => 'HEADER.SOURCE_TABLE');
2944 l_return_status := OKL_API.G_RET_STS_UNEXP_ERROR;
2945 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
2946 END IF;
2947 -- Check the return status and if errored, return the error back
2948 IF (l_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
2949 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
2950 ELSIF (l_return_status = OKL_API.G_RET_STS_ERROR) THEN
2951 RAISE OKL_API.G_EXCEPTION_ERROR;
2952 END IF;
2953 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
2954 'After populate_tcn_sources: HEADER_EXTENSION_ID= ' || l_trans_hdr_rec.header_extension_id );
2955 -- Call the Populate TCL Sources API to populate the Transaction Line Level Sources
2956 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
2957 'Before the Call to the Populate_tcl_sources_tbl version');
2958 populate_tcl_sources(
2959 p_api_version => l_api_version
2960 ,p_init_msg_list => p_init_msg_list
2961 ,p_trans_hdr_rec => l_trans_hdr_rec
2962 ,p_acc_sources_tbl => l_acc_sources_tbl
2963 ,p_trans_line_tbl => l_trans_line_tbl -- Added by PRASJAIN Bug#6134235
2964 ,x_trans_line_tbl => x_trans_line_tbl -- Added by PRASJAIN Bug#6134235
2965 ,x_return_status => l_return_status
2966 ,x_msg_count => x_msg_count
2967 ,x_msg_data => x_msg_data );
2968 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
2969 'After the Call to the Populate_tcl_sources_tbl version' || l_return_status);
2970 IF (l_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
2971 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
2972 ELSIF (l_return_status = OKL_API.G_RET_STS_ERROR) THEN
2973 RAISE OKL_API.G_EXCEPTION_ERROR;
2974 END IF;
2975 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
2976 'Calling okl_api.end_activity');
2977 okl_api.end_activity(
2978 x_msg_count => x_msg_count
2979 ,x_msg_data => x_msg_data);
2980 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
2981 'END okl_sla_acc_sources_pvt.POPULATE_SOURCES');
2982 x_return_status := OKL_API.G_RET_STS_SUCCESS;
2983 EXCEPTION
2984 ------------------------------------------------------------
2985 -- Exception handling
2986 ------------------------------------------------------------
2987 WHEN OKL_API.G_EXCEPTION_ERROR
2988 THEN
2989 x_return_status := OKL_API.HANDLE_EXCEPTIONS (
2990 p_api_name => l_api_name
2991 ,p_pkg_name => G_PKG_NAME
2992 ,p_exc_name => OKL_API.G_RET_STS_ERROR
2993 ,x_msg_count => x_msg_count
2994 ,x_msg_data => x_msg_data
2995 ,p_api_type => '_PVT');
2996 WHEN OKL_API.G_EXCEPTION_UNEXPECTED_ERROR
2997 THEN
2998 x_return_status := OKL_API.HANDLE_EXCEPTIONS (
2999 p_api_name => l_api_name
3000 ,p_pkg_name => G_PKG_NAME
3001 ,p_exc_name => OKL_API.G_RET_STS_UNEXP_ERROR
3002 ,x_msg_count => x_msg_count
3003 ,x_msg_data => x_msg_data
3004 ,p_api_type => '_PVT');
3005 WHEN OTHERS
3006 THEN
3007 x_return_status := OKL_API.HANDLE_EXCEPTIONS (
3008 p_api_name => l_api_name
3009 ,p_pkg_name => G_PKG_NAME
3010 ,p_exc_name => 'OTHERS'
3011 ,x_msg_count => x_msg_count
3012 ,x_msg_data => x_msg_data
3013 ,p_api_type => '_PVT');
3014 END populate_sources;
3015
3016 PROCEDURE delete_trx_extension(
3017 p_api_version IN NUMBER
3018 ,p_init_msg_list IN VARCHAR2
3019 ,p_trans_hdr_rec IN tehv_rec_type
3020 ,x_trans_line_tbl OUT NOCOPY telv_tbl_type
3021 ,x_return_status OUT NOCOPY VARCHAR2
3022 ,x_msg_count OUT NOCOPY NUMBER
3023 ,x_msg_data OUT NOCOPY VARCHAR2
3024 )
3025 IS
3026 -----------------------------------------------------------------
3027 -- Declare Process Variable
3028 -----------------------------------------------------------------
3029 l_api_version CONSTANT NUMBER := 1;
3030 l_api_name CONSTANT VARCHAR2(30) := 'DELETE_TRX_EXTENSION';
3031 l_return_status VARCHAR2(1) := OKL_API.G_RET_STS_SUCCESS;
3032 l_telv_tbl okl_tel_pvt.telv_tbl_type;
3033 tel_index BINARY_INTEGER;
3034 l_trans_hdr_rec tehv_rec_type;
3035 -- Cursor Definitions
3036 CURSOR get_txl_ext_hdr_id( p_trx_hdr_id NUMBER, p_trx_hdr_table VARCHAR2)
3037 IS
3038 SELECT teh.header_extension_id header_extension_id
3039 FROM OKL_TRX_EXTENSION_B teh
3040 WHERE teh.source_id = p_trx_hdr_id
3041 AND teh.source_table = p_trx_hdr_table;
3042
3043 CURSOR get_txl_ext_line_ids( p_teh_id NUMBER)
3044 IS
3045 SELECT tel.line_extension_id line_extension_id
3046 ,tel.source_id source_id
3047 ,tel.source_table source_table
3048 FROM OKL_TXL_EXTENSION_B tel
3049 WHERE tel.teh_id = p_teh_id;
3050 -- Local Variables for enabling the Debug Statements
3051 l_module CONSTANT fnd_log_messages.module%TYPE := G_MODULE || l_api_name;
3052 l_debug_enabled VARCHAR2(10);
3053 is_debug_procedure_on BOOLEAN;
3054 is_debug_statement_on BOOLEAN;
3055 BEGIN
3056 l_debug_enabled := okl_debug_pub.check_log_enabled;
3057 -- check for logging on PROCEDURE level
3058 is_debug_procedure_on := okl_debug_pub.check_log_on(l_module,FND_LOG.LEVEL_PROCEDURE);
3059 -- check for logging on STATEMENT level
3060 is_debug_statement_on := okl_debug_pub.check_log_on(l_module,FND_LOG.LEVEL_STATEMENT);
3061 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
3062 'begin debug OKLRSLAB.pls call ' || l_api_name);
3063 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
3064 'BEGIN API OKL_SLA_ACC_SOURCES_PVT.DELETE_TRX_EXTENSION');
3065 l_return_status := OKL_API.G_RET_STS_SUCCESS;
3066 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
3067 'Calling OKL_API.START_ACTIVITY');
3068 l_return_status := OKL_API.START_ACTIVITY(
3069 p_api_name => l_api_name
3070 ,p_pkg_name => g_pkg_name
3071 ,p_init_msg_list => p_init_msg_list
3072 ,l_api_version => l_api_version
3073 ,p_api_version => p_api_version
3074 ,p_api_type => '_PVT'
3075 ,x_return_status => l_return_status);
3076 IF (l_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
3077 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
3078 ELSIF (l_return_status = OKL_API.G_RET_STS_ERROR) THEN
3079 RAISE OKL_API.G_EXCEPTION_ERROR;
3080 END IF;
3081 -- Actual Logic Starts Here ..
3082 l_trans_hdr_rec := p_trans_hdr_rec;
3083 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
3084 'Source ID=' || to_char(l_trans_hdr_rec.source_id) || 'Source Header Table=' || l_trans_hdr_rec.source_table );
3085 IF ( l_trans_hdr_rec.source_id = OKL_API.G_MISS_NUM or l_trans_hdr_rec.source_id IS NULL )
3086 THEN
3087 OKL_API.set_message(
3088 p_app_name => G_APP_NAME
3089 ,p_msg_name => G_INVALID_VALUE
3090 ,p_token1 => G_COL_NAME_TOKEN
3091 ,p_token1_value => 'HEADER.SOURCE_ID');
3092 l_return_status := OKL_API.G_RET_STS_UNEXP_ERROR;
3093 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
3094 END IF;
3095 IF ( l_trans_hdr_rec.source_table = OKL_API.G_MISS_CHAR or l_trans_hdr_rec.source_table IS NULL
3096 OR l_trans_hdr_rec.source_table NOT IN ( G_TRX_CONTRACTS) )
3097 THEN
3098 OKL_API.set_message(
3099 p_app_name => G_APP_NAME
3100 ,p_msg_name => G_INVALID_VALUE
3101 ,p_token1 => G_COL_NAME_TOKEN
3102 ,p_token1_value => 'HEADER.SOURCE_TABLE');
3103 l_return_status := OKL_API.G_RET_STS_UNEXP_ERROR;
3104 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
3105 END IF;
3106 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
3107 'Fetch the Extension Header ID by executing cursor get_txl_ext_hdr_id' );
3108 FOR t_rec IN get_txl_ext_hdr_id(
3109 p_trx_hdr_id => l_trans_hdr_rec.source_id
3110 ,p_trx_hdr_table => l_trans_hdr_rec.source_table)
3111 LOOP
3112 l_trans_hdr_rec.header_extension_id := t_rec.header_extension_id;
3113 END LOOP;
3114 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
3115 'Extension Header ID To be Deleted=' || TO_CHAR(l_trans_hdr_rec.header_extension_id));
3116 -- Fetch the Transaction Extension Line IDs to be deleted
3117 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
3118 'Extension Line ID(s) To be Deleted=');
3119 tel_index := 1;
3120 FOR t_rec IN get_txl_ext_line_ids( p_teh_id => l_trans_hdr_rec.header_extension_id)
3121 LOOP
3122 l_telv_tbl(tel_index).line_extension_id := t_rec.line_extension_id;
3123 l_telv_tbl(tel_index).source_id := t_rec.source_id;
3124 l_telv_tbl(tel_index).source_table := t_rec.source_table;
3125 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
3126 'LINE_EXTENSION_ID[' || tel_index || '] = ' || TO_CHAR(l_telv_tbl(tel_index).line_extension_id) );
3127 -- Increment i
3128 tel_index := tel_index + 1;
3129 END LOOP; -- End get_trans_line_ids
3130 -- Store the Transaction Line IDs and Line Source Tables so as to return back
3131 x_trans_line_tbl := l_telv_tbl;
3132 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
3133 'Calling the okl_trx_extension_pvt.delete_trx_extension. HEADER_EXTENSION_ID = ' ||
3134 TO_CHAR(l_trans_hdr_rec.header_extension_id) );
3135 okl_trx_extension_pvt.delete_trx_extension(
3136 p_api_version => p_api_version
3137 ,p_init_msg_list => p_init_msg_list
3138 ,x_return_status => l_return_status
3139 ,x_msg_count => x_msg_count
3140 ,x_msg_data => x_msg_data
3141 ,p_tehv_rec => l_trans_hdr_rec -- Initalized with the HEADER_EXTENSION_ID
3142 );
3143 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
3144 'After executing the okl_trx_extension_pvt.delete_trx_extension l_return_status' || l_return_status );
3145 IF (l_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
3146 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
3147 ELSIF (l_return_status = OKL_API.G_RET_STS_ERROR) THEN
3148 RAISE OKL_API.G_EXCEPTION_ERROR;
3149 END IF;
3150 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
3151 'Calling okl_api.end_activity');
3152 okl_api.end_activity(
3153 x_msg_count => x_msg_count
3154 ,x_msg_data => x_msg_data);
3155 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
3156 'END OKL_SLA_ACC_SOURCES_PVT.DELETE_TRX_EXTENSION');
3157 x_return_status := OKL_API.G_RET_STS_SUCCESS;
3158 EXCEPTION
3159 ------------------------------------------------------------
3160 -- Exception handling
3161 ------------------------------------------------------------
3162 WHEN OKL_API.G_EXCEPTION_ERROR
3163 THEN
3164 x_return_status := OKL_API.HANDLE_EXCEPTIONS (
3165 p_api_name => l_api_name
3166 ,p_pkg_name => G_PKG_NAME
3167 ,p_exc_name => OKL_API.G_RET_STS_ERROR
3168 ,x_msg_count => x_msg_count
3169 ,x_msg_data => x_msg_data
3170 ,p_api_type => '_PVT');
3171 WHEN OKL_API.G_EXCEPTION_UNEXPECTED_ERROR
3172 THEN
3173 x_return_status := OKL_API.HANDLE_EXCEPTIONS (
3174 p_api_name => l_api_name
3175 ,p_pkg_name => G_PKG_NAME
3176 ,p_exc_name => OKL_API.G_RET_STS_UNEXP_ERROR
3177 ,x_msg_count => x_msg_count
3178 ,x_msg_data => x_msg_data
3179 ,p_api_type => '_PVT');
3180 WHEN OTHERS
3181 THEN
3182 x_return_status := OKL_API.HANDLE_EXCEPTIONS (
3183 p_api_name => l_api_name
3184 ,p_pkg_name => G_PKG_NAME
3185 ,p_exc_name => 'OTHERS'
3186 ,x_msg_count => x_msg_count
3187 ,x_msg_data => x_msg_data
3188 ,p_api_type => '_PVT');
3189 END delete_trx_extension;
3190
3191 ------------------------------------------------------------------------------
3192 -- Start of comments
3193 -- API name : write_khr_sources_to_log
3194 -- Pre-reqs : None
3195 -- Function : log captured khr sources for FA/AR/AP OKL Transactions
3196 -- Parameters :
3197 -- IN : p_khr_source_rec khr_source_rec_type
3198 -- Version : 1.0
3199 -- History : Prashant Jain created
3200 -- End of comments
3201 ------------------------------------------------------------------------------
3202
3203 PROCEDURE write_khr_sources_to_log(
3204 p_khr_source_rec IN khr_source_rec_type
3205 ,p_module IN fnd_log_messages.module%TYPE)
3206 AS
3207 BEGIN
3208 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'KHR_ID =' || p_khr_source_rec.KHR_ID );
3209 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'CONTRACT_NUMBER =' || p_khr_source_rec.CONTRACT_NUMBER );
3210 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'CONTRACT_STATUS =' || p_khr_source_rec.CONTRACT_STATUS );
3211 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'CUSTOMER_NAME =' || p_khr_source_rec.CUSTOMER_NAME );
3212 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'CUSTOMER_ACCOUNT_NUMBER =' || p_khr_source_rec.CUSTOMER_ACCOUNT_NUMBER );
3213 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'CONTRACT_CURRENCY_CODE =' || p_khr_source_rec.CONTRACT_CURRENCY_CODE );
3214 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'CONTRACT_EFFECTIVE_FROM =' || p_khr_source_rec.CONTRACT_EFFECTIVE_FROM );
3215 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'PRODUCT_NAME =' || p_khr_source_rec.PRODUCT_NAME );
3216 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'BOOK_CLASSIFICATION_CODE=' || p_khr_source_rec.BOOK_CLASSIFICATION_CODE );
3217 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'TAX_OWNER_CODE =' || p_khr_source_rec.TAX_OWNER_CODE );
3218 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'REV_REC_METHOD_CODE =' || p_khr_source_rec.REV_REC_METHOD_CODE );
3219 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'INT_CALC_METHOD_CODE =' || p_khr_source_rec.INT_CALC_METHOD_CODE );
3220 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'VENDOR_PROGRAM_NUMBER =' || p_khr_source_rec.VENDOR_PROGRAM_NUMBER );
3221 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'CONVERTED_NUMBER =' || p_khr_source_rec.CONVERTED_NUMBER );
3222 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'CONVERTED_ACCOUNT_FLAG =' || p_khr_source_rec.CONVERTED_ACCOUNT_FLAG );
3223 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'ASSIGNABLE_FLAG =' || p_khr_source_rec.ASSIGNABLE_FLAG );
3224 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'PO_ORDER_NUMBER =' || p_khr_source_rec.PO_ORDER_NUMBER );
3225 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'ACCRUAL_OVERRIDE_FLAG =' || p_khr_source_rec.ACCRUAL_OVERRIDE_FLAG );
3226 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'RENT_IA_CONTRACT_NUMBER =' || p_khr_source_rec.RENT_IA_CONTRACT_NUMBER );
3227 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'RENT_IA_PRODUCT_NAME =' || p_khr_source_rec.RENT_IA_PRODUCT_NAME );
3228 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'RENT_IA_ACCOUNTING_CODE =' || p_khr_source_rec.RENT_IA_ACCOUNTING_CODE );
3229 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'RES_IA_CONTRACT_NUMBER =' || p_khr_source_rec.RES_IA_CONTRACT_NUMBER );
3230 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'RES_IA_PRODUCT_NAME =' || p_khr_source_rec.RES_IA_PRODUCT_NAME );
3231 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'RES_IA_ACCOUNTING_CODE =' || p_khr_source_rec.RES_IA_ACCOUNTING_CODE );
3232 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'KHR_ATTRIBUTE_CATEGORY =' || p_khr_source_rec.KHR_ATTRIBUTE_CATEGORY );
3233 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'KHR_ATTRIBUTE1 =' || p_khr_source_rec.KHR_ATTRIBUTE1 );
3234 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'KHR_ATTRIBUTE2 =' || p_khr_source_rec.KHR_ATTRIBUTE2 );
3235 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'KHR_ATTRIBUTE3 =' || p_khr_source_rec.KHR_ATTRIBUTE3 );
3236 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'KHR_ATTRIBUTE4 =' || p_khr_source_rec.KHR_ATTRIBUTE4 );
3237 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'KHR_ATTRIBUTE5 =' || p_khr_source_rec.KHR_ATTRIBUTE5 );
3238 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'KHR_ATTRIBUTE6 =' || p_khr_source_rec.KHR_ATTRIBUTE6 );
3239 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'KHR_ATTRIBUTE7 =' || p_khr_source_rec.KHR_ATTRIBUTE7 );
3240 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'KHR_ATTRIBUTE8 =' || p_khr_source_rec.KHR_ATTRIBUTE8 );
3241 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'KHR_ATTRIBUTE9 =' || p_khr_source_rec.KHR_ATTRIBUTE9 );
3242 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'KHR_ATTRIBUTE10 =' || p_khr_source_rec.KHR_ATTRIBUTE10 );
3243 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'KHR_ATTRIBUTE11 =' || p_khr_source_rec.KHR_ATTRIBUTE11 );
3244 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'KHR_ATTRIBUTE12 =' || p_khr_source_rec.KHR_ATTRIBUTE12 );
3245 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'KHR_ATTRIBUTE13 =' || p_khr_source_rec.KHR_ATTRIBUTE13 );
3246 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'KHR_ATTRIBUTE14 =' || p_khr_source_rec.KHR_ATTRIBUTE14 );
3247 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'KHR_ATTRIBUTE15 =' || p_khr_source_rec.KHR_ATTRIBUTE15 );
3248 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'CUST_ATTRIBUTE_CATEGORY =' || p_khr_source_rec.CUST_ATTRIBUTE_CATEGORY );
3249 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'CUST_ATTRIBUTE1 =' || p_khr_source_rec.CUST_ATTRIBUTE1 );
3250 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'CUST_ATTRIBUTE2 =' || p_khr_source_rec.CUST_ATTRIBUTE2 );
3251 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'CUST_ATTRIBUTE3 =' || p_khr_source_rec.CUST_ATTRIBUTE3 );
3252 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'CUST_ATTRIBUTE4 =' || p_khr_source_rec.CUST_ATTRIBUTE4 );
3253 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'CUST_ATTRIBUTE5 =' || p_khr_source_rec.CUST_ATTRIBUTE5 );
3254 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'CUST_ATTRIBUTE6 =' || p_khr_source_rec.CUST_ATTRIBUTE6 );
3255 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'CUST_ATTRIBUTE7 =' || p_khr_source_rec.CUST_ATTRIBUTE7 );
3256 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'CUST_ATTRIBUTE8 =' || p_khr_source_rec.CUST_ATTRIBUTE8 );
3257 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'CUST_ATTRIBUTE9 =' || p_khr_source_rec.CUST_ATTRIBUTE9 );
3258 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'CUST_ATTRIBUTE10 =' || p_khr_source_rec.CUST_ATTRIBUTE10 );
3259 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'CUST_ATTRIBUTE11 =' || p_khr_source_rec.CUST_ATTRIBUTE11 );
3260 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'CUST_ATTRIBUTE12 =' || p_khr_source_rec.CUST_ATTRIBUTE12 );
3261 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'CUST_ATTRIBUTE13 =' || p_khr_source_rec.CUST_ATTRIBUTE13 );
3262 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'CUST_ATTRIBUTE14 =' || p_khr_source_rec.CUST_ATTRIBUTE14 );
3263 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'CUST_ATTRIBUTE15 =' || p_khr_source_rec.CUST_ATTRIBUTE15 );
3264 write_to_log(FND_LOG.LEVEL_STATEMENT,P_MODULE,'CONTRACT_STATUS_CODE =' || p_khr_source_rec.CONTRACT_STATUS_CODE );
3265 write_to_log(FND_LOG.LEVEL_STATEMENT,P_MODULE,'INV_AGRMNT_NUMBER =' || p_khr_source_rec.INV_AGRMNT_NUMBER );
3266 write_to_log(FND_LOG.LEVEL_STATEMENT,P_MODULE,'INV_AGRMNT_EFFECTIVE_FROM =' || p_khr_source_rec.INV_AGRMNT_EFFECTIVE_FROM );
3267 write_to_log(FND_LOG.LEVEL_STATEMENT,P_MODULE,'INV_AGRMNT_PRODUCT_NAME =' || p_khr_source_rec.INV_AGRMNT_PRODUCT_NAME );
3268 write_to_log(FND_LOG.LEVEL_STATEMENT,P_MODULE,'INV_AGRMNT_CURRENCY_CODE =' || p_khr_source_rec.INV_AGRMNT_CURRENCY_CODE );
3269 write_to_log(FND_LOG.LEVEL_STATEMENT,P_MODULE,'INV_AGRMNT_SYND_CODE =' || p_khr_source_rec.INV_AGRMNT_SYND_CODE );
3270 write_to_log(FND_LOG.LEVEL_STATEMENT,P_MODULE,'INV_AGRMNT_POOL_NUMBER =' || p_khr_source_rec.INV_AGRMNT_POOL_NUMBER );
3271 write_to_log(FND_LOG.LEVEL_STATEMENT,P_MODULE,'INV_AGRMNT_STATUS_CODE =' || p_khr_source_rec.INV_AGRMNT_STATUS_CODE );
3272 write_to_log(FND_LOG.LEVEL_STATEMENT,P_MODULE,'INV_AGRMNT_STATUS =' || p_khr_source_rec.INV_AGRMNT_STATUS );
3273 write_to_log(FND_LOG.LEVEL_STATEMENT,P_MODULE,'SCS_CODE =' || p_khr_source_rec.SCS_CODE );
3274 END write_khr_sources_to_log;
3275
3276 ------------------------------------------------------------------------------
3277 -- Start of comments
3278 -- API name : write_kle_sources_to_log
3279 -- Pre-reqs : None
3280 -- Function : log captured kle sources for FA/AR/AP OKL Transactions
3281 -- Parameters :
3282 -- IN : p_kle_source_rec kle_source_rec_type
3283 -- Version : 1.0
3284 -- History : Prashant Jain created
3285 -- End of comments
3286 ------------------------------------------------------------------------------
3287
3288 PROCEDURE write_kle_sources_to_log(
3289 p_kle_source_rec IN kle_source_rec_type
3290 ,p_module IN fnd_log_messages.module%TYPE)
3291 AS
3292 BEGIN
3293 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'KHR_ID =' || p_kle_source_rec.KHR_ID );
3294 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'KLE_ID =' || p_kle_source_rec.KLE_ID );
3295 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'ASSET_NUMBER =' || p_kle_source_rec.ASSET_NUMBER );
3296 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'CONTRACT_LINE_NUMBER =' || p_kle_source_rec.CONTRACT_LINE_NUMBER );
3297 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'ASSET_VENDOR_NAME =' || p_kle_source_rec.ASSET_VENDOR_NAME );
3298 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'INSTALLED_SITE_ID =' || p_kle_source_rec.INSTALLED_SITE_ID );
3299 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'FIXED_ASSET_LOCATION_NAME =' || p_kle_source_rec.FIXED_ASSET_LOCATION_NAME );
3300 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'LINE_TYPE_CODE =' || p_kle_source_rec.LINE_TYPE_CODE );
3301 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'LINE_ATTRIBUTE_CATEGORY =' || p_kle_source_rec.LINE_ATTRIBUTE_CATEGORY );
3302 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'LINE_ATTRIBUTE1 =' || p_kle_source_rec.LINE_ATTRIBUTE1 );
3303 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'LINE_ATTRIBUTE2 =' || p_kle_source_rec.LINE_ATTRIBUTE2 );
3304 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'LINE_ATTRIBUTE3 =' || p_kle_source_rec.LINE_ATTRIBUTE3 );
3305 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'LINE_ATTRIBUTE4 =' || p_kle_source_rec.LINE_ATTRIBUTE4 );
3306 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'LINE_ATTRIBUTE5 =' || p_kle_source_rec.LINE_ATTRIBUTE5 );
3307 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'LINE_ATTRIBUTE6 =' || p_kle_source_rec.LINE_ATTRIBUTE6 );
3308 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'LINE_ATTRIBUTE7 =' || p_kle_source_rec.LINE_ATTRIBUTE7 );
3309 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'LINE_ATTRIBUTE8 =' || p_kle_source_rec.LINE_ATTRIBUTE8 );
3310 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'LINE_ATTRIBUTE9 =' || p_kle_source_rec.LINE_ATTRIBUTE9 );
3311 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'LINE_ATTRIBUTE10 =' || p_kle_source_rec.LINE_ATTRIBUTE10 );
3312 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'LINE_ATTRIBUTE11 =' || p_kle_source_rec.LINE_ATTRIBUTE11 );
3313 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'LINE_ATTRIBUTE12 =' || p_kle_source_rec.LINE_ATTRIBUTE12 );
3314 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'LINE_ATTRIBUTE13 =' || p_kle_source_rec.LINE_ATTRIBUTE13 );
3315 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'LINE_ATTRIBUTE14 =' || p_kle_source_rec.LINE_ATTRIBUTE14 );
3316 write_to_log(FND_LOG.LEVEL_STATEMENT,p_module,'LINE_ATTRIBUTE15 =' || p_kle_source_rec.LINE_ATTRIBUTE15 );
3317 END write_kle_sources_to_log;
3318
3319 ------------------------------------------------------------------------------
3320 -- Start of comments
3321 -- API name : assign_khr_rec_to_fxhv_rec
3322 -- Pre-reqs : None
3323 -- Function : assign khr rec to fxhv rec for FA OKL Transactions
3324 -- Parameters :
3325 -- IN : p_khr_source_rec khr_source_rec_type
3326 -- OUT : x_fxhv_rec fxhv_rec_type
3327 -- Version : 1.0
3328 -- History : Prashant Jain created
3329 -- End of comments
3330 ------------------------------------------------------------------------------
3331 -- Changes for Bug# 6268782 : PRASJAIN
3332 -- 1. func name assign_khr_rec_to_fxhv_rec to assign_khr_rec_to_fxh_rec
3333 -- 2. out param fxhv_rec_type to fxh_rec_type
3334 ------------------------------------------------------------------------------
3335 PROCEDURE assign_khr_rec_to_fxh_rec(
3336 p_khr_source_rec IN khr_source_rec_type
3337 ,x_fxh_rec IN OUT NOCOPY fxh_rec_type
3338 )
3339 AS
3340 BEGIN
3341 x_fxh_rec.khr_id := p_khr_source_rec.khr_id;
3342 x_fxh_rec.contract_number := p_khr_source_rec.contract_number;
3343 x_fxh_rec.customer_name := p_khr_source_rec.customer_name;
3344 x_fxh_rec.customer_account_number := p_khr_source_rec.customer_account_number;
3345 -- added by zrehman Bug#6707320 for Party Merge impact on Accounting sources tables start
3346 x_fxh_rec.party_id := p_khr_source_rec.customer_id;
3347 x_fxh_rec.cust_account_id := p_khr_source_rec.cust_account_id;
3348 -- added by zrehman Bug#6707320 for Party Merge impact on Accounting sources tables end
3349 x_fxh_rec.contract_currency_code := p_khr_source_rec.contract_currency_code;
3350 x_fxh_rec.contract_effective_from := p_khr_source_rec.contract_effective_from;
3351 x_fxh_rec.product_name := p_khr_source_rec.product_name;
3352 x_fxh_rec.book_classification_code:= p_khr_source_rec.book_classification_code;
3353 x_fxh_rec.tax_owner_code := p_khr_source_rec.tax_owner_code;
3354 x_fxh_rec.rev_rec_method_code := p_khr_source_rec.rev_rec_method_code;
3355 x_fxh_rec.int_calc_method_code := p_khr_source_rec.int_calc_method_code;
3356 x_fxh_rec.vendor_program_number := p_khr_source_rec.vendor_program_number;
3357 x_fxh_rec.converted_number := p_khr_source_rec.converted_number;
3358 x_fxh_rec.converted_account_flag := p_khr_source_rec.converted_account_flag;
3359 x_fxh_rec.assignable_flag := p_khr_source_rec.assignable_flag;
3360 x_fxh_rec.po_order_number := p_khr_source_rec.po_order_number;
3361 x_fxh_rec.accrual_override_flag := p_khr_source_rec.accrual_override_flag;
3362 x_fxh_rec.rent_ia_contract_number := p_khr_source_rec.rent_ia_contract_number;
3363 x_fxh_rec.rent_ia_product_name := p_khr_source_rec.rent_ia_product_name;
3364 x_fxh_rec.rent_ia_accounting_code := p_khr_source_rec.rent_ia_accounting_code;
3365 x_fxh_rec.res_ia_contract_number := p_khr_source_rec.res_ia_contract_number;
3366 x_fxh_rec.res_ia_product_name := p_khr_source_rec.res_ia_product_name;
3367 x_fxh_rec.res_ia_accounting_code := p_khr_source_rec.res_ia_accounting_code;
3368 x_fxh_rec.khr_attribute_category := p_khr_source_rec.khr_attribute_category;
3369 x_fxh_rec.khr_attribute1 := p_khr_source_rec.khr_attribute1;
3370 x_fxh_rec.khr_attribute2 := p_khr_source_rec.khr_attribute2;
3371 x_fxh_rec.khr_attribute3 := p_khr_source_rec.khr_attribute3;
3372 x_fxh_rec.khr_attribute4 := p_khr_source_rec.khr_attribute4;
3373 x_fxh_rec.khr_attribute5 := p_khr_source_rec.khr_attribute5;
3374 x_fxh_rec.khr_attribute6 := p_khr_source_rec.khr_attribute6;
3375 x_fxh_rec.khr_attribute7 := p_khr_source_rec.khr_attribute7;
3376 x_fxh_rec.khr_attribute8 := p_khr_source_rec.khr_attribute8;
3377 x_fxh_rec.khr_attribute9 := p_khr_source_rec.khr_attribute9;
3378 x_fxh_rec.khr_attribute10 := p_khr_source_rec.khr_attribute10;
3379 x_fxh_rec.khr_attribute11 := p_khr_source_rec.khr_attribute11;
3380 x_fxh_rec.khr_attribute12 := p_khr_source_rec.khr_attribute12;
3381 x_fxh_rec.khr_attribute13 := p_khr_source_rec.khr_attribute13;
3382 x_fxh_rec.khr_attribute14 := p_khr_source_rec.khr_attribute14;
3383 x_fxh_rec.khr_attribute15 := p_khr_source_rec.khr_attribute15;
3384 x_fxh_rec.cust_attribute_category := p_khr_source_rec.cust_attribute_category;
3385 x_fxh_rec.cust_attribute1 := p_khr_source_rec.cust_attribute1;
3386 x_fxh_rec.cust_attribute2 := p_khr_source_rec.cust_attribute2;
3387 x_fxh_rec.cust_attribute3 := p_khr_source_rec.cust_attribute3;
3388 x_fxh_rec.cust_attribute4 := p_khr_source_rec.cust_attribute4;
3389 x_fxh_rec.cust_attribute5 := p_khr_source_rec.cust_attribute5;
3390 x_fxh_rec.cust_attribute6 := p_khr_source_rec.cust_attribute6;
3391 x_fxh_rec.cust_attribute7 := p_khr_source_rec.cust_attribute7;
3392 x_fxh_rec.cust_attribute8 := p_khr_source_rec.cust_attribute8;
3393 x_fxh_rec.cust_attribute9 := p_khr_source_rec.cust_attribute9;
3394 x_fxh_rec.cust_attribute10 := p_khr_source_rec.cust_attribute10;
3395 x_fxh_rec.cust_attribute11 := p_khr_source_rec.cust_attribute11;
3396 x_fxh_rec.cust_attribute12 := p_khr_source_rec.cust_attribute12;
3397 x_fxh_rec.cust_attribute13 := p_khr_source_rec.cust_attribute13;
3398 x_fxh_rec.cust_attribute14 := p_khr_source_rec.cust_attribute14;
3399 x_fxh_rec.cust_attribute15 := p_khr_source_rec.cust_attribute15;
3400 x_fxh_rec.contract_status_code := p_khr_source_rec.contract_status_code;
3401 END assign_khr_rec_to_fxh_rec;
3402 ------------------------------------------------------------------------------
3403 -- Start of comments
3404 -- API name : assign_kle_rec_to_fxlv_rec
3405 -- Pre-reqs : None
3406 -- Function : assign kle rec to fxlv rec for FA OKL Transactions
3407 -- Parameters :
3408 -- IN : p_kle_source_rec kle_source_rec_type
3409 -- OUT : x_fxlv_rec fxlv_rec_type
3410 -- Version : 1.0
3411 -- History : Prashant Jain created
3412 -- End of comments
3413 ------------------------------------------------------------------------------
3414 -- Changes for Bug# 6268782 : PRASJAIN
3415 -- 1. func name assign_kle_rec_to_fxlv_rec to assign_kle_rec_to_fxl_rec
3416 -- 2. out param fxlv_rec_type to fxl_rec_type
3417 ------------------------------------------------------------------------------
3418 PROCEDURE assign_kle_rec_to_fxl_rec(
3419 p_kle_source_rec IN kle_source_rec_type
3420 ,x_fxl_rec IN OUT NOCOPY fxl_rec_type
3421 )
3422 AS
3423 BEGIN
3424 x_fxl_rec.kle_id := p_kle_source_rec.kle_id;
3425 x_fxl_rec.asset_number := p_kle_source_rec.asset_number;
3426 x_fxl_rec.contract_line_number := p_kle_source_rec.contract_line_number;
3427 x_fxl_rec.asset_vendor_name := p_kle_source_rec.asset_vendor_name;
3428 -- added by zrehman Bug#6707320 for Party Merge impact on Accounting sources tables start
3429 x_fxl_rec.asset_vendor_id := p_kle_source_rec.asset_vendor_id;
3430 -- added by zrehman Bug#6707320 for Party Merge impact on Accounting sources tables end
3431 x_fxl_rec.installed_site_id := p_kle_source_rec.installed_site_id;
3432 x_fxl_rec.line_attribute_category := p_kle_source_rec.line_attribute_category;
3433 x_fxl_rec.line_attribute1 := p_kle_source_rec.line_attribute1;
3434 x_fxl_rec.line_attribute2 := p_kle_source_rec.line_attribute2;
3435 x_fxl_rec.line_attribute3 := p_kle_source_rec.line_attribute3;
3436 x_fxl_rec.line_attribute4 := p_kle_source_rec.line_attribute4;
3437 x_fxl_rec.line_attribute5 := p_kle_source_rec.line_attribute5;
3438 x_fxl_rec.line_attribute6 := p_kle_source_rec.line_attribute6;
3439 x_fxl_rec.line_attribute7 := p_kle_source_rec.line_attribute7;
3440 x_fxl_rec.line_attribute8 := p_kle_source_rec.line_attribute8;
3441 x_fxl_rec.line_attribute9 := p_kle_source_rec.line_attribute9;
3442 x_fxl_rec.line_attribute10 := p_kle_source_rec.line_attribute10;
3443 x_fxl_rec.line_attribute11 := p_kle_source_rec.line_attribute11;
3444 x_fxl_rec.line_attribute12 := p_kle_source_rec.line_attribute12;
3445 x_fxl_rec.line_attribute13 := p_kle_source_rec.line_attribute13;
3446 x_fxl_rec.line_attribute14 := p_kle_source_rec.line_attribute14;
3447 x_fxl_rec.line_attribute15 := p_kle_source_rec.line_attribute15;
3448 END assign_kle_rec_to_fxl_rec;
3449 -----------------------------------------------------------------------------------------
3450 -- Start of comments
3451 -- API name : populate_khr_sources
3452 -- Pre-reqs : None
3453 -- Function : populate khr header sources for FA/AR/AP OKL Transactions
3454 -- Parameters :
3455 -- IN : x_khr_source_rec.khr_id NUMBER Required
3456 -- -- Change for Bug# 6268782 : PRASJAIN
3457 -- x_led_lang_tbl led_lang_tbl_type Required
3458 -- OUT : x_khr_source_rec khr_source_rec_type
3459 -- Version : 1.0
3460 -- History : Prashant Jain created
3461 -- End of comments
3462 -----------------------------------------------------------------------------------------
3463
3464 PROCEDURE populate_khr_sources(
3465 p_api_version IN NUMBER
3466 ,p_init_msg_list IN VARCHAR2
3467 ,x_khr_source_rec IN OUT NOCOPY khr_source_rec_type
3468 ,x_led_lang_tbl IN OUT NOCOPY led_lang_tbl_type
3469 ,x_return_status OUT NOCOPY VARCHAR2
3470 ,x_msg_count OUT NOCOPY NUMBER
3471 ,x_msg_data OUT NOCOPY VARCHAR2
3472 )
3473 IS
3474 -----------------------------------------------------------------
3475 -- Declare Process Variable
3476 -----------------------------------------------------------------
3477 l_api_version CONSTANT NUMBER := 1;
3478 l_api_name CONSTANT VARCHAR2(30) := 'POPULATE_KHR_SOURCES';
3479 l_return_status VARCHAR2(1) := OKL_API.G_RET_STS_SUCCESS;
3480
3481 ----------------------------------------------
3482 -- Variables based on Cursor record structures
3483 ----------------------------------------------
3484 l_kpl_attributes_csr_rec c_kpl_attributes_csr%ROWTYPE;
3485 l_khr_category_attr_csr_rec c_khr_category_attributes_csr%ROWTYPE;
3486 l_khr_attributes_csr_rec c_khr_attributes_csr%ROWTYPE;
3487 l_get_status_meaning_csr_rec c_get_status_meaning_csr%ROWTYPE;
3488 l_insurance_csr_rec c_insurance_csr%ROWTYPE;
3489 l_rev_rec_int_calc_mtd_csr_rec c_rev_rec_int_calc_methods_csr%ROWTYPE;
3490 l_cust_name_account_csr_rec c_cust_name_account_csr%ROWTYPE;
3491 l_inv_agree_acc_code_csr_rec c_investor_agree_acc_code_csr%ROWTYPE;
3492 l_investor_agree_main_csr_rec c_investor_agreement_main_csr%ROWTYPE;
3493 l_vendor_prg_number_csr_rec c_vendor_program_number_csr%ROWTYPE;
3494 l_pdt_bc_to_icm_rrb_rec c_pdt_bc_to_icm_rrb_csr%ROWTYPE;
3495 l_inv_agrmnt_details_rec c_inv_agrmnt_details_csr%ROWTYPE;
3496 ---------------------------------------------------------------
3497 -- Local Variables for storing value used in another procedure
3498 ---------------------------------------------------------------
3499 l_khr_id NUMBER;
3500 l_cust_acct_id NUMBER;
3501 l_pdt_id NUMBER;
3502 l_rent_ia_chr_id NUMBER;
3503 l_res_ia_chr_id NUMBER;
3504 l_ledger_language VARCHAR2(12);
3505 tl_sources_in NUMBER := 1;
3506
3507 ----------------------------------------------------
3508 -- Local variables for enabling the debug statements
3509 ----------------------------------------------------
3510 l_module CONSTANT fnd_log_messages.module%TYPE := G_MODULE || l_api_name;
3511 l_debug_enabled VARCHAR2(10);
3512 is_debug_procedure_on BOOLEAN;
3513 is_debug_statement_on BOOLEAN;
3514 BEGIN
3515 l_debug_enabled := okl_debug_pub.check_log_enabled;
3516 -- check for logging on PROCEDURE level
3517 is_debug_procedure_on := okl_debug_pub.check_log_on(l_module,FND_LOG.LEVEL_PROCEDURE);
3518 -- check for logging on STATEMENT level
3519 is_debug_statement_on := okl_debug_pub.check_log_on(l_module,FND_LOG.LEVEL_STATEMENT);
3520 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
3521 'BEGIN DEBUG OKLRSLAB.PLS CALL ' || l_api_name);
3522 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
3523 'BEGIN API OKL_SLA_ACC_SOURCES_PVT.POPULATE_KHR_SOURCES');
3524 l_return_status := OKL_API.G_RET_STS_SUCCESS;
3525 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
3526 'CALLING OKL_API.START_ACTIVITY');
3527 l_return_status := OKL_API.START_ACTIVITY(
3528 p_api_name => l_api_name
3529 ,p_pkg_name => g_pkg_name
3530 ,p_init_msg_list => p_init_msg_list
3531 ,l_api_version => l_api_version
3532 ,p_api_version => p_api_version
3533 ,p_api_type => '_PVT'
3534 ,x_return_status => l_return_status);
3535 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
3536 'AFTER START ACTIVITY L_RETURN_STATUS ' || l_return_status );
3537
3538 IF (l_return_status = OKL_API.G_RET_STS_UNEXP_ERROR)
3539 THEN
3540 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
3541 ELSIF (l_return_status = OKL_API.G_RET_STS_ERROR)
3542 THEN
3543 RAISE OKL_API.G_EXCEPTION_ERROR;
3544 END IF;
3545
3546 -- Copy input parameter to local variable
3547 l_khr_id := x_khr_source_rec.khr_id;
3548
3549 -- fetch and populate contract attributes
3550 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
3551 'Executing Cursor l_khr_attributes_csr_rec : l_khr_id = ' || TO_CHAR(l_khr_id));
3552 FOR t_rec IN c_khr_attributes_csr (l_khr_id)
3553 LOOP
3554 l_khr_attributes_csr_rec := t_rec;
3555 -- First Capture the scs_code of the Entity ..
3556 -- If its lease then capture contract related sources, other wise not !!
3557 x_khr_source_rec.scs_code := l_khr_attributes_csr_rec.scs_code;
3558 IF l_khr_attributes_csr_rec.scs_code = G_LEASE
3559 THEN
3560 x_khr_source_rec.contract_number := l_khr_attributes_csr_rec.contract_number;
3561 x_khr_source_rec.contract_currency_code := l_khr_attributes_csr_rec.currency_code;
3562 x_khr_source_rec.contract_effective_from := l_khr_attributes_csr_rec.start_date;
3563 x_khr_source_rec.converted_number := l_khr_attributes_csr_rec.orig_system_reference1;
3564 x_khr_source_rec.assignable_flag := l_khr_attributes_csr_rec.assignable_yn;
3565 x_khr_source_rec.converted_account_flag := l_khr_attributes_csr_rec.converted_account_yn;
3566 x_khr_source_rec.po_order_number := l_khr_attributes_csr_rec.cust_po_number;
3567 x_khr_source_rec.accrual_override_flag := l_khr_attributes_csr_rec.generate_accrual_override_yn;
3568 l_cust_acct_id := l_khr_attributes_csr_rec.cust_acct_id;
3569 l_pdt_id := l_khr_attributes_csr_rec.pdt_id;
3570 -- Assign the Contract Status Code
3571 x_khr_source_rec.contract_status_code := l_khr_attributes_csr_rec.sts_code;
3572
3573 -- MG uptake .. for secondary rep get the reporting product id.
3574 if G_REPRESENTATION_TYPE = 'SECONDARY' then
3575 open c_rep_pdt_csr(l_pdt_id);
3576 fetch c_rep_pdt_csr into l_pdt_id;
3577 close c_rep_pdt_csr;
3578 end if;
3579
3580 -- Fetch contract status wrt ledger language
3581 FOR tl_sources_in IN x_led_lang_tbl.FIRST .. x_led_lang_tbl.LAST
3582 LOOP
3583 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
3584 'Executing the Cursor c_get_status_meaning_csr. p_sts_code=' ||
3585 l_khr_attributes_csr_rec.sts_code || 'p_led_lang= ' || x_led_lang_tbl(tl_sources_in).language );
3586 FOR t_rec IN c_get_status_meaning_csr(
3587 p_sts_code => l_khr_attributes_csr_rec.sts_code
3588 ,p_led_lang => x_led_lang_tbl(tl_sources_in).language )
3589 LOOP
3590 l_get_status_meaning_csr_rec := t_rec;
3591 x_led_lang_tbl(tl_sources_in).contract_status := l_get_status_meaning_csr_rec.status_meaning;
3592 END LOOP; -- End for c_get_status_meaning_csr
3593 END LOOP;
3594 ELSIF l_khr_attributes_csr_rec.scs_code = G_INVESTOR
3595 THEN
3596 x_khr_source_rec.inv_agrmnt_number := l_khr_attributes_csr_rec.contract_number;
3597 x_khr_source_rec.inv_agrmnt_effective_from := l_khr_attributes_csr_rec.start_date;
3598 x_khr_source_rec.inv_agrmnt_currency_code := l_khr_attributes_csr_rec.currency_code;
3599 x_khr_source_rec.inv_agrmnt_status_code := l_khr_attributes_csr_rec.sts_code;
3600 -- Fetch Investor Agreement status wrt ledger language
3601 FOR tl_sources_in IN x_led_lang_tbl.FIRST .. x_led_lang_tbl.LAST
3602 LOOP
3603 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
3604 'Executing the Cursor c_get_status_meaning_csr. p_sts_code=' ||
3605 l_khr_attributes_csr_rec.sts_code || 'p_led_lang= ' || x_led_lang_tbl(tl_sources_in).language );
3606 FOR t_rec IN c_get_status_meaning_csr(
3607 p_sts_code => l_khr_attributes_csr_rec.sts_code
3608 ,p_led_lang => x_led_lang_tbl(tl_sources_in).language )
3609 LOOP
3610 l_get_status_meaning_csr_rec := t_rec;
3611 x_led_lang_tbl(tl_sources_in).inv_agrmnt_status := l_get_status_meaning_csr_rec.status_meaning;
3612 END LOOP; -- End for c_get_status_meaning_csr
3613 END LOOP;
3614 END IF;
3615 END LOOP; -- End for c_khr_attributes_csr
3616
3617 IF l_khr_attributes_csr_rec.scs_code = G_LEASE
3618 THEN
3619 -- fetch and populate contract attribute category and attributes
3620 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
3621 'Executing the Cursor c_khr_category_attributes_csr l_khr_id = ' || TO_CHAR(l_khr_id) );
3622 FOR t_rec IN c_khr_category_attributes_csr (l_khr_id)
3623 LOOP
3624 l_khr_category_attr_csr_rec := t_rec;
3625 x_khr_source_rec.khr_attribute_category := l_khr_category_attr_csr_rec.attribute_category;
3626 x_khr_source_rec.khr_attribute1 := l_khr_category_attr_csr_rec.attribute1;
3627 x_khr_source_rec.khr_attribute2 := l_khr_category_attr_csr_rec.attribute2;
3628 x_khr_source_rec.khr_attribute3 := l_khr_category_attr_csr_rec.attribute3;
3629 x_khr_source_rec.khr_attribute4 := l_khr_category_attr_csr_rec.attribute4;
3630 x_khr_source_rec.khr_attribute5 := l_khr_category_attr_csr_rec.attribute5;
3631 x_khr_source_rec.khr_attribute6 := l_khr_category_attr_csr_rec.attribute6;
3632 x_khr_source_rec.khr_attribute7 := l_khr_category_attr_csr_rec.attribute7;
3633 x_khr_source_rec.khr_attribute8 := l_khr_category_attr_csr_rec.attribute8;
3634 x_khr_source_rec.khr_attribute9 := l_khr_category_attr_csr_rec.attribute9;
3635 x_khr_source_rec.khr_attribute10 := l_khr_category_attr_csr_rec.attribute10;
3636 x_khr_source_rec.khr_attribute11 := l_khr_category_attr_csr_rec.attribute11;
3637 x_khr_source_rec.khr_attribute12 := l_khr_category_attr_csr_rec.attribute12;
3638 x_khr_source_rec.khr_attribute13 := l_khr_category_attr_csr_rec.attribute13;
3639 x_khr_source_rec.khr_attribute14 := l_khr_category_attr_csr_rec.attribute14;
3640 x_khr_source_rec.khr_attribute15 := l_khr_category_attr_csr_rec.attribute15;
3641 END LOOP; -- End for c_khr_category_attributes_csr
3642
3643 -- Fetch and populate book classification code and tax owner code
3644 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
3645 'Executing the Cursor c_pdt_bc_to_icm_rrb_csr. l_pdt_id = ' || TO_CHAR(l_pdt_id) );
3646 FOR t_rec IN c_pdt_bc_to_icm_rrb_csr (p_pdt_id => l_pdt_id)
3647 LOOP
3648 l_pdt_bc_to_icm_rrb_rec := t_rec;
3649 x_khr_source_rec.product_name := l_pdt_bc_to_icm_rrb_rec.pdt_name;
3650 x_khr_source_rec.book_classification_code := l_pdt_bc_to_icm_rrb_rec.deal_type;
3651 x_khr_source_rec.tax_owner_code := l_pdt_bc_to_icm_rrb_rec.tax_owner;
3652 x_khr_source_rec.int_calc_method_code := l_pdt_bc_to_icm_rrb_rec.interest_calc_meth_code;
3653 x_khr_source_rec.rev_rec_method_code := l_pdt_bc_to_icm_rrb_rec.revenue_recog_meth_code;
3654 END LOOP; -- End for c_book_tax_csr
3655
3656 -- fetch and populate vendor program number
3657 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
3658 'Executing the Cursor c_vendor_program_number_csr p_khr_id = ' || TO_CHAR(l_khr_id) );
3659 FOR t_rec IN c_vendor_program_number_csr (p_khr_id => l_khr_id)
3660 LOOP
3661 l_vendor_prg_number_csr_rec := t_rec;
3662 x_khr_source_rec.vendor_program_number := l_vendor_prg_number_csr_rec.contract_number;
3663 END LOOP; -- End for c_vendor_program_number_csr
3664
3665 -- fetch and populate customer account properties
3666 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
3667 'Executing the Cursor l_cust_name_account_csr. p_khr_id = ' || TO_CHAR(l_khr_id)
3668 || ' p_cust_acct_id = ' || TO_CHAR(l_cust_acct_id ) );
3669 FOR t_rec IN c_cust_name_account_csr (l_khr_id,l_cust_acct_id)
3670 LOOP
3671 l_cust_name_account_csr_rec := t_rec;
3672 x_khr_source_rec.customer_name := l_cust_name_account_csr_rec.party_name;
3673 x_khr_source_rec.customer_account_number := l_cust_name_account_csr_rec.account_number;
3674 -- added by zrehman Bug#6707320 for Party Merge impact on Accounting sources tables start
3675 x_khr_source_rec.cust_account_id := l_cust_acct_id;
3676 x_khr_source_rec.customer_id := l_cust_name_account_csr_rec.party_id;
3677 -- added by zrehman Bug#6707320 for Party Merge impact on Accounting sources tables end
3678 END LOOP; -- End for c_cust_name_account_csr
3679
3680 -- fetch and populate customer attribute category and attributes
3681 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
3682 'Executing the Cursor c_kpl_attributes_csr l_khr_id = ' || TO_CHAR(l_khr_id) );
3683 FOR t_rec IN c_kpl_attributes_csr (l_khr_id)
3684 LOOP
3685 l_kpl_attributes_csr_rec := t_rec;
3686 x_khr_source_rec.cust_attribute_category := l_kpl_attributes_csr_rec.attribute_category;
3687 x_khr_source_rec.cust_attribute1 := l_kpl_attributes_csr_rec.attribute1;
3688 x_khr_source_rec.cust_attribute2 := l_kpl_attributes_csr_rec.attribute2;
3689 x_khr_source_rec.cust_attribute3 := l_kpl_attributes_csr_rec.attribute3;
3690 x_khr_source_rec.cust_attribute4 := l_kpl_attributes_csr_rec.attribute4;
3691 x_khr_source_rec.cust_attribute5 := l_kpl_attributes_csr_rec.attribute5;
3692 x_khr_source_rec.cust_attribute6 := l_kpl_attributes_csr_rec.attribute6;
3693 x_khr_source_rec.cust_attribute7 := l_kpl_attributes_csr_rec.attribute7;
3694 x_khr_source_rec.cust_attribute8 := l_kpl_attributes_csr_rec.attribute8;
3695 x_khr_source_rec.cust_attribute9 := l_kpl_attributes_csr_rec.attribute9;
3696 x_khr_source_rec.cust_attribute10 := l_kpl_attributes_csr_rec.attribute10;
3697 x_khr_source_rec.cust_attribute11 := l_kpl_attributes_csr_rec.attribute11;
3698 x_khr_source_rec.cust_attribute12 := l_kpl_attributes_csr_rec.attribute12;
3699 x_khr_source_rec.cust_attribute13 := l_kpl_attributes_csr_rec.attribute13;
3700 x_khr_source_rec.cust_attribute14 := l_kpl_attributes_csr_rec.attribute14;
3701 x_khr_source_rec.cust_attribute15 := l_kpl_attributes_csr_rec.attribute15;
3702 END LOOP; -- End for c_kpl_attributes_csr
3703
3704 -- fetch and populate rent investor agreement attributes
3705 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
3706 'RENT: Executing the Cursor c_investor_agreement_main_csr l_khr_id = : ' || TO_CHAR(l_khr_id));
3707 FOR t_rec IN c_investor_agreement_main_csr(
3708 p_khr_id => l_khr_id
3709 ,p_sty_type => 'RENT')
3710 LOOP
3711 l_investor_agree_main_csr_rec := t_rec;
3712 l_rent_ia_chr_id := l_investor_agree_main_csr_rec.ia_chr_id;
3713 x_khr_source_rec.rent_ia_contract_number := l_investor_agree_main_csr_rec.ia_contract_number;
3714 x_khr_source_rec.rent_ia_product_name := l_investor_agree_main_csr_rec.ia_product_name;
3715 END LOOP; -- End for c_investor_agreement_main_csr
3716
3717 -- fetch and populate residual investor agreement attributes
3718 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
3719 'RESIDUAL VALUE: Executing the Cursor c_investor_agreement_main_csr l_khr_id = : ' || TO_CHAR(l_khr_id));
3720 FOR t_rec IN c_investor_agreement_main_csr(
3721 p_khr_id => l_khr_id
3722 ,p_sty_type => 'RESIDUAL VALUE')
3723 LOOP
3724 l_investor_agree_main_csr_rec := t_rec;
3725 l_res_ia_chr_id := l_investor_agree_main_csr_rec.ia_chr_id;
3726 x_khr_source_rec.res_ia_contract_number := l_investor_agree_main_csr_rec.ia_contract_number;
3727 x_khr_source_rec.res_ia_product_name := l_investor_agree_main_csr_rec.ia_product_name;
3728 END LOOP; -- Enf for c_investor_agreement_main_csr
3729
3730 -- fetch and populate rent investor agreement account properties
3731 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
3732 'Executing the Cursor c_investor_agree_acc_code_csr. p_rent_ia_chr_id = '
3733 || TO_CHAR(l_rent_ia_chr_id) || ' p_res_ia_chr_id = ' || TO_CHAR(l_res_ia_chr_id));
3734 FOR t_rec in c_investor_agree_acc_code_csr (l_rent_ia_chr_id, l_res_ia_chr_id)
3735 LOOP
3736 l_inv_agree_acc_code_csr_rec := t_rec;
3737 x_khr_source_rec.rent_ia_accounting_code := l_inv_agree_acc_code_csr_rec.rent_ia_accounting_code;
3738 x_khr_source_rec.res_ia_accounting_code := l_inv_agree_acc_code_csr_rec.res_ia_accounting_code;
3739 END LOOP; -- End for c_investor_agree_acc_code_csr
3740
3741 ELSIF l_khr_attributes_csr_rec.scs_code = G_INVESTOR
3742 THEN
3743
3744 -- Code to fetch the Sources like
3745 -- Investor Agreement Type, Pool Number and Product Name
3746 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
3747 'Executing the Cursor c_inv_agrmnt_details_csr. l_khr_id = ' || TO_CHAR(l_khr_id) );
3748 FOR t_rec IN c_inv_agrmnt_details_csr( p_inv_agrmnt_id => l_khr_id )
3749 LOOP
3750 l_inv_agrmnt_details_rec := t_rec;
3751 x_khr_source_rec.inv_agrmnt_synd_code := l_inv_agrmnt_details_rec.inv_agrmnt_synd_code;
3752 -- Commented out the Investor Pool Agreement Source, as this is not mentioned as Source by PMs
3753 -- x_khr_source_rec.inv_agrmnt_pool_number := l_inv_agrmnt_details_rec.inv_agrmnt_pool_number;
3754 END LOOP; -- FOR t_rec IN c_inv_agrmnt_details_csr( p_inv_agrmnt_id => l_khr_id )
3755 FOR t_rec IN c_get_pdt_name_csr( p_pdt_id => l_khr_attributes_csr_rec.pdt_id )
3756 LOOP
3757 x_khr_source_rec.inv_agrmnt_product_name := t_rec.pdt_name;
3758 END LOOP;
3759
3760 END IF; -- IF l_khr_attributes_csr_rec.scs_code = G_INVESTOR
3761 -- If Log is enabled, print all khr sources fetched.
3762 IF (l_debug_enabled='Y' AND is_debug_statement_on)
3763 THEN
3764 write_khr_sources_to_log(
3765 p_khr_source_rec => x_khr_source_rec
3766 ,p_module => l_module);
3767 END IF;
3768 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
3769 'CALLING OKL_API.END_ACTIVITY');
3770 okl_api.end_activity(
3771 x_msg_count => x_msg_count
3772 ,x_msg_data => x_msg_data);
3773 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
3774 'END OKL_SLA_ACC_SOURCES_PVT.POPULATE_KHR_SOURCES');
3775 x_return_status := OKL_API.G_RET_STS_SUCCESS;
3776 EXCEPTION
3777 ------------------------------------------------------------
3778 -- Exception handling
3779 ------------------------------------------------------------
3780 WHEN OKL_API.G_EXCEPTION_ERROR
3781 THEN
3782 x_return_status := OKL_API.HANDLE_EXCEPTIONS (
3783 p_api_name => l_api_name
3784 ,p_pkg_name => G_PKG_NAME
3785 ,p_exc_name => OKL_API.G_RET_STS_ERROR
3786 ,x_msg_count => x_msg_count
3787 ,x_msg_data => x_msg_data
3788 ,p_api_type => '_PVT');
3789 WHEN OKL_API.G_EXCEPTION_UNEXPECTED_ERROR
3790 THEN
3791 x_return_status := OKL_API.HANDLE_EXCEPTIONS (
3792 p_api_name => l_api_name
3793 ,p_pkg_name => G_PKG_NAME
3794 ,p_exc_name => OKL_API.G_RET_STS_UNEXP_ERROR
3795 ,x_msg_count => x_msg_count
3796 ,x_msg_data => x_msg_data
3797 ,p_api_type => '_PVT');
3798 WHEN OTHERS
3799 THEN
3800 x_return_status := OKL_API.HANDLE_EXCEPTIONS (
3801 p_api_name => l_api_name
3802 ,p_pkg_name => G_PKG_NAME
3803 ,p_exc_name => 'OTHERS'
3804 ,x_msg_count => x_msg_count
3805 ,x_msg_data => x_msg_data
3806 ,p_api_type => '_PVT');
3807 END populate_khr_sources;
3808 ---------------------------------------------------------------------------------------
3809 -- Start of comments
3810 -- API name : populate_kle_sources
3811 -- Pre-reqs : None
3812 -- Function : populate khr / kle line sources for FA/AR/AP OKL Transactions
3813 -- Parameters :
3814 -- IN : x_kle_source_rec.khr_id NUMBER Required
3815 -- x_kle_source_rec.kle_id NUMBER Required
3816 -- Version : 1.0
3817 -- History : Prashant Jain created
3818 -- End of comments
3819 ---------------------------------------------------------------------------------------
3820
3821 PROCEDURE populate_kle_sources(
3822 p_api_version IN NUMBER
3823 ,p_init_msg_list IN VARCHAR2
3824 ,x_kle_source_rec IN OUT NOCOPY kle_source_rec_type
3825 ,x_return_status OUT NOCOPY VARCHAR2
3826 ,x_msg_count OUT NOCOPY NUMBER
3827 ,x_msg_data OUT NOCOPY VARCHAR2
3828 )
3829 IS
3830 -----------------------------------------------------------------
3831 -- Declare Process Variable
3832 -----------------------------------------------------------------
3833 l_api_version CONSTANT NUMBER := 1;
3834 l_api_name CONSTANT VARCHAR2(30) := 'POPULATE_KLE_SOURCES';
3835 l_return_status VARCHAR2(1) := OKL_API.G_RET_STS_SUCCESS;
3836
3837 ----------------------------------------------
3838 -- Variables based on cursor record structures
3839 ----------------------------------------------
3840 l_line_attributes_rec c_line_attributes_csr%ROWTYPE;
3841 l_k_lines_rec c_k_lines_csr%ROWTYPE;
3842 l_vendor_name_rec c_vendor_name_csr%ROWTYPE;
3843 l_installed_site_rec c_installed_site_csr%ROWTYPE;
3844 l_location_id_rec c_location_id_csr%ROWTYPE;
3845 l_asset_location_name_rec c_asset_location_name_csr%ROWTYPE;
3846 l_khr_attributes_csr_rec c_khr_attributes_csr%ROWTYPE;
3847 ---------------------------------------------------------------
3848 -- Local Variables for storing value used in another procedure
3849 ---------------------------------------------------------------
3850 l_khr_id NUMBER;
3851 l_kle_id NUMBER;
3852 l_ledger_language VARCHAR2(12);
3853
3854 ----------------------------------------------------
3855 -- Local Variables for enabling the Debug Statements
3856 ----------------------------------------------------
3857 l_module CONSTANT fnd_log_messages.module%TYPE := G_MODULE || l_api_name;
3858 l_debug_enabled VARCHAR2(10);
3859 is_debug_procedure_on BOOLEAN;
3860 is_debug_statement_on BOOLEAN;
3861 BEGIN
3862 l_debug_enabled := okl_debug_pub.check_log_enabled;
3863 -- check for logging on PROCEDURE level
3864 is_debug_procedure_on := okl_debug_pub.check_log_on(l_module,FND_LOG.LEVEL_PROCEDURE);
3865 -- check for logging on STATEMENT level
3866 is_debug_statement_on := okl_debug_pub.check_log_on(l_module,FND_LOG.LEVEL_STATEMENT);
3867 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
3868 'BEGIN DEBUG OKLRSLAB.PLS CALL ' || l_api_name);
3869 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
3870 'BEGIN API OKL_SLA_ACC_SOURCES_PVT.POPULATE_KLE_SOURCES');
3871 l_return_status := OKL_API.G_RET_STS_SUCCESS;
3872 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
3873 'CALLING OKL_API.START_ACTIVITY');
3874 l_return_status := OKL_API.START_ACTIVITY(
3875 p_api_name => l_api_name
3876 ,p_pkg_name => g_pkg_name
3877 ,p_init_msg_list => p_init_msg_list
3878 ,l_api_version => l_api_version
3879 ,p_api_version => p_api_version
3880 ,p_api_type => '_PVT'
3881 ,x_return_status => l_return_status);
3882 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
3883 'AFTER START ACTIVITY L_RETURN_STATUS ' || l_return_status );
3884
3885 IF (l_return_status = OKL_API.G_RET_STS_UNEXP_ERROR)
3886 THEN
3887 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
3888 ELSIF (l_return_status = OKL_API.G_RET_STS_ERROR)
3889 THEN
3890 RAISE OKL_API.G_EXCEPTION_ERROR;
3891 END IF;
3892
3893 -- Copy input parameter to local variables
3894 l_khr_id := x_kle_source_rec.khr_id;
3895 l_kle_id := x_kle_source_rec.kle_id;
3896
3897 -- fetch and populate line attribute category and attributes
3898 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
3899 'Executing the Cursor c_line_attributes_csr l_kle_id = ' || TO_CHAR(l_kle_id) );
3900 FOR t_rec IN c_line_attributes_csr (l_kle_id)
3901 LOOP
3902 l_line_attributes_rec := t_rec;
3903 x_kle_source_rec.line_attribute_category := l_line_attributes_rec.attribute_category;
3904 x_kle_source_rec.line_attribute1 := l_line_attributes_rec.attribute1;
3905 x_kle_source_rec.line_attribute2 := l_line_attributes_rec.attribute2;
3906 x_kle_source_rec.line_attribute3 := l_line_attributes_rec.attribute3;
3907 x_kle_source_rec.line_attribute4 := l_line_attributes_rec.attribute4;
3908 x_kle_source_rec.line_attribute5 := l_line_attributes_rec.attribute5;
3909 x_kle_source_rec.line_attribute6 := l_line_attributes_rec.attribute6;
3910 x_kle_source_rec.line_attribute7 := l_line_attributes_rec.attribute7;
3911 x_kle_source_rec.line_attribute8 := l_line_attributes_rec.attribute8;
3912 x_kle_source_rec.line_attribute9 := l_line_attributes_rec.attribute9;
3913 x_kle_source_rec.line_attribute10 := l_line_attributes_rec.attribute10;
3914 x_kle_source_rec.line_attribute11 := l_line_attributes_rec.attribute11;
3915 x_kle_source_rec.line_attribute12 := l_line_attributes_rec.attribute12;
3916 x_kle_source_rec.line_attribute13 := l_line_attributes_rec.attribute13;
3917 x_kle_source_rec.line_attribute14 := l_line_attributes_rec.attribute14;
3918 x_kle_source_rec.line_attribute15 := l_line_attributes_rec.attribute15;
3919 END LOOP; -- End for c_line_attributes_csr
3920
3921 -- fetch and populate line type code, asset number and contract line number
3922 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
3923 'Executing the Cursor c_k_lines_csr l_kle_id = ' || TO_CHAR(l_kle_id) );
3924 FOR t_rec IN c_k_lines_csr (l_kle_id)
3925 LOOP
3926 l_k_lines_rec := t_rec;
3927 x_kle_source_rec.line_type_code := l_k_lines_rec.contract_line_type;
3928 x_kle_source_rec.asset_number := l_k_lines_rec.asset_number;
3929 x_kle_source_rec.contract_line_number := l_k_lines_rec.line_number;
3930 END LOOP; -- End for c_k_lines_csr
3931
3932 -- fetch and populate assest vendor name
3933 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
3934 'Executing the Cursor c_vendor_name_csr l_kle_id = ' || TO_CHAR(l_kle_id) ||
3935 ' l_khr_id = ' || TO_CHAR(l_khr_id));
3936 FOR t_rec IN c_vendor_name_csr (
3937 p_kle_id => l_kle_id
3938 ,p_khr_id => l_khr_id)
3939 LOOP
3940 l_vendor_name_rec := t_rec;
3941 x_kle_source_rec.asset_vendor_name := l_vendor_name_rec.vendor_name;
3942 -- added by zrehman Bug#6707320 as part of Party Merge impact on transaction sources tables start
3943 x_kle_source_rec.asset_vendor_id := l_vendor_name_rec.vendor_id;
3944 -- added by zrehman Bug#6707320 as part of Party Merge impact on transaction sources tables end
3945 END LOOP; -- End for c_vendor_name_csr
3946
3947 -- fetch and populate installed site
3948 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
3949 'Executing the Cursor c_installed_site_csr l_kle_id = ' || TO_CHAR(l_kle_id) ||
3950 ' l_khr_id = ' || TO_CHAR(l_khr_id));
3951 FOR t_rec IN c_installed_site_csr (
3952 p_kle_id => l_kle_id
3953 ,p_khr_id => l_khr_id)
3954 LOOP
3955 l_installed_site_rec := t_rec;
3956 x_kle_source_rec.installed_site_id := l_installed_site_rec.installed_site_id;
3957 END LOOP; -- End for c_installed_site_csr
3958
3959 -- fetch and populate fixed asset location name
3960 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
3961 'Executing the Cursor c_location_id_csr l_kle_id = ' || TO_CHAR(l_kle_id) ||
3962 ' l_khr_id = ' || TO_CHAR(l_khr_id));
3963 FOR t_rec IN c_location_id_csr (
3964 p_kle_id => l_kle_id
3965 ,p_khr_id => l_khr_id)
3966 LOOP
3967 l_location_id_rec := t_rec;
3968
3969 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
3970 'Executing the Cursor c_asset_location_name_csr location_id = ' || TO_CHAR(l_location_id_rec.location_id));
3971 FOR t_rec IN c_asset_location_name_csr (p_fdh_location_id => l_location_id_rec.location_id)
3972 LOOP
3973 l_asset_location_name_rec := t_rec;
3974 x_kle_source_rec.fixed_asset_location_name := l_asset_location_name_rec.asset_location_name;
3975 END LOOP; -- End for c_asset_location_name_csr
3976 END LOOP; -- End for c_location_id_csr
3977
3978 -- fetch and populate product id
3979 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
3980 'Executing Cursor c_khr_attributes_csr : l_khr_id = ' ||to_char(l_khr_id));
3981 FOR t_rec IN c_khr_attributes_csr (l_khr_id)
3982 LOOP
3983 l_khr_attributes_csr_rec := t_rec;
3984 END LOOP; -- End for c_khr_attributes_csr
3985
3986 -- If log is enabled, print all the sources fetched.
3987 IF (l_debug_enabled='Y' AND is_debug_statement_on)
3988 THEN
3989 write_kle_sources_to_log(
3990 p_kle_source_rec => x_kle_source_rec
3991 ,p_module => l_module);
3992 END IF;
3993
3994 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
3995 'CALLING OKL_API.END_ACTIVITY');
3996 okl_api.end_activity(
3997 x_msg_count => x_msg_count
3998 ,x_msg_data => x_msg_data);
3999 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
4000 'END OKL_SLA_ACC_SOURCES_PVT.POPULATE_KLE_SOURCES');
4001 x_return_status := OKL_API.G_RET_STS_SUCCESS;
4002 EXCEPTION
4003 ------------------------------------------------------------
4004 -- Exception handling
4005 ------------------------------------------------------------
4006 WHEN OKL_API.G_EXCEPTION_ERROR
4007 THEN
4008 x_return_status := OKL_API.HANDLE_EXCEPTIONS (
4009 p_api_name => l_api_name
4010 ,p_pkg_name => G_PKG_NAME
4011 ,p_exc_name => OKL_API.G_RET_STS_ERROR
4012 ,x_msg_count => x_msg_count
4013 ,x_msg_data => x_msg_data
4014 ,p_api_type => '_PVT');
4015 WHEN OKL_API.G_EXCEPTION_UNEXPECTED_ERROR
4016 THEN
4017 x_return_status := OKL_API.HANDLE_EXCEPTIONS (
4018 p_api_name => l_api_name
4019 ,p_pkg_name => G_PKG_NAME
4020 ,p_exc_name => OKL_API.G_RET_STS_UNEXP_ERROR
4021 ,x_msg_count => x_msg_count
4022 ,x_msg_data => x_msg_data
4023 ,p_api_type => '_PVT');
4024 WHEN OTHERS
4025 THEN
4026 x_return_status := OKL_API.HANDLE_EXCEPTIONS (
4027 p_api_name => l_api_name
4028 ,p_pkg_name => G_PKG_NAME
4029 ,p_exc_name => 'OTHERS'
4030 ,x_msg_count => x_msg_count
4031 ,x_msg_data => x_msg_data
4032 ,p_api_type => '_PVT');
4033 END populate_kle_sources;
4034 ------------------------------------------------------------------------------
4035 -- Start of comments
4036 -- API name : populate_sources
4037 -- Pre-reqs : None
4038 -- Function : populate sources for OKL FA Transactions
4039 -- Parameters :
4040 -- IN :
4041 -- fxhv_rec_type.source_id IN NUMBER Required
4042 -- fxhv_rec_type.source_table IN VARCHAR2 Required
4043 -- fxhv_rec_type.khr_id IN NUMBER Required
4044 -- fxhv_rec_type.try_id IN NUMBER Required
4045 -- fxlv_rec_type.source_id IN NUMBER Required
4046 -- fxlv_rec_type.source_table IN VARCHAR2 Required
4047 -- fxlv_rec_type.kle_id IN NUMBER Required
4048 -- fxlv_rec_type.asset_id IN NUMBER Required
4049 -- fxlv_rec_type.fa_transaction_id IN NUMBER Required
4050 -- fxlv_rec_type.asset_book_type_name IN VARCHAR2 Required
4051 -- History : Prashant Jain created
4052 -- : Dec 11 2007 Rkuttiya modfied for bug# 6674730
4053 -- Version : 1.0
4054 -- End of comments
4055 ------------------------------------------------------------------------------
4056
4057 PROCEDURE populate_sources(
4058 p_api_version IN NUMBER
4059 ,p_init_msg_list IN VARCHAR2
4060 ,p_fxhv_rec IN fxhv_rec_type
4061 ,p_fxlv_rec IN fxlv_rec_type
4062 ,x_return_status OUT NOCOPY VARCHAR2
4063 ,x_msg_count OUT NOCOPY NUMBER
4064 ,x_msg_data OUT NOCOPY VARCHAR2
4065 )
4066 IS
4067 -----------------------------------------------------------------
4068 -- Declare Process Variable
4069 -----------------------------------------------------------------
4070 l_api_version CONSTANT NUMBER := 1;
4071 l_api_name CONSTANT VARCHAR2(30) := 'POPULATE_SOURCES-FA';
4072 l_return_status VARCHAR2(1) := OKL_API.G_RET_STS_SUCCESS;
4073 -----------------------------------------------------------------
4074 -- Local Variables
4075 -----------------------------------------------------------------
4076 l_khr_id NUMBER;
4077 l_kle_id NUMBER;
4078 l_try_id NUMBER;
4079 l_ledger_id NUMBER;
4080 l_ledger_language VARCHAR2(12);
4081 l_header_extension_id NUMBER;
4082 l_txl_id NUMBER;
4083 l_pk_attributes VARCHAR2(1000);
4084 l_line_style VARCHAR2(100);
4085 -- KHR and KLE Based Record Structures
4086 l_khr_source_rec khr_source_rec_type;
4087 l_kle_source_rec kle_source_rec_type;
4088 -- Record structures based on FA Extension Header and Line Tables
4089 l_fxh_rec okl_fxh_pvt.fxh_rec_type;
4090 lx_fxh_rec okl_fxh_pvt.fxh_rec_type;
4091 -- for capture header translatable sources
4092 l_fxhl_tbl okl_fxh_pvt.fxhl_tbl_type;
4093 lx_fxhl_tbl okl_fxh_pvt.fxhl_tbl_type;
4094
4095 l_fxl_rec okl_fxl_pvt.fxl_rec_type;
4096 lx_fxl_rec okl_fxl_pvt.fxl_rec_type;
4097 -- for capture header translatable sources
4098 l_fxll_tbl okl_fxl_pvt.fxll_tbl_type;
4099 lx_fxll_tbl okl_fxl_pvt.fxll_tbl_type;
4100
4101 l_led_lang_tbl led_lang_tbl_type;
4102
4103 -- Record structures based on the Cursor defintions
4104 l_sales_rep_csr_rec c_sales_rep_csr%ROWTYPE;
4105 -- Local Variables for enabling the Debug Statements
4106 l_module CONSTANT fnd_log_messages.module%TYPE := G_MODULE || l_api_name;
4107 l_debug_enabled VARCHAR2(10);
4108 is_debug_procedure_on BOOLEAN;
4109 is_debug_statement_on BOOLEAN;
4110 tl_sources_in NUMBER := 1;
4111
4112 l_rep_code VARCHAR2(30);
4113 l_rep_name VARCHAR2(30);
4114 l_rep_type VARCHAR2(20);
4115 BEGIN
4116 l_debug_enabled := okl_debug_pub.check_log_enabled;
4117 -- check for logging on PROCEDURE level
4118 is_debug_procedure_on := okl_debug_pub.check_log_on(l_module,FND_LOG.LEVEL_PROCEDURE);
4119 -- check for logging on STATEMENT level
4120 is_debug_statement_on := okl_debug_pub.check_log_on(l_module,FND_LOG.LEVEL_STATEMENT);
4121 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
4122 'begin debug OKLRSLAB.pls call ' || l_api_name);
4123 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
4124 'BEGIN API OKL_SLA_ACC_SOURCES_PVT.POPULATE_SOURCES');
4125 l_return_status := OKL_API.G_RET_STS_SUCCESS;
4126 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
4127 'Calling OKL_API.START_ACTIVITY');
4128 l_return_status := OKL_API.START_ACTIVITY(
4129 p_api_name => l_api_name
4130 ,p_pkg_name => g_pkg_name
4131 ,p_init_msg_list => p_init_msg_list
4132 ,l_api_version => l_api_version
4133 ,p_api_version => p_api_version
4134 ,p_api_type => '_PVT'
4135 ,x_return_status => l_return_status);
4136 IF (l_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
4137 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
4138 ELSIF (l_return_status = OKL_API.G_RET_STS_ERROR) THEN
4139 RAISE OKL_API.G_EXCEPTION_ERROR;
4140 END IF;
4141 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
4142 'Before Performing validations');
4143 -- Validations to be done:
4144 -- 1. The following should be NOT NULL
4145 -- dnz_khr_id, kle_id, try_id, asset_id, fa_transaction_id, source_id,
4146 -- source_table and asset_book_type_code
4147 l_pk_attributes := NULL;
4148 IF p_fxhv_rec.source_id IS NULL OR
4149 p_fxhv_rec.source_id = OKL_API.G_MISS_NUM
4150 THEN
4151 IF l_pk_attributes IS NOT NULL
4152 THEN
4153 l_pk_attributes := l_pk_attributes || ' , ';
4154 END IF;
4155 l_pk_attributes := l_pk_attributes || 'FXH.SOURCE_ID';
4156 END IF;
4157 IF p_fxhv_rec.source_table IS NULL OR
4158 p_fxhv_rec.source_table = OKL_API.G_MISS_CHAR
4159 THEN
4160 IF l_pk_attributes IS NOT NULL
4161 THEN
4162 l_pk_attributes := l_pk_attributes || ' , ';
4163 END IF;
4164 l_pk_attributes := l_pk_attributes || 'FXH.SOURCE_TABLE';
4165 END IF;
4166 IF p_fxhv_rec.khr_id IS NULL OR
4167 p_fxhv_rec.khr_id = OKL_API.G_MISS_NUM
4168 THEN
4169 IF l_pk_attributes IS NOT NULL
4170 THEN
4171 l_pk_attributes := l_pk_attributes || ' , ';
4172 END IF;
4173 l_pk_attributes := l_pk_attributes || 'KHR_ID';
4174 END IF;
4175 IF p_fxlv_rec.kle_id IS NULL OR
4176 p_fxlv_rec.kle_id = OKL_API.G_MISS_NUM
4177 THEN
4178 IF l_pk_attributes IS NOT NULL
4179 THEN
4180 l_pk_attributes := l_pk_attributes || ' , ';
4181 END IF;
4182 l_pk_attributes := l_pk_attributes || 'KLE_ID';
4183 END IF;
4184 IF p_fxhv_rec.try_id IS NULL OR
4185 p_fxhv_rec.try_id = OKL_API.G_MISS_NUM
4186 THEN
4187 IF l_pk_attributes IS NOT NULL
4188 THEN
4189 l_pk_attributes := l_pk_attributes || ' , ';
4190 END IF;
4191 l_pk_attributes := l_pk_attributes || 'TRY_ID';
4192 END IF;
4193 IF p_fxlv_rec.asset_id IS NULL OR
4194 p_fxlv_rec.asset_id = OKL_API.G_MISS_NUM
4195 THEN
4196 IF l_pk_attributes IS NOT NULL
4197 THEN
4198 l_pk_attributes := l_pk_attributes || ' , ';
4199 END IF;
4200 l_pk_attributes := l_pk_attributes || 'ASSET_ID';
4201 END IF;
4202
4203 IF p_fxlv_rec.fa_transaction_id IS NULL OR
4204 p_fxlv_rec.fa_transaction_id = OKL_API.G_MISS_NUM
4205 THEN
4206 IF l_pk_attributes IS NOT NULL
4207 THEN
4208 l_pk_attributes := l_pk_attributes || ' , ';
4209 END IF;
4210 l_pk_attributes := l_pk_attributes || 'FA_TRANSACTION_ID';
4211 END IF;
4212 IF p_fxlv_rec.asset_book_type_name IS NULL OR
4213 p_fxlv_rec.asset_book_type_name = OKL_API.G_MISS_CHAR
4214 THEN
4215 IF l_pk_attributes IS NOT NULL
4216 THEN
4217 l_pk_attributes := l_pk_attributes || ' , ';
4218 END IF;
4219 l_pk_attributes := l_pk_attributes || 'ASSET_BOOK_TYPE_NAME';
4220 END IF;
4221 IF p_fxlv_rec.source_id IS NULL OR
4222 p_fxlv_rec.source_id = OKL_API.G_MISS_NUM
4223 THEN
4224 IF l_pk_attributes IS NOT NULL
4225 THEN
4226 l_pk_attributes := l_pk_attributes || ' , ';
4227 END IF;
4228 l_pk_attributes := l_pk_attributes || 'FXL.SOURCE_ID';
4229 END IF;
4230 IF p_fxlv_rec.source_table IS NULL OR
4231 p_fxlv_rec.source_table = OKL_API.G_MISS_CHAR
4232 THEN
4233 IF l_pk_attributes IS NOT NULL
4234 THEN
4235 l_pk_attributes := l_pk_attributes || ' , ';
4236 END IF;
4237 l_pk_attributes := l_pk_attributes || 'FXL.SOURCE_TABLE';
4238 END IF;
4239 IF LENGTH(l_pk_attributes) > 0
4240 THEN
4241 -- Raise an Exception
4242 OKL_API.set_message(
4243 p_app_name => G_APP_NAME
4244 ,p_msg_name => G_INVALID_VALUE
4245 ,p_token1 => G_COL_NAME_TOKEN
4246 ,p_token1_value => l_pk_attributes);
4247 l_return_status := OKL_API.G_RET_STS_UNEXP_ERROR;
4248 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
4249 END IF;
4250 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
4251 'Validation 1 Successfull !');
4252 -- Validation 2: Source Table should be OKL_TXL_ASSETS_B/OKL_TXD_ASSETS_B only
4253 IF p_fxhv_rec.source_table <> G_TRX_ASSETS
4254 THEN
4255 -- Raise an Exception
4256 OKL_API.set_message(
4257 p_app_name => G_APP_NAME
4258 ,p_msg_name => G_INVALID_VALUE
4259 ,p_token1 => G_COL_NAME_TOKEN
4260 ,p_token1_value => 'SOURCE_TABLE');
4261 l_return_status := OKL_API.G_RET_STS_UNEXP_ERROR;
4262 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
4263 END IF;
4264 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
4265 'Validation 2 Successfull !');
4266 -- Validation 3: Source Table should be OKL_TXL_ASSETS_B/OKL_TXD_ASSETS_B only
4267 IF p_fxlv_rec.source_table NOT IN ( G_TXL_ASSETS, G_TXD_ASSETS )
4268 THEN
4269 -- Raise an Exception
4270 OKL_API.set_message(
4271 p_app_name => G_APP_NAME
4272 ,p_msg_name => G_INVALID_VALUE
4273 ,p_token1 => G_COL_NAME_TOKEN
4274 ,p_token1_value => 'SOURCE_TABLE');
4275 l_return_status := OKL_API.G_RET_STS_UNEXP_ERROR;
4276 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
4277 END IF;
4278 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
4279 'Validation 3 Successfull !');
4280 -- Validation 4: The kle_id value passed should be the Id of the Line with
4281 -- line style as FREE_FORM1
4282 FOR t_rec IN get_line_style_csr ( p_kle_id => p_fxlv_rec.kle_id )
4283 LOOP
4284 l_line_style := t_rec.line_style;
4285 END LOOP;
4286 IF l_line_style IS NULL OR
4287 l_line_style <> 'FREE_FORM1'
4288 THEN
4289 -- Raise an Exception
4290 OKL_API.set_message(
4291 p_app_name => G_APP_NAME
4292 ,p_msg_name => G_INVALID_VALUE
4293 ,p_token1 => G_COL_NAME_TOKEN
4294 ,p_token1_value => 'KLE_ID');
4295 l_return_status := OKL_API.G_RET_STS_UNEXP_ERROR;
4296 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
4297 END IF;
4298
4299 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
4300 'Validation 4 Successfull !');
4301 -- Copy the Input Parameters to the Local Variables
4302 l_khr_id := p_fxhv_rec.khr_id;
4303 l_kle_id := p_fxlv_rec.kle_id;
4304 l_try_id := p_fxhv_rec.try_id;
4305
4306 -- initialize the local l_fxlv_rec to the input record values
4307 l_fxh_rec.source_id := p_fxhv_rec.source_id;
4308 l_fxh_rec.source_table := p_fxhv_rec.source_table;
4309 l_fxh_rec.khr_id := p_fxhv_rec.khr_id;
4310 l_fxh_rec.try_id := p_fxhv_rec.try_id;
4311
4312 l_fxl_rec.source_id := p_fxlv_rec.source_id;
4313 l_fxl_rec.source_table := p_fxlv_rec.source_table;
4314 l_fxl_rec.kle_id := p_fxlv_rec.kle_id;
4315 l_fxl_rec.asset_id := p_fxlv_rec.asset_id;
4316 l_fxl_rec.fa_transaction_id := p_fxlv_rec.fa_transaction_id;
4317 l_fxl_rec.asset_book_type_code := p_fxlv_rec.asset_book_type_name;
4318
4319 -- get the book type code based on asset_book_type_name .. MG uptake
4320 OPEN get_book_type_name(l_fxl_rec.asset_book_type_code);
4321 FETCH get_book_type_name INTO l_fxl_rec.asset_book_type_name;
4322 CLOSE get_book_type_name;
4323
4324 -- get the ledger based on the asset_book_type_name. MG uptake
4325 OPEN get_reps_csr(l_fxl_rec.asset_book_type_code);
4326 FETCH get_reps_csr into l_ledger_id, l_fxh_rec.representation_code,
4327 l_fxh_rec.representation_name, l_rep_type;
4328 CLOSE get_reps_csr;
4329
4330 if l_rep_type is not null then
4331 G_REPRESENTATION_TYPE := l_rep_type;
4332 else
4333 G_REPRESENTATION_TYPE := 'PRIMARY';
4334 end if;
4335
4336 /* -- commented as the ledger is obtained above. MG uptake.
4337 -- Fetch Ledger ID to fetch the Ledger Language associated to the contracts
4338 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
4339 'Executing the Cursor c_khr_to_ledger_id_csr. p_khr_id=' || TO_CHAR(l_khr_id));
4340 FOR t_rec IN c_khr_to_ledger_id_csr( p_khr_id => l_khr_id )
4341 LOOP
4342 l_ledger_id := t_rec.ledger_id;
4343 END LOOP;
4344 */
4345
4346 -- Using the Ledger ID fetch the Ledger Language
4347 -- Fetch the ledger language in order to populate the sources
4348 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
4349 'Executing the Cursor c_ledger_lang_csr. p_ledger_id=' || TO_CHAR(l_ledger_id));
4350 FOR t_rec IN c_ledger_lang_csr( p_ledger_id => l_ledger_id )
4351 LOOP
4352 l_led_lang_tbl(tl_sources_in).language := t_rec.language_code;
4353 l_fxll_tbl(tl_sources_in).language := t_rec.language_code;
4354 END LOOP;
4355
4356 -- Prepare khr_source_rec_type with khr_id and ledger_language
4357 l_khr_source_rec.khr_id := l_khr_id;
4358
4359 -- Calling populate_khr_sources
4360 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
4361 'Calling the populate_khr_sources' );
4362 populate_khr_sources(
4363 p_api_version => l_api_version
4364 ,p_init_msg_list => p_init_msg_list
4365 ,x_khr_source_rec => l_khr_source_rec
4366 ,x_led_lang_tbl => l_led_lang_tbl
4367 ,x_return_status => l_return_status
4368 ,x_msg_count => x_msg_count
4369 ,x_msg_data => x_msg_data );
4370 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
4371 'After populate_khr_sources: l_return_status ' || l_return_status );
4372 -- Check the return status and if errored, return the error back
4373 IF (l_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
4374 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
4375 ELSIF (l_return_status = OKL_API.G_RET_STS_ERROR) THEN
4376 RAISE OKL_API.G_EXCEPTION_ERROR;
4377 END IF;
4378
4379 --calling assign_khr_rec_to_fxhv_rec
4380 assign_khr_rec_to_fxh_rec(
4381 p_khr_source_rec => l_khr_source_rec
4382 ,x_fxh_rec => l_fxh_rec );
4383
4384 FOR tl_sources_in IN l_led_lang_tbl.FIRST .. l_led_lang_tbl.LAST
4385 LOOP
4386 l_fxhl_tbl(tl_sources_in).language := l_led_lang_tbl(tl_sources_in).language;
4387 l_fxhl_tbl(tl_sources_in).contract_status := l_led_lang_tbl(tl_sources_in).contract_status;
4388
4389 -- Fetch transaction type name wrt ledger language
4390 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
4391 'Executing the Cursor c_trx_type_name_csr. p_try_id=' || l_try_id || 'p_led_lang= ' || l_fxhl_tbl(tl_sources_in).language );
4392 FOR t_rec IN c_trx_type_name_csr(
4393 p_try_id => l_try_id
4394 ,p_led_lang => l_fxhl_tbl(tl_sources_in).language )
4395 LOOP
4396 l_fxhl_tbl(tl_sources_in).transaction_type_name := t_rec.transaction_type_name;
4397 -- Assign the Trx. Type Class Code also.
4398 l_fxh_rec.trx_type_class_code := t_rec.trx_type_class_code;
4399 END LOOP; -- End for c_trx_type_name_csr
4400 END LOOP;
4401
4402 IF l_fxh_rec.trx_type_class_code = 'OFFLEASE_AMORTIZATION'
4403 THEN
4404 -- Fetch Termination Quote related Sources during Offlease Amortization
4405 FOR t_rec IN c_tq_dtls_offlease( p_kle_id => l_kle_id )
4406 LOOP
4407 l_fxh_rec.term_quote_num := t_rec.quote_number;
4408 l_fxh_rec.term_quote_accept_date := t_rec.quote_accepted_date;
4409 l_fxh_rec.term_quote_type_code := t_rec.quote_type;
4410 END LOOP;
4411 ELSIF l_fxh_rec.trx_type_class_code = 'SPLIT_ASSET'
4412 THEN
4413 -- Fetch Termination Quote related Sources during Split Asset
4414 FOR t_rec IN c_tq_dtls_split_ast(
4415 p_kle_id => l_kle_id
4416 ,p_split_asset_trx_id => l_fxh_rec.source_id )
4417 LOOP
4418 l_fxh_rec.term_quote_num := t_rec.quote_number;
4419 l_fxh_rec.term_quote_accept_date := t_rec.quote_accepted_date;
4420 l_fxh_rec.term_quote_type_code := t_rec.quote_type;
4421 END LOOP;
4422 ELSIF l_fxh_rec.trx_type_class_code = 'RELEASE'
4423 THEN
4424 -- Fetch Termination Quote related Sources during Release
4425 FOR t_rec IN c_tq_dtls_release( p_khr_id => l_khr_id )
4426 LOOP
4427 l_fxh_rec.term_quote_num := t_rec.quote_number;
4428 l_fxh_rec.term_quote_accept_date := t_rec.quote_accepted_date;
4429 l_fxh_rec.term_quote_type_code := t_rec.quote_type;
4430 END LOOP;
4431 --rkuttiya added for bug#6674730 Loans Repossession
4432 ELSIF l_fxh_rec.trx_type_class_code = 'INTERNAL_ASSET_CREATION' AND
4433 p_fxhv_rec.repossess_flag = 'Y' THEN
4434 --Fetch Termination Quote related Sources during Repossession
4435 l_fxh_rec.term_quote_num := p_fxhv_rec.term_quote_num;
4436 l_fxh_rec.term_quote_accept_date := p_fxhv_rec.term_quote_accept_date;
4437 l_fxh_rec.term_quote_type_code := p_fxhv_rec.term_quote_type_code;
4438 l_fxh_rec.repossess_flag := p_fxhv_rec.repossess_flag;
4439 END IF;
4440
4441 -- Start populating the FXLV Record Structure
4442 -- Fetch transaction number
4443 IF p_fxlv_rec.source_table = 'OKL_TXL_ASSETS_B'
4444 THEN
4445 -- if source table is OKL_TXL_ASSETS_B
4446 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
4447 'Executing the Cursor c_txl_trans_number_csr. p_source_id=' || p_fxlv_rec.source_id);
4448 FOR t_rec IN c_txl_trans_number_csr(
4449 p_source_id => p_fxlv_rec.source_id )
4450 LOOP
4451 l_fxh_rec.trans_number := t_rec.trans_number;
4452 l_txl_id := t_rec.txl_id;
4453 l_fxh_rec.source_id := t_rec.tas_id;
4454 END LOOP; -- End for c_txl_trans_number_csr
4455 ELSIF p_fxlv_rec.source_table = 'OKL_TXD_ASSETS_B'
4456 THEN
4457 --if source table is OKL_TXD_ASSETS_B
4458 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
4459 'Executing the Cursor c_txd_trans_number_csr. p_source_id=' || p_fxlv_rec.source_id);
4460 FOR t_rec IN c_txd_trans_number_csr(
4461 p_source_id => p_fxlv_rec.source_id )
4462 LOOP
4463 l_fxh_rec.trans_number := t_rec.trans_number;
4464 l_txl_id := t_rec.txl_id;
4465 l_fxh_rec.source_id := t_rec.tas_id;
4466 END LOOP; -- End for c_txd_trans_number_csr
4467 END IF;
4468
4469 -- Fetch and Populate Sales Representative Name
4470 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
4471 'Executing the Cursor c_sales_rep_csr. p_khr_id = ' || TO_CHAR(l_khr_id) );
4472 FOR t_rec IN c_sales_rep_csr (l_khr_id)
4473 LOOP
4474 l_sales_rep_csr_rec := t_rec;
4475 l_fxh_rec.sales_rep_name := l_sales_rep_csr_rec.name;
4476 END LOOP; -- End for c_sales_rep_csr
4477
4478 -- Calling insert_row
4479 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
4480 'Calling the okl_fa_extension_pvt.create_fxh_extension ' || l_fxh_rec.source_id );
4481 okl_fa_extension_pvt.create_fxh_extension(
4482 p_api_version => l_api_version
4483 ,p_init_msg_list => p_init_msg_list
4484 ,x_return_status => l_return_status
4485 ,x_msg_count => x_msg_count
4486 ,x_msg_data => x_msg_data
4487 ,p_fxh_rec => l_fxh_rec
4488 ,p_fxhl_tbl => l_fxhl_tbl
4489 ,x_fxh_rec => lx_fxh_rec
4490 ,x_fxhl_tbl => lx_fxhl_tbl
4491 );
4492 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
4493 'After okl_fa_extension_pvt.create_fxh_extension: l_return_status ' || l_return_status );
4494 -- Check the return status and if errored, return the error back
4495 IF (l_return_status = OKL_API.G_RET_STS_UNEXP_ERROR)
4496 THEN
4497 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
4498 ELSIF (l_return_status = OKL_API.G_RET_STS_ERROR) THEN
4499 RAISE OKL_API.G_EXCEPTION_ERROR;
4500 END IF;
4501
4502 l_header_extension_id := lx_fxh_rec.header_extension_id;
4503 -- Prepare kle_source_rec_type with khr_id, kle_id and ledger_language
4504 l_kle_source_rec.khr_id := l_khr_id;
4505 l_kle_source_rec.kle_id := l_kle_id;
4506 -- Calling populate_kle_sources
4507 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
4508 'Calling the populate_kle_sources' );
4509 populate_kle_sources(
4510 p_api_version => l_api_version
4511 ,p_init_msg_list => p_init_msg_list
4512 ,x_kle_source_rec => l_kle_source_rec
4513 ,x_return_status => l_return_status
4514 ,x_msg_count => x_msg_count
4515 ,x_msg_data => x_msg_data );
4516 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
4517 'After populate_kle_sources: l_return_status ' || l_return_status );
4518 -- Check the return status and if errored, return the error back
4519 IF (l_return_status = OKL_API.G_RET_STS_UNEXP_ERROR)
4520 THEN
4521 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
4522 ELSIF (l_return_status = OKL_API.G_RET_STS_ERROR) THEN
4523 RAISE OKL_API.G_EXCEPTION_ERROR;
4524 END IF;
4525
4526 -- Assin the KLE Sources to the FA Extension Line
4527 assign_kle_rec_to_fxl_rec(
4528 p_kle_source_rec => l_kle_source_rec
4529 ,x_fxl_rec => l_fxl_rec );
4530
4531 -- Fetch and Populate Inventory Organization Name
4532 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
4533 'Executing Cursor c_inventory_org_id_csr : l_khr_id = ' ||to_char(l_khr_id));
4534 FOR t_rec IN c_inventory_org_id_csr (l_khr_id)
4535 LOOP
4536 -- Assign the Inventory Organization Code
4537 l_fxl_rec.inventory_org_code := t_rec.hrb_name;
4538 FOR tl_sources_in IN l_fxll_tbl.FIRST .. l_fxll_tbl.LAST
4539 LOOP
4540 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
4541 'Executing Cursor c_org_name_csr : p_org_id = ' ||to_char(t_rec.inv_organization_id)
4542 || ' p_ledger_lang = ' || to_char(l_fxll_tbl(tl_sources_in).language));
4543 FOR t_org_rec IN c_org_name_csr (
4544 p_org_id => t_rec.inv_organization_id
4545 ,p_ledger_lang => l_fxll_tbl(tl_sources_in).language)
4546 LOOP
4547 l_fxll_tbl(tl_sources_in).inventory_org_name := t_org_rec.org_name;
4548 END LOOP; -- End for c_org_name_csr
4549
4550 -- Fetch transaction line description
4551 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
4552 'Executing the Cursor get_txl_line_desc_csr. p_txl_id=' || l_txl_id
4553 || ' p_ledger_language=' || l_fxll_tbl(tl_sources_in).language);
4554 FOR t_rec IN get_txl_line_desc_csr(
4555 p_txl_id => l_txl_id
4556 ,p_ledger_lang => l_fxll_tbl(tl_sources_in).language )
4557 LOOP
4558 l_fxll_tbl(tl_sources_in).trans_line_description := t_rec.trans_line_description;
4559 END LOOP; -- End for get_txl_line_desc_csr
4560 END LOOP;
4561 END LOOP; -- End for c_inventory_org_id_csr
4562
4563 -- Stamp the FA Extension Header ID on the FA Extension Line Table also
4564 l_fxl_rec.header_extension_id := l_header_extension_id;
4565 -- Calling insert_row
4566 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
4567 'Calling the okl_fa_extension_pvt.create_fxl_extension' );
4568 okl_fa_extension_pvt.create_fxl_extension(
4569 p_api_version => l_api_version
4570 ,p_init_msg_list => p_init_msg_list
4571 ,x_return_status => l_return_status
4572 ,x_msg_count => x_msg_count
4573 ,x_msg_data => x_msg_data
4574 ,p_fxl_rec => l_fxl_rec
4575 ,p_fxll_tbl => l_fxll_tbl
4576 ,x_fxl_rec => lx_fxl_rec
4577 ,x_fxll_tbl => lx_fxll_tbl
4578 );
4579 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
4580 'After okl_fa_extension_pvt.create_fxl_extension: l_return_status ' || l_return_status );
4581 -- Check the return status and if errored, return the error back
4582 IF (l_return_status = OKL_API.G_RET_STS_UNEXP_ERROR)
4583 THEN
4584 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
4585 ELSIF (l_return_status = OKL_API.G_RET_STS_ERROR)
4586 THEN
4587 RAISE OKL_API.G_EXCEPTION_ERROR;
4588 END IF;
4589 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
4590 'Calling okl_api.end_activity');
4591 okl_api.end_activity(
4592 x_msg_count => x_msg_count
4593 ,x_msg_data => x_msg_data);
4594 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
4595 'END OKL_SLA_ACC_SOURCES_PVT.POPULATE_SOURCES');
4596 x_return_status := OKL_API.G_RET_STS_SUCCESS;
4597 EXCEPTION
4598 ------------------------------------------------------------
4599 -- Exception handling
4600 ------------------------------------------------------------
4601 WHEN OKL_API.G_EXCEPTION_ERROR
4602 THEN
4603 x_return_status := OKL_API.HANDLE_EXCEPTIONS (
4604 p_api_name => l_api_name
4605 ,p_pkg_name => G_PKG_NAME
4606 ,p_exc_name => OKL_API.G_RET_STS_ERROR
4607 ,x_msg_count => x_msg_count
4608 ,x_msg_data => x_msg_data
4609 ,p_api_type => '_PVT');
4610 WHEN OKL_API.G_EXCEPTION_UNEXPECTED_ERROR
4611 THEN
4612 x_return_status := OKL_API.HANDLE_EXCEPTIONS (
4613 p_api_name => l_api_name
4614 ,p_pkg_name => G_PKG_NAME
4615 ,p_exc_name => OKL_API.G_RET_STS_UNEXP_ERROR
4616 ,x_msg_count => x_msg_count
4617 ,x_msg_data => x_msg_data
4618 ,p_api_type => '_PVT');
4619 WHEN OTHERS
4620 THEN
4621 x_return_status := OKL_API.HANDLE_EXCEPTIONS (
4622 p_api_name => l_api_name
4623 ,p_pkg_name => G_PKG_NAME
4624 ,p_exc_name => 'OTHERS'
4625 ,x_msg_count => x_msg_count
4626 ,x_msg_data => x_msg_data
4627 ,p_api_type => '_PVT');
4628 END populate_sources;
4629
4630 PROCEDURE delete_fa_extension(
4631 p_api_version IN NUMBER
4632 ,p_init_msg_list IN VARCHAR2
4633 ,p_fxhv_rec IN fxhv_rec_type
4634 ,x_fxlv_tbl OUT NOCOPY fxlv_tbl_type
4635 ,x_return_status OUT NOCOPY VARCHAR2
4636 ,x_msg_count OUT NOCOPY NUMBER
4637 ,x_msg_data OUT NOCOPY VARCHAR2
4638 )
4639 IS
4640 -----------------------------------------------------------------
4641 -- Declare Process Variable
4642 -----------------------------------------------------------------
4643 l_api_version CONSTANT NUMBER := 1;
4644 l_api_name CONSTANT VARCHAR2(30) := 'DELETE_TRX_EXTENSION';
4645 l_return_status VARCHAR2(1) := OKL_API.G_RET_STS_SUCCESS;
4646 fxl_index BINARY_INTEGER;
4647 l_fxhv_rec okl_fxh_pvt.fxhv_rec_type;
4648 l_fxlv_tbl okl_fxl_pvt.fxlv_tbl_type;
4649 lx_fxhv_rec okl_fxh_pvt.fxhv_rec_type;
4650 lx_fxlv_tbl okl_fxl_pvt.fxlv_tbl_type;
4651 -- Cursor Definitions
4652 CURSOR get_fa_ext_hdr_id( p_source_id NUMBER, p_source_table VARCHAR2)
4653 IS
4654 SELECT fxh.header_extension_id header_extension_id
4655 FROM okl_ext_fa_header_sources_b fxh
4656 WHERE fxh.source_id = p_source_id
4657 AND fxh.source_table = p_source_table;
4658
4659 CURSOR get_fa_ext_lns_id( p_hdr_ext_id NUMBER)
4660 IS
4661 SELECT fxl.line_extension_id line_extension_id
4662 ,fxl.source_id source_id
4663 ,fxl.source_table source_table
4664 FROM okl_ext_fa_line_sources_b fxl
4665 WHERE fxl.header_extension_id = p_hdr_ext_id;
4666 -- Local Variables for enabling the Debug Statements
4667 l_module CONSTANT fnd_log_messages.module%TYPE := G_MODULE || l_api_name;
4668 l_debug_enabled VARCHAR2(10);
4669 is_debug_procedure_on BOOLEAN;
4670 is_debug_statement_on BOOLEAN;
4671 BEGIN
4672 l_debug_enabled := okl_debug_pub.check_log_enabled;
4673 -- check for logging on PROCEDURE level
4674 is_debug_procedure_on := okl_debug_pub.check_log_on(l_module,FND_LOG.LEVEL_PROCEDURE);
4675 -- check for logging on STATEMENT level
4676 is_debug_statement_on := okl_debug_pub.check_log_on(l_module,FND_LOG.LEVEL_STATEMENT);
4677 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
4678 'begin debug OKLRSLAB.pls call ' || l_api_name);
4679 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
4680 'BEGIN API OKL_SLA_ACC_SOURCES_PVT.DELETE_TRX_EXTENSION');
4681 l_return_status := OKL_API.G_RET_STS_SUCCESS;
4682 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
4683 'Calling OKL_API.START_ACTIVITY');
4684 l_return_status := OKL_API.START_ACTIVITY(
4685 p_api_name => l_api_name
4686 ,p_pkg_name => g_pkg_name
4687 ,p_init_msg_list => p_init_msg_list
4688 ,l_api_version => l_api_version
4689 ,p_api_version => p_api_version
4690 ,p_api_type => '_PVT'
4691 ,x_return_status => l_return_status);
4692 IF (l_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
4693 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
4694 ELSIF (l_return_status = OKL_API.G_RET_STS_ERROR) THEN
4695 RAISE OKL_API.G_EXCEPTION_ERROR;
4696 END IF;
4697 -- Actual Logic Starts Here ..
4698 l_fxhv_rec := p_fxhv_rec;
4699 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
4700 'Source ID=' || to_char(l_fxhv_rec.source_id) || 'Source Header Table=' || l_fxhv_rec.source_table );
4701 IF ( l_fxhv_rec.source_id = OKL_API.G_MISS_NUM or l_fxhv_rec.source_id IS NULL )
4702 THEN
4703 OKL_API.set_message(
4704 p_app_name => G_APP_NAME
4705 ,p_msg_name => G_INVALID_VALUE
4706 ,p_token1 => G_COL_NAME_TOKEN
4707 ,p_token1_value => 'FXH.SOURCE_ID');
4708 l_return_status := OKL_API.G_RET_STS_UNEXP_ERROR;
4709 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
4710 END IF;
4711 IF ( l_fxhv_rec.source_table = OKL_API.G_MISS_CHAR OR l_fxhv_rec.source_table IS NULL
4712 OR l_fxhv_rec.source_table NOT IN ( G_TRX_ASSETS) )
4713 THEN
4714 OKL_API.set_message(
4715 p_app_name => G_APP_NAME
4716 ,p_msg_name => G_INVALID_VALUE
4717 ,p_token1 => G_COL_NAME_TOKEN
4718 ,p_token1_value => 'FXH.SOURCE_TABLE');
4719 l_return_status := OKL_API.G_RET_STS_UNEXP_ERROR;
4720 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
4721 END IF;
4722 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
4723 'Fetch the Extension Header ID by executing cursor get_txl_ext_hdr_id' );
4724 FOR t_rec IN get_fa_ext_hdr_id(
4725 p_source_id => l_fxhv_rec.source_id
4726 ,p_source_table => l_fxhv_rec.source_table)
4727 LOOP
4728 l_fxhv_rec.header_extension_id := t_rec.header_extension_id;
4729 END LOOP;
4730 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
4731 'Extension Header ID To be Deleted=' || TO_CHAR(l_fxhv_rec.header_extension_id));
4732
4733 -- Fetch the Transaction Extension Line IDs to be deleted
4734 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
4735 'Extension Line ID(s) To be Deleted=');
4736 fxl_index := 1;
4737 FOR t_rec IN get_fa_ext_lns_id( p_hdr_ext_id => l_fxhv_rec.header_extension_id)
4738 LOOP
4739 l_fxlv_tbl(fxl_index).line_extension_id := t_rec.line_extension_id;
4740 l_fxlv_tbl(fxl_index).source_id := t_rec.source_id;
4741 l_fxlv_tbl(fxl_index).source_table := t_rec.source_table;
4742 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
4743 'LINE_EXTENSION_ID[' || fxl_index || '] = ' || TO_CHAR(l_fxlv_tbl(fxl_index).line_extension_id) );
4744 -- Increment i
4745 fxl_index := fxl_index + 1;
4746 END LOOP; -- End get_trans_line_ids
4747 -- Store the Transaction Line IDs and Line Source Tables so as to return back
4748 x_fxlv_tbl := l_fxlv_tbl;
4749
4750 -- Delete the FA Extension Lines by calling the TAPI first
4751 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
4752 'calling the okl_fa_extension_pvt okl_fxl_pvt.delete_row Line Count=' || l_fxlv_tbl.COUNT );
4753 okl_fa_extension_pvt.delete_fxh_extension(
4754 p_api_version => p_api_version
4755 ,p_init_msg_list => p_init_msg_list
4756 ,x_return_status => x_return_status
4757 ,x_msg_count => x_msg_count
4758 ,x_msg_data => x_msg_data
4759 ,p_fxhv_rec => l_fxhv_rec
4760 );
4761 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
4762 'After okl_fa_extension_pvt.delete_fxh_extension: l_return_status ' || l_return_status );
4763 -- Check the return status and if errored, return the error back
4764 IF (l_return_status = OKL_API.G_RET_STS_UNEXP_ERROR)
4765 THEN
4766 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
4767 ELSIF (l_return_status = OKL_API.G_RET_STS_ERROR) THEN
4768 RAISE OKL_API.G_EXCEPTION_ERROR;
4769 END IF;
4770 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
4771 'Calling okl_api.end_activity');
4772 okl_api.end_activity(
4773 x_msg_count => x_msg_count
4774 ,x_msg_data => x_msg_data);
4775 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
4776 'END OKL_SLA_ACC_SOURCES_PVT.DELETE_TRX_EXTENSION');
4777 x_return_status := OKL_API.G_RET_STS_SUCCESS;
4778 EXCEPTION
4779 ------------------------------------------------------------
4780 -- Exception handling
4781 ------------------------------------------------------------
4782 WHEN OKL_API.G_EXCEPTION_ERROR
4783 THEN
4784 x_return_status := OKL_API.HANDLE_EXCEPTIONS (
4785 p_api_name => l_api_name
4786 ,p_pkg_name => G_PKG_NAME
4787 ,p_exc_name => OKL_API.G_RET_STS_ERROR
4788 ,x_msg_count => x_msg_count
4789 ,x_msg_data => x_msg_data
4790 ,p_api_type => '_PVT');
4791 WHEN OKL_API.G_EXCEPTION_UNEXPECTED_ERROR
4792 THEN
4793 x_return_status := OKL_API.HANDLE_EXCEPTIONS (
4794 p_api_name => l_api_name
4795 ,p_pkg_name => G_PKG_NAME
4796 ,p_exc_name => OKL_API.G_RET_STS_UNEXP_ERROR
4797 ,x_msg_count => x_msg_count
4798 ,x_msg_data => x_msg_data
4799 ,p_api_type => '_PVT');
4800 WHEN OTHERS
4801 THEN
4802 x_return_status := OKL_API.HANDLE_EXCEPTIONS (
4803 p_api_name => l_api_name
4804 ,p_pkg_name => G_PKG_NAME
4805 ,p_exc_name => 'OTHERS'
4806 ,x_msg_count => x_msg_count
4807 ,x_msg_data => x_msg_data
4808 ,p_api_type => '_PVT');
4809 END delete_fa_extension;
4810
4811 ------------------------------------------------------------------------------
4812 -- Start of comments
4813 -- API name : assign_khr_rec_to_rxhv_rec
4814 -- Pre-reqs : None
4815 -- Function : assign khr rec to rxhv rec for AR OKL Transactions
4816 -- Parameters :
4817 -- IN : p_khr_source_rec khr_source_rec_type
4818 -- OUT : x_rxhv_rec rxhv_rec_type
4819 -- Version : 1.0
4820 -- History : Prashant Jain created
4821 -- End of comments
4822 ------------------------------------------------------------------------------
4823 -- Changes for Bug# 6268782 : PRASJAIN
4824 -- 1. func name assign_khr_rec_to_rxhv_rec to assign_khr_rec_to_rxh_rec
4825 -- 2. out param rxhv_rec_type to rxh_rec_type
4826 ------------------------------------------------------------------------------
4827 PROCEDURE assign_khr_rec_to_rxh_rec(
4828 p_khr_source_rec IN khr_source_rec_type
4829 ,x_rxh_rec IN OUT NOCOPY rxh_rec_type
4830 )
4831 AS
4832 BEGIN
4833 x_rxh_rec.khr_id := p_khr_source_rec.khr_id;
4834 x_rxh_rec.contract_number := p_khr_source_rec.contract_number;
4835 x_rxh_rec.contract_currency_code := p_khr_source_rec.contract_currency_code;
4836 x_rxh_rec.contract_effective_from := p_khr_source_rec.contract_effective_from;
4837 x_rxh_rec.product_name := p_khr_source_rec.product_name;
4838 x_rxh_rec.book_classification_code:= p_khr_source_rec.book_classification_code;
4839 x_rxh_rec.tax_owner_code := p_khr_source_rec.tax_owner_code;
4840 x_rxh_rec.rev_rec_method_code := p_khr_source_rec.rev_rec_method_code;
4841 x_rxh_rec.int_calc_method_code := p_khr_source_rec.int_calc_method_code;
4842 x_rxh_rec.vendor_program_number := p_khr_source_rec.vendor_program_number;
4843 x_rxh_rec.converted_number := p_khr_source_rec.converted_number;
4844 x_rxh_rec.converted_account_flag := p_khr_source_rec.converted_account_flag;
4845 x_rxh_rec.assignable_flag := p_khr_source_rec.assignable_flag;
4846 x_rxh_rec.po_order_number := p_khr_source_rec.po_order_number;
4847 x_rxh_rec.accrual_override_flag := p_khr_source_rec.accrual_override_flag;
4848 x_rxh_rec.rent_ia_contract_number := p_khr_source_rec.rent_ia_contract_number;
4849 x_rxh_rec.rent_ia_product_name := p_khr_source_rec.rent_ia_product_name;
4850 x_rxh_rec.rent_ia_accounting_code := p_khr_source_rec.rent_ia_accounting_code;
4851 x_rxh_rec.res_ia_contract_number := p_khr_source_rec.res_ia_contract_number;
4852 x_rxh_rec.res_ia_product_name := p_khr_source_rec.res_ia_product_name;
4853 x_rxh_rec.res_ia_accounting_code := p_khr_source_rec.res_ia_accounting_code;
4854 x_rxh_rec.khr_attribute_category := p_khr_source_rec.khr_attribute_category;
4855 x_rxh_rec.khr_attribute1 := p_khr_source_rec.khr_attribute1;
4856 x_rxh_rec.khr_attribute2 := p_khr_source_rec.khr_attribute2;
4857 x_rxh_rec.khr_attribute3 := p_khr_source_rec.khr_attribute3;
4858 x_rxh_rec.khr_attribute4 := p_khr_source_rec.khr_attribute4;
4859 x_rxh_rec.khr_attribute5 := p_khr_source_rec.khr_attribute5;
4860 x_rxh_rec.khr_attribute6 := p_khr_source_rec.khr_attribute6;
4861 x_rxh_rec.khr_attribute7 := p_khr_source_rec.khr_attribute7;
4862 x_rxh_rec.khr_attribute8 := p_khr_source_rec.khr_attribute8;
4863 x_rxh_rec.khr_attribute9 := p_khr_source_rec.khr_attribute9;
4864 x_rxh_rec.khr_attribute10 := p_khr_source_rec.khr_attribute10;
4865 x_rxh_rec.khr_attribute11 := p_khr_source_rec.khr_attribute11;
4866 x_rxh_rec.khr_attribute12 := p_khr_source_rec.khr_attribute12;
4867 x_rxh_rec.khr_attribute13 := p_khr_source_rec.khr_attribute13;
4868 x_rxh_rec.khr_attribute14 := p_khr_source_rec.khr_attribute14;
4869 x_rxh_rec.khr_attribute15 := p_khr_source_rec.khr_attribute15;
4870 x_rxh_rec.cust_attribute_category := p_khr_source_rec.cust_attribute_category;
4871 x_rxh_rec.cust_attribute1 := p_khr_source_rec.cust_attribute1;
4872 x_rxh_rec.cust_attribute2 := p_khr_source_rec.cust_attribute2;
4873 x_rxh_rec.cust_attribute3 := p_khr_source_rec.cust_attribute3;
4874 x_rxh_rec.cust_attribute4 := p_khr_source_rec.cust_attribute4;
4875 x_rxh_rec.cust_attribute5 := p_khr_source_rec.cust_attribute5;
4876 x_rxh_rec.cust_attribute6 := p_khr_source_rec.cust_attribute6;
4877 x_rxh_rec.cust_attribute7 := p_khr_source_rec.cust_attribute7;
4878 x_rxh_rec.cust_attribute8 := p_khr_source_rec.cust_attribute8;
4879 x_rxh_rec.cust_attribute9 := p_khr_source_rec.cust_attribute9;
4880 x_rxh_rec.cust_attribute10 := p_khr_source_rec.cust_attribute10;
4881 x_rxh_rec.cust_attribute11 := p_khr_source_rec.cust_attribute11;
4882 x_rxh_rec.cust_attribute12 := p_khr_source_rec.cust_attribute12;
4883 x_rxh_rec.cust_attribute13 := p_khr_source_rec.cust_attribute13;
4884 x_rxh_rec.cust_attribute14 := p_khr_source_rec.cust_attribute14;
4885 x_rxh_rec.cust_attribute15 := p_khr_source_rec.cust_attribute15;
4886 x_rxh_rec.contract_status_code := p_khr_source_rec.contract_status_code;
4887 x_rxh_rec.inv_agrmnt_number := p_khr_source_rec.inv_agrmnt_number;
4888 x_rxh_rec.inv_agrmnt_effective_from := p_khr_source_rec.inv_agrmnt_effective_from;
4889 x_rxh_rec.inv_agrmnt_product_name := p_khr_source_rec.inv_agrmnt_product_name;
4890 x_rxh_rec.inv_agrmnt_currency_code := p_khr_source_rec.inv_agrmnt_currency_code;
4891 x_rxh_rec.inv_agrmnt_synd_code := p_khr_source_rec.inv_agrmnt_synd_code;
4892 x_rxh_rec.inv_agrmnt_pool_number := p_khr_source_rec.inv_agrmnt_pool_number;
4893 x_rxh_rec.inv_agrmnt_status_code := p_khr_source_rec.inv_agrmnt_status_code;
4894 x_rxh_rec.scs_code := p_khr_source_rec.scs_code;
4895 END assign_khr_rec_to_rxh_rec;
4896
4897 ------------------------------------------------------------------------------
4898 -- Start of comments
4899 -- API name : assign_kle_rec_to_rxlv_rec
4900 -- Pre-reqs : None
4901 -- Function : assign kle rec to rxlv rec for AR OKL Transactions
4902 -- Parameters :
4903 -- IN : p_kle_source_rec kle_source_rec_type
4904 -- OUT : x_rxlv_rec rxlv_rec_type
4905 -- Version : 1.0
4906 -- History : Prashant Jain created
4907 -- End of comments
4908 ------------------------------------------------------------------------------
4909 -- Changes for Bug# 6268782 : PRASJAIN
4910 -- 1. func name assign_kle_rec_to_rxlv_rec to assign_kle_rec_to_rxl_rec
4911 -- 2. out param rxlv_rec_type to rxl_rec_type
4912 ------------------------------------------------------------------------------
4913 PROCEDURE assign_kle_rec_to_rxl_rec(
4914 p_kle_source_rec IN kle_source_rec_type
4915 ,x_rxl_rec IN OUT NOCOPY rxl_rec_type
4916 )
4917 AS
4918 BEGIN
4919 x_rxl_rec.kle_id := p_kle_source_rec.kle_id;
4920 x_rxl_rec.asset_number := p_kle_source_rec.asset_number;
4921 x_rxl_rec.contract_line_number := p_kle_source_rec.contract_line_number;
4922 x_rxl_rec.asset_vendor_name := p_kle_source_rec.asset_vendor_name;
4923 -- added by zrehman Bug#6707320 for Party Merge impact on Accounting sources tables start
4924 x_rxl_rec.asset_vendor_id := p_kle_source_rec.asset_vendor_id;
4925 -- added by zrehman Bug#6707320 for Party Merge impact on Accounting sources tables end
4926 x_rxl_rec.installed_site_id := p_kle_source_rec.installed_site_id;
4927 x_rxl_rec.fixed_asset_location_name := p_kle_source_rec.fixed_asset_location_name;
4928 x_rxl_rec.contract_line_type := p_kle_source_rec.line_type_code;
4929 x_rxl_rec.line_attribute_category := p_kle_source_rec.line_attribute_category;
4930 x_rxl_rec.line_attribute1 := p_kle_source_rec.line_attribute1;
4931 x_rxl_rec.line_attribute2 := p_kle_source_rec.line_attribute2;
4932 x_rxl_rec.line_attribute3 := p_kle_source_rec.line_attribute3;
4933 x_rxl_rec.line_attribute4 := p_kle_source_rec.line_attribute4;
4934 x_rxl_rec.line_attribute5 := p_kle_source_rec.line_attribute5;
4935 x_rxl_rec.line_attribute6 := p_kle_source_rec.line_attribute6;
4936 x_rxl_rec.line_attribute7 := p_kle_source_rec.line_attribute7;
4937 x_rxl_rec.line_attribute8 := p_kle_source_rec.line_attribute8;
4938 x_rxl_rec.line_attribute9 := p_kle_source_rec.line_attribute9;
4939 x_rxl_rec.line_attribute10 := p_kle_source_rec.line_attribute10;
4940 x_rxl_rec.line_attribute11 := p_kle_source_rec.line_attribute11;
4941 x_rxl_rec.line_attribute12 := p_kle_source_rec.line_attribute12;
4942 x_rxl_rec.line_attribute13 := p_kle_source_rec.line_attribute13;
4943 x_rxl_rec.line_attribute14 := p_kle_source_rec.line_attribute14;
4944 x_rxl_rec.line_attribute15 := p_kle_source_rec.line_attribute15;
4945 END assign_kle_rec_to_rxl_rec;
4946
4947 ------------------------------------------------------------------------------
4948 -- Start of comments
4949 -- API name : populate_ar_sources
4950 -- Pre-reqs : None
4951 -- Function : populate sources for OKL AR Transactions
4952 -- Parameters :
4953 -- IN : rxhv_rec_type.source_id IN NUMBER Required
4954 -- rxhv_rec_type.source_table IN VARCHAR2 Required
4955
4956 -- rxhv_rec_type.khr_id IN NUMBER Required
4957 -- rxlv_rec_type.kle_id IN NUMBER Optional
4958 -- rxhv_rec_type.try_id IN NUMBER Required
4959 -- rxlv_rec_type.sty_id IN NUMBER Optional
4960 -- rxlv_rec_type.source_id IN NUMBER Required
4961 -- rxlv_rec_type.source_table IN VARCHAR2 Required
4962 -- History : Prashant Jain created
4963 -- Version : 1.0
4964 -- End of comments
4965 ------------------------------------------------------------------------------
4966 PROCEDURE populate_ar_sources(
4967 p_api_version IN NUMBER
4968 ,p_init_msg_list IN VARCHAR2
4969 ,p_rxhv_rec IN rxhv_rec_type
4970 ,p_rxlv_rec IN rxlv_rec_type
4971 ,p_acc_sources_rec IN asev_rec_type
4972 ,x_return_status OUT NOCOPY VARCHAR2
4973 ,x_msg_count OUT NOCOPY NUMBER
4974 ,x_msg_data OUT NOCOPY VARCHAR2
4975 )
4976 IS
4977 -- Cursor to fetch header_extension_id
4978 CURSOR c_header_extension_id_csr (
4979 p_header_source_id NUMBER
4980 ,p_header_source_table VARCHAR2
4981 ,p_khr_id NUMBER)
4982 IS
4983 SELECT hdr.header_extension_id header_extension_id
4984 FROM okl_ext_ar_header_sources_b hdr
4985 WHERE hdr.source_id = p_header_source_id
4986 AND hdr.khr_id = p_khr_id;
4987
4988 -- Cursor to fetch trans number
4989 CURSOR c_trans_number_csr (p_header_source_id NUMBER)
4990 IS
4991 SELECT tai.trx_number trans_number
4992 ,tai.tcn_id tai_tcn_id
4993 FROM okl_trx_ar_invoices_b tai
4994 WHERE tai.id = p_header_source_id;
4995
4996 -- Cursor to fetch the Qte_id from the AR Transaction Header
4997 --
4998 CURSOR get_tai_tcn_qte_id_csr( p_tcn_id NUMBER)
4999 IS
5000 SELECT tcn.qte_id qte_id
5001 FROM okl_trx_contracts_all tcn
5002 WHERE tcn.id = p_tcn_id;
5003 -----------------------------------------------------------------
5004 -- Declare Process Variable
5005 -----------------------------------------------------------------
5006 l_api_version CONSTANT NUMBER := 1;
5007 l_api_name CONSTANT VARCHAR2(30) := 'populate_ar_sources';
5008 l_return_status VARCHAR2(1) := OKL_API.G_RET_STS_SUCCESS;
5009 -----------------------------------------------------------------
5010 -- Local Variables
5011 -----------------------------------------------------------------
5012 l_khr_id NUMBER;
5013 l_try_id NUMBER;
5014 l_kle_id NUMBER;
5015 l_sty_id NUMBER;
5016 l_ledger_id NUMBER;
5017 l_ledger_language VARCHAR2(12);
5018 l_header_source_id NUMBER;
5019 l_header_source_table VARCHAR2(30);
5020 l_template_id NUMBER;
5021 l_source_id NUMBER;
5022 l_source_table VARCHAR2(30);
5023 l_header_extension_id NUMBER;
5024 l_pk_attributes VARCHAR2(1000);
5025 l_tcn_id NUMBER;
5026 l_line_style VARCHAR2(30);
5027 l_parent_line_id NUMBER;
5028 -- KHR and KLE Based Record Structures
5029 l_khr_source_rec khr_source_rec_type;
5030 l_kle_source_rec kle_source_rec_type;
5031 -- Record structures based on the Cursor Definitions
5032 l_termination_qte_csr_rec c_termination_qte_csr%ROWTYPE;
5033 -- Record Structures based on OKL AR Extension Header and Line Tables
5034 -- Start : PRASJAIN : Bug# 6268782
5035 l_rxh_rec rxh_rec_type;
5036 lx_rxh_rec rxh_rec_type;
5037 l_rxhl_tbl rxhl_tbl_type;
5038 lx_rxhl_tbl rxhl_tbl_type;
5039 l_rxl_rec rxl_rec_type;
5040 lx_rxl_rec rxl_rec_type;
5041 l_rxll_tbl rxll_tbl_type;
5042 lx_rxll_tbl rxll_tbl_type;
5043 l_led_lang_tbl led_lang_tbl_type;
5044 -- End : PRASJAIN : Bug# 6268782
5045 l_ledger_lang_rec c_ledger_lang_csr%ROWTYPE;
5046 -- Local Variables for enabling the Debug Statements
5047 l_module CONSTANT fnd_log_messages.module%TYPE := G_MODULE || l_api_name;
5048 l_debug_enabled VARCHAR2(10);
5049 is_debug_procedure_on BOOLEAN;
5050 is_debug_statement_on BOOLEAN;
5051 tl_sources_in NUMBER := 1;
5052 BEGIN
5053 l_debug_enabled := okl_debug_pub.check_log_enabled;
5054 -- check for logging on PROCEDURE level
5055 is_debug_procedure_on := okl_debug_pub.check_log_on(l_module,FND_LOG.LEVEL_PROCEDURE);
5056 -- check for logging on STATEMENT level
5057 is_debug_statement_on := okl_debug_pub.check_log_on(l_module,FND_LOG.LEVEL_STATEMENT);
5058 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
5059 'begin debug OKLRSLAB.pls call ' || l_api_name);
5060 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
5061 'BEGIN API OKL_SLA_ACC_SOURCES_PVT.populate_ar_sources');
5062 l_return_status := OKL_API.G_RET_STS_SUCCESS;
5063 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
5064 'Calling OKL_API.START_ACTIVITY');
5065 l_return_status := OKL_API.START_ACTIVITY(
5066 p_api_name => l_api_name
5067 ,p_pkg_name => g_pkg_name
5068 ,p_init_msg_list => p_init_msg_list
5069 ,l_api_version => l_api_version
5070 ,p_api_version => p_api_version
5071 ,p_api_type => '_PVT'
5072 ,x_return_status => l_return_status);
5073 IF (l_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
5074 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
5075 ELSIF (l_return_status = OKL_API.G_RET_STS_ERROR) THEN
5076 RAISE OKL_API.G_EXCEPTION_ERROR;
5077 END IF;
5078 -- Validations to be done
5079 -- Validation 1:
5080 -- The following attributes should not be NULL
5081 -- hdr.source_id, hdr.source_table, khr_id, try_id
5082 -- line.source_id, line.source_table
5083 -- Bug 6328168: sty_id is made optional as for On-Account Credit Memo
5084 -- its not mandatory at all
5085 l_pk_attributes := NULL;
5086 IF p_rxhv_rec.source_id IS NULL OR
5087 p_rxhv_rec.source_id = OKL_API.G_MISS_NUM
5088 THEN
5089 IF l_pk_attributes IS NOT NULL
5090 THEN
5091 l_pk_attributes := l_pk_attributes || ' , ';
5092 END IF;
5093 l_pk_attributes := l_pk_attributes || 'RXH.SOURCE_ID';
5094 END IF;
5095 IF p_rxhv_rec.source_table IS NULL OR
5096 p_rxhv_rec.source_table = OKL_API.G_MISS_CHAR
5097 THEN
5098 IF l_pk_attributes IS NOT NULL
5099 THEN
5100 l_pk_attributes := l_pk_attributes || ' , ';
5101 END IF;
5102 l_pk_attributes := l_pk_attributes || 'RXH.SOURCE_TABLE';
5103 END IF;
5104 IF p_rxhv_rec.khr_id IS NULL OR
5105 p_rxhv_rec.khr_id = OKL_API.G_MISS_NUM
5106 THEN
5107 IF l_pk_attributes IS NOT NULL
5108 THEN
5109 l_pk_attributes := l_pk_attributes || ' , ';
5110 END IF;
5111 l_pk_attributes := l_pk_attributes || 'KHR_ID';
5112 END IF;
5113 IF p_rxhv_rec.try_id IS NULL OR
5114 p_rxhv_rec.try_id = OKL_API.G_MISS_NUM
5115 THEN
5116 IF l_pk_attributes IS NOT NULL
5117 THEN
5118 l_pk_attributes := l_pk_attributes || ' , ';
5119 END IF;
5120 l_pk_attributes := l_pk_attributes || 'TRY_ID';
5121 END IF;
5122 -- For few Transactions kle_id is not mandatory at all ..
5123 -- hence knocking off kle_id as the mandatory parameter
5124 IF p_rxlv_rec.source_id IS NULL OR
5125 p_rxlv_rec.source_id = OKL_API.G_MISS_NUM
5126 THEN
5127 IF l_pk_attributes IS NOT NULL
5128 THEN
5129 l_pk_attributes := l_pk_attributes || ' , ';
5130 END IF;
5131 l_pk_attributes := l_pk_attributes || 'RXL.SOURCE_ID';
5132 END IF;
5133 IF p_rxlv_rec.source_table IS NULL OR
5134 p_rxlv_rec.source_table = OKL_API.G_MISS_CHAR
5135 THEN
5136 IF l_pk_attributes IS NOT NULL
5137 THEN
5138 l_pk_attributes := l_pk_attributes || ' , ';
5139 END IF;
5140 l_pk_attributes := l_pk_attributes || 'RXL.SOURCE_TABLE';
5141 END IF;
5142 IF LENGTH(l_pk_attributes) > 0
5143 THEN
5144 -- Raise an Exception
5145 OKL_API.set_message(
5146 p_app_name => G_APP_NAME
5147 ,p_msg_name => G_INVALID_VALUE
5148 ,p_token1 => G_COL_NAME_TOKEN
5149 ,p_token1_value => l_pk_attributes);
5150 l_return_status := OKL_API.G_RET_STS_UNEXP_ERROR;
5151 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
5152 END IF;
5153 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
5154 'Validation 1 Successfull !');
5155 -- Validation 2:
5156 -- Source Table should be OKL_TXD_AR_LN_DTLS_B/OKL_TXL_ADJSTS_LNS_B
5157 -- Comparing with the Upper(Source_table) as billing is passing the value in the
5158 -- lower cases currently, need to knock this upper once billing passes it correctly
5159 IF UPPER(p_rxlv_rec.source_table) NOT IN ( G_TXD_AR_LN_DTLS_B, G_TXL_ADJSTS_LNS_B )
5160 THEN
5161 -- Raise an Exception
5162 OKL_API.set_message(
5163 p_app_name => G_APP_NAME
5164 ,p_msg_name => G_INVALID_VALUE
5165 ,p_token1 => G_COL_NAME_TOKEN
5166 ,p_token1_value => 'SOURCE_TABLE');
5167 l_return_status := OKL_API.G_RET_STS_UNEXP_ERROR;
5168 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
5169 END IF;
5170 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
5171 'Validation 2 Successfull !');
5172 -- Copy input rec to local variable
5173 -- Start : PRASJAIN : Bug# 6268782
5174 l_rxh_rec.source_id := p_rxhv_rec.source_id;
5175 l_rxh_rec.source_table := p_rxhv_rec.source_table;
5176 l_rxh_rec.khr_id := p_rxhv_rec.khr_id;
5177 l_rxh_rec.try_id := p_rxhv_rec.try_id;
5178
5179 l_rxl_rec.kle_id := p_rxlv_rec.kle_id;
5180 l_rxl_rec.sty_id := p_rxlv_rec.sty_id;
5181 l_rxl_rec.source_id := p_rxlv_rec.source_id;
5182 l_rxl_rec.source_table := p_rxlv_rec.source_table;
5183 -- End : PRASJAIN : Bug# 6268782
5184 -- Make sure that the source_tables are in upper case
5185 l_rxh_rec.source_table := UPPER(l_rxh_rec.source_table);
5186 l_rxl_rec.source_table := UPPER(l_rxl_rec.source_table);
5187 -- Copy the input parameters to the local variables
5188 l_header_source_id := l_rxh_rec.source_id;
5189 l_header_source_table := l_rxh_rec.source_table;
5190 l_khr_id := l_rxh_rec.khr_id;
5191 l_try_id := l_rxh_rec.try_id;
5192 l_source_id := l_rxl_rec.source_id;
5193 l_source_table := l_rxl_rec.source_table;
5194 l_kle_id := l_rxl_rec.kle_id; -- For Subsidy this is will be a SUBSIDY Line but not the Asset
5195 l_sty_id := l_rxl_rec.sty_id;
5196
5197 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
5198 '**** KLE_ID = ' || l_kle_id );
5199 IF l_kle_id IS NOT NULL OR l_kle_id <> OKL_API.G_MISS_NUM
5200 THEN
5201 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
5202 'Executing the Cursor get_line_style_csr kle_id=' || l_rxl_rec.kle_id );
5203 FOR t_rec IN get_line_style_csr(p_kle_id => l_rxl_rec.kle_id )
5204 LOOP
5205 l_line_style := t_rec.line_style;
5206 IF l_line_style = 'SUBSIDY'
5207 THEN
5208 l_parent_line_id := t_rec.parent_line_id;
5209 END IF;
5210 END LOOP;
5211 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
5212 '**** LINE STYLE = ' || l_line_style || ' PARENT LINE ID = ' || l_parent_line_id );
5213 END IF; -- IF l_kle_id IS NOT NULL OR l_kle_id <> OKL_API.G_MISS_NUM
5214
5215 -- Fetch ledger id and ledger language associated to the contracts
5216 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
5217 'Executing the Cursor c_khr_to_ledger_id_csr. p_khr_id=' || TO_CHAR(l_khr_id));
5218 FOR t_rec IN c_khr_to_ledger_id_csr( p_khr_id => l_khr_id )
5219 LOOP
5220 l_ledger_id := t_rec.ledger_id;
5221 END LOOP;
5222
5223 -- Fetch the ledger language in order to populate the sources
5224 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
5225 'Executing the Cursor c_ledger_lang_csr. p_ledger_id=' || TO_CHAR(l_ledger_id));
5226 FOR t_rec IN c_ledger_lang_csr( p_ledger_id => l_ledger_id )
5227 LOOP
5228 l_ledger_lang_rec := t_rec;
5229 -- Start : PRASJAIN : Bug# 6268782
5230 l_led_lang_tbl(tl_sources_in).language := t_rec.language_code;
5231 l_rxll_tbl(tl_sources_in).language := t_rec.language_code;
5232 tl_sources_in := tl_sources_in + 1;
5233 -- End : PRASJAIN : Bug# 6268782
5234 END LOOP;
5235
5236 -- Logic Description:
5237 -- 1. The OKL AR Extension Header _B/_TL sources will be captured only once
5238 -- for a KHR_ID.
5239 -- 2. For every AR Transaction Line, there will be a single record in the
5240 -- OKL AR Extension Line _B/_TL
5241 -- For Eg., if a Transaction is having 10 transaction lines with two different khr_id1, khr_id2
5242 -- there will be only two records in the Header but 10 transaction lines in Extension Line.
5243 -- Hence, for every Transaction Line check whether the KHR Sources have been captured
5244 -- already or not by passing the Transaction ID and KHR_ID
5245 -- Fetch header extension id
5246 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
5247 'Executing the Cursor c_header_extension_id_csr.
5248 p_header_source_id=' || TO_CHAR(l_header_source_id)
5249 || ' p_header_source_table=' || l_header_source_table
5250 || ' p_khr_id= ' || TO_CHAR(l_khr_id));
5251 l_header_extension_id := NULL;
5252 FOR t_rec IN c_header_extension_id_csr(
5253 p_header_source_id => l_header_source_id
5254 ,p_header_source_table => l_header_source_table
5255 ,p_khr_id => l_khr_id )
5256 LOOP
5257 l_header_extension_id := t_rec.header_extension_id;
5258 END LOOP; -- End for c_header_extension_id_csr
5259
5260 -- If l_header_extension_id is NOT NULL, then it means the KHR sources are already captured
5261 -- So, populate extension line sources only.
5262 -- Else Populate both the Extension Header and Line Sources.
5263 IF l_header_extension_id IS NULL
5264 THEN
5265 -- Prepare khr_source_rec_type with khr_id and ledger_language
5266 l_khr_source_rec.khr_id := l_khr_id;
5267 -- Calling populate_khr_sources to fetch the KHR Sources
5268 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
5269 'Calling the populate_khr_sources' );
5270 populate_khr_sources( -- Change : PRASJAIN : Bug# 6268782
5271 p_api_version => l_api_version
5272 ,p_init_msg_list => p_init_msg_list
5273 ,x_khr_source_rec => l_khr_source_rec
5274 ,x_led_lang_tbl => l_led_lang_tbl
5275 ,x_return_status => l_return_status
5276 ,x_msg_count => x_msg_count
5277 ,x_msg_data => x_msg_data );
5278 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
5279 'After populate_khr_sources: l_return_status ' || l_return_status );
5280 -- Check the return status and if errored, return the error back
5281 IF (l_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
5282 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
5283 ELSIF (l_return_status = OKL_API.G_RET_STS_ERROR) THEN
5284 RAISE OKL_API.G_EXCEPTION_ERROR;
5285 END IF;
5286 -- Assign the KHR Sources to the rxhv_rec
5287 assign_khr_rec_to_rxh_rec(
5288 p_khr_source_rec => l_khr_source_rec
5289 ,x_rxh_rec => l_rxh_rec );
5290
5291 -- Start : PRASJAIN : Bug# 6268782
5292 FOR tl_sources_in IN l_led_lang_tbl.FIRST .. l_led_lang_tbl.LAST
5293 LOOP
5294 l_rxhl_tbl(tl_sources_in).language := l_led_lang_tbl(tl_sources_in).language;
5295 l_rxhl_tbl(tl_sources_in).contract_status := l_led_lang_tbl(tl_sources_in).contract_status;
5296 l_rxhl_tbl(tl_sources_in).inv_agrmnt_status := l_led_lang_tbl(tl_sources_in).inv_agrmnt_status;
5297
5298 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
5299 'Executing the Cursor c_trx_type_name_csr. p_try_id=' ||
5300 l_try_id || 'p_led_lang= ' || l_rxhl_tbl(tl_sources_in).language );
5301 FOR t_rec IN c_trx_type_name_csr(
5302 p_try_id => l_try_id
5303 ,p_led_lang => l_rxhl_tbl(tl_sources_in).language ) -- Change : PRASJAIN : Bug# 6268782
5304 LOOP
5305 l_rxhl_tbl(tl_sources_in).transaction_type_name := t_rec.transaction_type_name;-- Change : PRASJAIN : Bug# 6268782
5306 -- Assign the Trx. Type Class Code also.
5307 l_rxh_rec.trx_type_class_code := t_rec.trx_type_class_code;
5308 END LOOP; -- End for c_trx_type_name_csr
5309 END LOOP;
5310 -- End : PRASJAIN : Bug# 6268782
5311
5312
5313 -- Fetch the Transaction Number
5314 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
5315 'Executing the Cursor c_trans_number_csr. p_header_source_id=' || l_header_source_id );
5316 FOR t_rec IN c_trans_number_csr( p_header_source_id => l_header_source_id )
5317 LOOP
5318 l_rxh_rec.trans_number := t_rec.trans_number;
5319 l_tcn_id := t_rec.tai_tcn_id;
5320 END LOOP; -- End for c_trans_number_csr
5321
5322 -- Fetch the Transaction Number
5323 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
5324 'Executing the Cursor get_tai_tcn_qte_id_csr. p_tcn_id=' || l_tcn_id );
5325 FOR t_rec IN get_tai_tcn_qte_id_csr(p_tcn_id => l_tcn_id )
5326 LOOP
5327 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
5328 'Executing the Cursor c_termination_qte_csr. l_qte_id=' || t_rec.qte_id );
5329 -- Cursor to fetch termination quote attr
5330 FOR l_termination_qte_csr_rec IN c_termination_qte_csr (l_qte_id => t_rec.qte_id)
5331 LOOP
5332 l_rxh_rec.term_quote_accept_date := l_termination_qte_csr_rec.date_effective_from;
5333 l_rxh_rec.term_quote_num := l_termination_qte_csr_rec.quote_number;
5334 l_rxh_rec.term_quote_type_code := l_termination_qte_csr_rec.qtp_code;
5335 END LOOP; -- c_termination_qte_csr
5336 END LOOP;
5337
5338 IF(p_acc_sources_rec.jtf_sales_reps_pk IS NOT NULL AND
5339 p_acc_sources_rec.jtf_sales_reps_pk <> OKL_API.G_MISS_CHAR) THEN
5340 -- Need to populate the Sales Representative Name
5341 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
5342 'Executing the Cursor c_sales_rep_acc_sources_csr. l_sales_rep_id = ' ||
5343 TO_CHAR(p_acc_sources_rec.jtf_sales_reps_pk) );
5344 FOR t_rec IN c_sales_rep_acc_sources_csr (p_jtf_sales_rep_pk => p_acc_sources_rec.jtf_sales_reps_pk)
5345 LOOP
5346 l_rxh_rec.sales_rep_name := t_rec.name;
5347
5348 END LOOP; -- c_sales_rep_acc_sources_csr
5349 END IF;
5350
5351 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
5352 'Calling the okl_ar_extension_pvt.create_rxh_extension ' || l_rxh_rec.source_id );
5353 okl_ar_extension_pvt.create_rxh_extension( -- Change : PRASJAIN : Bug# 6268782
5354 p_api_version => l_api_version
5355 ,p_init_msg_list => p_init_msg_list
5356 ,x_return_status => l_return_status
5357 ,x_msg_count => x_msg_count
5358 ,x_msg_data => x_msg_data
5359 ,p_rxh_rec => l_rxh_rec
5360 ,p_rxhl_tbl => l_rxhl_tbl
5361 ,x_rxh_rec => lx_rxh_rec
5362 ,x_rxhl_tbl => lx_rxhl_tbl
5363 );
5364 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
5365 'After okl_ar_extension_pvt.create_rxh_extension: l_return_status ' || l_return_status );
5366 -- Check the return status and if errored, return the error back
5367 IF (l_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
5368 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
5369 ELSIF (l_return_status = OKL_API.G_RET_STS_ERROR) THEN
5370 RAISE OKL_API.G_EXCEPTION_ERROR;
5371 END IF;
5372 -- Store the Header Extension ID into the Local Variable l_header_extension_id
5373 l_header_extension_id := lx_rxh_rec.header_extension_id;
5374 END IF;
5375 IF l_kle_id IS NOT NULL AND
5376 l_kle_id <> OKL_API.G_MISS_NUM
5377 THEN
5378 -- Start populating the Sources at the Extension Line Level
5379 -- Prepare kle_source_rec_type with khr_id, kle_id and ledger_language
5380 l_kle_source_rec.khr_id := l_khr_id;
5381 l_kle_source_rec.kle_id := l_kle_id;
5382 IF l_line_style = 'SUBSIDY'
5383 THEN
5384 -- If the Line Style is SUBSIDY, then pass the Asset line id to the
5385 -- Populate KLE Sources to fetch the Asset Details
5386 l_kle_source_rec.kle_id := l_parent_line_id;
5387 END IF;
5388 -- Calling populate_kle_sources only when kle_id is not NULL or G_MISS_NUM
5389 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
5390 'Before Calling the populate_kle_sources' );
5391 populate_kle_sources(
5392 p_api_version => l_api_version
5393 ,p_init_msg_list => p_init_msg_list
5394 ,x_kle_source_rec => l_kle_source_rec
5395 ,x_return_status => l_return_status
5396 ,x_msg_count => x_msg_count
5397 ,x_msg_data => x_msg_data );
5398 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
5399 'After populate_kle_sources: l_return_status ' || l_return_status );
5400 -- Check the return status and if errored, return the error back
5401 IF (l_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
5402 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
5403 ELSIF (l_return_status = OKL_API.G_RET_STS_ERROR) THEN
5404 RAISE OKL_API.G_EXCEPTION_ERROR;
5405 END IF;
5406 -- calling assign_kle_rec_to_rxlv_rec
5407 assign_kle_rec_to_rxl_rec(
5408 p_kle_source_rec => l_kle_source_rec
5409 ,x_rxl_rec => l_rxl_rec );
5410 -- Fetch fee type code
5411 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
5412 'Executing the curosr c_k_lines_csr. p_kle_id= ' || TO_CHAR(l_kle_id));
5413 FOR t_rec IN c_k_lines_csr ( p_kle_id => l_kle_id )
5414 LOOP
5415 l_rxl_rec.fee_type_code := t_rec.fee_type;
5416 END LOOP; -- End for c_k_lines_csr
5417
5418 -- Fetch asset category name
5419 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
5420 'Executing the curosr c_manufacture_model_csr. p_kle_id= ' || TO_CHAR(l_kle_id)
5421 || ' p_khr_id= ' || TO_CHAR(l_khr_id));
5422 FOR t_rec IN c_manufacture_model_csr ( p_kle_id => l_kle_id, p_khr_id => l_khr_id )
5423 LOOP
5424 l_rxl_rec.asset_category_name := t_rec.asset_category_name;
5425 END LOOP; -- End for c_manufacture_model_csr
5426
5427 FOR tl_sources_in IN l_rxll_tbl.FIRST .. l_rxll_tbl.LAST
5428 LOOP
5429 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
5430 'Executing the Cursor c_inventory_item_name_csr. p_inventory_item_id_pk1= ' ||
5431 to_char(p_acc_sources_rec.inventory_item_id_pk1) || ' p_inventory_org_id_pk2=' ||
5432 to_char(p_acc_sources_rec.inventory_org_id_pk2) || ' ledger_language=' ||
5433 l_rxll_tbl(tl_sources_in).language );
5434 FOR t_rec IN c_inventory_item_name_csr(
5435 p_inventory_item_id_pk1 => p_acc_sources_rec.inventory_item_id_pk1
5436 ,p_inventory_org_id_pk2 => p_acc_sources_rec.inventory_org_id_pk2
5437 ,p_ledger_language => l_rxll_tbl(tl_sources_in).language)
5438 LOOP
5439 l_rxll_tbl(tl_sources_in).inventory_item_name := t_rec.description;
5440 l_rxl_rec.inventory_item_name_code := t_rec.b_description;
5441 END LOOP;
5442 END LOOP;
5443 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
5444 'Fetching the Subsidy Sources LINE_STYLE =' || l_line_style );
5445 IF l_line_style = 'SUBSIDY'
5446 THEN
5447 -- Fetch Subsidy Name and Subsidy Party Name
5448 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
5449 'Executing the curosr get_subsidy_details_csr. p_kle_id= ' || TO_CHAR(l_kle_id));
5450 FOR t_rec IN get_subsidy_details_csr ( p_kle_id => l_kle_id )
5451 LOOP
5452 l_rxl_rec.subsidy_name := t_rec.subsidy_name;
5453 l_rxl_rec.subsidy_party_name := t_rec.subsidy_party_name;
5454 -- added by zrehman Bug#6707320 for Party Merge impact on Transaction sources tables start
5455 l_rxl_rec.subsidy_vendor_id := t_rec.subsidy_vendor_id;
5456 -- added by zrehman Bug#6707320 for Party Merge impact on Transaction sources tables end
5457 END LOOP; -- End for c_k_lines_csr
5458 END IF;
5459 --ELSE
5460 -- Populate the l_pxlv_rec with the khr_id, ledger_language
5461 -- but not with the kle_id
5462 -- l_rxl_rec.language := l_ledger_language ;
5463 END IF; -- IF l_kle_id IS NOT NULL OR l_kle_id <> OKL_API.G_MISS_NUM
5464
5465 -- Stamp the Header Extension ID on the Extension Line Table
5466 l_rxl_rec.header_extension_id := l_header_extension_id;
5467
5468 -- Fetch the Account Template ID
5469 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
5470 'Executing the curosr c_account_dist_csr. p_source_id= ' || to_char(l_source_id)
5471 || ' p_source_table= ' || to_char(l_source_table));
5472 FOR t_rec IN c_account_dist_csr (
5473 p_source_id => l_source_id
5474 ,p_source_table => l_source_table)
5475 LOOP
5476 l_template_id := t_rec.template_id;
5477 END LOOP; -- End for c_account_dist_csr
5478
5479 -- Assigning the Memo Indicator to the Extension Line Record structure ..
5480 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
5481 '** AGS Memo Flag ' || p_acc_sources_rec.memo_yn );
5482 l_rxl_rec.memo_flag := p_acc_sources_rec.memo_yn;
5483
5484 -- Fetch Memo Flag and Accounting Template Name using the template_id
5485 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
5486 'Executing the curosr c_ae_templates_csr. template_id= ' || to_char(l_template_id) );
5487 FOR t_rec IN c_ae_templates_csr (p_template_id => l_template_id)
5488 LOOP
5489 l_rxl_rec.accounting_template_name := t_rec.name;
5490 END LOOP; -- End for c_ae_templates_csr
5491
5492 -- Bug 6328168: STY_ID is Optional
5493 IF l_sty_id IS NOT NULL
5494 THEN
5495 -- Fetch contingency code and stream type name
5496 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
5497 'Executing the curosr c_contingency_strm_b_csr. p_sty_id= ' || TO_CHAR(l_sty_id)
5498 || ' Ledger Language = ' || l_ledger_language);
5499 FOR t_rec IN c_contingency_strm_b_csr ( p_sty_id => l_sty_id )
5500 LOOP
5501 l_rxl_rec.contingency_code := t_rec.contingency_code;
5502 l_rxl_rec.stream_type_code := t_rec.stream_type_code;
5503 l_rxl_rec.stream_type_purpose_code := t_rec.stream_type_purpose;
5504 END LOOP; -- End for c_contingency_strm_b_csr
5505 END IF; -- IF l_sty_id IS NOT NULL
5506
5507 -- Fetch contingency code and stream type name
5508 FOR tl_sources_in IN l_rxll_tbl.FIRST .. l_rxll_tbl.LAST
5509 LOOP
5510 -- Bug 6328168: STY_ID is Optional
5511 IF l_sty_id IS NOT NULL
5512 THEN
5513 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
5514 'Executing the curosr c_strm_name_tl_csr. p_sty_id= ' || TO_CHAR(l_sty_id)
5515 || ' Ledger Language = ' || l_rxll_tbl(tl_sources_in).language);
5516 FOR t_rec IN c_strm_name_tl_csr ( p_sty_id => l_sty_id, p_lang => l_rxll_tbl(tl_sources_in).language )
5517 LOOP
5518 l_rxll_tbl(tl_sources_in).stream_type_name := t_rec.stream_type_name;
5519 END LOOP; -- End for c_strm_name_tl_csr
5520 END IF; -- IF l_sty_id IS NOT NULL
5521 -- Unable to find the corresponding Transaction Line Description Column in okl_txl_adjsts_lns_all_tl Table
5522 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
5523 'Executing the curosr c_tld_line_description. p_tld_tl_id= ' || TO_CHAR(l_source_id)
5524 || ' p_lang = ' || l_rxll_tbl(tl_sources_in).language);
5525 FOR t_rec IN c_tld_line_description (
5526 p_tld_tl_id => l_source_id
5527 ,p_lang => l_rxll_tbl(tl_sources_in).language )
5528 LOOP
5529 l_rxll_tbl(tl_sources_in).trans_line_description := t_rec.trans_line_description;
5530 END LOOP;
5531 END LOOP; -- Loop on l_rxll_tbl
5532
5533 IF(p_acc_sources_rec.inventory_org_id_pk2 IS NOT NULL AND
5534 p_acc_sources_rec.inventory_org_id_pk2 <> OKL_API.G_MISS_CHAR) THEN
5535 -- Populate Inventory Organization Name
5536 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
5537 '*** AGS Inventory Org ID used to fetch teh Inventory Organization Code : Org ID=' ||
5538 p_acc_sources_rec.inventory_org_id_pk2 );
5539 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
5540 'Executing the Cursor c_org_name_code_csr. p_org_id= ' || TO_CHAR(p_acc_sources_rec.inventory_org_id_pk2) );
5541 FOR t_rec IN c_org_name_code_csr(
5542 p_org_id => p_acc_sources_rec.inventory_org_id_pk2 )
5543 LOOP
5544 l_rxl_rec.inventory_org_code := t_rec.org_name;
5545 END LOOP;
5546
5547 FOR tl_sources_in IN l_rxll_tbl.FIRST .. l_rxll_tbl.LAST
5548 LOOP
5549 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
5550 'Executing the Cursor c_org_name_csr. p_org_id= ' || TO_CHAR(p_acc_sources_rec.inventory_org_id_pk2) ||
5551 ' ledger_language=' || l_rxll_tbl(tl_sources_in).language );
5552 FOR t_rec IN c_org_name_csr(
5553 p_org_id => p_acc_sources_rec.inventory_org_id_pk2
5554 ,p_ledger_lang => l_rxll_tbl(tl_sources_in).language )
5555 LOOP
5556 l_rxll_tbl(tl_sources_in).inventory_org_name := t_rec.org_name;
5557 END LOOP;
5558 END LOOP;
5559 END IF;
5560
5561 -- Calling insert_row
5562 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
5563 'Calling the okl_ar_extension_pvt.create_rxl_extension source_id=' || l_rxl_rec.source_id );
5564 okl_ar_extension_pvt.create_rxl_extension(
5565 p_api_version => l_api_version
5566 ,p_init_msg_list => p_init_msg_list
5567 ,x_return_status => l_return_status
5568 ,x_msg_count => x_msg_count
5569 ,x_msg_data => x_msg_data
5570 ,p_rxl_rec => l_rxl_rec
5571 ,p_rxll_tbl => l_rxll_tbl
5572 ,x_rxl_rec => lx_rxl_rec
5573 ,x_rxll_tbl => lx_rxll_tbl
5574 );
5575 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
5576 'After okl_ar_extension_pvt.create_rxl_extension: l_return_status ' || l_return_status );
5577 IF (l_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
5578 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
5579 ELSIF (l_return_status = OKL_API.G_RET_STS_ERROR) THEN
5580 RAISE OKL_API.G_EXCEPTION_ERROR;
5581 END IF;
5582 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
5583 'Calling okl_api.end_activity');
5584 okl_api.end_activity(
5585 x_msg_count => x_msg_count
5586 ,x_msg_data => x_msg_data);
5587 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
5588 'END OKL_SLA_ACC_SOURCES_PVT.populate_ar_sources');
5589 x_return_status := OKL_API.G_RET_STS_SUCCESS;
5590 EXCEPTION
5591 ------------------------------------------------------------
5592 -- Exception handling
5593 ------------------------------------------------------------
5594 WHEN OKL_API.G_EXCEPTION_ERROR
5595 THEN
5596 x_return_status := OKL_API.HANDLE_EXCEPTIONS (
5597 p_api_name => l_api_name
5598 ,p_pkg_name => G_PKG_NAME
5599 ,p_exc_name => OKL_API.G_RET_STS_ERROR
5600 ,x_msg_count => x_msg_count
5601 ,x_msg_data => x_msg_data
5602 ,p_api_type => '_PVT');
5603 WHEN OKL_API.G_EXCEPTION_UNEXPECTED_ERROR
5604 THEN
5605 x_return_status := OKL_API.HANDLE_EXCEPTIONS (
5606 p_api_name => l_api_name
5607 ,p_pkg_name => G_PKG_NAME
5608 ,p_exc_name => OKL_API.G_RET_STS_UNEXP_ERROR
5609 ,x_msg_count => x_msg_count
5610 ,x_msg_data => x_msg_data
5611 ,p_api_type => '_PVT');
5612 WHEN OTHERS
5613 THEN
5614 x_return_status := OKL_API.HANDLE_EXCEPTIONS (
5615 p_api_name => l_api_name
5616 ,p_pkg_name => G_PKG_NAME
5617 ,p_exc_name => 'OTHERS'
5618 ,x_msg_count => x_msg_count
5619 ,x_msg_data => x_msg_data
5620 ,p_api_type => '_PVT');
5621 END populate_ar_sources;
5622
5623 ------------------------------------------------------------------------------
5624 -- Start of comments
5625 -- API name : populate_sources
5626 -- Pre-reqs : None
5627 -- Function : populate sources for OKL AR Transactions
5628 -- Parameters :
5629 -- IN :
5630 -- rxhv_rec_type.source_id IN NUMBER Required
5631 -- rxhv_rec_type.source_table IN VARCHAR2 Required
5632 -- History : Prashant Jain created
5633 -- Version : 1.0
5634 -- End of comments
5635 ------------------------------------------------------------------------------
5636 PROCEDURE populate_sources(
5637 p_api_version IN NUMBER
5638 ,p_init_msg_list IN VARCHAR2
5639 ,p_rxhv_rec IN rxhv_rec_type
5640 ,p_rxlv_tbl IN rxlv_tbl_type
5641 ,p_acc_sources_tbl IN asev_tbl_type
5642 ,x_return_status OUT NOCOPY VARCHAR2
5643 ,x_msg_count OUT NOCOPY NUMBER
5644 ,x_msg_data OUT NOCOPY VARCHAR2
5645 )
5646 IS
5647 -- Cursor to fetch source_id, khr_id, kle_id,
5648 -- sty_id, try_id
5649 CURSOR c_trx_ar_inv_lines_csr (p_header_source_id NUMBER)
5650 IS
5651 SELECT tld.id source_id
5652 ,'OKL_TXD_AR_LN_DTLS_B' source_table
5653 ,tld.khr_id khr_id
5654 ,tld.kle_id kle_id
5655 ,tld.sty_id sty_id
5656 ,tai.try_id try_id
5657 FROM okl_trx_ar_invoices_b tai
5658 ,okl_txl_ar_inv_lns_b til
5659 ,okl_txd_ar_ln_dtls_b tld
5660 WHERE tld.til_id_details = til.id
5661 AND til.tai_id = tai.id
5662 AND tai.id = p_header_source_id;
5663
5664 -- Cursor to fetch source_id, khr_id, kle_id,
5665 -- sty_id, try_id
5666 CURSOR c_trx_ar_adj_lines_csr (p_header_source_id NUMBER)
5667 IS
5668 SELECT adjl.id source_id
5669 ,'OKL_TXL_ADJSTS_LNS_B' source_table
5670 ,adjl.khr_id khr_id
5671 ,adjl.kle_id kle_id
5672 ,adjl.sty_id sty_id
5673 ,adj.try_id try_id
5674 FROM okl_trx_ar_adjsts_all_b adj
5675 ,okl_txl_adjsts_lns_all_b adjl
5676 WHERE adj.id = adjl.adj_id
5677 AND adj.id = p_header_source_id;
5678
5679 -- Data structures based on the Cursor Variables
5680 TYPE c_trx_ar_inv_lines_tbl IS TABLE OF c_trx_ar_inv_lines_csr%ROWTYPE
5681 INDEX BY BINARY_INTEGER;
5682 l_trx_ar_inv_lines_tbl c_trx_ar_inv_lines_tbl;
5683 TYPE c_trx_ar_adj_lines_tbl IS TABLE OF c_trx_ar_adj_lines_csr%ROWTYPE
5684 INDEX BY BINARY_INTEGER;
5685 l_trx_ar_adj_lines_tbl c_trx_ar_adj_lines_tbl;
5686 tld_count NUMBER; -- Count of the l_trx_ar_inv_lines_tbl
5687 tld_index NUMBER; -- Index for the l_trx_ar_inv_lines_tbl
5688 rxl_index NUMBER; -- Index for the l_rxlv_tbl
5689 l_acc_srcs_index NUMBER; -- Index for the p_acc_sources_tbl
5690 l_capture_sources VARCHAR2(3); -- Flag to decide whether to Capture Sources or Not !
5691 -----------------------------------------------------------------
5692 -- Declare Process Variable
5693 -----------------------------------------------------------------
5694 l_api_version CONSTANT NUMBER := 1;
5695 l_api_name CONSTANT VARCHAR2(30) := 'POPULATE_SOURCES-AR';
5696 l_return_status VARCHAR2(1) := OKL_API.G_RET_STS_SUCCESS;
5697
5698 -----------------------------------------------------------------
5699 -- Local Variables
5700 -----------------------------------------------------------------
5701 l_header_source_id NUMBER;
5702 l_header_source_table VARCHAR2(30);
5703 l_rxhv_rec rxhv_rec_type;
5704 l_rxlv_rec rxlv_rec_type;
5705 l_rxlv_tbl rxlv_tbl_type;
5706 -- Local Variables for enabling the Debug Statements
5707 l_module CONSTANT fnd_log_messages.module%TYPE := G_MODULE || l_api_name;
5708 l_debug_enabled VARCHAR2(10);
5709 is_debug_procedure_on BOOLEAN;
5710 is_debug_statement_on BOOLEAN;
5711 BEGIN
5712 l_debug_enabled := okl_debug_pub.check_log_enabled;
5713 -- check for logging on PROCEDURE level
5714 is_debug_procedure_on := okl_debug_pub.check_log_on(l_module,FND_LOG.LEVEL_PROCEDURE);
5715 -- check for logging on STATEMENT level
5716 is_debug_statement_on := okl_debug_pub.check_log_on(l_module,FND_LOG.LEVEL_STATEMENT);
5717 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
5718 'begin debug OKLRSLAB.pls call ' || l_api_name);
5719 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
5720 'BEGIN API OKL_SLA_ACC_SOURCES_PVT.POPULATE_SOURCES');
5721 l_return_status := OKL_API.G_RET_STS_SUCCESS;
5722 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
5723 'Calling OKL_API.START_ACTIVITY');
5724 l_return_status := OKL_API.START_ACTIVITY(
5725 p_api_name => l_api_name
5726 ,p_pkg_name => g_pkg_name
5727 ,p_init_msg_list => p_init_msg_list
5728 ,l_api_version => l_api_version
5729 ,p_api_version => p_api_version
5730 ,p_api_type => '_PVT'
5731 ,x_return_status => l_return_status);
5732 IF (l_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
5733 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
5734 ELSIF (l_return_status = OKL_API.G_RET_STS_ERROR) THEN
5735 RAISE OKL_API.G_EXCEPTION_ERROR;
5736 END IF;
5737
5738 -- Validation 1: Source ID and Source Table should not be NULL in the
5739 -- AR Extension Header Record Structure
5740 IF (p_rxhv_rec.source_id IS NULL OR
5741 p_rxhv_rec.source_table IS NULL)
5742 THEN
5743 OKL_API.set_message(
5744 p_app_name => G_APP_NAME
5745 ,p_msg_name => G_INVALID_VALUE
5746 ,p_token1 => G_COL_NAME_TOKEN
5747 ,p_token1_value => 'HEADER.SOURCE_ID_TABLE');
5748 l_return_status := OKL_API.G_RET_STS_UNEXP_ERROR;
5749 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
5750 END IF;
5751 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
5752 'Header SOURCE_ID= ' || p_rxhv_rec.source_id || ' SOURCE_TABLE=' || p_rxhv_rec.source_table );
5753 -- Validation 2: The Header Source Table should be either the
5754 -- OKL AR Invoice Trx Header or OKL AR Adjustment Trx. Header table only
5755 -- ie. it should be either OKL_TRX_AR_INVOICES_B or OKL_TRX_AR_ADJSTS_B only
5756 IF UPPER(p_rxhv_rec.source_table) NOT IN ( G_TRX_AR_INVOICES_B, G_TRX_AR_ADJSTS_B)
5757 THEN
5758 OKL_API.set_message(
5759 p_app_name => G_APP_NAME
5760 ,p_msg_name => G_INVALID_VALUE
5761 ,p_token1 => G_COL_NAME_TOKEN
5762 ,p_token1_value => 'HEADER.SOURCE_TABLE');
5763 l_return_status := OKL_API.G_RET_STS_UNEXP_ERROR;
5764 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
5765 END IF;
5766
5767 -- Copy to local variables
5768 l_rxhv_rec := p_rxhv_rec;
5769 l_rxhv_rec.source_table := UPPER(p_rxhv_rec.source_table);
5770 l_header_source_id := p_rxhv_rec.source_id;
5771 l_header_source_table := UPPER(p_rxhv_rec.source_table);
5772 l_rxlv_tbl := p_rxlv_tbl;
5773 -- Validation 3: There should be atleast one Transaction Detail Line
5774 -- for which the Populate AR Sources should be called
5775 IF l_rxlv_tbl.COUNT = 0
5776 THEN
5777 OKL_API.set_message(
5778 p_app_name => G_APP_NAME
5779 ,p_msg_name => G_INVALID_VALUE
5780 ,p_token1 => G_COL_NAME_TOKEN
5781 ,p_token1_value => 'RXLV_TBL.COUNT()');
5782 l_return_status := OKL_API.G_RET_STS_UNEXP_ERROR;
5783 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
5784 END IF;
5785
5786 -- Validation 4: p_rxlv_tbl.COUNT should be equal to the p_acc_sources_tbl.COUNT
5787 IF l_rxlv_tbl.COUNT <> p_acc_sources_tbl.COUNT
5788 THEN
5789 OKL_API.set_message(
5790 p_app_name => G_APP_NAME
5791 ,p_msg_name => G_INVALID_VALUE
5792 ,p_token1 => G_COL_NAME_TOKEN
5793 ,p_token1_value => 'P_ACC_SOURCES_TBL.COUNT()');
5794 l_return_status := OKL_API.G_RET_STS_UNEXP_ERROR;
5795 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
5796 END IF;
5797
5798 -- Loop on the details for the current transaction header
5799 -- Call the populate_tld_sources
5800 IF l_header_source_table = 'OKL_TRX_AR_INVOICES_B'
5801 THEN
5802 -- As we wanted to store the records in the PL/SQL table starting from 1
5803 -- and after the loop, the tld_index should be nothing but the count of the
5804 -- Transaction Detail Lines fetched ...
5805 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
5806 'Executing the Cursor c_trx_ar_inv_lines_csr. p_header_source_id=' ||
5807 TO_CHAR(l_header_source_id));
5808 -- Initialize the tld_count to ZERO
5809 tld_count := 0;
5810 FOR t_rec IN c_trx_ar_inv_lines_csr( p_header_source_id => l_header_source_id )
5811 LOOP
5812 -- Increment the tld_count
5813 tld_count := tld_count + 1;
5814 -- Store the Current Record in the PL/SQL Table for further usage
5815 l_trx_ar_inv_lines_tbl(tld_count) := t_rec;
5816 END LOOP;
5817 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
5818 'Number of Transaction Detail Lines present in DB = ' || TO_CHAR(tld_count) );
5819 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
5820 'Number of Transaction Detail Lines passed to the API = ' || TO_CHAR(l_rxlv_tbl.COUNT) );
5821 FOR tld_index IN l_trx_ar_inv_lines_tbl.FIRST .. l_trx_ar_inv_lines_tbl.LAST
5822 LOOP
5823 -- Logic Explanation:
5824 -- 1. Check for the Count of the Trx. Detail Lines fetched from DB
5825 -- 2. Compare this count with the count of Trx. Detail Lines passed to this API
5826 -- 3. If the count is same, then, capture sources for every Trx. Detail Line
5827 -- otherwise, capture sources for only those transaction detail line, which have
5828 -- been passed by the Accounting Engine
5829 l_capture_sources := 'N';
5830 l_acc_srcs_index := NULL;
5831 rxl_index := l_rxlv_tbl.FIRST;
5832 LOOP
5833 IF l_rxlv_tbl(rxl_index).source_id = l_trx_ar_inv_lines_tbl(tld_index).source_id AND
5834 l_rxlv_tbl(rxl_index).source_table = l_trx_ar_inv_lines_tbl(tld_index).source_table
5835 THEN
5836 -- Need to the Call the Populate AR Sources for this Transaction Detail Line
5837 l_capture_sources := 'Y';
5838 -- Assumption: p_rxlv_tbl and p_acc_sources_tbl are populated using the Same Index.
5839 l_acc_srcs_index := rxl_index;
5840 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
5841 'Case 2: Populate Sources has been asked to capture sources for the Current Transaction Detail by Accounting Engine ' ||
5842 ' TXD ID = ' || TO_CHAR( l_trx_ar_inv_lines_tbl(tld_index).source_id ) );
5843 END IF;
5844 -- Exit when this is the Last Record or the Transaction Details has been found
5845 EXIT WHEN ( rxl_index = l_rxlv_tbl.LAST ) -- When reached End of the Table
5846 OR ( l_capture_sources = 'Y' ); -- Or When the TXD has been found
5847 -- Increment the rxl_index
5848 rxl_index := l_rxlv_tbl.NEXT( rxl_index );
5849 END LOOP; -- Loop on l_rxlv_tbl ..
5850
5851 IF l_capture_sources = 'Y'
5852 THEN
5853 -- If the AGS Index is not found then return error
5854 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
5855 'Account Generator Sources Index =' || TO_CHAR(l_acc_srcs_index) );
5856 IF l_acc_srcs_index IS NULL OR
5857 ( p_acc_sources_tbl.EXISTS(l_acc_srcs_index) = FALSE )
5858 THEN
5859 -- accounting_event_class_code is missing
5860 OKL_API.set_message(
5861 p_app_name => G_APP_NAME
5862 ,p_msg_name => G_INVALID_VALUE
5863 ,p_token1 => G_COL_NAME_TOKEN
5864 ,p_token1_value => 'AGS_SOURCES_INDEX');
5865 l_return_status := OKL_API.G_RET_STS_UNEXP_ERROR;
5866 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
5867 END IF; -- IF l_acc_sources_found = FALSE
5868
5869 -- l_rxhv_rec.source_id and l_rxhv_rec.source_table are already assigned
5870 l_rxhv_rec.khr_id := l_trx_ar_inv_lines_tbl(tld_index).khr_id;
5871 l_rxhv_rec.try_id := l_trx_ar_inv_lines_tbl(tld_index).try_id;
5872 -- Id of Detail Line Table
5873 l_rxlv_rec.source_id := l_trx_ar_inv_lines_tbl(tld_index).source_id;
5874 l_rxlv_rec.source_table := l_trx_ar_inv_lines_tbl(tld_index).source_table;
5875 l_rxlv_rec.kle_id := l_trx_ar_inv_lines_tbl(tld_index).kle_id;
5876 l_rxlv_rec.sty_id := l_trx_ar_inv_lines_tbl(tld_index).sty_id;
5877 -- The populate_tld_sources will capture sources at extension line level always
5878 -- If the extension header sources with the l_rxlv_rec.source_id and l_rxhv_rec.khr_id is not captured
5879 -- Then only capture the extension header sources
5880 -- Calling populate_tld_sources
5881 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
5882 'Calling the populate_ar_sources' );
5883 populate_ar_sources(
5884 p_api_version => l_api_version
5885 ,p_init_msg_list => p_init_msg_list
5886 ,p_rxhv_rec => l_rxhv_rec
5887 ,p_rxlv_rec => l_rxlv_rec
5888 ,p_acc_sources_rec => p_acc_sources_tbl(l_acc_srcs_index)
5889 ,x_return_status => l_return_status
5890 ,x_msg_count => x_msg_count
5891 ,x_msg_data => x_msg_data);
5892 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
5893 'After populate_ar_sources: l_return_status ' || l_return_status );
5894 -- Check the return status and if errored, return the error back
5895 IF (l_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
5896 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
5897 ELSIF (l_return_status = OKL_API.G_RET_STS_ERROR) THEN
5898 RAISE OKL_API.G_EXCEPTION_ERROR;
5899 END IF;
5900 END IF; -- IF l_capture_sources = 'Y'
5901 END LOOP; -- Loop on l_trx_ar_inv_lines_tbl ..
5902 ELSE
5903 -- As we wanted to store the records in the PL/SQL table starting from 1
5904 -- and after the loop, the tld_index should be nothing but the count of the
5905 -- Transaction Detail Lines fetched ...
5906 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
5907 'Executing the Cursor c_trx_ar_adj_lines_csr. p_header_source_id=' ||
5908 TO_CHAR(l_header_source_id));
5909 -- Initialize the tld_count to ZERO
5910 tld_count := 0;
5911 FOR t_rec IN c_trx_ar_adj_lines_csr( p_header_source_id => l_header_source_id )
5912 LOOP
5913 -- Increment the tld_count
5914 tld_count := tld_count + 1;
5915 -- Store the Current Record in the PL/SQL Table for further usage
5916 l_trx_ar_adj_lines_tbl(tld_count) := t_rec;
5917 END LOOP;
5918 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
5919 'Number of Transaction Detail Lines present in DB = ' || TO_CHAR(tld_count) );
5920 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
5921 'Number of Transaction Detail Lines passed to the API = ' || TO_CHAR(l_rxlv_tbl.COUNT) );
5922 FOR tld_index IN l_trx_ar_adj_lines_tbl.FIRST .. l_trx_ar_adj_lines_tbl.LAST
5923 LOOP
5924 -- Logic Explanation:
5925 -- 1. Check for the Count of the Trx. Detail Lines fetched from DB
5926 -- 2. Compare this count with the count of Trx. Detail Lines passed to this API
5927 -- 3. If the count is same, then, capture sources for every Trx. Detail Line
5928 -- otherwise, capture sources for only those transaction detail line, which have
5929 -- been passed by the Accounting Engine
5930 l_capture_sources := 'N';
5931 l_acc_srcs_index := NULL;
5932 rxl_index := l_rxlv_tbl.FIRST;
5933 LOOP
5934 IF l_rxlv_tbl(rxl_index).source_id = l_trx_ar_adj_lines_tbl(tld_index).source_id AND
5935 l_rxlv_tbl(rxl_index).source_table = l_trx_ar_adj_lines_tbl(tld_index).source_table
5936 THEN
5937 -- Need to the Call the Populate AR Sources for this Transaction Detail Line
5938 l_capture_sources := 'Y';
5939 -- Assumption: p_rxlv_tbl and p_acc_sources_tbl are populated using the Same Index.
5940 l_acc_srcs_index := rxl_index;
5941 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
5942 'Case 2: Populate Sources has been asked to capture sources for the Current Transaction Detail by Accounting Engine ' ||
5943 ' TXD ID = ' || TO_CHAR( l_trx_ar_adj_lines_tbl(tld_index).source_id ) );
5944 END IF;
5945 -- Exit when this is the Last Record or the Transaction Details has been found
5946 EXIT WHEN ( rxl_index = l_rxlv_tbl.LAST ) -- When reached End of the Table
5947 OR ( l_capture_sources = 'Y' ); -- Or When the TXD has been found
5948 -- Increment the rxl_index
5949 rxl_index := l_rxlv_tbl.NEXT( rxl_index );
5950 END LOOP; -- Loop on l_rxlv_tbl ..
5951
5952 IF l_capture_sources = 'Y'
5953 THEN
5954 -- If the AGS Index is not found then return error
5955 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
5956 'Account Generator Sources Index =' || TO_CHAR(l_acc_srcs_index) );
5957 IF l_acc_srcs_index IS NULL OR
5958 ( p_acc_sources_tbl.EXISTS(l_acc_srcs_index) = FALSE )
5959 THEN
5960 -- accounting_event_class_code is missing
5961 OKL_API.set_message(
5962 p_app_name => G_APP_NAME
5963 ,p_msg_name => G_INVALID_VALUE
5964 ,p_token1 => G_COL_NAME_TOKEN
5965 ,p_token1_value => 'AGS_SOURCES_INDEX');
5966 l_return_status := OKL_API.G_RET_STS_UNEXP_ERROR;
5967 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
5968 END IF; -- IF l_acc_sources_found = FALSE
5969
5970 -- l_rxhv_rec.source_id and l_rxhv_rec.source_table are already assigned
5971 l_rxhv_rec.khr_id := l_trx_ar_adj_lines_tbl(tld_index).khr_id;
5972 l_rxhv_rec.try_id := l_trx_ar_adj_lines_tbl(tld_index).try_id;
5973 -- Id of Detail Line Table
5974 l_rxlv_rec.source_id := l_trx_ar_adj_lines_tbl(tld_index).source_id;
5975 l_rxlv_rec.source_table := l_trx_ar_adj_lines_tbl(tld_index).source_table;
5976 l_rxlv_rec.kle_id := l_trx_ar_adj_lines_tbl(tld_index).kle_id;
5977 l_rxlv_rec.sty_id := l_trx_ar_adj_lines_tbl(tld_index).sty_id;
5978 -- l_rxlv_rec.trans_line_description := l_trx_ar_adj_lines_tbl(tld_index).trans_line_description;
5979 -- The populate_tld_sources will capture sources at extension line level always
5980 -- If the extension header sources with the l_rxlv_rec.source_id and l_rxhv_rec.khr_id is not captured
5981 -- Then only capture the extension header sources
5982 -- Calling populate_tld_sources
5983 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
5984 'Calling the populate_ar_sources' );
5985 populate_ar_sources(
5986 p_api_version => l_api_version
5987 ,p_init_msg_list => p_init_msg_list
5988 ,p_rxhv_rec => l_rxhv_rec
5989 ,p_rxlv_rec => l_rxlv_rec
5990 ,p_acc_sources_rec => p_acc_sources_tbl(l_acc_srcs_index)
5991 ,x_return_status => l_return_status
5992 ,x_msg_count => x_msg_count
5993 ,x_msg_data => x_msg_data);
5994 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
5995 'After populate_ar_sources: l_return_status ' || l_return_status );
5996 -- Check the return status and if errored, return the error back
5997 IF (l_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
5998 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
5999 ELSIF (l_return_status = OKL_API.G_RET_STS_ERROR) THEN
6000 RAISE OKL_API.G_EXCEPTION_ERROR;
6001 END IF;
6002 END IF; -- IF l_capture_sources = 'Y'
6003 END LOOP; -- Loop on l_trx_ar_adj_lines_tbl ..
6004 END IF; -- IF l_header_source_table = 'OKL_TRX_AR_INVOICES_B'
6005 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
6006 'Calling okl_api.end_activity');
6007 okl_api.end_activity(
6008 x_msg_count => x_msg_count
6009 ,x_msg_data => x_msg_data);
6010 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
6011 'END OKL_SLA_ACC_SOURCES_PVT.POPULATE_SOURCES');
6012 x_return_status := OKL_API.G_RET_STS_SUCCESS;
6013 EXCEPTION
6014 ------------------------------------------------------------
6015 -- Exception handling
6016 ------------------------------------------------------------
6017 WHEN OKL_API.G_EXCEPTION_ERROR
6018 THEN
6019 x_return_status := OKL_API.HANDLE_EXCEPTIONS (
6020 p_api_name => l_api_name
6021 ,p_pkg_name => G_PKG_NAME
6022 ,p_exc_name => OKL_API.G_RET_STS_ERROR
6023 ,x_msg_count => x_msg_count
6024 ,x_msg_data => x_msg_data
6025 ,p_api_type => '_PVT');
6026 WHEN OKL_API.G_EXCEPTION_UNEXPECTED_ERROR
6027 THEN
6028 x_return_status := OKL_API.HANDLE_EXCEPTIONS (
6029 p_api_name => l_api_name
6030 ,p_pkg_name => G_PKG_NAME
6031 ,p_exc_name => OKL_API.G_RET_STS_UNEXP_ERROR
6032 ,x_msg_count => x_msg_count
6033 ,x_msg_data => x_msg_data
6034 ,p_api_type => '_PVT');
6035 WHEN OTHERS
6036 THEN
6037 x_return_status := OKL_API.HANDLE_EXCEPTIONS (
6038 p_api_name => l_api_name
6039 ,p_pkg_name => G_PKG_NAME
6040 ,p_exc_name => 'OTHERS'
6041 ,x_msg_count => x_msg_count
6042 ,x_msg_data => x_msg_data
6043 ,p_api_type => '_PVT');
6044 END populate_sources;
6045
6046 PROCEDURE delete_ar_extension(
6047 p_api_version IN NUMBER
6048 ,p_init_msg_list IN VARCHAR2
6049 ,p_rxhv_rec IN rxhv_rec_type
6050 ,x_rxlv_tbl OUT NOCOPY rxlv_tbl_type
6051 ,x_return_status OUT NOCOPY VARCHAR2
6052 ,x_msg_count OUT NOCOPY NUMBER
6053 ,x_msg_data OUT NOCOPY VARCHAR2
6054 )
6055 IS
6056 -----------------------------------------------------------------
6057 -- Declare Process Variable
6058 -----------------------------------------------------------------
6059 l_api_version CONSTANT NUMBER := 1;
6060 l_api_name CONSTANT VARCHAR2(30) := 'DELETE_TRX_EXTENSION';
6061 l_return_status VARCHAR2(1) := OKL_API.G_RET_STS_SUCCESS;
6062 rxl_index BINARY_INTEGER;
6063 l_rxhv_rec okl_rxh_pvt.rxhv_rec_type;
6064 l_rxlv_tbl okl_rxl_pvt.rxlv_tbl_type;
6065 lx_rxhv_rec okl_rxh_pvt.rxhv_rec_type;
6066 lx_rxlv_tbl okl_rxl_pvt.rxlv_tbl_type;
6067 -- Cursor Definitions
6068 CURSOR get_ar_ext_hdr_id( p_source_id NUMBER, p_source_table VARCHAR2)
6069 IS
6070 SELECT rxh.header_extension_id header_extension_id
6071 FROM okl_ext_ar_header_sources_b rxh
6072 WHERE rxh.source_id = p_source_id
6073 AND rxh.source_table = p_source_table;
6074
6075 CURSOR get_ar_ext_lns_id( p_hdr_ext_id NUMBER)
6076 IS
6077 SELECT rxl.line_extension_id line_extension_id
6078 ,rxl.source_id source_id
6079 ,rxl.source_table source_table
6080 FROM okl_ext_ar_line_sources_b rxl
6081 WHERE rxl.header_extension_id = p_hdr_ext_id;
6082 -- Local Variables for enabling the Debug Statements
6083 l_module CONSTANT fnd_log_messages.module%TYPE := G_MODULE || l_api_name;
6084 l_debug_enabled VARCHAR2(10);
6085 is_debug_procedure_on BOOLEAN;
6086 is_debug_statement_on BOOLEAN;
6087 BEGIN
6088 l_debug_enabled := okl_debug_pub.check_log_enabled;
6089 -- check for logging on PROCEDURE level
6090 is_debug_procedure_on := okl_debug_pub.check_log_on(l_module,FND_LOG.LEVEL_PROCEDURE);
6091 -- check for logging on STATEMENT level
6092 is_debug_statement_on := okl_debug_pub.check_log_on(l_module,FND_LOG.LEVEL_STATEMENT);
6093 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
6094 'begin debug OKLRSLAB.pls call ' || l_api_name);
6095 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
6096 'BEGIN API OKL_SLA_ACC_SOURCES_PVT.DELETE_TRX_EXTENSION');
6097 l_return_status := OKL_API.G_RET_STS_SUCCESS;
6098 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
6099 'Calling OKL_API.START_ACTIVITY');
6100 l_return_status := OKL_API.START_ACTIVITY(
6101 p_api_name => l_api_name
6102 ,p_pkg_name => g_pkg_name
6103 ,p_init_msg_list => p_init_msg_list
6104 ,l_api_version => l_api_version
6105 ,p_api_version => p_api_version
6106 ,p_api_type => '_PVT'
6107 ,x_return_status => l_return_status);
6108 IF (l_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
6109 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
6110 ELSIF (l_return_status = OKL_API.G_RET_STS_ERROR) THEN
6111 RAISE OKL_API.G_EXCEPTION_ERROR;
6112 END IF;
6113 -- Actual Logic Starts Here ..
6114 l_rxhv_rec := p_rxhv_rec;
6115 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
6116 'Source ID=' || to_char(l_rxhv_rec.source_id) || 'Source Header Table=' || l_rxhv_rec.source_table );
6117 IF ( l_rxhv_rec.source_id = OKL_API.G_MISS_NUM or l_rxhv_rec.source_id IS NULL )
6118 THEN
6119 OKL_API.set_message(
6120 p_app_name => G_APP_NAME
6121 ,p_msg_name => G_INVALID_VALUE
6122 ,p_token1 => G_COL_NAME_TOKEN
6123 ,p_token1_value => 'HEADER.SOURCE_ID');
6124 l_return_status := OKL_API.G_RET_STS_UNEXP_ERROR;
6125 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
6126 END IF;
6127 IF ( l_rxhv_rec.source_table = OKL_API.G_MISS_CHAR or l_rxhv_rec.source_table IS NULL
6128 OR l_rxhv_rec.source_table NOT IN ( G_TRX_AR_INVOICES_B, G_TRX_AR_ADJSTS_B) )
6129 THEN
6130 OKL_API.set_message(
6131 p_app_name => G_APP_NAME
6132 ,p_msg_name => G_INVALID_VALUE
6133 ,p_token1 => G_COL_NAME_TOKEN
6134 ,p_token1_value => 'HEADER.SOURCE_TABLE');
6135 l_return_status := OKL_API.G_RET_STS_UNEXP_ERROR;
6136 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
6137 END IF;
6138 -- Initialize the rxl_index
6139 rxl_index := 1;
6140 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
6141 'Fetch the Extension Header ID by executing cursor get_txl_ext_hdr_id' );
6142 FOR t_rec IN get_ar_ext_hdr_id(
6143 p_source_id => l_rxhv_rec.source_id
6144 ,p_source_table => l_rxhv_rec.source_table)
6145 LOOP
6146 -- Note that for a given Source ID and Source Table in OKL_EXT_AR_HEADER_SOURCES_B
6147 -- there can be multiple records each having different KHR_ID ..
6148 l_rxhv_rec.header_extension_id := t_rec.header_extension_id;
6149 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
6150 'Extension Header ID To be Deleted=' || TO_CHAR(l_rxhv_rec.header_extension_id));
6151 -- Fetch the Transaction Extension Line IDs to be deleted
6152 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
6153 'Extension Line ID(s) To be Deleted=');
6154 FOR t_rec IN get_ar_ext_lns_id( p_hdr_ext_id => l_rxhv_rec.header_extension_id)
6155 LOOP
6156 l_rxlv_tbl(rxl_index).line_extension_id := t_rec.line_extension_id;
6157 l_rxlv_tbl(rxl_index).source_id := t_rec.source_id;
6158 l_rxlv_tbl(rxl_index).source_table := t_rec.source_table;
6159 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
6160 'LINE_EXTENSION_ID[' || rxl_index || '] = ' || TO_CHAR(l_rxlv_tbl(rxl_index).line_extension_id) );
6161 -- Increment i
6162 rxl_index := rxl_index + 1;
6163 END LOOP; -- End get_trans_line_ids
6164 -- Call the Wrapper API to delete the Extension Lines and then Header
6165 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
6166 'calling the okl_ar_extension_pvt.delete_rxh_extension Line Count=' || l_rxlv_tbl.COUNT );
6167 okl_ar_extension_pvt.delete_rxh_extension(
6168 p_api_version => p_api_version
6169 ,p_init_msg_list => p_init_msg_list
6170 ,x_return_status => x_return_status
6171 ,x_msg_count => x_msg_count
6172 ,x_msg_data => x_msg_data
6173 ,p_rxhv_rec => l_rxhv_rec
6174 );
6175 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
6176 'After okl_ar_extension_pvt.delete_rxh_extension: l_return_status ' || l_return_status );
6177 -- Check the return status and if errored, return the error back
6178 IF (l_return_status = OKL_API.G_RET_STS_UNEXP_ERROR)
6179 THEN
6180 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
6181 ELSIF (l_return_status = OKL_API.G_RET_STS_ERROR) THEN
6182 RAISE OKL_API.G_EXCEPTION_ERROR;
6183 END IF;
6184 END LOOP; -- Loop on the get_ar_ext_hdr_id
6185 -- Store the Transaction Line IDs and Line Source Tables so as to return back
6186 x_rxlv_tbl := l_rxlv_tbl;
6187 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
6188 'Calling okl_api.end_activity');
6189 okl_api.end_activity(
6190 x_msg_count => x_msg_count
6191 ,x_msg_data => x_msg_data);
6192 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
6193 'END OKL_SLA_ACC_SOURCES_PVT.DELETE_TRX_EXTENSION');
6194 x_return_status := OKL_API.G_RET_STS_SUCCESS;
6195 EXCEPTION
6196 ------------------------------------------------------------
6197 -- Exception handling
6198 ------------------------------------------------------------
6199 WHEN OKL_API.G_EXCEPTION_ERROR
6200 THEN
6201 x_return_status := OKL_API.HANDLE_EXCEPTIONS (
6202 p_api_name => l_api_name
6203 ,p_pkg_name => G_PKG_NAME
6204 ,p_exc_name => OKL_API.G_RET_STS_ERROR
6205 ,x_msg_count => x_msg_count
6206 ,x_msg_data => x_msg_data
6207 ,p_api_type => '_PVT');
6208 WHEN OKL_API.G_EXCEPTION_UNEXPECTED_ERROR
6209 THEN
6210 x_return_status := OKL_API.HANDLE_EXCEPTIONS (
6211 p_api_name => l_api_name
6212 ,p_pkg_name => G_PKG_NAME
6213 ,p_exc_name => OKL_API.G_RET_STS_UNEXP_ERROR
6214 ,x_msg_count => x_msg_count
6215 ,x_msg_data => x_msg_data
6216 ,p_api_type => '_PVT');
6217 WHEN OTHERS
6218 THEN
6219 x_return_status := OKL_API.HANDLE_EXCEPTIONS (
6220 p_api_name => l_api_name
6221 ,p_pkg_name => G_PKG_NAME
6222 ,p_exc_name => 'OTHERS'
6223 ,x_msg_count => x_msg_count
6224 ,x_msg_data => x_msg_data
6225 ,p_api_type => '_PVT');
6226 END delete_ar_extension;
6227
6228 ------------------------------------------------------------------------------
6229 -- Start of comments
6230 -- API name : assign_khr_rec_to_pxhv_rec
6231 -- Pre-reqs : None
6232 -- Function : assign khr rec to pxhv rec for AP OKL Transactions
6233 -- Parameters :
6234 -- IN : p_khr_source_rec khr_source_rec_type
6235 -- OUT : x_pxhv_rec pxhv_rec_type
6236 -- Version : 1.0
6237 -- History : Prashant Jain created
6238 -- End of comments
6239 ------------------------------------------------------------------------------
6240 -- Changes for Bug# 6268782 : PRASJAIN
6241 -- 1. func name assign_khr_rec_to_pxhv_rec to assign_khr_rec_to_pxh_rec
6242 -- 2. out param pxhv_rec_type to pxh_rec_type
6243 ------------------------------------------------------------------------------
6244 PROCEDURE assign_khr_rec_to_pxh_rec(
6245 p_khr_source_rec IN khr_source_rec_type
6246 ,x_pxh_rec IN OUT NOCOPY pxh_rec_type
6247 )
6248 AS
6249 BEGIN
6250 x_pxh_rec.khr_id := p_khr_source_rec.khr_id;
6251 x_pxh_rec.contract_number := p_khr_source_rec.contract_number;
6252 x_pxh_rec.customer_name := p_khr_source_rec.customer_name;
6253 x_pxh_rec.cust_account_number := p_khr_source_rec.customer_account_number;
6254 -- added by zrehman Bug#6707320 for Party Merge impact on Accounting sources tables start
6255 x_pxh_rec.party_id := p_khr_source_rec.customer_id;
6256 x_pxh_rec.cust_account_id := p_khr_source_rec.cust_account_id;
6257 -- added by zrehman Bug#6707320 for Party Merge impact on Accounting sources tables end
6258 x_pxh_rec.contract_currency_code := p_khr_source_rec.contract_currency_code;
6259 x_pxh_rec.contract_effective_from := p_khr_source_rec.contract_effective_from;
6260 x_pxh_rec.product_name := p_khr_source_rec.product_name;
6261 x_pxh_rec.book_classification_code:= p_khr_source_rec.book_classification_code;
6262 x_pxh_rec.tax_owner_code := p_khr_source_rec.tax_owner_code;
6263 x_pxh_rec.rev_rec_method_code := p_khr_source_rec.rev_rec_method_code;
6264 x_pxh_rec.int_calc_method_code := p_khr_source_rec.int_calc_method_code;
6265 x_pxh_rec.vendor_program_number := p_khr_source_rec.vendor_program_number;
6266 x_pxh_rec.converted_number := p_khr_source_rec.converted_number;
6267 x_pxh_rec.converted_account_flag := p_khr_source_rec.converted_account_flag;
6268 x_pxh_rec.assignable_flag := p_khr_source_rec.assignable_flag;
6269 x_pxh_rec.po_order_number := p_khr_source_rec.po_order_number;
6270 x_pxh_rec.accrual_override_flag := p_khr_source_rec.accrual_override_flag;
6271 x_pxh_rec.rent_ia_contract_number := p_khr_source_rec.rent_ia_contract_number;
6272 x_pxh_rec.rent_ia_product_name := p_khr_source_rec.rent_ia_product_name;
6273 x_pxh_rec.rent_ia_accounting_code := p_khr_source_rec.rent_ia_accounting_code;
6274 x_pxh_rec.res_ia_contract_number := p_khr_source_rec.res_ia_contract_number;
6275 x_pxh_rec.res_ia_product_name := p_khr_source_rec.res_ia_product_name;
6276 x_pxh_rec.res_ia_accounting_code := p_khr_source_rec.res_ia_accounting_code;
6277 x_pxh_rec.khr_attribute_category := p_khr_source_rec.khr_attribute_category;
6278 x_pxh_rec.khr_attribute1 := p_khr_source_rec.khr_attribute1;
6279 x_pxh_rec.khr_attribute2 := p_khr_source_rec.khr_attribute2;
6280 x_pxh_rec.khr_attribute3 := p_khr_source_rec.khr_attribute3;
6281 x_pxh_rec.khr_attribute4 := p_khr_source_rec.khr_attribute4;
6282 x_pxh_rec.khr_attribute5 := p_khr_source_rec.khr_attribute5;
6283 x_pxh_rec.khr_attribute6 := p_khr_source_rec.khr_attribute6;
6284 x_pxh_rec.khr_attribute7 := p_khr_source_rec.khr_attribute7;
6285 x_pxh_rec.khr_attribute8 := p_khr_source_rec.khr_attribute8;
6286 x_pxh_rec.khr_attribute9 := p_khr_source_rec.khr_attribute9;
6287 x_pxh_rec.khr_attribute10 := p_khr_source_rec.khr_attribute10;
6288 x_pxh_rec.khr_attribute11 := p_khr_source_rec.khr_attribute11;
6289 x_pxh_rec.khr_attribute12 := p_khr_source_rec.khr_attribute12;
6290 x_pxh_rec.khr_attribute13 := p_khr_source_rec.khr_attribute13;
6291 x_pxh_rec.khr_attribute14 := p_khr_source_rec.khr_attribute14;
6292 x_pxh_rec.khr_attribute15 := p_khr_source_rec.khr_attribute15;
6293 x_pxh_rec.cust_attribute_category := p_khr_source_rec.cust_attribute_category;
6294 x_pxh_rec.cust_attribute1 := p_khr_source_rec.cust_attribute1;
6295 x_pxh_rec.cust_attribute2 := p_khr_source_rec.cust_attribute2;
6296 x_pxh_rec.cust_attribute3 := p_khr_source_rec.cust_attribute3;
6297 x_pxh_rec.cust_attribute4 := p_khr_source_rec.cust_attribute4;
6298 x_pxh_rec.cust_attribute5 := p_khr_source_rec.cust_attribute5;
6299 x_pxh_rec.cust_attribute6 := p_khr_source_rec.cust_attribute6;
6300 x_pxh_rec.cust_attribute7 := p_khr_source_rec.cust_attribute7;
6301 x_pxh_rec.cust_attribute8 := p_khr_source_rec.cust_attribute8;
6302 x_pxh_rec.cust_attribute9 := p_khr_source_rec.cust_attribute9;
6303 x_pxh_rec.cust_attribute10 := p_khr_source_rec.cust_attribute10;
6304 x_pxh_rec.cust_attribute11 := p_khr_source_rec.cust_attribute11;
6305 x_pxh_rec.cust_attribute12 := p_khr_source_rec.cust_attribute12;
6306 x_pxh_rec.cust_attribute13 := p_khr_source_rec.cust_attribute13;
6307 x_pxh_rec.cust_attribute14 := p_khr_source_rec.cust_attribute14;
6308 x_pxh_rec.cust_attribute15 := p_khr_source_rec.cust_attribute15;
6309 x_pxh_rec.contract_status_code := p_khr_source_rec.contract_status_code;
6310 x_pxh_rec.inv_agrmnt_number := p_khr_source_rec.inv_agrmnt_number;
6311 x_pxh_rec.inv_agrmnt_effective_from := p_khr_source_rec.inv_agrmnt_effective_from;
6312 x_pxh_rec.inv_agrmnt_product_name := p_khr_source_rec.inv_agrmnt_product_name;
6313 x_pxh_rec.inv_agrmnt_currency_code := p_khr_source_rec.inv_agrmnt_currency_code;
6314 x_pxh_rec.inv_agrmnt_synd_code := p_khr_source_rec.inv_agrmnt_synd_code;
6315 x_pxh_rec.inv_agrmnt_pool_number := p_khr_source_rec.inv_agrmnt_pool_number;
6316 x_pxh_rec.inv_agrmnt_status_code := p_khr_source_rec.inv_agrmnt_status_code;
6317 x_pxh_rec.scs_code := p_khr_source_rec.scs_code;
6318 END assign_khr_rec_to_pxh_rec;
6319
6320 ------------------------------------------------------------------------------
6321 -- Start of comments
6322 -- API name : assign_kle_rec_to_pxlv_rec
6323 -- Pre-reqs : None
6324 -- Function : assign kle rec to pxlv rec for AP OKL Transactions
6325 -- Parameters :
6326 -- IN : p_kle_source_rec kle_source_rec_type
6327 -- OUT : x_pxlv_rec pxlv_rec_type
6328 -- Version : 1.0
6329 -- History : Prashant Jain created
6330 -- End of comments
6331 ------------------------------------------------------------------------------
6332 -- Changes for Bug# 6268782 : PRASJAIN
6333 -- 1. func name assign_kle_rec_to_pxlv_rec to assign_kle_rec_to_pxl_rec
6334 -- 2. out param pxlv_rec_type to pxl_rec_type
6335 ------------------------------------------------------------------------------
6336 PROCEDURE assign_kle_rec_to_pxl_rec(
6337 p_kle_source_rec IN kle_source_rec_type
6338 ,x_pxl_rec IN OUT NOCOPY pxl_rec_type
6339 )
6340 AS
6341 BEGIN
6342 x_pxl_rec.kle_id := p_kle_source_rec.kle_id;
6343 x_pxl_rec.asset_number := p_kle_source_rec.asset_number;
6344 x_pxl_rec.contract_line_number := p_kle_source_rec.contract_line_number;
6345 x_pxl_rec.asset_vendor_name := p_kle_source_rec.asset_vendor_name;
6346 -- added by zrehman Bug#6707320 for Party Merge impact on Accounting sources tables start
6347 x_pxl_rec.asset_vendor_id := p_kle_source_rec.asset_vendor_id;
6348 -- added by zrehman Bug#6707320 for Party Merge impact on Accounting sources tables end
6349 x_pxl_rec.installed_site_id := p_kle_source_rec.installed_site_id;
6350 x_pxl_rec.fixed_asset_location_name := p_kle_source_rec.fixed_asset_location_name;
6351 x_pxl_rec.contract_line_type := p_kle_source_rec.line_type_code;
6352 x_pxl_rec.line_attribute_category := p_kle_source_rec.line_attribute_category;
6353 x_pxl_rec.line_attribute1 := p_kle_source_rec.line_attribute1;
6354 x_pxl_rec.line_attribute2 := p_kle_source_rec.line_attribute2;
6355 x_pxl_rec.line_attribute3 := p_kle_source_rec.line_attribute3;
6356 x_pxl_rec.line_attribute4 := p_kle_source_rec.line_attribute4;
6357 x_pxl_rec.line_attribute5 := p_kle_source_rec.line_attribute5;
6358 x_pxl_rec.line_attribute6 := p_kle_source_rec.line_attribute6;
6359 x_pxl_rec.line_attribute7 := p_kle_source_rec.line_attribute7;
6360 x_pxl_rec.line_attribute8 := p_kle_source_rec.line_attribute8;
6361 x_pxl_rec.line_attribute9 := p_kle_source_rec.line_attribute9;
6362 x_pxl_rec.line_attribute10 := p_kle_source_rec.line_attribute10;
6363 x_pxl_rec.line_attribute11 := p_kle_source_rec.line_attribute11;
6364 x_pxl_rec.line_attribute12 := p_kle_source_rec.line_attribute12;
6365 x_pxl_rec.line_attribute13 := p_kle_source_rec.line_attribute13;
6366 x_pxl_rec.line_attribute14 := p_kle_source_rec.line_attribute14;
6367 x_pxl_rec.line_attribute15 := p_kle_source_rec.line_attribute15;
6368 END assign_kle_rec_to_pxl_rec;
6369
6370 ------------------------------------------------------------------------------
6371 -- Start of comments
6372 -- API name : populate_ap_sources
6373 -- Pre-reqs : None
6374 -- Function : populate sources for OKL AP Transactions
6375 -- Parameters :
6376 -- IN : pxhv_rec_type.source_id IN NUMBER Required
6377 -- pxhv_rec_type.source_table IN VARCHAR2 Required
6378
6379 -- pxhv_rec_type.khr_id IN NUMBER Required
6380 -- pxlv_rec_type.kle_id IN NUMBER Required
6381 -- pxhv_rec_type.try_id IN NUMBER Required
6382 -- pxlv_rec_type.sty_id IN NUMBER Required
6383 -- pxlv_rec_type.source_id IN NUMBER Required
6384 -- pxlv_rec_type.source_table IN VARCHAR2 Required
6385 -- History : Prashant Jain created
6386 -- Version : 1.0
6387 -- End of comments
6388 ------------------------------------------------------------------------------
6389 PROCEDURE populate_ap_sources(
6390 p_api_version IN NUMBER
6391 ,p_init_msg_list IN VARCHAR2
6392 ,p_pxhv_rec IN pxhv_rec_type
6393 ,p_pxlv_rec IN pxlv_rec_type
6394 ,p_acc_sources_rec IN asev_rec_type
6395 ,x_return_status OUT NOCOPY VARCHAR2
6396 ,x_msg_count OUT NOCOPY NUMBER
6397 ,x_msg_data OUT NOCOPY VARCHAR2
6398 )
6399 IS
6400 -- Cursor to fetch header_extension_id
6401 CURSOR c_header_extension_id_csr (p_header_source_id NUMBER, p_khr_id NUMBER)
6402 IS
6403 SELECT hdr.header_extension_id header_extension_id
6404 FROM okl_ext_ap_header_sources_b hdr
6405 WHERE hdr.source_id = p_header_source_id
6406 AND hdr.khr_id = p_khr_id;
6407 -- Cursor to fetch trans number
6408 CURSOR c_trans_number_csr (p_header_source_id NUMBER)
6409 IS
6410 SELECT tap.vendor_invoice_number trans_number
6411 FROM okl_trx_ap_invoices_b tap
6412 WHERE tap.id = p_header_source_id;
6413
6414 -----------------------------------------------------------------
6415 -- Declare Process Variable
6416 -----------------------------------------------------------------
6417 l_api_version CONSTANT NUMBER := 1;
6418 l_api_name CONSTANT VARCHAR2(30) := 'populate_ap_sources';
6419 l_return_status VARCHAR2(1) := OKL_API.G_RET_STS_SUCCESS;
6420 -----------------------------------------------------------------
6421 -- Local Variables
6422 -----------------------------------------------------------------
6423 l_khr_id NUMBER;
6424 l_try_id NUMBER;
6425 l_kle_id NUMBER;
6426 l_sty_id NUMBER;
6427 l_ledger_id NUMBER;
6428 l_ledger_language VARCHAR2(12);
6429 l_header_source_id NUMBER;
6430 l_header_source_table VARCHAR2(30);
6431 l_template_id NUMBER;
6432 l_source_id NUMBER;
6433 l_source_table VARCHAR2(30);
6434 l_header_extension_id NUMBER;
6435 l_pk_attributes VARCHAR2(1000);
6436 l_tcn_id NUMBER;
6437 l_line_style VARCHAR2(30);
6438 l_parent_line_id NUMBER;
6439 -- KHR and KLE Based Record Structures
6440 l_khr_source_rec khr_source_rec_type;
6441 l_kle_source_rec kle_source_rec_type;
6442 -- Record structures based on the Cursor Definitions
6443 l_termination_qte_csr_rec c_termination_qte_csr%ROWTYPE;
6444 -- Record Structures based on OKL AP Extension Header and Line Tables
6445 l_pxh_rec pxh_rec_type;
6446 lx_pxh_rec pxh_rec_type;
6447
6448 l_pxhl_tbl pxhl_tbl_type;
6449 lx_pxhl_tbl pxhl_tbl_type;
6450
6451 l_pxl_rec pxl_rec_type;
6452 lx_pxl_rec pxl_rec_type;
6453
6454 l_pxll_tbl pxll_tbl_type;
6455 lx_pxll_tbl pxll_tbl_type;
6456
6457 l_led_lang_tbl led_lang_tbl_type;
6458
6459 l_ledger_lang_rec c_ledger_lang_csr%ROWTYPE;
6460 -- Local Variables for enabling the Debug Statements
6461 l_module CONSTANT fnd_log_messages.module%TYPE := G_MODULE || l_api_name;
6462 l_debug_enabled VARCHAR2(10);
6463 is_debug_procedure_on BOOLEAN;
6464 is_debug_statement_on BOOLEAN;
6465 tl_sources_in NUMBER := 1;
6466 BEGIN
6467 l_debug_enabled := okl_debug_pub.check_log_enabled;
6468 -- check for logging on PROCEDURE level
6469 is_debug_procedure_on := okl_debug_pub.check_log_on(l_module,FND_LOG.LEVEL_PROCEDURE);
6470 -- check for logging on STATEMENT level
6471 is_debug_statement_on := okl_debug_pub.check_log_on(l_module,FND_LOG.LEVEL_STATEMENT);
6472 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
6473 'begin debug OKLRSLAB.pls call ' || l_api_name);
6474 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
6475 'BEGIN API OKL_SLA_ACC_SOURCES_PVT.populate_ap_sources');
6476 l_return_status := OKL_API.G_RET_STS_SUCCESS;
6477 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
6478 'Calling OKL_API.START_ACTIVITY');
6479 l_return_status := OKL_API.START_ACTIVITY(
6480 p_api_name => l_api_name
6481 ,p_pkg_name => g_pkg_name
6482 ,p_init_msg_list => p_init_msg_list
6483 ,l_api_version => l_api_version
6484 ,p_api_version => p_api_version
6485 ,p_api_type => '_PVT'
6486 ,x_return_status => l_return_status);
6487 IF (l_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
6488 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
6489 ELSIF (l_return_status = OKL_API.G_RET_STS_ERROR) THEN
6490 RAISE OKL_API.G_EXCEPTION_ERROR;
6491 END IF;
6492 -- Validations to be done
6493 -- Validation 1:
6494 -- The following attributes should not be NULL
6495 -- dnz_khr_id, kle_id, try_id, source_id, sty_id
6496 l_pk_attributes := NULL;
6497 IF p_pxhv_rec.source_id IS NULL OR
6498 p_pxhv_rec.source_id = OKL_API.G_MISS_NUM
6499 THEN
6500 IF l_pk_attributes IS NOT NULL
6501 THEN
6502 l_pk_attributes := l_pk_attributes || ' , ';
6503 END IF;
6504 l_pk_attributes := l_pk_attributes || 'PXH.SOURCE_ID';
6505 END IF;
6506 IF p_pxhv_rec.source_table IS NULL OR
6507 p_pxhv_rec.source_table = OKL_API.G_MISS_CHAR
6508 THEN
6509 IF l_pk_attributes IS NOT NULL
6510 THEN
6511 l_pk_attributes := l_pk_attributes || ' , ';
6512 END IF;
6513 l_pk_attributes := l_pk_attributes || 'PXH.SOURCE_TABLE';
6514 END IF;
6515 IF p_pxhv_rec.khr_id IS NULL OR
6516 p_pxhv_rec.khr_id = OKL_API.G_MISS_NUM
6517 THEN
6518 IF l_pk_attributes IS NOT NULL
6519 THEN
6520 l_pk_attributes := l_pk_attributes || ' , ';
6521 END IF;
6522 l_pk_attributes := l_pk_attributes || 'KHR_ID';
6523 END IF;
6524 IF p_pxhv_rec.try_id IS NULL OR
6525 p_pxhv_rec.try_id = OKL_API.G_MISS_NUM
6526 THEN
6527 IF l_pk_attributes IS NOT NULL
6528 THEN
6529 l_pk_attributes := l_pk_attributes || ' , ';
6530 END IF;
6531 l_pk_attributes := l_pk_attributes || 'TRY_ID';
6532 END IF;
6533 IF p_pxlv_rec.source_id IS NULL OR
6534 p_pxlv_rec.source_id = OKL_API.G_MISS_NUM
6535 THEN
6536 IF l_pk_attributes IS NOT NULL
6537 THEN
6538 l_pk_attributes := l_pk_attributes || ' , ';
6539 END IF;
6540 l_pk_attributes := l_pk_attributes || 'PXL.SOURCE_ID';
6541 END IF;
6542 IF p_pxlv_rec.source_table IS NULL OR
6543 p_pxlv_rec.source_table = OKL_API.G_MISS_CHAR
6544 THEN
6545 IF l_pk_attributes IS NOT NULL
6546 THEN
6547 l_pk_attributes := l_pk_attributes || ' , ';
6548 END IF;
6549 l_pk_attributes := l_pk_attributes || 'PXL.SOURCE_TABLE';
6550 END IF;
6551 IF p_pxlv_rec.sty_id IS NULL OR
6552 p_pxlv_rec.sty_id = OKL_API.G_MISS_NUM
6553 THEN
6554 IF l_pk_attributes IS NOT NULL
6555 THEN
6556 l_pk_attributes := l_pk_attributes || ' , ';
6557 END IF;
6558 l_pk_attributes := l_pk_attributes || 'STY_ID';
6559 END IF;
6560 IF LENGTH(l_pk_attributes) > 0
6561 THEN
6562 -- Raise an Exception
6563 OKL_API.set_message(
6564 p_app_name => G_APP_NAME
6565 ,p_msg_name => G_INVALID_VALUE
6566 ,p_token1 => G_COL_NAME_TOKEN
6567 ,p_token1_value => l_pk_attributes);
6568 l_return_status := OKL_API.G_RET_STS_UNEXP_ERROR;
6569 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
6570 END IF;
6571 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
6572 'Validation 1 Successfull !');
6573 -- Validation 2:
6574 -- Source Table should be OKL_TXL_AP_INV_LNS_B
6575 IF p_pxlv_rec.source_table NOT IN ( G_TXL_AP_INV_LNS_B )
6576 THEN
6577 -- Raise an Exception
6578 OKL_API.set_message(
6579 p_app_name => G_APP_NAME
6580 ,p_msg_name => G_INVALID_VALUE
6581 ,p_token1 => G_COL_NAME_TOKEN
6582 ,p_token1_value => 'SOURCE_TABLE');
6583 l_return_status := OKL_API.G_RET_STS_UNEXP_ERROR;
6584 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
6585 END IF;
6586 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
6587 'Validation 2 Successfull !');
6588 -- Copy input rec to local variable
6589 l_pxh_rec.source_id := p_pxhv_rec.source_id;
6590 l_pxh_rec.source_table := p_pxhv_rec.source_table;
6591 l_pxh_rec.khr_id := p_pxhv_rec.khr_id;
6592 l_pxh_rec.try_id := p_pxhv_rec.try_id;
6593
6594 l_pxl_rec.source_id := p_pxlv_rec.source_id;
6595 l_pxl_rec.source_table := p_pxlv_rec.source_table;
6596 l_pxl_rec.kle_id := p_pxlv_rec.kle_id;
6597 l_pxl_rec.sty_id := p_pxlv_rec.sty_id;
6598 -- Copy the input parameters to the local variables
6599 l_header_source_id := l_pxh_rec.source_id;
6600 l_header_source_table := l_pxh_rec.source_table;
6601 l_khr_id := l_pxh_rec.khr_id;
6602 l_try_id := l_pxh_rec.try_id;
6603 l_source_id := l_pxl_rec.source_id;
6604 l_source_table := l_pxl_rec.source_table;
6605 l_kle_id := l_pxl_rec.kle_id; -- For Subsidy this is will be a SUBSIDY Line but not the Asset
6606 l_sty_id := l_pxl_rec.sty_id;
6607
6608 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
6609 '**** KLE_ID = ' || l_kle_id );
6610 IF l_kle_id IS NOT NULL OR
6611 l_kle_id <> OKL_API.G_MISS_NUM
6612 THEN
6613 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
6614 'Executing the Cursor get_line_style_csr kle_id=' || l_pxl_rec.kle_id );
6615 FOR t_rec IN get_line_style_csr(p_kle_id => l_pxl_rec.kle_id )
6616 LOOP
6617 l_line_style := t_rec.line_style;
6618 IF l_line_style = 'SUBSIDY'
6619 THEN
6620 l_parent_line_id := t_rec.parent_line_id;
6621 END IF;
6622 END LOOP;
6623 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
6624 '**** LINE STYLE = ' || l_line_style || ' PARENT LINE ID = ' || l_parent_line_id );
6625 END IF; -- IF l_kle_id IS NOT NULL OR l_kle_id <> OKL_API.G_MISS_NUM
6626
6627 -- Fetch ledger id and ledger language associated to the contracts
6628 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
6629 'Executing the Cursor c_khr_to_ledger_id_csr. p_khr_id=' || TO_CHAR(l_khr_id));
6630 FOR t_rec IN c_khr_to_ledger_id_csr( p_khr_id => l_khr_id )
6631 LOOP
6632 l_ledger_id := t_rec.ledger_id;
6633 END LOOP;
6634
6635 -- Fetch the ledger language in order to populate the sources
6636 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
6637 'Executing the Cursor c_ledger_lang_csr. p_ledger_id=' || TO_CHAR(l_ledger_id));
6638 FOR t_rec IN c_ledger_lang_csr( p_ledger_id => l_ledger_id )
6639 LOOP
6640 l_ledger_lang_rec := t_rec;
6641 l_led_lang_tbl(tl_sources_in).language := t_rec.language_code;
6642 l_pxll_tbl(tl_sources_in).language := t_rec.language_code;
6643 tl_sources_in := tl_sources_in + 1;
6644 END LOOP;
6645
6646 -- Logic Description:
6647 -- 1. The OKL AP Extension Header _B/_TL sources will be captured only once
6648 -- for a KHR_ID.
6649 -- 2. For every AP Transaction Line, there will be a single record in the
6650 -- OKL AP Extension Line _B/_TL
6651 -- For Eg., if a Transaction is having 10 transaction lines with two different khr_id1, khr_id2
6652 -- there will be only two records in the Header but 10 transaction lines in Extension Line.
6653 -- Hence, for every Transaction Line check whether the KHR Sources have been captured
6654 -- already or not by passing the Transaction ID and KHR_ID
6655 -- Fetch header extension id
6656 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
6657 'Executing the Cursor c_header_extension_id_csr.
6658 p_header_source_id=' || TO_CHAR(l_header_source_id)
6659 || ' p_khr_id= ' || TO_CHAR(l_khr_id));
6660 l_header_extension_id := NULL;
6661 FOR t_rec IN c_header_extension_id_csr(
6662 p_header_source_id => l_header_source_id
6663 ,p_khr_id => l_khr_id )
6664 LOOP
6665 l_header_extension_id := t_rec.header_extension_id;
6666 END LOOP; -- End for c_header_extension_id_csr
6667
6668 -- If l_header_extension_id is NOT NULL, then it means the KHR sources are already captured
6669 -- So, populate extension line sources only.
6670 -- Else Populate both the Extension Header and Line Sources.
6671 IF l_header_extension_id IS NULL
6672 THEN
6673 -- Prepare khr_source_rec_type with khr_id and ledger_language
6674 l_khr_source_rec.khr_id := l_khr_id;
6675 -- Calling populate_khr_sources to fetch the KHR Sources
6676 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
6677 'Calling the populate_khr_sources' );
6678 populate_khr_sources(
6679 p_api_version => l_api_version
6680 ,p_init_msg_list => p_init_msg_list
6681 ,x_khr_source_rec => l_khr_source_rec
6682 ,x_led_lang_tbl => l_led_lang_tbl
6683 ,x_return_status => l_return_status
6684 ,x_msg_count => x_msg_count
6685 ,x_msg_data => x_msg_data );
6686 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
6687 'After populate_khr_sources: l_return_status ' || l_return_status );
6688 -- Check the return status and if errored, return the error back
6689 IF (l_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
6690 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
6691 ELSIF (l_return_status = OKL_API.G_RET_STS_ERROR) THEN
6692 RAISE OKL_API.G_EXCEPTION_ERROR;
6693 END IF;
6694 -- Assign the KHR Sources to the pxhv_rec
6695 assign_khr_rec_to_pxh_rec(
6696 p_khr_source_rec => l_khr_source_rec
6697 ,x_pxh_rec => l_pxh_rec );
6698
6699 FOR tl_sources_in IN l_led_lang_tbl.FIRST .. l_led_lang_tbl.LAST
6700 LOOP
6701 l_pxhl_tbl(tl_sources_in).language := l_led_lang_tbl(tl_sources_in).language;
6702 l_pxhl_tbl(tl_sources_in).contract_status := l_led_lang_tbl(tl_sources_in).contract_status;
6703 l_pxhl_tbl(tl_sources_in).inv_agrmnt_status := l_led_lang_tbl(tl_sources_in).inv_agrmnt_status;
6704
6705 -- Fetch transaction type name wrt ledger language
6706 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
6707 'Executing the Cursor c_trx_type_name_csr. p_try_id=' ||
6708 l_try_id || 'p_led_lang= ' || l_pxhl_tbl(tl_sources_in).language );
6709 FOR t_rec IN c_trx_type_name_csr(
6710 p_try_id => l_try_id
6711 ,p_led_lang => l_pxhl_tbl(tl_sources_in).language )
6712 LOOP
6713 l_pxhl_tbl(tl_sources_in).transaction_type_name := t_rec.transaction_type_name;
6714 -- Assign the Trx. Type Class Code also.
6715 l_pxh_rec.trx_type_class_code := t_rec.trx_type_class_code;
6716 END LOOP; -- End for c_trx_type_name_csr
6717 END LOOP;
6718
6719 IF(p_acc_sources_rec.jtf_sales_reps_pk IS NOT NULL AND
6720 p_acc_sources_rec.jtf_sales_reps_pk <> OKL_API.G_MISS_CHAR) THEN
6721 -- Need to populate the Sales Representative Name
6722 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
6723 'Executing the Cursor c_sales_rep_acc_sources_csr. l_sales_rep_id = ' ||
6724 TO_CHAR(p_acc_sources_rec.jtf_sales_reps_pk) );
6725 FOR t_rec IN c_sales_rep_acc_sources_csr (p_jtf_sales_rep_pk => p_acc_sources_rec.jtf_sales_reps_pk)
6726 LOOP
6727 l_pxh_rec.sales_rep_name := t_rec.name;
6728 END LOOP; -- c_sales_rep_acc_sources_csr
6729 END IF;
6730
6731 -- Fetch the Transaction Number
6732 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
6733 'Executing the Cursor c_trans_number_csr. p_header_source_id=' || l_header_source_id );
6734 FOR t_rec IN c_trans_number_csr( p_header_source_id => l_header_source_id )
6735 LOOP
6736 l_pxh_rec.trans_number := t_rec.trans_number;
6737 END LOOP; -- End for c_trans_number_csr
6738 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
6739 'Calling the okl_ap_extension_pvt.create_pxh_extension ' || l_pxh_rec.source_id );
6740 okl_ap_extension_pvt.create_pxh_extension(
6741 p_api_version => l_api_version
6742 ,p_init_msg_list => p_init_msg_list
6743 ,x_return_status => l_return_status
6744 ,x_msg_count => x_msg_count
6745 ,x_msg_data => x_msg_data
6746 ,p_pxh_rec => l_pxh_rec
6747 ,p_pxhl_tbl => l_pxhl_tbl
6748 ,x_pxh_rec => lx_pxh_rec
6749 ,x_pxhl_tbl => lx_pxhl_tbl
6750 );
6751 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
6752 'After okl_ap_extension_pvt.create_pxh_extension: l_return_status ' || l_return_status );
6753 -- Check the return status and if errored, return the error back
6754 IF (l_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
6755 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
6756 ELSIF (l_return_status = OKL_API.G_RET_STS_ERROR) THEN
6757 RAISE OKL_API.G_EXCEPTION_ERROR;
6758 END IF;
6759 -- Store the Header Extension ID into the Local Variable l_header_extension_id
6760 l_header_extension_id := lx_pxh_rec.header_extension_id;
6761 END IF;
6762 IF l_kle_id IS NOT NULL OR
6763 l_kle_id <> OKL_API.G_MISS_NUM
6764 THEN
6765 -- Start populating the Sources at the Extension Line Level
6766 -- Prepare kle_source_rec_type with khr_id, kle_id and ledger_language
6767 l_kle_source_rec.khr_id := l_khr_id;
6768 l_kle_source_rec.kle_id := l_kle_id;
6769 IF l_line_style = 'SUBSIDY'
6770 THEN
6771 -- If the Line Style is SUBSIDY, then pass the Asset line id to the
6772 -- Populate KLE Sources to fetch the Asset Details
6773 l_kle_source_rec.kle_id := l_parent_line_id;
6774 END IF;
6775 -- l_kle_source_rec.ledger_language := l_ledger_language;
6776 -- Calling populate_kle_sources
6777 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
6778 'Before Calling the populate_kle_sources' );
6779 populate_kle_sources(
6780 p_api_version => l_api_version
6781 ,p_init_msg_list => p_init_msg_list
6782 ,x_kle_source_rec => l_kle_source_rec
6783 ,x_return_status => l_return_status
6784 ,x_msg_count => x_msg_count
6785 ,x_msg_data => x_msg_data );
6786 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
6787 'After populate_kle_sources: l_return_status ' || l_return_status );
6788 -- Check the return status and if errored, return the error back
6789 IF (l_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
6790 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
6791 ELSIF (l_return_status = OKL_API.G_RET_STS_ERROR) THEN
6792 RAISE OKL_API.G_EXCEPTION_ERROR;
6793 END IF;
6794 -- calling assign_kle_rec_to_pxlv_rec
6795 assign_kle_rec_to_pxl_rec(
6796 p_kle_source_rec => l_kle_source_rec
6797 ,x_pxl_rec => l_pxl_rec );
6798
6799 -- Fetch fee type code
6800 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
6801 'Executing the curosr c_k_lines_csr. p_kle_id= ' || TO_CHAR(l_kle_id));
6802 FOR t_rec IN c_k_lines_csr ( p_kle_id => l_kle_id )
6803 LOOP
6804 l_pxl_rec.fee_type_code := t_rec.fee_type;
6805 END LOOP; -- End for c_k_lines_csr
6806 --ELSE
6807 -- Populate the l_pxlv_rec with the khr_id, ledger_language
6808 -- but not with the kle_id
6809 --l_pxlv_rec.language := l_ledger_language ;
6810 END IF; -- IF l_kle_id IS NOT NULL OR l_kle_id <> OKL_API.G_MISS_NUM
6811
6812 -- Stamp the Header Extension ID on the Extension Line Table
6813 l_pxl_rec.header_extension_id := l_header_extension_id;
6814
6815 -- Fetch the Account Template ID
6816 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
6817 'Executing the curosr c_account_dist_csr. p_source_id= ' || to_char(l_source_id)
6818 || ' p_source_table= ' || to_char(l_source_table));
6819 FOR t_rec IN c_account_dist_csr (
6820 p_source_id => l_source_id
6821 ,p_source_table => l_source_table)
6822 LOOP
6823 l_template_id := t_rec.template_id;
6824 END LOOP; -- End for c_account_dist_csr
6825
6826 -- Assigning the Memo Indicator to the Extension Line Record structure ..
6827 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
6828 '** AGS Memo Flag ' || p_acc_sources_rec.memo_yn );
6829 l_pxl_rec.memo_flag := p_acc_sources_rec.memo_yn;
6830
6831 -- Fetch Memo Flag and Accounting Template Name using the template_id
6832 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
6833 'Executing the curosr c_ae_templates_csr. template_id= ' || to_char(l_template_id) );
6834 FOR t_rec IN c_ae_templates_csr (p_template_id => l_template_id)
6835 LOOP
6836 l_pxl_rec.accounting_template_name := t_rec.name;
6837 END LOOP; -- End for c_ae_templates_csr
6838
6839 -- Fetch stream type code and stream type purpose code
6840 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
6841 'Executing the curosr c_contingency_strm_b_csr. p_sty_id= ' || TO_CHAR(l_sty_id));
6842 FOR t_rec IN c_contingency_strm_b_csr ( p_sty_id => l_sty_id )
6843 LOOP
6844 l_pxl_rec.stream_type_code := t_rec.stream_type_code;
6845 l_pxl_rec.stream_type_purpose_code := t_rec.stream_type_purpose;
6846 END LOOP; -- End for c_contingency_strm_b_csr
6847
6848 -- Fetch stream type name
6849 FOR tl_sources_in IN l_pxll_tbl.FIRST .. l_pxll_tbl.LAST
6850 LOOP
6851 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
6852 'Executing the curosr c_strm_name_tl_csr. p_sty_id= ' || TO_CHAR(l_sty_id)
6853 || ' Ledger Language = ' || l_pxll_tbl(tl_sources_in).language);
6854 FOR t_rec IN c_strm_name_tl_csr ( p_sty_id => l_sty_id, p_lang => l_pxll_tbl(tl_sources_in).language )
6855 LOOP
6856 l_pxll_tbl(tl_sources_in).stream_type_name := t_rec.stream_type_name;
6857 END LOOP; -- End for c_strm_name_tl_csr
6858 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
6859 'Executing the curosr c_txl_ap_inv_desc_csr. p_tpld_id= ' || TO_CHAR(l_source_id)
6860 || ' p_lang = ' || l_pxll_tbl(tl_sources_in).language);
6861 FOR t_rec IN c_txl_ap_inv_desc_csr (
6862 p_tpld_id => l_source_id
6863 ,p_lang => l_pxll_tbl(tl_sources_in).language )
6864 LOOP
6865 l_pxll_tbl(tl_sources_in).trans_line_description := t_rec.trans_line_description;
6866 END LOOP;
6867 END LOOP;
6868
6869 -- Fetch asset category name
6870 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
6871 'Executing the curosr c_manufacture_model_csr. p_kle_id= ' || TO_CHAR(l_kle_id)
6872 || ' p_khr_id= ' || TO_CHAR(l_khr_id));
6873 FOR t_rec IN c_manufacture_model_csr ( p_kle_id => l_kle_id, p_khr_id => l_khr_id )
6874 LOOP
6875 l_pxl_rec.asset_category_name := t_rec.asset_category_name;
6876 END LOOP; -- End for c_manufacture_model_csr
6877
6878 IF(p_acc_sources_rec.inventory_org_id_pk2 IS NOT NULL AND
6879 p_acc_sources_rec.inventory_org_id_pk2 <> OKL_API.G_MISS_CHAR AND
6880 p_acc_sources_rec.inventory_item_id_pk1 IS NOT NULL AND
6881 p_acc_sources_rec.inventory_item_id_pk1 <> OKL_API.G_MISS_CHAR) THEN
6882 FOR tl_sources_in IN l_pxll_tbl.FIRST .. l_pxll_tbl.LAST
6883 LOOP
6884 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
6885 'Executing the Cursor c_inventory_item_name_csr. p_inventory_item_id_pk1= ' ||
6886 to_char(p_acc_sources_rec.inventory_item_id_pk1) || ' p_inventory_org_id_pk2=' ||
6887 to_char(p_acc_sources_rec.inventory_org_id_pk2) || ' ledger_language=' ||
6888 l_pxll_tbl(tl_sources_in).language );
6889 FOR t_rec IN c_inventory_item_name_csr(
6890 p_inventory_item_id_pk1 => p_acc_sources_rec.inventory_item_id_pk1
6891 ,p_inventory_org_id_pk2 => p_acc_sources_rec.inventory_org_id_pk2
6892 ,p_ledger_language => l_pxll_tbl(tl_sources_in).language)
6893 LOOP
6894 l_pxll_tbl(tl_sources_in).inventory_item_name := t_rec.description;
6895 l_pxl_rec.inventory_item_name_code := t_rec.b_description;
6896 END LOOP;
6897 END LOOP;
6898 END IF;
6899 IF(p_acc_sources_rec.inventory_org_id_pk2 IS NOT NULL AND
6900 p_acc_sources_rec.inventory_org_id_pk2 <> OKL_API.G_MISS_CHAR) THEN
6901 -- Populate Inventory Organization Name
6902 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
6903 '*** AGS Inventory Org ID used to fetch teh Inventory Organization Code : Org ID=' ||
6904 p_acc_sources_rec.inventory_org_id_pk2 );
6905 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
6906 'Executing the Cursor c_org_name_code_csr. p_org_id= ' || TO_CHAR(p_acc_sources_rec.inventory_org_id_pk2) );
6907 FOR t_rec IN c_org_name_code_csr(
6908 p_org_id => p_acc_sources_rec.inventory_org_id_pk2 )
6909 LOOP
6910 l_pxl_rec.inventory_org_code := t_rec.org_name;
6911 END LOOP;
6912
6913 FOR tl_sources_in IN l_pxll_tbl.FIRST .. l_pxll_tbl.LAST
6914 LOOP
6915 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
6916 'Executing the Cursor c_org_name_csr. p_org_id= ' || TO_CHAR(p_acc_sources_rec.inventory_org_id_pk2) ||
6917 ' ledger_language=' || l_pxll_tbl(tl_sources_in).language );
6918 FOR t_rec IN c_org_name_csr(
6919 p_org_id => p_acc_sources_rec.inventory_org_id_pk2
6920 ,p_ledger_lang => l_pxll_tbl(tl_sources_in).language )
6921 LOOP
6922 l_pxll_tbl(tl_sources_in).inventory_org_name := t_rec.org_name;
6923 END LOOP;
6924 END LOOP;
6925 END IF;
6926
6927 -- Calling insert_row
6928 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
6929 'Calling the okl_ap_extension_pvt.create_pxl_extension source_id=' || l_pxl_rec.source_id );
6930 okl_ap_extension_pvt.create_pxl_extension(
6931 p_api_version => l_api_version
6932 ,p_init_msg_list => p_init_msg_list
6933 ,x_return_status => l_return_status
6934 ,x_msg_count => x_msg_count
6935 ,x_msg_data => x_msg_data
6936 ,p_pxl_rec => l_pxl_rec
6937 ,p_pxll_tbl => l_pxll_tbl
6938 ,x_pxl_rec => lx_pxl_rec
6939 ,x_pxll_tbl => lx_pxll_tbl
6940 );
6941 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
6942 'After okl_ap_extension_pvt.create_pxl_extension: l_return_status ' || l_return_status );
6943 IF (l_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
6944 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
6945 ELSIF (l_return_status = OKL_API.G_RET_STS_ERROR) THEN
6946 RAISE OKL_API.G_EXCEPTION_ERROR;
6947 END IF;
6948 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
6949 'Calling okl_api.end_activity');
6950 okl_api.end_activity(
6951 x_msg_count => x_msg_count
6952 ,x_msg_data => x_msg_data);
6953 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
6954 'END OKL_SLA_ACC_SOURCES_PVT.populate_ap_sources');
6955 x_return_status := OKL_API.G_RET_STS_SUCCESS;
6956 EXCEPTION
6957 ------------------------------------------------------------
6958 -- Exception handling
6959 ------------------------------------------------------------
6960 WHEN OKL_API.G_EXCEPTION_ERROR
6961 THEN
6962 x_return_status := OKL_API.HANDLE_EXCEPTIONS (
6963 p_api_name => l_api_name
6964 ,p_pkg_name => G_PKG_NAME
6965 ,p_exc_name => OKL_API.G_RET_STS_ERROR
6966 ,x_msg_count => x_msg_count
6967 ,x_msg_data => x_msg_data
6968 ,p_api_type => '_PVT');
6969 WHEN OKL_API.G_EXCEPTION_UNEXPECTED_ERROR
6970 THEN
6971 x_return_status := OKL_API.HANDLE_EXCEPTIONS (
6972 p_api_name => l_api_name
6973 ,p_pkg_name => G_PKG_NAME
6974 ,p_exc_name => OKL_API.G_RET_STS_UNEXP_ERROR
6975 ,x_msg_count => x_msg_count
6976 ,x_msg_data => x_msg_data
6977 ,p_api_type => '_PVT');
6978 WHEN OTHERS
6979 THEN
6980 x_return_status := OKL_API.HANDLE_EXCEPTIONS (
6981 p_api_name => l_api_name
6982 ,p_pkg_name => G_PKG_NAME
6983 ,p_exc_name => 'OTHERS'
6984 ,x_msg_count => x_msg_count
6985 ,x_msg_data => x_msg_data
6986 ,p_api_type => '_PVT');
6987 END populate_ap_sources;
6988
6989 ------------------------------------------------------------------------------
6990 -- Start of comments
6991 -- API name : populate_sources
6992 -- Pre-reqs : None
6993 -- Function : populate sources for OKL AP Transactions
6994 -- Parameters :
6995 -- IN :
6996 -- pxhv_rec_type.source_id IN NUMBER Required
6997 -- pxhv_rec_type.source_table IN VARCHAR2 Required
6998 -- History : Prashant Jain created
6999 -- Version : 1.0
7000 -- End of comments
7001 ------------------------------------------------------------------------------
7002 PROCEDURE populate_sources(
7003 p_api_version IN NUMBER
7004 ,p_init_msg_list IN VARCHAR2
7005 ,p_pxhv_rec IN pxhv_rec_type
7006 ,p_pxlv_tbl IN pxlv_tbl_type
7007 ,p_acc_sources_tbl IN asev_tbl_type
7008 ,x_return_status OUT NOCOPY VARCHAR2
7009 ,x_msg_count OUT NOCOPY NUMBER
7010 ,x_msg_data OUT NOCOPY VARCHAR2
7011 )
7012 IS
7013 -- Cursor to fetch source_id, khr_id, kle_id,
7014 -- sty_id, try_id
7015 CURSOR c_ap_fcase_csr (p_header_source_id NUMBER)
7016 IS
7017 SELECT tpl.id source_id
7018 ,'OKL_TXL_AP_INV_LNS_B' source_table
7019 ,tpl.khr_id khr_id
7020 ,tpl.kle_id kle_id
7021 ,tpl.sty_id sty_id
7022 ,tap.try_id try_id
7023 ,tap.vendor_invoice_number trans_number
7024 FROM okl_trx_ap_invoices_b tap
7025 ,okl_txl_ap_inv_lns_b tpl
7026 WHERE tap.id = tpl.tap_id
7027 AND tap.id = p_header_source_id;
7028
7029 -- Data structures based on the Cursor Variables
7030 TYPE c_ap_fcase_tbl IS TABLE OF c_ap_fcase_csr%ROWTYPE
7031 INDEX BY BINARY_INTEGER;
7032 l_ap_fcase_tbl c_ap_fcase_tbl;
7033 tld_count NUMBER; -- Count of the l_ap_fcase_tbl
7034 tld_index NUMBER; -- Index for the l_ap_fcase_tbl
7035 pxl_index NUMBER; -- Index for the l_pxlv_tbl
7036 l_acc_srcs_index NUMBER; -- Index for the p_acc_sources_tbl
7037 l_capture_sources VARCHAR2(3); -- Flag to decide whether to Capture Sources or Not !
7038 -----------------------------------------------------------------
7039 -- Declare Process Variable
7040 -----------------------------------------------------------------
7041 l_api_version CONSTANT NUMBER := 1;
7042 l_api_name CONSTANT VARCHAR2(30) := 'POPULATE_SOURCES-AP';
7043 l_return_status VARCHAR2(1) := OKL_API.G_RET_STS_SUCCESS;
7044
7045 -----------------------------------------------------------------
7046 -- Local Variables
7047 -----------------------------------------------------------------
7048 l_header_source_id NUMBER;
7049 l_header_source_table VARCHAR2(30);
7050 l_pxhv_rec pxhv_rec_type;
7051 l_pxlv_rec pxlv_rec_type;
7052 l_pxlv_tbl pxlv_tbl_type;
7053 -- Local Variables for enabling the Debug Statements
7054 l_module CONSTANT fnd_log_messages.module%TYPE := G_MODULE || l_api_name;
7055 l_debug_enabled VARCHAR2(10);
7056 is_debug_procedure_on BOOLEAN;
7057 is_debug_statement_on BOOLEAN;
7058 BEGIN
7059 l_debug_enabled := okl_debug_pub.check_log_enabled;
7060 -- check for logging on PROCEDURE level
7061 is_debug_procedure_on := okl_debug_pub.check_log_on(l_module,FND_LOG.LEVEL_PROCEDURE);
7062 -- check for logging on STATEMENT level
7063 is_debug_statement_on := okl_debug_pub.check_log_on(l_module,FND_LOG.LEVEL_STATEMENT);
7064 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
7065 'begin debug OKLRSLAB.pls call ' || l_api_name);
7066 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
7067 'BEGIN API OKL_SLA_ACC_SOURCES_PVT.POPULATE_SOURCES');
7068 l_return_status := OKL_API.G_RET_STS_SUCCESS;
7069 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
7070 'Calling OKL_API.START_ACTIVITY');
7071 l_return_status := OKL_API.START_ACTIVITY(
7072 p_api_name => l_api_name
7073 ,p_pkg_name => g_pkg_name
7074 ,p_init_msg_list => p_init_msg_list
7075 ,l_api_version => l_api_version
7076 ,p_api_version => p_api_version
7077 ,p_api_type => '_PVT'
7078 ,x_return_status => l_return_status);
7079 IF (l_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
7080 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
7081 ELSIF (l_return_status = OKL_API.G_RET_STS_ERROR) THEN
7082 RAISE OKL_API.G_EXCEPTION_ERROR;
7083 END IF;
7084
7085 -- Validation 1: Source ID and Source Table should not be NULL in the
7086 -- AP Extension Header Record Structure
7087 IF (p_pxhv_rec.source_id IS NULL OR
7088 p_pxhv_rec.source_table IS NULL)
7089 THEN
7090 OKL_API.set_message(
7091 p_app_name => G_APP_NAME
7092 ,p_msg_name => G_INVALID_VALUE
7093 ,p_token1 => G_COL_NAME_TOKEN
7094 ,p_token1_value => 'HEADER.SOURCE_ID_TABLE');
7095 l_return_status := OKL_API.G_RET_STS_UNEXP_ERROR;
7096 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
7097 END IF;
7098
7099 -- Validation 2: The Header Source Table should be the
7100 -- OKL AP Invoice Trx Header . Header table only
7101 -- ie. it should be okl_trx_ap_invoices_b only
7102 IF (p_pxhv_rec.source_table <> G_TRX_AP_INVOICES_B)
7103 THEN
7104 OKL_API.set_message(
7105 p_app_name => G_APP_NAME
7106 ,p_msg_name => G_INVALID_VALUE
7107 ,p_token1 => G_COL_NAME_TOKEN
7108 ,p_token1_value => 'HEADER.SOURCE_TABLE');
7109 l_return_status := OKL_API.G_RET_STS_UNEXP_ERROR;
7110 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
7111 END IF;
7112
7113 -- Copy to local variables
7114 l_pxhv_rec := p_pxhv_rec;
7115 l_header_source_id := p_pxhv_rec.source_id;
7116 l_header_source_table := p_pxhv_rec.source_table;
7117 l_pxlv_tbl := p_pxlv_tbl;
7118 -- Validation 3: There should be atleast one Transaction Detail Line
7119 -- for which the Populate AP Sources should be called
7120 IF l_pxlv_tbl.COUNT = 0
7121 THEN
7122 OKL_API.set_message(
7123 p_app_name => G_APP_NAME
7124 ,p_msg_name => G_INVALID_VALUE
7125 ,p_token1 => G_COL_NAME_TOKEN
7126 ,p_token1_value => 'PXLV_TBL.COUNT()');
7127 l_return_status := OKL_API.G_RET_STS_UNEXP_ERROR;
7128 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
7129 END IF;
7130
7131 -- Validation 4: p_pxlv_tbl.COUNT should be equal to the p_acc_sources_tbl.COUNT
7132 IF l_pxlv_tbl.COUNT <> p_acc_sources_tbl.COUNT
7133 THEN
7134 OKL_API.set_message(
7135 p_app_name => G_APP_NAME
7136 ,p_msg_name => G_INVALID_VALUE
7137 ,p_token1 => G_COL_NAME_TOKEN
7138 ,p_token1_value => 'P_ACC_SOURCES_TBL.COUNT()');
7139 l_return_status := OKL_API.G_RET_STS_UNEXP_ERROR;
7140 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
7141 END IF;
7142
7143 -- Loop on the details for the current transaction header
7144 -- Call the populate_ap_sources
7145 -- As we wanted to store the records in the PL/SQL table starting from 1
7146 -- and after the loop, the tld_index should be nothing but the count of the
7147 -- Transaction Detail Lines fetched ...
7148 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
7149 'Executing the Cursor c_ap_fcase_csr. p_header_source_id=' ||
7150 TO_CHAR(l_header_source_id));
7151 -- Initialize the tld_count to ZERO
7152 tld_count := 0;
7153 FOR t_rec IN c_ap_fcase_csr( p_header_source_id => l_header_source_id )
7154 LOOP
7155 -- Increment the tld_count
7156 tld_count := tld_count + 1;
7157 -- Store the Current Record in the PL/SQL Table for further usage
7158 l_ap_fcase_tbl(tld_count) := t_rec;
7159 END LOOP;
7160 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
7161 'Number of Transaction Detail Lines present in DB = ' || TO_CHAR(tld_count) );
7162 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
7163 'Number of Transaction Detail Lines passed to the API = ' || TO_CHAR(l_pxlv_tbl.COUNT) );
7164 FOR tld_index IN l_ap_fcase_tbl.FIRST .. l_ap_fcase_tbl.LAST
7165 LOOP
7166 -- Logic Explanation:
7167 -- 1. Check for the Count of the Trx. Detail Lines fetched from DB
7168 -- 2. Compare this count with the count of Trx. Detail Lines passed to this API
7169 -- 3. If the count is same, then, capture sources for every Trx. Detail Line
7170 -- otherwise, capture sources for only those transaction detail line, which have
7171 -- been passed by the Accounting Engine
7172 l_capture_sources := 'N';
7173 l_acc_srcs_index := NULL;
7174 pxl_index := l_pxlv_tbl.FIRST;
7175 LOOP
7176 IF l_pxlv_tbl(pxl_index).source_id = l_ap_fcase_tbl(tld_index).source_id AND
7177 l_pxlv_tbl(pxl_index).source_table = l_ap_fcase_tbl(tld_index).source_table
7178 THEN
7179 -- Need to the Call the Populate AP Sources for this Transaction Detail Line
7180 l_capture_sources := 'Y';
7181 -- Assumption: p_pxlv_tbl and p_acc_sources_tbl are populated using the Same Index.
7182 l_acc_srcs_index := pxl_index;
7183 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
7184 'Case 2: Populate Sources has been asked to capture sources for the Current Transaction Detail by Accounting Engine ' ||
7185 ' TXD ID = ' || TO_CHAR( l_ap_fcase_tbl(tld_index).source_id ) );
7186 END IF;
7187 -- Exit when this is the Last Record or the Transaction Details has been found
7188 EXIT WHEN ( pxl_index = l_pxlv_tbl.LAST ) -- When reached End of the Table
7189 OR ( l_capture_sources = 'Y' ); -- Or When the TXD has been found
7190 -- Increment the pxl_index
7191 pxl_index := l_pxlv_tbl.NEXT( pxl_index );
7192 END LOOP; -- Loop on l_pxlv_tbl ..
7193
7194 IF l_capture_sources = 'Y'
7195 THEN
7196 -- If the AGS Index is not found then return error
7197 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
7198 'Account Generator Sources Index =' || TO_CHAR(l_acc_srcs_index) );
7199 IF l_acc_srcs_index IS NULL OR
7200 ( p_acc_sources_tbl.EXISTS(l_acc_srcs_index) = FALSE )
7201 THEN
7202 -- accounting_event_class_code is missing
7203 OKL_API.set_message(
7204 p_app_name => G_APP_NAME
7205 ,p_msg_name => G_INVALID_VALUE
7206 ,p_token1 => G_COL_NAME_TOKEN
7207 ,p_token1_value => 'AGS_SOURCES_INDEX');
7208 l_return_status := OKL_API.G_RET_STS_UNEXP_ERROR;
7209 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
7210 END IF; -- IF l_acc_sources_found = FALSE
7211
7212 l_pxhv_rec.try_id := l_ap_fcase_tbl(tld_index).try_id;
7213 l_pxhv_rec.khr_id := l_ap_fcase_tbl(tld_index).khr_id;
7214 -- l_pxhv_rec.source_id and l_pxhv_rec.source_table are already assigned
7215 -- Id of Detail Line Table
7216 l_pxlv_rec.source_id := l_ap_fcase_tbl(tld_index).source_id;
7217 l_pxlv_rec.source_table := l_ap_fcase_tbl(tld_index).source_table;
7218 l_pxlv_rec.kle_id := l_ap_fcase_tbl(tld_index).kle_id;
7219 l_pxlv_rec.sty_id := l_ap_fcase_tbl(tld_index).sty_id;
7220 --l_pxhv_rec.trans_number := l_ap_fcase_tbl(tld_index).trans_number;
7221 -- The populate_ap_sources will capture sources at extension line level always
7222 -- If the extension header sources with the l_pxlv_rec.source_id and l_pxhv_rec.khr_id is not captured
7223 -- Then only capture the extension header sources
7224 -- Calling populate_ap_sources
7225 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
7226 'Calling the populate_ap_sources' );
7227 populate_ap_sources(
7228 p_api_version => l_api_version
7229 ,p_init_msg_list => p_init_msg_list
7230 ,p_pxhv_rec => l_pxhv_rec
7231 ,p_pxlv_rec => l_pxlv_rec
7232 ,p_acc_sources_rec => p_acc_sources_tbl(l_acc_srcs_index)
7233 ,x_return_status => l_return_status
7234 ,x_msg_count => x_msg_count
7235 ,x_msg_data => x_msg_data);
7236 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
7237 'After populate_ap_sources: l_return_status ' || l_return_status );
7238 -- Check the return status and if errored, return the error back
7239 IF (l_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
7240 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
7241 ELSIF (l_return_status = OKL_API.G_RET_STS_ERROR) THEN
7242 RAISE OKL_API.G_EXCEPTION_ERROR;
7243 END IF;
7244 END IF; -- IF l_capture_sources = 'Y'
7245 END LOOP; -- Loop on l_ap_fcase_tbl ..
7246 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
7247 'Calling okl_api.end_activity');
7248 okl_api.end_activity(
7249 x_msg_count => x_msg_count
7250 ,x_msg_data => x_msg_data);
7251 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
7252 'END OKL_SLA_ACC_SOURCES_PVT.POPULATE_SOURCES');
7253 x_return_status := OKL_API.G_RET_STS_SUCCESS;
7254 EXCEPTION
7255 ------------------------------------------------------------
7256 -- Exception handling
7257 ------------------------------------------------------------
7258 WHEN OKL_API.G_EXCEPTION_ERROR
7259 THEN
7260 x_return_status := OKL_API.HANDLE_EXCEPTIONS (
7261 p_api_name => l_api_name
7262 ,p_pkg_name => G_PKG_NAME
7263 ,p_exc_name => OKL_API.G_RET_STS_ERROR
7264 ,x_msg_count => x_msg_count
7265 ,x_msg_data => x_msg_data
7266 ,p_api_type => '_PVT');
7267 WHEN OKL_API.G_EXCEPTION_UNEXPECTED_ERROR
7268 THEN
7269 x_return_status := OKL_API.HANDLE_EXCEPTIONS (
7270 p_api_name => l_api_name
7271 ,p_pkg_name => G_PKG_NAME
7272 ,p_exc_name => OKL_API.G_RET_STS_UNEXP_ERROR
7273 ,x_msg_count => x_msg_count
7274 ,x_msg_data => x_msg_data
7275 ,p_api_type => '_PVT');
7276 WHEN OTHERS
7277 THEN
7278 x_return_status := OKL_API.HANDLE_EXCEPTIONS (
7279 p_api_name => l_api_name
7280 ,p_pkg_name => G_PKG_NAME
7281 ,p_exc_name => 'OTHERS'
7282 ,x_msg_count => x_msg_count
7283 ,x_msg_data => x_msg_data
7284 ,p_api_type => '_PVT');
7285 END populate_sources;
7286
7287 PROCEDURE delete_ap_extension(
7288 p_api_version IN NUMBER
7289 ,p_init_msg_list IN VARCHAR2
7290 ,p_pxhv_rec IN pxhv_rec_type
7291 ,x_pxlv_tbl OUT NOCOPY pxlv_tbl_type
7292 ,x_return_status OUT NOCOPY VARCHAR2
7293 ,x_msg_count OUT NOCOPY NUMBER
7294 ,x_msg_data OUT NOCOPY VARCHAR2
7295 )
7296 IS
7297 -----------------------------------------------------------------
7298 -- Declare Process Variable
7299 -----------------------------------------------------------------
7300 l_api_version CONSTANT NUMBER := 1;
7301 l_api_name CONSTANT VARCHAR2(30) := 'DELETE_AP_EXTENSION';
7302 l_return_status VARCHAR2(1) := OKL_API.G_RET_STS_SUCCESS;
7303 pxl_index BINARY_INTEGER;
7304 l_pxhv_rec okl_pxh_pvt.pxhv_rec_type;
7305 l_pxlv_tbl okl_pxl_pvt.pxlv_tbl_type;
7306 lx_pxhv_rec okl_pxh_pvt.pxhv_rec_type;
7307 lx_pxlv_tbl okl_pxl_pvt.pxlv_tbl_type;
7308 -- Cursor Definitions
7309 CURSOR get_ap_ext_hdr_id( p_source_id NUMBER, p_source_table VARCHAR2)
7310 IS
7311 SELECT pxh.header_extension_id header_extension_id
7312 FROM okl_ext_ap_header_sources_b pxh
7313 WHERE pxh.source_id = p_source_id
7314 AND pxh.source_table = p_source_table;
7315
7316 CURSOR get_ap_ext_lns_id( p_hdr_ext_id NUMBER)
7317 IS
7318 SELECT pxl.line_extension_id line_extension_id
7319 ,pxl.source_id source_id
7320 ,pxl.source_table source_table
7321 FROM okl_ext_ap_line_sources_b pxl
7322 WHERE pxl.header_extension_id = p_hdr_ext_id;
7323 -- Local Variables for enabling the Debug Statements
7324 l_module CONSTANT fnd_log_messages.module%TYPE := G_MODULE || l_api_name;
7325 l_debug_enabled VARCHAR2(10);
7326 is_debug_procedure_on BOOLEAN;
7327 is_debug_statement_on BOOLEAN;
7328 BEGIN
7329 l_debug_enabled := okl_debug_pub.check_log_enabled;
7330 -- check for logging on PROCEDURE level
7331 is_debug_procedure_on := okl_debug_pub.check_log_on(l_module,FND_LOG.LEVEL_PROCEDURE);
7332 -- check for logging on STATEMENT level
7333 is_debug_statement_on := okl_debug_pub.check_log_on(l_module,FND_LOG.LEVEL_STATEMENT);
7334 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
7335 'begin debug OKLRSLAB.pls call ' || l_api_name);
7336 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
7337 'BEGIN API OKL_SLA_ACC_SOURCES_PVT.DELETE_AP_EXTENSION');
7338 l_return_status := OKL_API.G_RET_STS_SUCCESS;
7339 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
7340 'Calling OKL_API.START_ACTIVITY');
7341 l_return_status := OKL_API.START_ACTIVITY(
7342 p_api_name => l_api_name
7343 ,p_pkg_name => g_pkg_name
7344 ,p_init_msg_list => p_init_msg_list
7345 ,l_api_version => l_api_version
7346 ,p_api_version => p_api_version
7347 ,p_api_type => '_PVT'
7348 ,x_return_status => l_return_status);
7349 IF (l_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
7350 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
7351 ELSIF (l_return_status = OKL_API.G_RET_STS_ERROR) THEN
7352 RAISE OKL_API.G_EXCEPTION_ERROR;
7353 END IF;
7354 -- Actual Logic Starts Here ..
7355 l_pxhv_rec := p_pxhv_rec;
7356 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
7357 'Source ID=' || to_char(l_pxhv_rec.source_id) || 'Source Header Table=' || l_pxhv_rec.source_table );
7358 IF ( l_pxhv_rec.source_id = OKL_API.G_MISS_NUM or l_pxhv_rec.source_id IS NULL )
7359 THEN
7360 OKL_API.set_message(
7361 p_app_name => G_APP_NAME
7362 ,p_msg_name => G_INVALID_VALUE
7363 ,p_token1 => G_COL_NAME_TOKEN
7364 ,p_token1_value => 'HEADER.SOURCE_ID');
7365 l_return_status := OKL_API.G_RET_STS_UNEXP_ERROR;
7366 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
7367 END IF;
7368 IF ( l_pxhv_rec.source_table = OKL_API.G_MISS_CHAR or l_pxhv_rec.source_table IS NULL
7369 OR l_pxhv_rec.source_table NOT IN ( G_TRX_AP_INVOICES_B) )
7370 THEN
7371 OKL_API.set_message(
7372 p_app_name => G_APP_NAME
7373 ,p_msg_name => G_INVALID_VALUE
7374 ,p_token1 => G_COL_NAME_TOKEN
7375 ,p_token1_value => 'HEADER.SOURCE_TABLE');
7376 l_return_status := OKL_API.G_RET_STS_UNEXP_ERROR;
7377 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
7378 END IF;
7379 -- Initialize the pxl_index
7380 pxl_index := 1;
7381 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
7382 'Fetch the Extension Header ID by executing cursor get_ap_ext_hdr_id' );
7383 FOR t_rec IN get_ap_ext_hdr_id(
7384 p_source_id => l_pxhv_rec.source_id
7385 ,p_source_table => l_pxhv_rec.source_table)
7386 LOOP
7387 -- Note that for a given Source ID and Source Table in OKL_EXT_AP_HEADER_SOURCES_B
7388 -- there can be multiple records each having different KHR_ID ..
7389 l_pxhv_rec.header_extension_id := t_rec.header_extension_id;
7390 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
7391 'Extension Header ID To be Deleted=' || TO_CHAR(l_pxhv_rec.header_extension_id));
7392 -- Fetch the Transaction Extension Line IDs to be deleted
7393 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
7394 'Extension Line ID(s) To be Deleted=');
7395 FOR t_rec IN get_ap_ext_lns_id( p_hdr_ext_id => l_pxhv_rec.header_extension_id)
7396 LOOP
7397 l_pxlv_tbl(pxl_index).line_extension_id := t_rec.line_extension_id;
7398 l_pxlv_tbl(pxl_index).source_id := t_rec.source_id;
7399 l_pxlv_tbl(pxl_index).source_table := t_rec.source_table;
7400 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
7401 'LINE_EXTENSION_ID[' || pxl_index || '] = ' || TO_CHAR(l_pxlv_tbl(pxl_index).line_extension_id) );
7402 -- Increment i
7403 pxl_index := pxl_index + 1;
7404 END LOOP; -- End get_trans_line_ids
7405 -- Call the Wrapper API to delete the Extension Lines and then Header
7406 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
7407 'calling the okl_ap_extension_pvt.delete_pxh_extension Line Count=' || l_pxlv_tbl.COUNT );
7408 okl_ap_extension_pvt.delete_pxh_extension(
7409 p_api_version => p_api_version
7410 ,p_init_msg_list => p_init_msg_list
7411 ,x_return_status => x_return_status
7412 ,x_msg_count => x_msg_count
7413 ,x_msg_data => x_msg_data
7414 ,p_pxhv_rec => l_pxhv_rec
7415 );
7416 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
7417 'After okl_ap_extension_pvt.delete_pxh_extension: l_return_status ' || l_return_status );
7418 -- Check the return status and if errored, return the error back
7419 IF (l_return_status = OKL_API.G_RET_STS_UNEXP_ERROR)
7420 THEN
7421 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
7422 ELSIF (l_return_status = OKL_API.G_RET_STS_ERROR) THEN
7423 RAISE OKL_API.G_EXCEPTION_ERROR;
7424 END IF;
7425 END LOOP; -- Loop on the get_ap_ext_hdr_id
7426 -- Store the Transaction Line IDs and Line Source Tables so as to return back
7427 x_pxlv_tbl := l_pxlv_tbl;
7428 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
7429 'Calling okl_api.end_activity');
7430 okl_api.end_activity(
7431 x_msg_count => x_msg_count
7432 ,x_msg_data => x_msg_data);
7433 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
7434 'END OKL_SLA_ACC_SOURCES_PVT.DELETE_AP_EXTENSION');
7435 x_return_status := OKL_API.G_RET_STS_SUCCESS;
7436 EXCEPTION
7437 ------------------------------------------------------------
7438 -- Exception handling
7439 ------------------------------------------------------------
7440 WHEN OKL_API.G_EXCEPTION_ERROR
7441 THEN
7442 x_return_status := OKL_API.HANDLE_EXCEPTIONS (
7443 p_api_name => l_api_name
7444 ,p_pkg_name => G_PKG_NAME
7445 ,p_exc_name => OKL_API.G_RET_STS_ERROR
7446 ,x_msg_count => x_msg_count
7447 ,x_msg_data => x_msg_data
7448 ,p_api_type => '_PVT');
7449 WHEN OKL_API.G_EXCEPTION_UNEXPECTED_ERROR
7450 THEN
7451 x_return_status := OKL_API.HANDLE_EXCEPTIONS (
7452 p_api_name => l_api_name
7453 ,p_pkg_name => G_PKG_NAME
7454 ,p_exc_name => OKL_API.G_RET_STS_UNEXP_ERROR
7455 ,x_msg_count => x_msg_count
7456 ,x_msg_data => x_msg_data
7457 ,p_api_type => '_PVT');
7458 WHEN OTHERS
7459 THEN
7460 x_return_status := OKL_API.HANDLE_EXCEPTIONS (
7461 p_api_name => l_api_name
7462 ,p_pkg_name => G_PKG_NAME
7463 ,p_exc_name => 'OTHERS'
7464 ,x_msg_count => x_msg_count
7465 ,x_msg_data => x_msg_data
7466 ,p_api_type => '_PVT');
7467 END delete_ap_extension;
7468 ------------------------------------------------------------------------------
7469 -- Start of comments
7470 -- API name : populate_sources
7471 -- Pre-reqs : None
7472 -- Function : populate sources for OKL FA Depreciation Transactions
7473 -- Parameters :
7474 -- IN :
7475 -- History : Prashant Jain created
7476 -- Version : 1.0
7477 -- End of comments
7478 ------------------------------------------------------------------------------
7479 PROCEDURE populate_sources(
7480 p_api_version IN NUMBER
7481 ,p_init_msg_list IN VARCHAR2
7482 ,p_khr_id IN NUMBER
7483 ,p_deprn_asset_tbl IN deprn_asset_tbl_type
7484 ,p_deprn_run_id IN NUMBER
7485 ,p_book_type_code IN VARCHAR2
7486 ,p_period_counter IN NUMBER
7487 ,x_return_status OUT NOCOPY VARCHAR2
7488 ,x_msg_count OUT NOCOPY NUMBER
7489 ,x_msg_data OUT NOCOPY VARCHAR2
7490 )
7491 IS
7492 -----------------------------------------------------------------
7493 -- Declare Process Variable
7494 -----------------------------------------------------------------
7495 l_api_version CONSTANT NUMBER := 1;
7496 l_api_name CONSTANT VARCHAR2(30) := 'POPULATE_SOURCES-DEPRN';
7497 l_return_status VARCHAR2(1) := OKL_API.G_RET_STS_SUCCESS;
7498 -----------------------------------------------------------------
7499 -- Local Variables
7500 -----------------------------------------------------------------
7501 l_khr_id NUMBER;
7502 l_kle_id NUMBER;
7503 l_asset_id NUMBER;
7504 l_try_id NUMBER;
7505 l_ledger_id NUMBER;
7506 l_ledger_language VARCHAR2(12);
7507 l_header_extension_id NUMBER;
7508 l_pk_attributes VARCHAR2(1000);
7509 l_deprn_asset_tbl deprn_asset_tbl_type;
7510 l_inventory_org_name VARCHAR2(240);
7511 l_inventory_org_code VARCHAR2(240);
7512 l_line_index NUMBER;
7513 -- KHR and KLE Based Record Structures
7514 l_khr_source_rec khr_source_rec_type;
7515 l_kle_source_rec kle_source_rec_type;
7516 -- Record structures based on FA Extension Header and Line Tables
7517 l_fxh_rec okl_fxh_pvt.fxh_rec_type;
7518 lx_fxh_rec okl_fxh_pvt.fxh_rec_type;
7519 l_fxhl_tbl okl_fxh_pvt.fxhl_tbl_type;
7520 lx_fxhl_tbl okl_fxh_pvt.fxhl_tbl_type;
7521 l_fxl_tbl_tbl fxl_tbl_tbl_type;
7522 lx_fxl_tbl_tbl fxl_tbl_tbl_type;
7523 l_fxl_tbl_tbl_out fxl_tbl_tbl_type;
7524 l_fxl_rec okl_fxl_pvt.fxl_rec_type;
7525 l_fxll_tbl okl_fxl_pvt.fxll_tbl_type;
7526 l_null_fxl_rec okl_fxl_pvt.fxl_rec_type;
7527 l_null_fxll_tbl okl_fxl_pvt.fxll_tbl_type;
7528 l_led_lang_tbl led_lang_tbl_type;
7529 -- Record structures based on the Cursor defintions
7530 l_sales_rep_csr_rec c_sales_rep_csr%ROWTYPE;
7531 l_ledger_lang_rec c_ledger_lang_csr%ROWTYPE;
7532 -- Local Variables for enabling the Debug Statements
7533 l_module CONSTANT fnd_log_messages.module%TYPE := G_MODULE || l_api_name;
7534 l_debug_enabled VARCHAR2(10);
7535 is_debug_procedure_on BOOLEAN;
7536 is_debug_statement_on BOOLEAN;
7537 tl_sources_in NUMBER := 1;
7538
7539 l_rep_type VARCHAR2(20);
7540 l_book_type_name VARCHAR2(30);
7541
7542 BEGIN
7543 l_debug_enabled := okl_debug_pub.check_log_enabled;
7544 -- check for logging on PROCEDURE level
7545 is_debug_procedure_on := okl_debug_pub.check_log_on(l_module,FND_LOG.LEVEL_PROCEDURE);
7546 -- check for logging on STATEMENT level
7547 is_debug_statement_on := okl_debug_pub.check_log_on(l_module,FND_LOG.LEVEL_STATEMENT);
7548 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
7549 'begin debug OKLRSLAB.pls call ' || l_api_name);
7550 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
7551 'BEGIN API OKL_SLA_ACC_SOURCES_PVT.POPULATE_SOURCES');
7552 l_return_status := OKL_API.G_RET_STS_SUCCESS;
7553 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
7554 'Calling OKL_API.START_ACTIVITY');
7555 l_return_status := OKL_API.START_ACTIVITY(
7556 p_api_name => l_api_name
7557 ,p_pkg_name => g_pkg_name
7558 ,p_init_msg_list => p_init_msg_list
7559 ,l_api_version => l_api_version
7560 ,p_api_version => p_api_version
7561 ,p_api_type => '_PVT'
7562 ,x_return_status => l_return_status);
7563 IF (l_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
7564 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
7565 ELSIF (l_return_status = OKL_API.G_RET_STS_ERROR) THEN
7566 RAISE OKL_API.G_EXCEPTION_ERROR;
7567 END IF;
7568 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
7569 'Before Performing validations');
7570 -- Validations to be done:
7571 -- 1. The following should be NOT NULL
7572 -- KHR_ID, Depreciation Run ID, Book Type Code, Period Name and Period Counter
7573 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
7574 'Parameters Passed: ');
7575 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
7576 'KHR_ID | DEPRN_RUN_ID ' );
7577 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
7578 p_khr_id || ' | ' || p_deprn_run_id);
7579
7580 l_pk_attributes := NULL;
7581 IF p_khr_ID IS NULL OR
7582 p_khr_ID = OKL_API.G_MISS_NUM
7583 THEN
7584 IF l_pk_attributes IS NOT NULL
7585 THEN
7586 l_pk_attributes := l_pk_attributes || ' , ';
7587 END IF;
7588 l_pk_attributes := l_pk_attributes || 'P_KHR_ID';
7589 END IF;
7590 IF p_deprn_run_id IS NULL OR
7591 p_deprn_run_id = OKL_API.G_MISS_NUM
7592 THEN
7593 IF l_pk_attributes IS NOT NULL
7594 THEN
7595 l_pk_attributes := l_pk_attributes || ' , ';
7596 END IF;
7597 l_pk_attributes := l_pk_attributes || 'P_DEPRN_RUN_ID';
7598 END IF;
7599 IF p_book_type_code IS NULL OR
7600 p_book_type_code = OKL_API.G_MISS_CHAR
7601 THEN
7602 IF l_pk_attributes IS NOT NULL
7603 THEN
7604 l_pk_attributes := l_pk_attributes || ' , ';
7605 END IF;
7606 l_pk_attributes := l_pk_attributes || 'P_BOOK_TYPE_CODE';
7607 END IF;
7608 IF p_period_counter IS NULL OR
7609 p_period_counter = OKL_API.G_MISS_NUM
7610 THEN
7611 IF l_pk_attributes IS NOT NULL
7612 THEN
7613 l_pk_attributes := l_pk_attributes || ' , ';
7614 END IF;
7615 l_pk_attributes := l_pk_attributes || 'P_PERIOD_COUNTER';
7616 END IF;
7617 IF LENGTH(l_pk_attributes) > 0
7618 THEN
7619 -- Raise an Exception
7620 OKL_API.set_message(
7621 p_app_name => G_APP_NAME
7622 ,p_msg_name => G_INVALID_VALUE
7623 ,p_token1 => G_COL_NAME_TOKEN
7624 ,p_token1_value => l_pk_attributes);
7625 l_return_status := OKL_API.G_RET_STS_UNEXP_ERROR;
7626 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
7627 END IF;
7628 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
7629 'Validation 1 Successfull !');
7630 -- Assign the p_deprn_asset_tbl to l_deprn_asset_tbl
7631 l_deprn_asset_tbl := p_deprn_asset_tbl;
7632 -- Validation 2: Atleast one KLE_ID has to be there to populate the source for ..
7633 IF l_deprn_asset_tbl.COUNT = 0
7634 THEN
7635 -- Raise an Exception
7636 OKL_API.set_message(
7637 p_app_name => G_APP_NAME
7638 ,p_msg_name => G_INVALID_VALUE
7639 ,p_token1 => G_COL_NAME_TOKEN
7640 ,p_token1_value => 'P_DEPRN_ASSET_TBL.COUNT');
7641 l_return_status := OKL_API.G_RET_STS_UNEXP_ERROR;
7642 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
7643 END IF;
7644
7645 -- Copy the Input Parameters to the Local Variables
7646 l_khr_id := p_khr_id;
7647 --l_try_id := NULL;
7648
7649 -- Need to stamp the Mandatory Columns Like
7650 -- KHR_ID, TRY_ID, SOURCE_ID, SOURCE_TABLE,
7651 -- initialize the local l_fxlv_rec to the input record values
7652 l_fxh_rec.khr_id := l_khr_id;
7653 l_fxh_rec.try_id := NULL; -- Not sure what to be stamped here
7654 l_fxh_rec.source_id := p_deprn_run_id; -- For time being stamping the Deprn Run ID
7655 l_fxh_rec.source_table := G_FA_DEPRN_SUMMARY;
7656
7657 -- get the representation details based on book_type_code. MG uptake
7658 OPEN get_reps_csr(p_book_type_code);
7659 FETCH get_reps_csr INTO l_ledger_id, l_fxh_rec.representation_code,
7660 l_fxh_rec.representation_name, l_rep_type;
7661 CLOSE get_reps_csr;
7662
7663 IF l_rep_type is not null then
7664 g_representation_type := l_rep_type;
7665 ELSE
7666 g_representation_type := 'PRIMARY';
7667 END IF;
7668
7669 /* commented as the ledger is obtained above.. MG Uptake.
7670 -- Fetch Ledger ID to fetch the Ledger Language associated to the contracts
7671 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
7672 'Executing the Cursor c_khr_to_ledger_id_csr. p_khr_id=' || TO_CHAR(l_khr_id));
7673
7674 FOR t_rec IN c_khr_to_ledger_id_csr( p_khr_id => l_khr_id )
7675 LOOP
7676 l_ledger_id := t_rec.ledger_id;
7677 END LOOP;
7678 */
7679
7680 -- Using the Ledger ID fetch the Ledger Language
7681 -- Fetch the ledger language in order to populate the sources
7682 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
7683 'Executing the Cursor c_ledger_lang_csr. p_ledger_id=' || TO_CHAR(l_ledger_id));
7684 FOR t_rec IN c_ledger_lang_csr( p_ledger_id => l_ledger_id )
7685 LOOP
7686 l_ledger_lang_rec := t_rec;
7687 l_led_lang_tbl(tl_sources_in).language := t_rec.language_code;
7688 l_fxll_tbl(tl_sources_in).language := t_rec.language_code;
7689 tl_sources_in := tl_sources_in + 1;
7690 END LOOP;
7691
7692 -- Prepare khr_source_rec_type with khr_id and ledger_language
7693 l_khr_source_rec.khr_id := l_khr_id;
7694
7695 -- Calling populate_khr_sources
7696 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
7697 'Calling the populate_khr_sources' );
7698 populate_khr_sources(
7699 p_api_version => l_api_version
7700 ,p_init_msg_list => p_init_msg_list
7701 ,x_khr_source_rec => l_khr_source_rec
7702 ,x_led_lang_tbl => l_led_lang_tbl
7703 ,x_return_status => l_return_status
7704 ,x_msg_count => x_msg_count
7705 ,x_msg_data => x_msg_data );
7706 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
7707 'After populate_khr_sources: l_return_status ' || l_return_status );
7708 -- Check the return status and if errored, return the error back
7709 IF (l_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
7710 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
7711 ELSIF (l_return_status = OKL_API.G_RET_STS_ERROR) THEN
7712 RAISE OKL_API.G_EXCEPTION_ERROR;
7713 END IF;
7714
7715 --calling assign_khr_rec_to_fxhv_rec
7716 assign_khr_rec_to_fxh_rec(
7717 p_khr_source_rec => l_khr_source_rec
7718 ,x_fxh_rec => l_fxh_rec );
7719
7720 FOR tl_sources_in IN l_led_lang_tbl.FIRST .. l_led_lang_tbl.LAST
7721 LOOP
7722 l_fxhl_tbl(tl_sources_in).language := l_led_lang_tbl(tl_sources_in).language;
7723 l_fxhl_tbl(tl_sources_in).contract_status := l_led_lang_tbl(tl_sources_in).contract_status;
7724 -- l_fxhl_tbl(tl_sources_in).inv_agrmnt_status := l_led_lang_tbl(tl_sources_in).inv_agrmnt_status;
7725 END LOOP;
7726
7727 -- Fetch and Populate Sales Representative Name
7728 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
7729 'Executing the Cursor c_sales_rep_csr. p_khr_id = ' || TO_CHAR(l_khr_id) );
7730 FOR t_rec IN c_sales_rep_csr (l_khr_id)
7731 LOOP
7732 l_sales_rep_csr_rec := t_rec;
7733 l_fxh_rec.sales_rep_name := l_sales_rep_csr_rec.name;
7734 END LOOP; -- End for c_sales_rep_csr
7735
7736 -- Fetch and Populate Inventory Organization Name
7737 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
7738 'Executing Cursor c_inventory_org_id_csr : l_khr_id = ' ||to_char(l_khr_id));
7739 FOR t_rec IN c_inventory_org_id_csr (l_khr_id)
7740 LOOP
7741 -- Assign the Inventory Organization Code
7742 l_inventory_org_code := t_rec.hrb_name;
7743 FOR tl_sources_in IN l_fxll_tbl.FIRST .. l_fxll_tbl.LAST
7744 LOOP
7745 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
7746 'Executing Cursor c_org_name_csr : p_org_id = ' ||to_char(t_rec.inv_organization_id)
7747 || ' p_ledger_lang = ' || to_char(l_fxll_tbl(tl_sources_in).language));
7748 FOR t_org_rec IN c_org_name_csr (
7749 p_org_id => t_rec.inv_organization_id
7750 ,p_ledger_lang => l_fxll_tbl(tl_sources_in).language)
7751 LOOP
7752 l_fxll_tbl(tl_sources_in).inventory_org_name := t_org_rec.org_name;
7753 END LOOP; -- End for c_org_name_csr
7754 END LOOP;
7755 END LOOP; -- End for c_inventory_org_id_csr
7756
7757 -- Calling insert_row
7758 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
7759 'Calling the okl_fa_extension_pvt.create_fxh_extension ' || l_fxh_rec.source_id );
7760 okl_fa_extension_pvt.create_fxh_extension(
7761 p_api_version => l_api_version
7762 ,p_init_msg_list => p_init_msg_list
7763 ,x_return_status => l_return_status
7764 ,x_msg_count => x_msg_count
7765 ,x_msg_data => x_msg_data
7766 ,p_fxh_rec => l_fxh_rec
7767 ,x_fxh_rec => lx_fxh_rec
7768 ,p_fxhl_tbl => l_fxhl_tbl
7769 ,x_fxhl_tbl => lx_fxhl_tbl
7770 );
7771 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
7772 'After okl_fa_extension_pvt.create_fxh_extension: l_return_status ' || l_return_status );
7773 -- Check the return status and if errored, return the error back
7774 IF (l_return_status = OKL_API.G_RET_STS_UNEXP_ERROR)
7775 THEN
7776 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
7777 ELSIF (l_return_status = OKL_API.G_RET_STS_ERROR) THEN
7778 RAISE OKL_API.G_EXCEPTION_ERROR;
7779 END IF;
7780 -- Store the Header Extension ID in to the Local Variable: l_header_extension_id
7781 l_header_extension_id := lx_fxh_rec.header_extension_id;
7782 -- Initialize the l_line_index
7783 l_line_index := 1;
7784 -- Now Loop on the Depreciated Assets Table and Capture Sources at Line Level
7785 FOR i IN l_deprn_asset_tbl.FIRST .. l_deprn_asset_tbl.LAST
7786 LOOP
7787 -- First of all Nullify the l_fxlv_rec
7788 l_fxl_rec := l_null_fxl_rec;
7789 --l_fxll_tbl := l_null_fxll_tbl;
7790 -- Assign the Mandatory Fields first like header_extension_id, fa_transaction_id [Deprn Run Id]
7791 -- kle_id, Asset ID, Source ID and Source ID.
7792 l_fxl_rec.source_id := p_deprn_run_id; -- For time bing stamping the Deprn Run ID
7793 l_fxl_rec.source_table := G_FA_DEPRN_SUMMARY;
7794 l_fxl_rec.header_extension_id := l_header_extension_id;
7795 l_fxl_rec.fa_transaction_id := p_deprn_run_id;
7796 l_fxl_rec.kle_id := l_deprn_asset_tbl(i).kle_id;
7797 l_fxl_rec.asset_id := l_deprn_asset_tbl(i).asset_id;
7798
7799 -- Store now the optional columns [But predicates for Deprn Ref. Views] like
7800 -- Book Type Code, Period Name, Period Counter
7801 l_fxl_rec.asset_book_type_code := p_book_type_code;
7802 l_fxl_rec.period_counter := p_period_counter;
7803
7804 -- MG uptake.
7805 OPEN get_book_type_name(p_book_type_code);
7806 FETCH get_book_type_name into l_fxl_rec.asset_book_type_name;
7807 CLOSE get_book_type_name;
7808
7809 -- Store the Asset and KLE_ID in the Local Varaibles for further Use
7810 l_kle_id := l_deprn_asset_tbl(i).kle_id;
7811 l_asset_id := l_deprn_asset_tbl(i).asset_id;
7812 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
7813 'KLE_ID= ' || TO_CHAR( l_kle_id) || ' ASSET_ID= ' || l_asset_id );
7814
7815 -- Prepare kle_source_rec_type with khr_id, kle_id and ledger_language
7816 l_kle_source_rec.khr_id := l_khr_id;
7817 l_kle_source_rec.kle_id := l_kle_id;
7818
7819 -- Calling populate_kle_sources
7820 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
7821 'Calling the populate_kle_sources' );
7822 populate_kle_sources(
7823 p_api_version => l_api_version
7824 ,p_init_msg_list => p_init_msg_list
7825 ,x_kle_source_rec => l_kle_source_rec
7826 ,x_return_status => l_return_status
7827 ,x_msg_count => x_msg_count
7828 ,x_msg_data => x_msg_data );
7829 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
7830 'After populate_kle_sources: l_return_status ' || l_return_status );
7831 -- Check the return status and if errored, return the error back
7832 IF (l_return_status = OKL_API.G_RET_STS_UNEXP_ERROR)
7833 THEN
7834 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
7835 ELSIF (l_return_status = OKL_API.G_RET_STS_ERROR) THEN
7836 RAISE OKL_API.G_EXCEPTION_ERROR;
7837 END IF;
7838 -- Assin the KLE Sources to the FA Extension Line
7839 assign_kle_rec_to_fxl_rec(
7840 p_kle_source_rec => l_kle_source_rec
7841 ,x_fxl_rec => l_fxl_rec );
7842
7843 -- Stamp the Inventory Org Code and Name on the Asset Line
7844 l_fxl_rec.inventory_org_code := l_inventory_org_code;
7845 --l_fxl_rec.inventory_org_name := l_inventory_org_name;
7846 -- Store the Record Structure into the table
7847 l_fxl_tbl_tbl(l_line_index).fxl_rec := l_fxl_rec;
7848 l_fxl_tbl_tbl(l_line_index).fxll_tbl := l_fxll_tbl;
7849 -- l_fxlv_tbl(l_line_index) := l_fxlv_rec;
7850 -- Increment the l_line_index
7851 l_line_index := l_line_index + 1;
7852 END LOOP; -- FOR l_line_index IN l_deprn_asset_tbl.FIRST .. l_deprn_asset_tbl.LAST
7853 -- Calling insert_row
7854 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
7855 'Calling the okl_fa_extension_pvt.create_fxl_extension-tbl Version' );
7856 okl_fa_extension_pvt.create_fxl_extension(
7857 p_api_version => l_api_version
7858 ,p_init_msg_list => p_init_msg_list
7859 ,x_return_status => l_return_status
7860 ,x_msg_count => x_msg_count
7861 ,x_msg_data => x_msg_data
7862 ,p_fxl_tbl_tbl => l_fxl_tbl_tbl
7863 ,x_fxl_tbl_tbl => lx_fxl_tbl_tbl
7864 );
7865 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
7866 'After okl_fa_extension_pvt.create_fxl_extension-tbl Version: l_return_status ' || l_return_status );
7867 -- Check the return status and if errored, return the error back
7868 IF (l_return_status = OKL_API.G_RET_STS_UNEXP_ERROR)
7869 THEN
7870 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
7871 ELSIF (l_return_status = OKL_API.G_RET_STS_ERROR)
7872 THEN
7873 RAISE OKL_API.G_EXCEPTION_ERROR;
7874 END IF;
7875 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
7876 'Calling okl_api.end_activity');
7877 okl_api.end_activity(
7878 x_msg_count => x_msg_count
7879 ,x_msg_data => x_msg_data);
7880 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
7881 'END OKL_SLA_ACC_SOURCES_PVT.POPULATE_SOURCES');
7882 x_return_status := OKL_API.G_RET_STS_SUCCESS;
7883 EXCEPTION
7884 ------------------------------------------------------------
7885 -- Exception handling
7886 ------------------------------------------------------------
7887 WHEN OKL_API.G_EXCEPTION_ERROR
7888 THEN
7889 x_return_status := OKL_API.HANDLE_EXCEPTIONS (
7890 p_api_name => l_api_name
7891 ,p_pkg_name => G_PKG_NAME
7892 ,p_exc_name => OKL_API.G_RET_STS_ERROR
7893 ,x_msg_count => x_msg_count
7894 ,x_msg_data => x_msg_data
7895 ,p_api_type => '_PVT');
7896 WHEN OKL_API.G_EXCEPTION_UNEXPECTED_ERROR
7897 THEN
7898 x_return_status := OKL_API.HANDLE_EXCEPTIONS (
7899 p_api_name => l_api_name
7900 ,p_pkg_name => G_PKG_NAME
7901 ,p_exc_name => OKL_API.G_RET_STS_UNEXP_ERROR
7902 ,x_msg_count => x_msg_count
7903 ,x_msg_data => x_msg_data
7904 ,p_api_type => '_PVT');
7905 WHEN OTHERS
7906 THEN
7907 x_return_status := OKL_API.HANDLE_EXCEPTIONS (
7908 p_api_name => l_api_name
7909 ,p_pkg_name => G_PKG_NAME
7910 ,p_exc_name => 'OTHERS'
7911 ,x_msg_count => x_msg_count
7912 ,x_msg_data => x_msg_data
7913 ,p_api_type => '_PVT');
7914 END populate_sources;
7915
7916 PROCEDURE log_msg(
7917 p_destination IN NUMBER
7918 ,p_msg IN VARCHAR2)
7919 IS
7920 BEGIN
7921 FND_FILE.PUT_LINE(p_destination, p_msg );
7922 END;
7923
7924 ------------------------------------------------------------------------------
7925 -- Start of comments
7926 -- API name : populate_deprn_sources
7927 -- Pre-reqs : None
7928 -- Function : populate sources for OKL AP Transactions
7929 -- Parameters :
7930 -- IN : Asset Book Type Code Mandatory
7931 -- Period Counter Mandatory
7932 -- Worker ID Mandatory
7933 -- Max. Deprn. Run ID Mandatory
7934 --
7935 -- History : Ravindranath Gooty created
7936 -- Version : 1.0
7937 -- Description: API called by the Parallel worker for the
7938 -- OKL: FA Capture Sources for Depreciation Transaction
7939 -- End of comments
7940 ------------------------------------------------------------------------------
7941 PROCEDURE populate_deprn_sources(
7942 errbuf OUT NOCOPY VARCHAR2
7943 ,retcode OUT NOCOPY NUMBER
7944 ,p_book_type_code IN VARCHAR2
7945 ,p_period_counter IN VARCHAR2
7946 ,p_worker_id IN VARCHAR2
7947 ,p_max_deprn_run_id IN VARCHAR2
7948 )
7949 IS
7950 CURSOR get_okl_assets_csr(
7951 p_book_type_code VARCHAR2
7952 ,p_period_counter NUMBER
7953 ,p_max_deprn_run_id NUMBER
7954 ,p_worker_id VARCHAR2
7955 )
7956 IS
7957 SELECT fa_dep.deprn_run_id deprn_run_id
7958 ,ast.dnz_chr_id khr_id
7959 ,ast.cle_id kle_id
7960 ,fa_dep.asset_id asset_id
7961 FROM fa_deprn_summary fa_dep
7962 ,okc_k_items okc_item
7963 ,okc_k_lines_b ast
7964 ,okl_parallel_processes opp
7965 WHERE fa_dep.book_type_code = p_book_type_code
7966 AND fa_dep.period_counter = p_period_counter
7967 AND fa_dep.deprn_source_code = 'DEPRN'
7968 AND fa_dep.deprn_run_id IS NOT NULL
7969 AND ( fa_dep.deprn_run_id > p_max_deprn_run_id OR
7970 p_max_deprn_run_id IS NULL )
7971 AND NVL(okc_item.object1_id2, '#') = '#'
7972 AND okc_item.jtot_object1_code = 'OKX_ASSET'
7973 AND okc_item.object1_id1 = fa_dep.asset_id
7974 AND okc_item.cle_id = ast.id
7975 AND ast.lse_id = 42 -- FIXED_ASSET Line Style ID
7976 AND opp.assigned_process = p_worker_id -- Fetch only Current Workers Contracts
7977 AND ast.dnz_chr_id = opp.khr_id
7978 ORDER BY fa_dep.deprn_run_id, ast.dnz_chr_id, ast.cle_id
7979 ; -- End of Cursor: get_okl_assets_csr
7980
7981 -- Type Declaration based on the Cursor Record Structure
7982 TYPE okl_deprn_assets_tbl IS TABLE OF get_okl_assets_csr%ROWTYPE
7983 INDEX BY BINARY_INTEGER;
7984
7985 CURSOR get_max_deprn_run_id(
7986 p_asset_book_type_code VARCHAR2
7987 ,p_period_counter NUMBER
7988 )
7989 IS
7990 SELECT MAX(fa_transaction_id) max_deprn_run_id
7991 FROM okl_ext_fa_line_sources_b fxl
7992 WHERE fxl.source_table = 'FA_DEPRN_SUMMARY'
7993 AND fxl.asset_book_type_code = p_asset_book_type_code
7994 AND fxl.period_counter = p_period_counter
7995 ; -- End of Cursor get_max_deprn_run_id
7996
7997 -- Local Variable Declaration
7998 l_outer_error_msg_tbl Okl_Accounting_Util.Error_Message_Type;
7999 l_book_type_code VARCHAR2(240);
8000 l_period_counter NUMBER;
8001 l_max_deprn_run_id NUMBER;
8002 l_fa_deprn_assets_tbl okl_deprn_assets_tbl;
8003 l_deprn_asset_tbl deprn_asset_tbl_type;
8004 l_khr_id NUMBER;
8005 l_curr_deprn_run_id NUMBER;
8006 ast_index NUMBER; -- Index for the l_deprn_asset_tbl
8007 -- Common Local Variables
8008 l_api_name CONSTANT VARCHAR2(30) := 'POPULATE_DEPRN_SOURCES';
8009 l_init_msg_list VARCHAR2(2000) := OKL_API.G_FALSE;
8010 l_return_status VARCHAR2(1) := OKL_API.G_RET_STS_SUCCESS;
8011 l_msg_count NUMBER;
8012 l_msg_data VARCHAR2(2000);
8013 l_api_version CONSTANT NUMBER := 1.0;
8014 l_khr_id_tbl Okl_Streams_Util.NumberTabTyp;
8015 khr_index NUMBER;
8016 BEGIN
8017 -- Assign the input params to the Local Variables
8018 l_book_type_code := p_book_type_code;
8019 l_period_counter := TO_NUMBER(p_period_counter);
8020 log_msg(FND_FILE.LOG, 'Parameters: ' );
8021 log_msg(FND_FILE.LOG, ' Book Type Code = ' || l_book_type_code );
8022 log_msg(FND_FILE.LOG, ' Period Counter = ' || l_period_counter );
8023 log_msg(FND_FILE.LOG, ' Worker ID = ' || p_worker_id );
8024 log_msg(FND_FILE.LOG, ' Max. Deprn. ID = ' || p_max_deprn_run_id );
8025 -- Find the Last Depreciation Run for which the Sources are captured
8026 -- for the inputted Book Type Code and Period
8027 l_max_deprn_run_id := TO_NUMBER( p_max_deprn_run_id );
8028 -- Initialize the khr_index
8029 khr_index := 0;
8030 -- Fetch all the OKL Assets for which FA has generated Depreciation Transactions
8031 -- in the inputted Asset Book and Period
8032 log_msg(FND_FILE.LOG, 'Before Executing the Cursor get_okl_assets_csr' );
8033 OPEN get_okl_assets_csr(
8034 p_book_type_code => l_book_type_code
8035 ,p_period_counter => l_period_counter
8036 ,p_max_deprn_run_id => l_max_deprn_run_id
8037 ,p_worker_id => p_worker_id
8038 );
8039 LOOP
8040 FETCH get_okl_assets_csr BULK COLLECT INTO l_fa_deprn_assets_tbl
8041 LIMIT 10000;
8042 log_msg(FND_FILE.LOG, 'After Executing the Cursor get_okl_assets_csr' );
8043 -- Exit when there are no Assets to be Processed
8044 EXIT WHEN get_okl_assets_csr%ROWCOUNT = 0;
8045 IF l_fa_deprn_assets_tbl.COUNT > 0
8046 THEN
8047 log_msg(FND_FILE.LOG, 'Total Number of Assets to be Processed in this iteration=' || l_fa_deprn_assets_tbl.COUNT );
8048 l_curr_deprn_run_id := l_fa_deprn_assets_tbl(l_fa_deprn_assets_tbl.FIRST).deprn_run_id;
8049 l_khr_id := l_fa_deprn_assets_tbl(l_fa_deprn_assets_tbl.FIRST).khr_id;
8050 -- Increment the khr_index and store the contract number in the l_khr_id_tbl
8051 khr_index := khr_index + 1;
8052 l_khr_id_tbl(khr_index) := l_khr_id; -- Store the Contract ID Already processed
8053 l_deprn_asset_tbl.DELETE;
8054 -- Initialize the ast_index
8055 ast_index := 1;
8056 log_msg(FND_FILE.OUTPUT, '-------------------------------------------------------------------' );
8057 log_msg(FND_FILE.OUTPUT, 'Capturing Sources for Deprn Run ID: ' || l_curr_deprn_run_id );
8058 log_msg(FND_FILE.OUTPUT, '-------------------------------------------------------------------' );
8059 log_msg(FND_FILE.OUTPUT, ' Capture Sources for ' );
8060 log_msg(FND_FILE.OUTPUT, ' KHR_ID=' || l_khr_id );
8061 FOR i IN l_fa_deprn_assets_tbl.FIRST .. l_fa_deprn_assets_tbl.LAST
8062 LOOP
8063 -- Logic:
8064 -- Loop on the OKL Assets Table [Ordered by KHR_ID]
8065 -- Once a break on the KHR_ID or Deprn. Run ID comes up .. Call the Populate Sources API
8066 -- Till then .. store all the assets in a collection ..
8067 IF l_curr_deprn_run_id = l_fa_deprn_assets_tbl(i).deprn_run_id AND
8068 l_khr_id = l_fa_deprn_assets_tbl(i).khr_id
8069 THEN
8070 -- Keep Storing the KLE_ID and ASSET_ID in the l_deprn_asset_tbl
8071 l_deprn_asset_tbl(ast_index).kle_id := l_fa_deprn_assets_tbl(i).kle_id;
8072 l_deprn_asset_tbl(ast_index).asset_id := l_fa_deprn_assets_tbl(i).asset_id;
8073 log_msg(FND_FILE.OUTPUT, ' KLE_ID=' || l_fa_deprn_assets_tbl(i).kle_id ||
8074 ' ASSET_ID=' || l_fa_deprn_assets_tbl(i).asset_id );
8075 -- Increment the Index
8076 ast_index := ast_index + 1;
8077 ELSE
8078 -- Call the Populate Sources
8079 log_msg(FND_FILE.LOG, 'Before Calling Populate Sources - Contract/Deprn Run Break' );
8080 log_msg(FND_FILE.LOG, ' khr_id=' || l_khr_id );
8081 log_msg(FND_FILE.LOG, ' Asset Count=' || l_deprn_asset_tbl.COUNT );
8082 log_msg(FND_FILE.LOG, ' Book Type=' || l_book_type_code );
8083 log_msg(FND_FILE.LOG, ' Period Counter=' || l_period_counter );
8084 populate_sources(
8085 p_api_version => l_api_version
8086 ,p_init_msg_list => l_init_msg_list
8087 ,p_khr_id => l_khr_id
8088 ,p_deprn_asset_tbl => l_deprn_asset_tbl
8089 ,p_deprn_run_id => l_curr_deprn_run_id
8090 ,p_book_type_code => l_book_type_code
8091 ,p_period_counter => l_period_counter
8092 ,x_return_status => l_return_status
8093 ,x_msg_count => l_msg_count
8094 ,x_msg_data => l_msg_data
8095 );
8096 log_msg(FND_FILE.LOG, ' After Calling the Populate Sources return_status=' || l_return_status );
8097 IF l_return_status = OKL_API.G_RET_STS_ERROR
8098 THEN
8099 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
8100 ELSIF (l_return_status = OKL_API.G_RET_STS_ERROR) THEN
8101 RAISE OKL_API.G_EXCEPTION_ERROR;
8102 END IF;
8103 log_msg(FND_FILE.OUTPUT, '---------------------------------------------------------' );
8104 -- Reset the Khr_id to the current KHR_ID
8105 l_khr_id := l_fa_deprn_assets_tbl(i).khr_id;
8106 -- Increment the khr_index and store the contract number in the l_khr_id_tbl
8107 khr_index := khr_index + 1;
8108 l_khr_id_tbl(khr_index) := l_khr_id; -- Store the Contract ID Already processed
8109 IF l_curr_deprn_run_id <> l_fa_deprn_assets_tbl(i).deprn_run_id
8110 THEN
8111 -- Break Happened on the Deprn Run ID itself .. Hence,
8112 -- Reset the Depreciation Run ID
8113 l_curr_deprn_run_id := l_fa_deprn_assets_tbl(i).deprn_run_id;
8114 log_msg(FND_FILE.OUTPUT, '-------------------------------------------------------------------' );
8115 log_msg(FND_FILE.OUTPUT, 'Capturing Sources for Deprn Run ID: ' || l_curr_deprn_run_id );
8116 log_msg(FND_FILE.OUTPUT, '-------------------------------------------------------------------' );
8117 END IF; -- Break on the Deprn Run ID
8118 -- Delete the l_deprn_asset_tbl
8119 l_deprn_asset_tbl.DELETE;
8120 -- Initialize teh ast_index
8121 ast_index := 1;
8122 -- Store the kle_id and asset_id in the current index of the l_deprn_asset_tbl
8123 l_deprn_asset_tbl(ast_index).kle_id := l_fa_deprn_assets_tbl(i).kle_id;
8124 l_deprn_asset_tbl(ast_index).asset_id := l_fa_deprn_assets_tbl(i).asset_id;
8125 log_msg(FND_FILE.OUTPUT, 'Capture Sources for ' );
8126 log_msg(FND_FILE.OUTPUT, ' KHR_ID=' || l_khr_id );
8127 log_msg(FND_FILE.OUTPUT, ' KLE_ID=' || l_fa_deprn_assets_tbl(i).kle_id ||
8128 ' ASSET_ID=' || l_fa_deprn_assets_tbl(i).asset_id );
8129 -- Increment the Index
8130 ast_index := ast_index + 1;
8131 END IF;
8132 END LOOP; -- FOR i IN l_deprn_assets_tbl.FIRST .. l_deprn_assets_tbl.LAST
8133 -- Call the Populate Sources at the End too for the lastly Populated Records
8134 log_msg(FND_FILE.OUTPUT, '---------------------------------------------------------' );
8135 -- Call the Populate Sources
8136 log_msg(FND_FILE.LOG, 'Before Calling Populate Sources - At the End of the Loop' );
8137 log_msg(FND_FILE.LOG, ' khr_id=' || l_khr_id );
8138 log_msg(FND_FILE.LOG, ' Asset Count=' || l_deprn_asset_tbl.COUNT );
8139 log_msg(FND_FILE.LOG, ' Book Type=' || l_book_type_code );
8140 log_msg(FND_FILE.LOG, ' Period Counter=' || l_period_counter );
8141 populate_sources(
8142 p_api_version => l_api_version
8143 ,p_init_msg_list => l_init_msg_list
8144 ,p_khr_id => l_khr_id
8145 ,p_deprn_asset_tbl => l_deprn_asset_tbl
8146 ,p_deprn_run_id => l_curr_deprn_run_id
8147 ,p_book_type_code => l_book_type_code
8148 ,p_period_counter => l_period_counter
8149 ,x_return_status => l_return_status
8150 ,x_msg_count => l_msg_count
8151 ,x_msg_data => l_msg_data
8152 );
8153 log_msg(FND_FILE.LOG, ' After Calling the Populate Sources return_status=' || l_return_status );
8154 IF l_return_status = OKL_API.G_RET_STS_ERROR
8155 THEN
8156 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
8157 ELSIF (l_return_status = OKL_API.G_RET_STS_ERROR) THEN
8158 RAISE OKL_API.G_EXCEPTION_ERROR;
8159 END IF;
8160 END IF; -- IF l_deprn_assets_tbl.COUNT > 0
8161 -- Exit When Cursor Has been Exhausted fetching all the Records
8162 EXIT WHEN get_okl_assets_csr%NOTFOUND;
8163 END LOOP; -- Loop on get_okl_assets_csr
8164 CLOSE get_okl_assets_csr; -- Close the Cursor
8165 -- Now Delete all the processed records from parallel process table
8166 FORALL khr_index IN l_khr_id_tbl.FIRST .. l_khr_id_tbl.LAST
8167 DELETE OKL_PARALLEL_PROCESSES
8168 WHERE khr_id = l_khr_id_tbl(khr_index);
8169 -- Return the Proper Return status
8170 retcode := 0; -- 0 Indicates 'S'uccess Status
8171 EXCEPTION
8172 ------------------------------------------------------------
8173 -- Exception handling
8174 ------------------------------------------------------------
8175 WHEN Okl_Api.G_EXCEPTION_ERROR
8176 THEN
8177 l_return_status := Okl_Api.G_RET_STS_ERROR;
8178 -- print the error message in the log file and output files
8179 log_msg(FND_FILE.OUTPUT,'');
8180 log_msg(FND_FILE.OUTPUT,FND_MESSAGE.GET_STRING('OKL','OKL_AGN_RPT_PROGRAM_ERROR'));
8181 log_msg(FND_FILE.LOG,FND_MESSAGE.GET_STRING('OKL','OKL_AGN_RPT_PROGRAM_STATUS')
8182 ||' '||l_return_status);
8183 Okl_Accounting_Util.GET_ERROR_MESSAGE(l_outer_error_msg_tbl);
8184 IF (l_outer_error_msg_tbl.COUNT > 0) THEN
8185 FOR i IN l_outer_error_msg_tbl.FIRST..l_outer_error_msg_tbl.LAST
8186 LOOP
8187 log_msg(FND_FILE.LOG, l_outer_error_msg_tbl(i));
8188 END LOOP;
8189 END IF;
8190 retcode := 2;
8191
8192 WHEN Okl_Api.G_EXCEPTION_UNEXPECTED_ERROR
8193 THEN
8194 l_return_status := Okl_Api.G_RET_STS_UNEXP_ERROR;
8195 -- print the error message in the log file
8196 log_msg(FND_FILE.OUTPUT,'');
8197 log_msg(FND_FILE.OUTPUT,FND_MESSAGE.GET_STRING('OKL','OKL_AGN_RPT_PROGRAM_ERROR'));
8198 log_msg(FND_FILE.LOG,FND_MESSAGE.GET_STRING('OKL','OKL_AGN_RPT_PROGRAM_STATUS')
8199 ||' '||l_return_status);
8200 Okl_Accounting_Util.GET_ERROR_MESSAGE(l_outer_error_msg_tbl);
8201 IF (l_outer_error_msg_tbl.COUNT > 0)
8202 THEN
8203 FOR i IN l_outer_error_msg_tbl.FIRST..l_outer_error_msg_tbl.LAST
8204 LOOP
8205 log_msg(FND_FILE.LOG, l_outer_error_msg_tbl(i));
8206 END LOOP;
8207 END IF;
8208 retcode := 2;
8209
8210 WHEN OTHERS
8211 THEN
8212 l_return_status := Okl_Api.G_RET_STS_UNEXP_ERROR;
8213 -- print the error message in the log file
8214 log_msg(FND_FILE.OUTPUT,'');
8215 log_msg(FND_FILE.OUTPUT,FND_MESSAGE.GET_STRING('OKL','OKL_AGN_RPT_PROGRAM_ERROR'));
8216 log_msg(FND_FILE.LOG,FND_MESSAGE.GET_STRING('OKL','OKL_AGN_RPT_PROGRAM_STATUS')
8217 ||' '||l_return_status);
8218 Okl_Accounting_Util.GET_ERROR_MESSAGE(l_outer_error_msg_tbl);
8219 IF (l_outer_error_msg_tbl.COUNT > 0)
8220 THEN
8221 FOR i IN l_outer_error_msg_tbl.FIRST..l_outer_error_msg_tbl.LAST
8222 LOOP
8223 log_msg(FND_FILE.LOG, l_outer_error_msg_tbl(i));
8224 END LOOP;
8225 END IF;
8226 errbuf := SQLERRM;
8227 retcode := 2;
8228 END populate_deprn_sources;
8229
8230 ------------------------------------------------------------------------------
8231 -- Start of comments
8232 -- API name : populate_deprn_sources_conc
8233 -- Pre-reqs : None
8234 -- Function : populate sources for OKL AP Transactions
8235 -- Parameters :
8236 -- IN : Asset Book Type Code Mandatory
8237 -- Period Counter Mandatory
8238 -- History : Ravindranath Gooty created
8239 -- Version : 1.0
8240 -- Description: API called by the Master Program of the conc. job
8241 -- OKL: FA Capture Sources for Depreciation Transaction
8242 -- End of comments
8243 ------------------------------------------------------------------------------
8244 PROCEDURE populate_deprn_sources_conc(
8245 errbuf OUT NOCOPY VARCHAR2
8246 ,retcode OUT NOCOPY NUMBER
8247 ,p_book_type_code IN VARCHAR2
8248 ,p_period_counter IN NUMBER
8249 )
8250 IS
8251 CURSOR get_deprn_contracts_csr(
8252 p_book_type_code VARCHAR2
8253 ,p_period_counter NUMBER
8254 ,p_max_deprn_run_id NUMBER
8255 )
8256 IS
8257 SELECT chr.id khr_id
8258 ,chr.contract_number contract_number
8259 ,COUNT(fa_dep.asset_id) no_of_assets
8260 FROM fa_deprn_summary fa_dep
8261 ,fa_books fa_books
8262 ,okc_k_headers_all_b chr
8263 WHERE -- Predicates on fa_deprn_summary
8264 fa_dep.book_type_code = p_book_type_code
8265 AND fa_dep.period_counter = p_period_counter
8266 AND fa_dep.deprn_source_code = 'DEPRN'
8267 AND fa_dep.deprn_run_id IS NOT NULL
8268 AND ( fa_dep.deprn_run_id > p_max_deprn_run_id OR
8269 p_max_deprn_run_id IS NULL )
8270 -- Predicates on fa_books
8271 AND fa_books.transaction_header_id_out IS NULL
8272 AND fa_books.date_ineffective IS NULL
8273 AND fa_books.contract_id IS NOT NULL
8274 -- Join Conditions between fa_deprn_summary and fa_books
8275 AND fa_dep.asset_id = fa_books.asset_id
8276 AND fa_dep.book_type_code = fa_books.book_type_code
8277 -- Join conditions between fa_books and okc_k_headers_all_b
8278 AND fa_books.contract_id = chr.id
8279 GROUP BY chr.id, CHR.contract_number
8280 ORDER BY COUNT(fa_dep.asset_id) DESC;
8281
8282 -- Cursor to fetch the Maximum Deprecation ID from the FA Extension Line Table
8283 CURSOR get_max_deprn_run_id(
8284 p_asset_book_type_code VARCHAR2
8285 ,p_period_counter NUMBER
8286 )
8287 IS
8288 SELECT MAX(fa_transaction_id) max_deprn_run_id
8289 FROM okl_ext_fa_line_sources_b fxl
8290 WHERE fxl.source_table = 'FA_DEPRN_SUMMARY'
8291 AND fxl.asset_book_type_code = p_asset_book_type_code
8292 AND fxl.period_counter = p_period_counter
8293 ; -- End of Cursor get_max_deprn_run_id
8294
8295 -- Local Record and Table Variables based on Cursors/Tables
8296 get_deprn_contracts_rec get_deprn_contracts_csr%ROWTYPE;
8297 TYPE deprn_contracts_tbl_type IS TABLE OF get_deprn_contracts_csr%ROWTYPE
8298 INDEX BY BINARY_INTEGER;
8299 l_deprn_contracts_tbl deprn_contracts_tbl_type;
8300 l_temp_deprn_contracts_tbl deprn_contracts_tbl_type;
8301 l_object_value_tbl Okl_Streams_Util.Var240TabTyp;
8302 l_assigned_process_tbl Okl_Streams_Util.Var30TabTyp;
8303 l_khr_id_tbl Okl_Streams_Util.NumberTabTyp;
8304 l_volume_tbl Okl_Streams_Util.NumberTabTyp;
8305 -- Local Variable Declaration
8306 dep_index NUMBER; -- Index for the l_deprn_contracts_tbl
8307 req_data VARCHAR2(10);
8308 l_book_type_code VARCHAR2(240);
8309 l_period_counter NUMBER;
8310 l_max_deprn_run_id NUMBER;
8311 l_num_workers NUMBER;
8312 l_seq_next NUMBER;
8313 l_data_found BOOLEAN := FALSE;
8314 l_worker_id VARCHAR2(2000);
8315 l_worker_load worker_load_tab;
8316 l_lightest_worker NUMBER;
8317 l_lightest_load NUMBER;
8318 l_reqid FND_CONCURRENT_REQUESTS.request_id%TYPE;
8319 BEGIN
8320 req_data := fnd_conc_global.request_data;
8321 log_msg(FND_FILE.LOG, 'Request Data= ' || req_data );
8322 IF req_data IS NOT NULL
8323 THEN
8324 errbuf:='Done';
8325 retcode := 0;
8326 log_msg(FND_FILE.LOG, 'Returning Out Successfully !' );
8327 RETURN;
8328 ELSE
8329 -- When the req_data is NULL, it means that this is the first run of the Program ..
8330 -- in the Sense, the current request is the run before triggerring off any parallel workers
8331 -- Fetch the Number of Workers to be Assigned
8332 l_num_workers := FND_PROFILE.VALUE(G_OKL_DEPRN_WORKERS);
8333 log_msg(FND_FILE.LOG, 'Number of Workers ' || TO_CHAR(l_num_workers) );
8334 IF l_num_workers IS NULL OR l_num_workers <= 0
8335 THEN
8336 OKL_API.set_message(
8337 p_app_name => G_APP_NAME
8338 ,p_msg_name => G_OKL_DEPRN_WORKER_ERROR);
8339 log_msg(FND_FILE.LOG, 'Please specify positive value for the profile option OKL: Capture Sources for Asset Depreciation Concurrent Workers');
8340 RAISE OKL_API.G_EXCEPTION_ERROR;
8341 END IF;
8342 -- Select sequence for marking processes
8343 SELECT okl_opp_seq.NEXTVAL
8344 INTO l_seq_next
8345 FROM DUAL;
8346 -- Assign the input params to the Local Variables
8347 l_book_type_code := p_book_type_code;
8348 l_period_counter := p_period_counter;
8349 -- Log the Input Variables
8350 log_msg(FND_FILE.LOG, 'Parameters: ' );
8351 log_msg(FND_FILE.LOG, ' Book Type Code =' || l_book_type_code );
8352 log_msg(FND_FILE.LOG, ' Period Counter =' || l_period_counter );
8353 -- Find the Last Depreciation Run for which the Sources are captured
8354 -- for the inputted Book Type Code and Period
8355 log_msg(FND_FILE.LOG, 'Before Executing the Cursor get_max_deprn_run_id' );
8356 l_max_deprn_run_id := NULL;
8357 FOR t_rec IN get_max_deprn_run_id(
8358 p_asset_book_type_code => l_book_type_code
8359 ,p_period_counter => l_period_counter
8360 )
8361 LOOP
8362 -- Store the Max. Deprn Run ID in the l_max_deprn_run_id
8363 l_max_deprn_run_id := t_rec.max_deprn_run_id;
8364 END LOOP; -- FOR t_rec IN get_max_deprn_run_id(
8365 log_msg(FND_FILE.LOG, 'After Executing the Cursor get_max_deprn_run_id. Max Deprn Run ID= ' || l_max_deprn_run_id );
8366 -- Initialize the dep_index first
8367 dep_index := 1;
8368 -- Fetch all the OKL Assets for which FA has generated Depreciation Transactions
8369 -- in the inputted Asset Book and Period
8370 log_msg(FND_FILE.LOG, 'Before Executing the Cursor get_deprn_contracts_csr' );
8371 OPEN get_deprn_contracts_csr(
8372 p_book_type_code => l_book_type_code
8373 ,p_period_counter => l_period_counter
8374 ,p_max_deprn_run_id => l_max_deprn_run_id
8375 );
8376 LOOP
8377 -- Bulk Collect the Contracts which has Assets depreciated in the inputted
8378 -- Book Type and Period
8379 FETCH get_deprn_contracts_csr BULK COLLECT INTO l_temp_deprn_contracts_tbl
8380 LIMIT G_LIMIT_SIZE;
8381 log_msg(FND_FILE.LOG, 'After Executing the fetch on the Cursor get_okl_assets_csr' );
8382 log_msg(FND_FILE.LOG, 'Distinct Contracts fetched in this Loop ' || l_temp_deprn_contracts_tbl.COUNT );
8383 -- Exit without setting the l_data_found to TRUE as no records found here
8384 EXIT WHEN get_deprn_contracts_csr%ROWCOUNT = 0;
8385 -- Assign the flag to indicate that there are few records found
8386 l_data_found := TRUE;
8387 -- Loop on the l_temp_deprn_contracts_tbl and append the records at the end of the
8388 -- l_deprn_contracts_tbl
8389 FOR i IN l_temp_deprn_contracts_tbl.FIRST .. l_temp_deprn_contracts_tbl.LAST
8390 LOOP
8391 l_deprn_contracts_tbl(dep_index) := l_temp_deprn_contracts_tbl(i);
8392 -- Increment the dep_index
8393 dep_index := dep_index + 1;
8394 END LOOP;
8395 -- Delete the Temporary Table now ..
8396 l_temp_deprn_contracts_tbl.DELETE;
8397 -- Exit when there are no Assets to be Processed
8398 EXIT WHEN get_deprn_contracts_csr%NOTFOUND;
8399 END LOOP; -- Loop on get_deprn_contracts_csr
8400 CLOSE get_deprn_contracts_csr; -- Close the Cursor
8401
8402 IF l_data_found = TRUE
8403 THEN
8404 log_msg(FND_FILE.LOG, 'Total Number of records fetched=' || l_deprn_contracts_tbl.COUNT );
8405 -- Assign the data from the l_deprn_contracts_tbl to l_pp_deprn_khrs_tbl
8406 FOR dep_index IN l_deprn_contracts_tbl.FIRST .. l_deprn_contracts_tbl.LAST
8407 LOOP
8408 l_object_value_tbl(dep_index) := l_deprn_contracts_tbl(dep_index).contract_number;
8409 l_khr_id_tbl(dep_index) := l_deprn_contracts_tbl(dep_index).khr_id;
8410 l_volume_tbl(dep_index) := l_deprn_contracts_tbl(dep_index).no_of_assets;
8411 l_assigned_process_tbl(dep_index) := TO_CHAR(l_seq_next);
8412 END LOOP;
8413 log_msg(FND_FILE.LOG, 'Successfully Populated the Individual Collection Tables object_value, khr_id, volume tables');
8414 -- Bulk Insert all the records into the OKL_PARALLEL_PROCESSES
8415 log_msg(FND_FILE.LOG, 'Before calling the Bulk Insert into the OKL_PARALLEL_PROCESSES' );
8416 FORALL dep_index IN l_deprn_contracts_tbl.FIRST .. l_deprn_contracts_tbl.LAST
8417 INSERT INTO OKL_PARALLEL_PROCESSES (
8418 OBJECT_TYPE
8419 ,OBJECT_VALUE
8420 ,ASSIGNED_PROCESS
8421 ,PROCESS_STATUS
8422 ,CREATION_DATE
8423 ,KHR_ID
8424 ,VOLUME
8425 )
8426 VALUES (
8427 G_OBJECT_TYPE_DEP_KHR -- Object Type
8428 ,l_object_value_tbl(dep_index) -- Object Value
8429 ,l_assigned_process_tbl(dep_index) -- Assigned Process
8430 ,'PENDING_ASSIGNMENT' -- Process Status
8431 ,SYSDATE -- Creation Date
8432 ,l_khr_id_tbl(dep_index) -- KHR_ID
8433 ,l_volume_tbl(dep_index) -- Volume
8434 );
8435 log_msg(FND_FILE.LOG, 'After calling the Bulk Insert into the OKL_PARALLEL_PROCESSES' );
8436 -- Commit the Records
8437 COMMIT;
8438 log_msg(FND_FILE.LOG, 'Committed the Insertion of the OKL_PARALLEL_PROCESSES Records' );
8439 -- Create l_num_workers number of Workers
8440 FOR i in 1..l_num_workers
8441 LOOP -- put all workers into a table
8442 l_worker_load(i).worker_number := i;
8443 l_worker_load(i).worker_load := 0; -- initialize load with zero
8444 l_worker_load(i).used := FALSE; -- Initialize with FALSE as none are assigned to this
8445 END LOOP;
8446 log_msg(FND_FILE.LOG, 'Initialized totally ' || l_num_workers || ' workers ' );
8447 log_msg(FND_FILE.LOG, 'Allocation of Workers for every contract is in Progress .. ' );
8448 l_lightest_worker := 1;
8449 -- Loop through the Depreciation Contracts and Assign the Workers
8450 FOR dep_index IN l_deprn_contracts_tbl.FIRST .. l_deprn_contracts_tbl.LAST
8451 LOOP
8452 l_assigned_process_tbl(dep_index) := l_lightest_worker;
8453 -- put current contract into the lightest worker
8454 IF l_worker_load.EXISTS(l_lightest_worker)
8455 THEN
8456 -- Increment the Assigned Worker Load by Number of Assets
8457 l_worker_load(l_lightest_worker).worker_load :=
8458 l_worker_load(l_lightest_worker).worker_load +
8459 l_deprn_contracts_tbl(dep_index).no_of_assets;
8460 -- Update the used flag of the current lightest worker to indicate that its used.
8461 l_worker_load(l_lightest_worker).used := TRUE;
8462 END IF;
8463 -- default the lighest load with the first element as a starting point
8464 IF l_worker_load.EXISTS(1)
8465 THEN
8466 l_lightest_load := l_worker_load(1).worker_load;
8467 l_lightest_worker := l_worker_load(1).worker_number;
8468 -- logic to find lightest load
8469 FOR i in 1..l_worker_load.COUNT
8470 LOOP
8471 IF (l_worker_load(i).worker_load = 0)
8472 OR (l_worker_load(i).worker_load < l_lightest_load)
8473 THEN
8474 l_lightest_load := l_worker_load(i).worker_load;
8475 l_lightest_worker := l_worker_load(i).worker_number;
8476 END IF;
8477 END LOOP;
8478 END IF;
8479 END LOOP; -- FOR dep_index IN l_deprn_contracts_tbl.FIRST .. l_deprn_contracts_tbl.LAST
8480 log_msg(FND_FILE.LOG, 'Done with allocation of Workers for every contract.' );
8481 log_msg(FND_FILE.LOG, 'Process Sequence Number =' || l_seq_next );
8482 log_msg(FND_FILE.LOG, 'G_OBJECT_TYPE_DEP_KHR =' || G_OBJECT_TYPE_DEP_KHR );
8483 log_msg(FND_FILE.LOG, 'Assigned Process Contract Number KHR_ID Volume ');
8484 log_msg(FND_FILE.LOG, '------------------------------------------------------------------------------------------------------------------------');
8485 FOR dep_index in l_deprn_contracts_tbl.FIRST .. l_deprn_contracts_tbl.LAST
8486 LOOP
8487 log_msg(FND_FILE.LOG, RPAD(l_assigned_process_tbl(dep_index),30, ' ') ||
8488 RPAD(l_object_value_tbl(dep_index),40, ' ') ||
8489 RPAD(l_khr_id_tbl(dep_index),32, ' ' ) ||
8490 LPAD(l_volume_tbl(dep_index),15, ' ') );
8491 END LOOP;
8492 -- Now Bulk Update the Contract Numbers in Parallel Processes with the
8493 -- Assigned Worker Number
8494 FORALL dep_index in l_deprn_contracts_tbl.FIRST .. l_deprn_contracts_tbl.LAST
8495 UPDATE OKL_PARALLEL_PROCESSES
8496 SET assigned_process = l_seq_next || '-' || l_assigned_process_tbl(dep_index)
8497 ,process_status = 'ASSIGNED'
8498 WHERE object_type = G_OBJECT_TYPE_DEP_KHR
8499 AND object_value = l_object_value_tbl(dep_index)
8500 AND process_status = 'PENDING_ASSIGNMENT'
8501 AND khr_id = l_khr_id_tbl(dep_index);
8502 log_msg(FND_FILE.LOG, 'Updated the Records in OKL_PARALLEL_PROCESSES with the Assigned Process' );
8503 -- COMMIT the Updation;
8504 COMMIT;
8505 log_msg(FND_FILE.LOG, 'Committed the Updation Changes' );
8506 FOR i in l_worker_load.FIRST .. l_worker_load.LAST
8507 LOOP
8508 -- Request only if the Worker is used and has some load to process ..
8509 IF l_worker_load(i).used
8510 THEN
8511 l_worker_id := TO_CHAR(l_seq_next)||'-'||TO_CHAR(i);
8512 -- FND_REQUEST.set_org_id(MO_GLOBAL.get_current_org_id); --MOAC- Concurrent request
8513 log_msg(FND_FILE.LOG, 'Submitted the Request with worker_id=' || l_worker_id );
8514 l_reqid := FND_REQUEST.submit_request(
8515 application => 'OKL'
8516 ,program => 'OKLCAPFADEPRNW' -- Parallel Worker Conc. Program
8517 ,sub_request => TRUE
8518 ,argument1 => p_book_type_code
8519 ,argument2 => p_period_counter
8520 ,argument3 => l_worker_id
8521 ,argument4 => l_max_deprn_run_id);
8522 log_msg(FND_FILE.LOG, ' Returned request_id=' || l_reqid );
8523 IF l_reqid = 0
8524 THEN
8525 -- Request Submission failed with Error .. Hence, Exit with Error
8526 errbuf := fnd_message.get;
8527 retcode := 2;
8528 ELSE
8529 errbuf := 'Sub-Request submitted successfully';
8530 retcode := 0 ;
8531 END IF;
8532 FND_FILE.PUT_LINE(FND_FILE.LOG, 'Launching Process '||l_worker_id||' with Request ID '||l_reqid);
8533 END IF; -- IF l_worker_load(i).used
8534 END LOOP; -- FOR j in 1 .. l_worker_load.LAST
8535 -- Set the Request Data to be used in the re-run of the Master Program ..
8536 FND_CONC_GLOBAL.set_req_globals(
8537 conc_status => 'PAUSED'
8538 ,request_data => '2 RUN'); -- Instead of NULL, it was i here ..
8539 ELSE
8540 log_msg(FND_FILE.LOG, 'No workers assigned due to no data found for prcocesing');
8541 END IF; -- IF l_data_found = TRUE
8542 END IF;
8543 END populate_deprn_sources_conc;
8544
8545 ------------------------------------------------------------------------------
8546 -- Start of comments
8547 -- API name : populate_sources
8548 -- Pre-reqs : None
8549 -- Function : populate sources for OKL Receipt Transactions
8550 -- Parameters :
8551 -- IN :
8552 -- History : Ravindranath Gooty Created
8553 -- Version : 1.0
8554 -- End of comments
8555 ------------------------------------------------------------------------------
8556 PROCEDURE populate_sources(
8557 p_api_version IN NUMBER
8558 ,p_init_msg_list IN VARCHAR2
8559 ,p_rxh_rec IN rxh_rec_type
8560 ,x_return_status OUT NOCOPY VARCHAR2
8561 ,x_msg_count OUT NOCOPY NUMBER
8562 ,x_msg_data OUT NOCOPY VARCHAR2
8563 )
8564 IS
8565 -----------------------------------------------------------------
8566 -- Declare Process Variable
8567 -----------------------------------------------------------------
8568 l_api_version CONSTANT NUMBER := 1;
8569 l_api_name CONSTANT VARCHAR2(30) := 'POPULATE_SOURCES-RECEIPT';
8570 l_return_status VARCHAR2(1) := OKL_API.G_RET_STS_SUCCESS;
8571 -- Local Variables for enabling the Debug Statements
8572 l_module CONSTANT fnd_log_messages.module%TYPE := G_MODULE || l_api_name;
8573 l_debug_enabled VARCHAR2(10);
8574 is_debug_procedure_on BOOLEAN;
8575 is_debug_statement_on BOOLEAN;
8576 -----------------------------------------------------------------
8577 -- Local Variables
8578 -----------------------------------------------------------------
8579 l_ar_receipt_id NUMBER;
8580 l_khr_id NUMBER;
8581 l_ledger_id NUMBER;
8582 l_rxh_rec rxh_rec_type;
8583 lx_rxh_rec rxh_rec_type;
8584 l_rxhl_tbl rxhl_tbl_type;
8585 lx_rxhl_tbl rxhl_tbl_type;
8586 tl_indx NUMBER; -- Index for the l_rxhl_tbl
8587 l_khr_source_rec khr_source_rec_type;
8588 l_led_lang_tbl led_lang_tbl_type;
8589 BEGIN
8590 l_debug_enabled := okl_debug_pub.check_log_enabled;
8591 -- check for logging on PROCEDURE level
8592 is_debug_procedure_on := okl_debug_pub.check_log_on(l_module,FND_LOG.LEVEL_PROCEDURE);
8593 -- check for logging on STATEMENT level
8594 is_debug_statement_on := okl_debug_pub.check_log_on(l_module,FND_LOG.LEVEL_STATEMENT);
8595 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
8596 'begin debug OKLRSLAB.pls call ' || l_api_name);
8597 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
8598 'BEGIN API OKL_SLA_ACC_SOURCES_PVT.POPULATE_SOURCES');
8599 l_return_status := OKL_API.G_RET_STS_SUCCESS;
8600 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
8601 'Calling OKL_API.START_ACTIVITY');
8602 l_return_status := OKL_API.START_ACTIVITY(
8603 p_api_name => l_api_name
8604 ,p_pkg_name => g_pkg_name
8605 ,p_init_msg_list => p_init_msg_list
8606 ,l_api_version => l_api_version
8607 ,p_api_version => p_api_version
8608 ,p_api_type => '_PVT'
8609 ,x_return_status => l_return_status);
8610 IF (l_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
8611 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
8612 ELSIF (l_return_status = OKL_API.G_RET_STS_ERROR) THEN
8613 RAISE OKL_API.G_EXCEPTION_ERROR;
8614 END IF;
8615 -- Assign the Input Parameters to the Local Variables
8616 l_ar_receipt_id := p_rxh_rec.source_id;
8617 l_khr_id := p_rxh_rec.khr_id;
8618 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
8619 'L_AR_RECEIPT_ID= ' || TO_CHAR(l_ar_receipt_id) || ' L_KHR_ID= ' || TO_CHAR(l_khr_id) );
8620 -- Validation 1: p_ar_receipt_id Should not be NULL
8621 IF l_ar_receipt_id IS NULL
8622 THEN
8623 OKL_API.set_message(
8624 p_app_name => G_APP_NAME
8625 ,p_msg_name => G_INVALID_VALUE
8626 ,p_token1 => G_COL_NAME_TOKEN
8627 ,p_token1_value => 'P_RXH_REC.SOURCE_ID');
8628 l_return_status := OKL_API.G_RET_STS_UNEXP_ERROR;
8629 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
8630 END IF;
8631 -- Validation 2: p_khr_id Should not be NULL
8632 IF l_khr_id IS NULL
8633 THEN
8634 OKL_API.set_message(
8635 p_app_name => G_APP_NAME
8636 ,p_msg_name => G_INVALID_VALUE
8637 ,p_token1 => G_COL_NAME_TOKEN
8638 ,p_token1_value => 'P_RXH_REC.KHR_ID');
8639 l_return_status := OKL_API.G_RET_STS_UNEXP_ERROR;
8640 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
8641 END IF;
8642 -- Assign the AR Receipt ID to the Header Extension Source ID Column
8643 l_rxh_rec := p_rxh_rec; -- Source ID and KHR_ID will be initalized
8644 l_rxh_rec.source_table := G_AR_CASH_RECEIPTS;
8645
8646 -- Now, fetch ledger id and ledger language associated to the contracts
8647 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
8648 'Executing the Cursor c_khr_to_ledger_id_csr. p_khr_id=' || TO_CHAR(l_khr_id));
8649 FOR t_rec IN c_khr_to_ledger_id_csr( p_khr_id => l_khr_id )
8650 LOOP
8651 l_ledger_id := t_rec.ledger_id;
8652 END LOOP;
8653
8654 -- Initialize the tl_indx
8655 tl_indx := 1;
8656 -- Fetch the ledger language in order to populate the sources
8657 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
8658 'Executing the Cursor c_ledger_lang_csr. p_ledger_id=' || TO_CHAR(l_ledger_id));
8659 FOR t_rec IN c_ledger_lang_csr( p_ledger_id => l_ledger_id )
8660 LOOP
8661 l_led_lang_tbl(tl_indx).language := t_rec.language_code;
8662 -- Increment the tl_indx
8663 tl_indx := tl_indx + 1;
8664 END LOOP;
8665 -- Call the Populate Sources to fetch the Lease Contract/IA related Sources
8666 l_khr_source_rec.khr_id := l_khr_id;
8667 -- Calling populate_khr_sources to fetch the KHR Sources
8668 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
8669 'Before calling the populate_khr_sources' );
8670 populate_khr_sources(
8671 p_api_version => l_api_version
8672 ,p_init_msg_list => p_init_msg_list
8673 ,x_khr_source_rec => l_khr_source_rec
8674 ,x_led_lang_tbl => l_led_lang_tbl
8675 ,x_return_status => l_return_status
8676 ,x_msg_count => x_msg_count
8677 ,x_msg_data => x_msg_data
8678 );
8679 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
8680 'After populate_khr_sources: l_return_status ' || l_return_status );
8681 -- Check the return status and if errored, return the error back
8682 IF (l_return_status = OKL_API.G_RET_STS_UNEXP_ERROR)
8683 THEN
8684 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
8685 ELSIF (l_return_status = OKL_API.G_RET_STS_ERROR)
8686 THEN
8687 RAISE OKL_API.G_EXCEPTION_ERROR;
8688 END IF;
8689 -- Assign the KHR Sources to the AR Extension Header Table Record
8690 assign_khr_rec_to_rxh_rec(
8691 p_khr_source_rec => l_khr_source_rec
8692 ,x_rxh_rec => l_rxh_rec );
8693 -- Fetch and Populate Sales Representative Name
8694 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
8695 'Executing the Cursor c_sales_rep_csr. p_khr_id = ' || TO_CHAR(l_khr_id) );
8696 FOR t_rec IN c_sales_rep_csr (l_khr_id)
8697 LOOP
8698 l_rxh_rec.sales_rep_name := t_rec.name;
8699 END LOOP; -- End for c_sales_rep_csr
8700
8701 FOR tl_indx IN l_led_lang_tbl.FIRST .. l_led_lang_tbl.LAST
8702 LOOP
8703 l_rxhl_tbl(tl_indx).language := l_led_lang_tbl(tl_indx).language;
8704 l_rxhl_tbl(tl_indx).contract_status := l_led_lang_tbl(tl_indx).contract_status;
8705 l_rxhl_tbl(tl_indx).inv_agrmnt_status := l_led_lang_tbl(tl_indx).inv_agrmnt_status;
8706 END LOOP;
8707
8708 -- Now call the API to insert the Sources in the OKL_EXT_AR_HEADER_SOURCES_B/_TL table
8709 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
8710 'Calling the okl_ar_extension_pvt.create_rxh_extension ' || l_rxh_rec.source_id );
8711 okl_ar_extension_pvt.create_rxh_extension(
8712 p_api_version => l_api_version
8713 ,p_init_msg_list => p_init_msg_list
8714 ,x_return_status => l_return_status
8715 ,x_msg_count => x_msg_count
8716 ,x_msg_data => x_msg_data
8717 ,p_rxh_rec => l_rxh_rec
8718 ,p_rxhl_tbl => l_rxhl_tbl
8719 ,x_rxh_rec => lx_rxh_rec
8720 ,x_rxhl_tbl => lx_rxhl_tbl
8721 );
8722 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'S',
8723 'After call to okl_ar_extension_pvt.create_rxh_extension: l_return_status ' || l_return_status );
8724 IF (l_return_status = OKL_API.G_RET_STS_UNEXP_ERROR)
8725 THEN
8726 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
8727 ELSIF (l_return_status = OKL_API.G_RET_STS_ERROR)
8728 THEN
8729 RAISE OKL_API.G_EXCEPTION_ERROR;
8730 END IF;
8731 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
8732 'Calling okl_api.end_activity');
8733 OKL_API.end_activity(
8734 x_msg_count => x_msg_count
8735 ,x_msg_data => x_msg_data);
8736 put_in_log(l_debug_enabled,is_debug_procedure_on,is_debug_statement_on,l_module, 'P',
8737 'END OKL_SLA_ACC_SOURCES_PVT.POPULATE_SOURCES_RECEIPT');
8738 x_return_status := OKL_API.G_RET_STS_SUCCESS;
8739 EXCEPTION
8740 ------------------------------------------------------------
8741 -- Exception handling
8742 ------------------------------------------------------------
8743 WHEN OKL_API.G_EXCEPTION_ERROR
8744 THEN
8745 x_return_status := OKL_API.HANDLE_EXCEPTIONS (
8746 p_api_name => l_api_name
8747 ,p_pkg_name => G_PKG_NAME
8748 ,p_exc_name => OKL_API.G_RET_STS_ERROR
8749 ,x_msg_count => x_msg_count
8750 ,x_msg_data => x_msg_data
8751 ,p_api_type => '_PVT');
8752 WHEN OKL_API.G_EXCEPTION_UNEXPECTED_ERROR
8753 THEN
8754 x_return_status := OKL_API.HANDLE_EXCEPTIONS (
8755 p_api_name => l_api_name
8756 ,p_pkg_name => G_PKG_NAME
8757 ,p_exc_name => OKL_API.G_RET_STS_UNEXP_ERROR
8758 ,x_msg_count => x_msg_count
8759 ,x_msg_data => x_msg_data
8760 ,p_api_type => '_PVT');
8761 WHEN OTHERS
8762 THEN
8763 x_return_status := OKL_API.HANDLE_EXCEPTIONS (
8764 p_api_name => l_api_name
8765 ,p_pkg_name => G_PKG_NAME
8766 ,p_exc_name => 'OTHERS'
8767 ,x_msg_count => x_msg_count
8768 ,x_msg_data => x_msg_data
8769 ,p_api_type => '_PVT');
8770 END populate_sources;
8771
8772 END okl_sla_acc_sources_pvt;