[Home] [Help]
PACKAGE BODY: APPS.FA_SLA_EVENTS_UPG_PKG
Source
1 PACKAGE BODY FA_SLA_EVENTS_UPG_PKG as
2 /* $Header: FAEVUPGB.pls 120.78.12010000.2 2008/07/31 06:43:44 sbhaskar ship $ */
3
4 Procedure Upgrade_Inv_Events (
5 p_start_rowid IN rowid,
6 p_end_rowid IN rowid,
7 p_batch_size IN number,
8 x_success_count OUT NOCOPY number,
9 x_failure_count OUT NOCOPY number,
10 x_return_status OUT NOCOPY number
11 ) IS
12
13 c_application_id constant number(15) := 140;
14 c_upgrade_bugno constant number(15) := -4107161;
15 c_fnd_user constant number(15) := 2;
16
17 c_entity_code constant varchar2(30) := 'INTER_ASSET_TRANSACTIONS';
18 c_amb_context_code constant varchar2(30) := 'DEFAULT';
19
20 -- this value can be altered in order to process more of less per batch
21 l_batch_size NUMBER;
22
23 l_rows_processed NUMBER;
24
25 -- type for table variable
26 type num_tbl_type is table of number index by binary_integer;
27 type char_tbl_type is table of varchar2(150) index by binary_integer;
28 type date_tbl_type is table of date index by binary_integer;
29 type rowid_tbl_type is table of rowid index by binary_integer;
30
31 -- used for bulk fetching
32 -- main cursor
33 l_event_id_tbl num_tbl_type;
34 l_src_asset_id_tbl num_tbl_type;
35 l_dest_asset_id_tbl num_tbl_type;
36 l_book_type_code_tbl char_tbl_type;
37 l_primary_set_of_books_id_tbl num_tbl_type;
38 l_org_id_tbl num_tbl_type;
39 l_src_trans_type_code_tbl char_tbl_type;
40 l_dest_trans_type_code_tbl char_tbl_type;
41 l_transaction_date_entered_tbl date_tbl_type;
42 l_src_thid_tbl num_tbl_type;
43 l_dest_thid_tbl num_tbl_type;
44 l_period_counter_tbl num_tbl_type;
45 l_period_name_tbl char_tbl_type;
46 l_cal_period_close_date_tbl date_tbl_type;
47 l_src_rowid_tbl rowid_tbl_type;
48 l_dest_rowid_tbl rowid_tbl_type;
49 l_trx_reference_id_tbl num_tbl_type;
50 l_src_hdr_desc_tbl char_tbl_type;
51 l_dest_hdr_desc_tbl char_tbl_type;
52 l_date_effective_tbl date_tbl_type;
53
54 l_upg_batch_id number;
55 l_ae_header_id number;
56
57 l_entity_id_tbl num_tbl_type;
58 l_event_class_code_tbl char_tbl_type;
59 l_rep_set_of_books_id_tbl num_tbl_type;
60 l_currency_code_tbl char_tbl_type;
61 l_je_category_name_tbl char_tbl_type;
62
63 l_adj_line_id_tbl num_tbl_type;
64 l_xla_gl_sl_link_id_tbl num_tbl_type;
65 l_ae_line_num_tbl num_tbl_type;
66 l_debit_amount_tbl num_tbl_type;
67 l_credit_amount_tbl num_tbl_type;
68 l_ccid_tbl num_tbl_type;
69 l_acct_class_code_tbl char_tbl_type;
70 l_line_def_owner_code_tbl char_tbl_type;
71 l_line_def_code_tbl char_tbl_type;
72 l_line_desc_tbl char_tbl_type;
73 l_gl_transfer_status_code_tbl char_tbl_type;
74 l_je_batch_id_tbl num_tbl_type;
75 l_je_header_id_tbl num_tbl_type;
76 l_je_line_num_tbl num_tbl_type;
77 l_distribution_id_tbl num_tbl_type;
78
79 l_error_level_tbl char_tbl_type;
80 l_err_entity_id_tbl num_tbl_type;
81 l_err_event_id_tbl num_tbl_type;
82 l_err_ae_header_id_tbl num_tbl_type;
83 l_err_ae_line_num_tbl num_tbl_type;
84 l_err_temp_line_num_tbl num_tbl_type;
85 l_error_message_name_tbl char_tbl_type;
86
87 CURSOR c_trans IS
88 select /*+ leading(tr) rowid(tr) */
89 xla_events_s.nextval,
90 th1.asset_id,
91 th2.asset_id,
92 tr.book_type_code,
93 bc.set_of_books_id,
94 bc.org_id,
95 th1.transaction_type_code,
96 th2.transaction_type_code,
97 th1.transaction_date_entered,
98 th1.transaction_header_id,
99 th2.transaction_header_id,
100 th1.rowid,
101 th2.rowid,
102 xla_transaction_entities_s.nextval,
103 decode(tr.transaction_type,
104 'RESERVE TRANSFER', 'RESERVE_TRANSFERS',
105 'INVOICE TRANSFER',
106 decode (th1.transaction_type_code,
107 'CIP ADJUSTMENT',
108 decode (th2.transaction_type_code,
109 'CIP ADJUSTMENT',
110 'CIP_SOURCE_LINE_TRANSFERS',
111 'SOURCE_LINE_TRANSFERS'),
112 'SOURCE_LINE_TRANSFERS'),
113 'OTHER'
114 ) event_class_code,
115 dp.period_name,
116 dp.period_counter,
117 dp.calendar_period_close_date,
118 tr.trx_reference_id,
119 lk1.description || ' - ' ||
120 to_char(dp.calendar_period_close_date, 'DD-MON-RR'),
121 lk2.description || ' - ' ||
122 to_char(dp.calendar_period_close_date, 'DD-MON-RR'),
123 nvl (decode(tr.transaction_type,
124 'RESERVE TRANSFER', bc.je_adjustment_category,
125 'INVOICE TRANSFER',
126 decode (th1.transaction_type_code,
127 'CIP ADJUSTMENT',
128 decode (th2.transaction_type_code,
129 'CIP ADJUSTMENT',
130 bc.je_cip_adjustment_category,
131 bc.je_adjustment_category),
132 bc.je_adjustment_category),
133 bc.je_adjustment_category
134 ), 'OTHER') je_category_name,
135 th1.date_effective
136 from fa_transaction_headers th1,
137 fa_transaction_headers th2,
138 fa_book_controls bc,
139 fa_deprn_periods dp,
140 fa_trx_references tr,
141 fa_lookups_tl lk1,
142 fa_lookups_tl lk2,
143 gl_period_statuses ps
144 where tr.rowid between p_start_rowid and p_end_rowid
145 and ps.application_id = 101
146 and ((ps.migration_status_code in ('P', 'U')) or
147 (dp.period_close_date is null))
148 and substr(dp.xla_conversion_status, 1, 1) in
149 ('H', 'U', 'E', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9')
150 and dp.xla_conversion_status not in ('UT', 'UA')
151 and ps.set_of_books_id = bc.set_of_books_id
152 and ps.period_name = dp.period_name
153 and tr.transaction_type in ('INVOICE TRANSFER', 'RESERVE TRANSFER')
154 and tr.book_type_code = th1.book_type_code
155 and tr.src_asset_id = th1.asset_id
156 and tr.src_transaction_header_id = th1.transaction_header_id
157 and tr.book_type_code = th2.book_type_code
158 and tr.dest_asset_id = th2.asset_id
159 and tr.dest_transaction_header_id = th2.transaction_header_id
160 and tr.book_type_code = bc.book_type_code
161 and bc.book_type_code = dp.book_type_code
162 and th1.date_effective between
163 dp.period_open_date and nvl(dp.period_close_date, sysdate)
164 and th1.member_transaction_header_id is null
165 and th1.event_id is null
166 and th1.transaction_type_code = lk1.lookup_code
167 and lk1.lookup_type = 'FAXOLTRX'
168 and th2.transaction_type_code = lk2.lookup_code
169 and lk2.lookup_type = 'FAXOLTRX'
170 and userenv('LANG') = lk1.language
171 and userenv('LANG') = lk2.language
172 and exists
173 (
174 select 'x'
175 from fa_adjustments adj
176 where th1.transaction_header_id = adj.transaction_header_id
177 and th1.book_type_code = adj.book_type_code
178 and th1.asset_id = adj.asset_id
179 )
180 and th2.date_effective between
181 dp.period_open_date and nvl(dp.period_close_date, sysdate)
182 and th2.member_transaction_header_id is null
183 and th2.event_id is null
184 and exists
185 (
186 select 'x'
187 from fa_adjustments adj
188 where th2.transaction_header_id = adj.transaction_header_id
189 and th2.book_type_code = adj.book_type_code
190 and th2.asset_id = adj.asset_id
191 );
192
193 CURSOR c_adj (l_book_type_code varchar2,
194 l_asset_id number,
195 l_transaction_header_id number,
196 l_date_effective date) IS
197 select adj.adjustment_line_id,
198 decode (adj.debit_credit_flag,
199 'DR', adj.adjustment_amount, null),
200 decode (adj.debit_credit_flag,
201 'CR', adj.adjustment_amount, null),
202 adj.code_combination_id,
203 glsob.currency_code,
204 decode (adj.adjustment_type,
205 'BONUS EXPENSE', 'EXPENSE',
206 'BONUS RESERVE', 'ASSET',
207 'CIP COST', 'ASSET',
208 'COST', 'ASSET',
209 'COST CLEARING', 'ASSET',
210 'DEPRN ADJUST', 'EXPENSE',
211 'EXPENSE', 'EXPENSE',
212 'GRP COR RESERVE', 'ASSET',
213 'GRP PRC RESERVE', 'ASSET',
214 'INTERCO AP', 'LIABILITY',
215 'INTERCO AR', 'ASSET',
216 'NBV RETIRED', 'ASSET',
217 'PROCEEDS', 'ASSET',
218 'PROCEEDS CLR', 'ASSET',
219 'REMOVALCOST', 'ASSET',
220 'REMOVALCOST CLR', 'ASSET',
221 'RESERVE', 'ASSET',
222 'REVAL RESERVE', 'ASSET',
223 'REVAL RSV RET', 'ASSET',
224 'REVAL AMORT', 'EXPENSE',
225 'REVAL EXPENSE', 'EXPENSE',
226 'ASSET'),
227 lk.description,
228 decode (adj.je_header_id, null, 'N', 'Y'),
229 gljh.je_batch_id,
230 adj.je_header_id,
231 nvl(adj.je_line_num, 0),
232 adj.distribution_id
233 from fa_adjustments adj,
234 gl_sets_of_books glsob,
235 fa_book_controls bc,
236 fa_lookups_tl lk,
237 gl_je_headers gljh
238 where bc.book_type_code = l_book_type_code
239 and bc.set_of_books_id = glsob.set_of_books_id
240 and bc.book_type_code = adj.book_type_code
241 and adj.asset_id = l_asset_id
242 and adj.transaction_header_id = l_transaction_header_id
243 and adj.code_combination_id is not null
244 and nvl(adj.track_member_flag, 'N') = 'N'
245 and lk.lookup_type = 'JOURNAL ENTRIES'
246 and lk.lookup_code = decode (adj.adjustment_type,
247 'BONUS EXPENSE', 'BONUS DEPRECIATION EXPENSE',
248 'BONUS RESERVE', 'BONUS DEPRECIATION RESERVE',
249 'CIP COST', adj.source_type_code ||' COST',
250 adj.source_type_code ||' '|| adj.adjustment_type)
251 and userenv('LANG') = lk.language
252 and adj.je_header_id = gljh.je_header_id (+)
253 UNION ALL
254 select adj.adjustment_line_id,
255 decode (adj.debit_credit_flag,
256 'DR', adj.adjustment_amount, null),
257 decode (adj.debit_credit_flag,
258 'CR', adj.adjustment_amount, null),
259 nvl(nvl(gljl.code_combination_id, da.deprn_reserve_account_ccid),
260 cb.reserve_account_ccid),
261 glsob.currency_code,
262 decode (adj.adjustment_type,
263 'BONUS EXPENSE', 'EXPENSE',
264 'BONUS RESERVE', 'ASSET',
265 'CIP COST', 'ASSET',
266 'COST', 'ASSET',
267 'COST CLEARING', 'ASSET',
268 'DEPRN ADJUST', 'EXPENSE',
269 'EXPENSE', 'EXPENSE',
270 'GRP COR RESERVE', 'ASSET',
271 'GRP PRC RESERVE', 'ASSET',
272 'INTERCO AP', 'LIABILITY',
273 'INTERCO AR', 'ASSET',
274 'NBV RETIRED', 'ASSET',
275 'PROCEEDS', 'ASSET',
276 'PROCEEDS CLR', 'ASSET',
277 'REMOVALCOST', 'ASSET',
278 'REMOVALCOST CLR', 'ASSET',
279 'RESERVE', 'ASSET',
280 'REVAL RESERVE', 'ASSET',
281 'REVAL RSV RET', 'ASSET',
282 'REVAL AMORT', 'EXPENSE',
283 'REVAL EXPENSE', 'EXPENSE',
284 'ASSET'),
285 lk.description,
286 decode (dd.je_header_id, null, 'N', 'Y'),
287 gljh.je_batch_id,
288 dd.je_header_id,
289 nvl(dd.deprn_reserve_je_line_num, 0),
290 adj.distribution_id
291 from fa_adjustments adj,
292 gl_sets_of_books glsob,
293 fa_book_controls bc,
294 fa_lookups_tl lk,
295 gl_je_headers gljh,
296 fa_deprn_detail dd,
297 gl_je_lines gljl,
298 fa_distribution_accounts da,
299 fa_asset_history ah,
300 fa_category_books cb
301 where bc.book_type_code = l_book_type_code
302 and bc.set_of_books_id = glsob.set_of_books_id
303 and bc.book_type_code = adj.book_type_code
304 and adj.asset_id = l_asset_id
305 and adj.transaction_header_id = l_transaction_header_id
306 and adj.adjustment_type = 'EXPENSE'
307 and adj.source_type_code in ('DEPRECIATION', 'CIP RETIREMENT',
308 'RETIREMENT')
309 and adj.code_combination_id is not null
310 and nvl(adj.track_member_flag, 'N') = 'N'
311 and lk.lookup_type = 'JOURNAL ENTRIES'
312 and lk.lookup_code = adj.source_type_code ||' RESERVE'
313 and userenv('LANG') = lk.language
314 and adj.asset_id = dd.asset_id (+)
315 and adj.book_type_code = dd.book_type_code (+)
316 and adj.distribution_id = dd.distribution_id (+)
317 and adj.period_counter_created = dd.period_counter (+)
318 and dd.je_header_id = gljl.je_header_id
319 and dd.deprn_reserve_je_line_num = gljl.je_line_num
320 and dd.je_header_id = gljh.je_header_id
321 and adj.book_type_code = da.book_type_code (+)
322 and adj.distribution_id = da.distribution_id (+)
323 and adj.asset_id = ah.asset_id
324 and l_date_effective >= ah.date_effective
325 and l_date_effective < nvl(ah.date_ineffective, sysdate+1)
326 and ah.category_id = cb.category_id
327 and bc.book_type_code = cb.book_type_code
328 UNION ALL
329 select adj.adjustment_line_id,
330 decode (adj.debit_credit_flag,
331 'DR', adj.adjustment_amount, null),
332 decode (adj.debit_credit_flag,
333 'CR', adj.adjustment_amount, null),
334 nvl(nvl(gljl.code_combination_id, da.deprn_reserve_account_ccid),
335 cb.reserve_account_ccid),
336 glsob.currency_code,
337 decode (adj.adjustment_type,
338 'BONUS EXPENSE', 'EXPENSE',
339 'BONUS RESERVE', 'ASSET',
340 'CIP COST', 'ASSET',
341 'COST', 'ASSET',
342 'COST CLEARING', 'ASSET',
343 'DEPRN ADJUST', 'EXPENSE',
344 'EXPENSE', 'EXPENSE',
345 'GRP COR RESERVE', 'ASSET',
346 'GRP PRC RESERVE', 'ASSET',
347 'INTERCO AP', 'LIABILITY',
348 'INTERCO AR', 'ASSET',
349 'NBV RETIRED', 'ASSET',
350 'PROCEEDS', 'ASSET',
351 'PROCEEDS CLR', 'ASSET',
352 'REMOVALCOST', 'ASSET',
353 'REMOVALCOST CLR', 'ASSET',
354 'RESERVE', 'ASSET',
355 'REVAL RESERVE', 'ASSET',
356 'REVAL RSV RET', 'ASSET',
357 'REVAL AMORT', 'EXPENSE',
358 'REVAL EXPENSE', 'EXPENSE',
359 'ASSET'),
360 lk.description,
361 decode (dd.je_header_id, null, 'N', 'Y'),
362 gljh.je_batch_id,
363 dd.je_header_id,
364 nvl(dd.deprn_reserve_je_line_num, 0),
365 adj.distribution_id
366 from fa_adjustments adj,
367 gl_sets_of_books glsob,
368 fa_book_controls bc,
369 fa_lookups_tl lk,
370 gl_je_headers gljh,
371 fa_deprn_detail dd,
372 gl_je_lines gljl,
373 fa_distribution_accounts da,
374 fa_asset_history ah,
375 fa_category_books cb
376 where bc.book_type_code = l_book_type_code
377 and bc.set_of_books_id = glsob.set_of_books_id
378 and bc.book_type_code = adj.book_type_code
379 and adj.asset_id = l_asset_id
380 and adj.transaction_header_id = l_transaction_header_id
381 and adj.adjustment_type = 'BONUS EXPENSE'
382 and adj.source_type_code = 'DEPRECIATION'
383 and adj.code_combination_id is not null
384 and nvl(adj.track_member_flag, 'N') = 'N'
385 and lk.lookup_type = 'JOURNAL ENTRIES'
386 and lk.lookup_code = 'BONUS DEPRECIATION RESERVE'
387 and userenv('LANG') = lk.language
388 and adj.asset_id = dd.asset_id (+)
389 and adj.book_type_code = dd.book_type_code (+)
390 and adj.distribution_id = dd.distribution_id (+)
391 and adj.period_counter_created = dd.period_counter (+)
392 and dd.je_header_id = gljl.je_header_id
393 and dd.bonus_deprn_rsv_je_line_num = gljl.je_line_num
394 and dd.je_header_id = gljh.je_header_id
395 and adj.book_type_code = da.book_type_code (+)
396 and adj.distribution_id = da.distribution_id (+)
397 and adj.asset_id = ah.asset_id
398 and l_date_effective >= ah.date_effective
399 and l_date_effective < nvl(ah.date_ineffective, sysdate+1)
400 and ah.category_id = cb.category_id
401 and bc.book_type_code = cb.book_type_code;
402
403 CURSOR c_mc_books (l_book_type_code varchar2) IS
404 select set_of_books_id
405 from fa_mc_book_controls
406 where book_type_code = l_book_type_code
407 and enabled_flag = 'Y';
408
409 CURSOR c_mc_adj (l_book_type_code varchar2,
410 l_asset_id number,
411 l_set_of_books_id number,
412 l_transaction_header_id number,
413 l_date_effective date) IS
414 select adj.adjustment_line_id,
415 decode (adj.debit_credit_flag,
416 'DR', adj.adjustment_amount, null),
417 decode (adj.debit_credit_flag,
418 'CR', adj.adjustment_amount, null),
419 adj.code_combination_id,
420 glsob.currency_code,
421 decode (adj.adjustment_type,
422 'BONUS EXPENSE', 'EXPENSE',
423 'BONUS RESERVE', 'ASSET',
424 'CIP COST', 'ASSET',
425 'COST', 'ASSET',
426 'COST CLEARING', 'ASSET',
427 'DEPRN ADJUST', 'EXPENSE',
428 'EXPENSE', 'EXPENSE',
429 'GRP COR RESERVE', 'ASSET',
430 'GRP PRC RESERVE', 'ASSET',
431 'INTERCO AP', 'LIABILITY',
432 'INTERCO AR', 'ASSET',
433 'NBV RETIRED', 'ASSET',
434 'PROCEEDS', 'ASSET',
435 'PROCEEDS CLR', 'ASSET',
436 'REMOVALCOST', 'ASSET',
437 'REMOVALCOST CLR', 'ASSET',
438 'RESERVE', 'ASSET',
439 'REVAL RESERVE', 'ASSET',
440 'REVAL RSV RET', 'ASSET',
441 'REVAL AMORT', 'EXPENSE',
442 'REVAL EXPENSE', 'EXPENSE',
443 'ASSET'),
444 lk.description,
445 decode (adj.je_header_id, null, 'N', 'Y'),
446 gljh.je_batch_id,
447 adj.je_header_id,
448 nvl(adj.je_line_num, 0),
449 adj.distribution_id
450 from fa_mc_adjustments adj,
451 gl_sets_of_books glsob,
452 fa_mc_book_controls bc,
453 fa_lookups_tl lk,
454 gl_je_headers gljh
455 where bc.book_type_code = l_book_type_code
456 and bc.set_of_books_id = l_set_of_books_id
457 and bc.enabled_flag = 'Y'
458 and bc.set_of_books_id = glsob.set_of_books_id
459 and bc.book_type_code = adj.book_type_code
460 and bc.set_of_books_id = adj.set_of_books_id
461 and adj.asset_id = l_asset_id
462 and adj.transaction_header_id = l_transaction_header_id
463 and adj.code_combination_id is not null
464 and nvl(adj.track_member_flag, 'N') = 'N'
465 and lk.lookup_type = 'JOURNAL ENTRIES'
466 and lk.lookup_code = decode (adj.adjustment_type,
467 'BONUS EXPENSE', 'BONUS DEPRECIATION EXPENSE',
468 'BONUS RESERVE', 'BONUS DEPRECIATION RESERVE',
469 'CIP COST', adj.source_type_code ||' COST',
470 adj.source_type_code ||' '|| adj.adjustment_type)
471 and userenv('LANG') = lk.language
472 and adj.je_header_id = gljh.je_header_id (+)
473 UNION ALL
474 select adj.adjustment_line_id,
475 decode (adj.debit_credit_flag,
476 'DR', adj.adjustment_amount, null),
477 decode (adj.debit_credit_flag,
478 'CR', adj.adjustment_amount, null),
479 nvl(nvl(gljl.code_combination_id, da.deprn_reserve_account_ccid),
480 cb.reserve_account_ccid),
481 glsob.currency_code,
482 decode (adj.adjustment_type,
483 'BONUS EXPENSE', 'EXPENSE',
484 'BONUS RESERVE', 'ASSET',
485 'CIP COST', 'ASSET',
486 'COST', 'ASSET',
487 'COST CLEARING', 'ASSET',
488 'DEPRN ADJUST', 'EXPENSE',
489 'EXPENSE', 'EXPENSE',
490 'GRP COR RESERVE', 'ASSET',
491 'GRP PRC RESERVE', 'ASSET',
492 'INTERCO AP', 'LIABILITY',
493 'INTERCO AR', 'ASSET',
494 'NBV RETIRED', 'ASSET',
495 'PROCEEDS', 'ASSET',
496 'PROCEEDS CLR', 'ASSET',
497 'REMOVALCOST', 'ASSET',
498 'REMOVALCOST CLR', 'ASSET',
499 'RESERVE', 'ASSET',
500 'REVAL RESERVE', 'ASSET',
501 'REVAL RSV RET', 'ASSET',
502 'REVAL AMORT', 'EXPENSE',
503 'REVAL EXPENSE', 'EXPENSE',
504 'ASSET'),
505 lk.description,
506 decode (dd.je_header_id, null, 'N', 'Y'),
507 gljh.je_batch_id,
508 dd.je_header_id,
509 nvl(dd.deprn_reserve_je_line_num, 0),
510 adj.distribution_id
511 from fa_mc_adjustments adj,
512 gl_sets_of_books glsob,
513 fa_mc_book_controls bc,
514 fa_lookups_tl lk,
515 gl_je_headers gljh,
516 fa_mc_deprn_detail dd,
517 gl_je_lines gljl,
518 fa_distribution_accounts da,
519 fa_asset_history ah,
520 fa_category_books cb
521 where bc.book_type_code = l_book_type_code
522 and bc.set_of_books_id = l_set_of_books_id
523 and bc.enabled_flag = 'Y'
524 and bc.set_of_books_id = glsob.set_of_books_id
525 and bc.book_type_code = adj.book_type_code
526 and bc.set_of_books_id = adj.set_of_books_id
527 and adj.asset_id = l_asset_id
528 and adj.transaction_header_id = l_transaction_header_id
529 and adj.adjustment_type = 'EXPENSE'
530 and adj.source_type_code in ('DEPRECIATION', 'CIP RETIREMENT',
531 'RETIREMENT')
532 and adj.code_combination_id is not null
533 and nvl(adj.track_member_flag, 'N') = 'N'
534 and lk.lookup_type = 'JOURNAL ENTRIES'
535 and lk.lookup_code = adj.source_type_code ||' RESERVE'
536 and userenv('LANG') = lk.language
537 and adj.asset_id = dd.asset_id (+)
538 and adj.book_type_code = dd.book_type_code (+)
539 and adj.set_of_books_id = dd.set_of_books_id (+)
540 and adj.distribution_id = dd.distribution_id (+)
541 and adj.period_counter_created = dd.period_counter (+)
542 and dd.je_header_id = gljl.je_header_id
543 and dd.deprn_reserve_je_line_num = gljl.je_line_num
544 and dd.je_header_id = gljh.je_header_id
545 and adj.book_type_code = da.book_type_code (+)
546 and adj.distribution_id = da.distribution_id (+)
547 and adj.asset_id = ah.asset_id
548 and l_date_effective >= ah.date_effective
549 and l_date_effective < nvl(ah.date_ineffective, sysdate+1)
550 and ah.category_id = cb.category_id
551 and bc.book_type_code = cb.book_type_code
552 UNION ALL
553 select adj.adjustment_line_id,
554 decode (adj.debit_credit_flag,
555 'DR', adj.adjustment_amount, null),
556 decode (adj.debit_credit_flag,
557 'CR', adj.adjustment_amount, null),
558 nvl(nvl(gljl.code_combination_id, da.deprn_reserve_account_ccid),
559 cb.reserve_account_ccid),
560 glsob.currency_code,
561 decode (adj.adjustment_type,
562 'BONUS EXPENSE', 'EXPENSE',
563 'BONUS RESERVE', 'ASSET',
564 'CIP COST', 'ASSET',
565 'COST', 'ASSET',
566 'COST CLEARING', 'ASSET',
567 'DEPRN ADJUST', 'EXPENSE',
568 'EXPENSE', 'EXPENSE',
569 'GRP COR RESERVE', 'ASSET',
570 'GRP PRC RESERVE', 'ASSET',
571 'INTERCO AP', 'LIABILITY',
572 'INTERCO AR', 'ASSET',
573 'NBV RETIRED', 'ASSET',
574 'PROCEEDS', 'ASSET',
575 'PROCEEDS CLR', 'ASSET',
576 'REMOVALCOST', 'ASSET',
577 'REMOVALCOST CLR', 'ASSET',
578 'RESERVE', 'ASSET',
579 'REVAL RESERVE', 'ASSET',
580 'REVAL RSV RET', 'ASSET',
581 'REVAL AMORT', 'EXPENSE',
582 'REVAL EXPENSE', 'EXPENSE',
583 'ASSET'),
584 lk.description,
585 decode (dd.je_header_id, null, 'N', 'Y'),
586 gljh.je_batch_id,
587 dd.je_header_id,
588 nvl(dd.deprn_reserve_je_line_num, 0),
589 adj.distribution_id
590 from fa_mc_adjustments adj,
591 gl_sets_of_books glsob,
592 fa_mc_book_controls bc,
593 fa_lookups_tl lk,
594 gl_je_headers gljh,
595 fa_mc_deprn_detail dd,
596 gl_je_lines gljl,
597 fa_distribution_accounts da,
598 fa_asset_history ah,
599 fa_category_books cb
600 where bc.book_type_code = l_book_type_code
601 and bc.set_of_books_id = l_set_of_books_id
602 and bc.enabled_flag = 'Y'
603 and bc.set_of_books_id = glsob.set_of_books_id
604 and bc.book_type_code = adj.book_type_code
605 and bc.set_of_books_id = adj.set_of_books_id
606 and adj.asset_id = l_asset_id
607 and adj.transaction_header_id = l_transaction_header_id
608 and adj.adjustment_type = 'BONUS EXPENSE'
609 and adj.source_type_code = 'DEPRECIATION'
610 and adj.code_combination_id is not null
611 and nvl(adj.track_member_flag, 'N') = 'N'
612 and lk.lookup_type = 'JOURNAL ENTRIES'
613 and lk.lookup_code = 'BONUS DEPRECIATION RESERVE'
614 and userenv('LANG') = lk.language
615 and adj.asset_id = dd.asset_id (+)
616 and adj.book_type_code = dd.book_type_code (+)
617 and adj.set_of_books_id = dd.set_of_books_id (+)
618 and adj.distribution_id = dd.distribution_id (+)
619 and adj.period_counter_created = dd.period_counter (+)
620 and dd.je_header_id = gljl.je_header_id
621 and dd.bonus_deprn_rsv_je_line_num = gljl.je_line_num
622 and dd.je_header_id = gljh.je_header_id
623 and adj.book_type_code = da.book_type_code (+)
624 and adj.distribution_id = da.distribution_id (+)
625 and adj.asset_id = ah.asset_id
626 and l_date_effective >= ah.date_effective
627 and l_date_effective < nvl(ah.date_ineffective, sysdate+1)
628 and ah.category_id = cb.category_id
629 and bc.book_type_code = cb.book_type_code;
630
631 BEGIN
632
633 x_success_count := 0;
634 x_failure_count := 0;
635
636 l_batch_size := nvl(nvl(p_batch_size, fa_cache_pkg.fa_batch_size), 1000);
637
638 open c_trans;
639 loop
640
641 fetch c_trans bulk collect
642 into l_event_id_tbl,
643 l_src_asset_id_tbl,
644 l_dest_asset_id_tbl,
645 l_book_type_code_tbl,
646 l_primary_set_of_books_id_tbl,
647 l_org_id_tbl,
648 l_src_trans_type_code_tbl,
649 l_dest_trans_type_code_tbl,
650 l_transaction_date_entered_tbl,
651 l_src_thid_tbl,
652 l_dest_thid_tbl,
653 l_src_rowid_tbl,
654 l_dest_rowid_tbl,
655 l_entity_id_tbl,
656 l_event_class_code_tbl,
657 l_period_name_tbl,
658 l_period_counter_tbl,
659 l_cal_period_close_date_tbl,
660 l_trx_reference_id_tbl,
661 l_src_hdr_desc_tbl,
662 l_dest_hdr_desc_tbl,
663 l_je_category_name_tbl,
664 l_date_effective_tbl
665 limit l_batch_size;
666
667 if (l_event_id_tbl.count = 0) then exit; end if;
668
669 -- Select upg_batch_id
670 select xla_upg_batches_s.nextval
671 into l_upg_batch_id
672 from dual;
673
674 -- Update table with event_id
675 FORALL l_count IN 1..l_event_id_tbl.count
676 update fa_transaction_headers th
677 set th.event_id = l_event_id_tbl(l_count)
678 where th.rowid = l_src_rowid_tbl(l_count);
679
680 FORALL l_count IN 1..l_event_id_tbl.count
681 update fa_transaction_headers th
682 set th.event_id = l_event_id_tbl(l_count)
683 where th.rowid = l_dest_rowid_tbl(l_count);
684
685 l_rows_processed := l_event_id_tbl.count;
686
687 -- Business Rules for xla_transaction_entities
688 -- * ledger_id is the same as set_of_books_id
689 -- * legal_entity_id is null
690 -- * entity_code is INTER_ASSET_TRANSACTIONS
691 -- * for TRANSACTIONS:
692 -- source_id_int_1 is trx_reference_id
693 -- transaction_number is trx_reference_id
694 -- * for DEPRECIATION:
695 -- source_id_int is asset_id
696 -- source_id_int_2 is period_counter
697 -- source_id_int_3 is deprn_run_id
698 -- transaction_number is set_of_books_id
699 -- * source_char_id_1 is book_type_code
700 -- * valuation_method is book_type_code
701
702 FORALL i IN 1..l_event_id_tbl.count
703 INSERT INTO xla_transaction_entities_upg (
704 upg_batch_id,
705 application_id,
706 ledger_id,
707 legal_entity_id,
708 entity_code,
709 source_id_int_1,
710 source_id_int_2,
711 source_id_int_3,
712 source_id_int_4,
713 source_id_char_1,
714 source_id_char_2,
715 source_id_char_3,
716 source_id_char_4,
717 security_id_int_1,
718 security_id_int_2,
719 security_id_int_3,
720 security_id_char_1,
721 security_id_char_2,
722 security_id_char_3,
723 transaction_number,
724 valuation_method,
725 source_application_id,
726 creation_date,
727 created_by,
728 last_update_date,
729 last_updated_by,
730 last_update_login,
731 entity_id,
732 upg_source_application_id
733 ) values (
734 l_upg_batch_id, -- upg_batch_id
735 c_application_id, -- application_id
736 l_primary_set_of_books_id_tbl(i), -- ledger_id
737 null, -- legal_entity_id,
738 c_entity_code, -- entity_code
739 l_trx_reference_id_tbl(i), -- source_id_int_1
740 null, -- source_id_int_2
741 null, -- source_id_int_3
742 null, -- source_id_int_4
743 null, -- source_id_char_1
744 null, -- source_id_char_2
745 null, -- source_id_char_3
746 null, -- source_id_char_4
747 null, -- security_id_int_1
748 null, -- security_id_int_2
749 null, -- security_id_int_3
750 null, -- security_id_char_1
751 null, -- security_id_char_2
752 null, -- security_id_char_3
753 l_trx_reference_id_tbl(i), -- transaction number
754 l_book_type_code_tbl(i), -- valuation_method
755 c_application_id, -- source_application_id
756 sysdate, -- creation_date
757 c_fnd_user, -- created_by
758 sysdate, -- last_update_date
759 c_upgrade_bugno, -- last_update_by
760 c_upgrade_bugno, -- last_update_login
761 l_entity_id_tbl(i), -- entity_id
762 c_application_id -- upg_source_application_id
763 );
764
765 -- Business Rules for xla_events
766 -- * event_type_code is similar to transaction_type_code
767 -- * event_number is 1, but is the serial event for chronological order
768 -- * event_status_code: N if event creates no journal entries
769 -- P if event would ultimately yield journals
770 -- I if event is not ready to be processed
771 -- U never use this value for upgrade
772 -- * process_status_code: E if error and journals not yet created
773 -- P if processed and journals already generated
774 -- U if unprocessed and journals not generated
775 -- D only used for Global Accounting Engine
776 -- I do not use for upgrade
777 -- * on_hold_flag: N should always be this value for upgraded entries
778 -- * event_date is basically transaction_date_entered
779
780 FORALL i IN 1..l_event_id_tbl.count
781 insert into xla_events (
782 upg_batch_id,
783 application_id,
784 event_type_code,
785 event_number,
786 event_status_code,
787 process_status_code,
788 on_hold_flag,
789 event_date,
790 creation_date,
791 created_by,
792 last_update_date,
793 last_updated_by,
794 last_update_login,
795 program_update_date,
796 program_id,
797 program_application_id,
798 request_id,
799 entity_id,
800 event_id,
801 upg_source_application_id,
802 transaction_date
803 ) values (
804 l_upg_batch_id, -- upg_batch_id
805 c_application_id, -- application_id
806 l_event_class_code_tbl(i), -- event_type_code
807 '1', -- event_number
808 'P', -- event_status_code
809 'P', -- process_status_code
810 'N', -- on_hold_flag
811 l_transaction_date_entered_tbl(i), -- event_date
812 sysdate, -- creation_date
813 c_fnd_user, -- created_by
814 sysdate, -- last_update_date
815 c_upgrade_bugno, -- last_update_by
816 c_upgrade_bugno, -- last_update_login
817 null, -- program_update_date
818 null, -- program_id
819 null, -- program_application_id
820 null, -- program_update_date
821 l_entity_id_tbl(i), -- entity_id
822 l_event_id_tbl(i), -- event_id
823 c_application_id, -- upg_source_appl_id
824 l_transaction_date_entered_tbl(i) -- transaction_date
825 );
826
827 FOR i IN 1..l_event_id_tbl.count LOOP
828
829 open c_adj (l_book_type_code_tbl(i),
830 l_src_asset_id_tbl(i),
831 l_src_thid_tbl(i),
832 l_date_effective_tbl(i));
833 fetch c_adj bulk collect
834 into l_adj_line_id_tbl,
835 l_debit_amount_tbl,
836 l_credit_amount_tbl,
837 l_ccid_tbl,
838 l_currency_code_tbl,
839 l_acct_class_code_tbl,
840 l_line_desc_tbl,
841 l_gl_transfer_status_code_tbl,
842 l_je_batch_id_tbl,
843 l_je_header_id_tbl,
844 l_je_line_num_tbl,
845 l_distribution_id_tbl;
846 close c_adj;
847
848 FOR j IN 1..l_adj_line_id_tbl.count LOOP
849 l_ae_line_num_tbl(j) := j;
850
851 select xla_gl_sl_link_id_s.nextval
852 into l_xla_gl_sl_link_id_tbl(j)
853 from dual;
854 END LOOP;
855
856 select xla_ae_headers_s.nextval
857 into l_ae_header_id
858 from dual;
859
860 -- Business Rules for xla_ae_headers
861 -- * amb_context_code is DEFAULT
862 -- * reference_date must be null
863 -- * balance_type_code:
864 -- A: Actual
865 -- B: Budget
866 -- E: Encumbrance
867 -- * gl_transfer_status_code:
868 -- Y: already transferred to GL
869 -- N: not transferred to GL
870 -- * gl_transfer_date is date entry transferred to GL
871 -- * accounting_entry_status_code must be F
872 -- * accounting_entry_type_code must be STANDARD
873 -- * product_rule_* not relevant for upgrade
874
875 insert into xla_ae_headers (
876 upg_batch_id,
877 application_id,
878 amb_context_code,
879 entity_id,
880 event_id,
881 event_type_code,
882 ae_header_id,
883 ledger_id,
884 accounting_date,
885 period_name,
886 reference_date,
887 balance_type_code,
888 je_category_name,
889 gl_transfer_status_code,
890 gl_transfer_date,
891 accounting_entry_status_code,
892 accounting_entry_type_code,
893 description,
894 budget_version_id,
895 funds_status_code,
896 encumbrance_type_id,
897 completed_date,
898 doc_sequence_id,
899 doc_sequence_value,
900 doc_category_code,
901 packet_id,
902 group_id,
903 creation_date,
904 created_by,
905 last_update_date,
906 last_updated_by,
907 last_update_login,
908 program_id,
909 program_application_id,
910 program_update_date,
911 request_id,
912 close_acct_seq_assign_id,
913 close_acct_seq_version_id,
914 close_acct_seq_value,
915 completion_acct_seq_assign_id,
916 completion_acct_seq_version_id,
917 completion_acct_seq_value,
918 accounting_batch_id,
919 product_rule_type_code,
920 product_rule_code,
921 product_rule_version,
922 upg_source_application_id,
923 upg_valid_flag
924 ) values (
925 l_upg_batch_id, -- upg_batch_id
926 c_application_id, -- application_id
927 c_amb_context_code, -- amb_context_code
928 l_entity_id_tbl(i), -- entity_id
929 l_event_id_tbl(i), -- event_id,
930 l_event_class_code_tbl(i), -- event_type_code
931 l_ae_header_id, -- ae_header_id,
932 l_primary_set_of_books_id_tbl(i),
933 -- ledger_id/sob_id
934 l_cal_period_close_date_tbl(i),
935 -- accounting_date,
936 l_period_name_tbl(i), -- period_name,
937 null, -- reference_date
938 'A', -- balance_type_code,
939 l_je_category_name_tbl(i), -- je_category_name
940 'Y', -- gl_transfer_status_code
941 null, -- gl_transfer_date
942 'F', -- accounting_entry_status_code
943 'STANDARD', -- accounting_entry_type_code
944 l_src_hdr_desc_tbl(i), -- description
945 null, -- budget_version_id
946 null, -- funds_status_code
947 null, -- encumbrance_type_id
948 null, -- completed_date
949 null, -- doc_sequence_id
950 null, -- doc_sequence_value
951 null, -- doc_category_code
952 null, -- packet_id,
953 null, -- group_id
954 sysdate, -- creation_date
955 c_fnd_user, -- created_by
956 sysdate, -- last_update_date
957 c_fnd_user, -- last_updated_by
958 c_upgrade_bugno, -- last_update_login
959 null, -- program_id
960 c_application_id, -- program_application_id
961 sysdate, -- program_update_date
962 null, -- request_id
963 null, -- close_acct_seq_assign_id
964 null, -- close_acct_seq_version_id
965 null, -- close_acct_seq_value
966 null, -- compl_acct_seq_assign_id
967 null, -- compl_acct_seq_version_id
968 null, -- compl_acct_seq_value
969 null, -- accounting_batch_id
970 null, -- product_rule_type_code
971 null, -- product_rule_code
972 null, -- product_rule_version
973 c_application_id, -- upg_souce_application_id
974 null -- upg_valid_flag
975 );
976
977 -- Business Rules for xla_ae_lines
978 -- * gl_transfer_mode_code:
979 -- D: Detailed mode when transferred to GL
980 -- S: Summary mode when transferred to GL
981 -- * gl_sl_link_table must be XLAJEL
982 -- * currency_conversion_* needs to be populated only if
983 -- different from ledger currency
984
985 forall j IN 1..l_xla_gl_sl_link_id_tbl.count
986 insert into xla_ae_lines (
987 upg_batch_id,
988 ae_header_id,
989 ae_line_num,
990 displayed_line_number,
991 application_id,
992 code_combination_id,
993 gl_transfer_mode_code,
994 accounted_dr,
995 accounted_cr,
996 currency_code,
997 currency_conversion_date,
998 currency_conversion_rate,
999 currency_conversion_type,
1000 entered_dr,
1001 entered_cr,
1002 description,
1003 accounting_class_code,
1004 gl_sl_link_id,
1005 gl_sl_link_table,
1006 party_type_code,
1007 party_id,
1008 party_site_id,
1009 statistical_amount,
1010 ussgl_transaction_code,
1011 jgzz_recon_ref,
1012 control_balance_flag,
1013 analytical_balance_flag,
1014 upg_tax_reference_id1,
1015 upg_tax_reference_id2,
1016 upg_tax_reference_id3,
1017 creation_date,
1018 created_by,
1019 last_update_date,
1020 last_updated_by,
1021 last_update_login,
1022 program_update_date,
1023 program_id,
1024 program_application_id,
1025 request_id,
1026 gain_or_loss_flag,
1027 accounting_date,
1028 ledger_id
1029 ) values (
1030 l_upg_batch_id, -- upg_batch_id
1031 l_ae_header_id, -- ae_header_id
1032 l_ae_line_num_tbl(j), -- ae_line_num
1033 l_ae_line_num_tbl(j), -- displayed_line_num
1034 c_application_id, -- application_id
1035 l_ccid_tbl(j), -- code_combination_id
1036 'S', -- gl_transfer_mode_code
1037 l_debit_amount_tbl(j), -- accounted_dr
1038 l_credit_amount_tbl(j), -- accounted_cr
1039 l_currency_code_tbl(j), -- currency_code
1040 null, -- currency_conversion_date
1041 null, -- currency_conversion_rate
1042 null, -- currency_conversion_type
1043 l_debit_amount_tbl(j), -- entered_dr
1044 l_credit_amount_tbl(j), -- entered_cr
1045 l_line_desc_tbl(j) || ' - ' ||
1046 to_char(l_cal_period_close_date_tbl(i), 'DD-MON-RR'),
1047 -- description
1048 l_acct_class_code_tbl(j), -- accounting_class_code
1049 l_xla_gl_sl_link_id_tbl(j), -- gl_sl_link_id
1050 'XLAJEL', -- gl_sl_link_table
1051 null, -- party_type_code
1052 null, -- party_id
1053 null, -- party_site_id
1054 null, -- statistical_amount
1055 null, -- ussgl_transaction_code
1056 null, -- glzz_recon_ref
1057 null, -- control_balance_flag
1058 null, -- analytical_balance_flag
1059 null, -- upg_tax_reference_id1
1060 null, -- upg_tax_reference_id2
1061 null, -- upg_tax_reference_id3
1062 sysdate, -- creation_date
1063 c_fnd_user, -- created_by
1064 sysdate, -- last_update_date
1065 c_fnd_user, -- last_updated_by
1066 c_upgrade_bugno, -- last_update_login
1067 null, -- program_update_date
1068 null, -- program_id
1069 c_application_id, -- program_application_id
1070 null, -- request_id
1071 'N', -- gain_or_loss_flag
1072 l_cal_period_close_date_tbl(i), -- accounting_date,
1073 l_primary_set_of_books_id_tbl(i)
1074 -- ledger_id/sob_id
1075 );
1076
1077 -- Business Rules for xla_distribution_links
1078 -- * accounting_line_code is similar to adjustment_type
1079 -- * accounting_line_type_code is S
1080 -- * merge_duplicate_code is N
1081 -- * source_distribution_type is TRX
1082 -- * source_distribution_id_num_1 is trx_reference_id
1083 -- * source_distribution_id_num_2 is event_id
1084
1085 forall j IN 1..l_xla_gl_sl_link_id_tbl.count
1086 insert into xla_distribution_links (
1087 upg_batch_id,
1088 application_id,
1089 event_id,
1090 ae_header_id,
1091 ae_line_num,
1092 accounting_line_code,
1093 accounting_line_type_code,
1094 source_distribution_type,
1095 source_distribution_id_char_1,
1096 source_distribution_id_char_2,
1097 source_distribution_id_char_3,
1098 source_distribution_id_char_4,
1099 source_distribution_id_char_5,
1100 source_distribution_id_num_1,
1101 source_distribution_id_num_2,
1102 source_distribution_id_num_3,
1103 source_distribution_id_num_4,
1104 source_distribution_id_num_5,
1105 merge_duplicate_code,
1106 statistical_amount,
1107 unrounded_entered_dr,
1108 unrounded_entered_cr,
1109 unrounded_accounted_dr,
1110 unrounded_accounted_cr,
1111 ref_ae_header_id,
1112 ref_temp_line_num,
1113 ref_event_id,
1114 temp_line_num,
1115 tax_line_ref_id,
1116 tax_summary_line_ref_id,
1117 tax_rec_nrec_dist_ref_id,
1118 line_definition_owner_code,
1119 line_definition_code,
1120 event_class_code,
1121 event_type_code
1122 ) values (
1123 l_upg_batch_id, -- upg_batch_id
1124 c_application_id, -- application_id
1125 l_event_id_tbl(i), -- event_id
1126 l_ae_header_id, -- ae_header_id
1127 l_ae_line_num_tbl(j), -- ae_line_num
1128 null, -- accounting_line_code
1129 'S', -- accounting_line_type_code
1130 'TRX', -- source_distribution_type
1131 null, -- source_distribution_id_char_1
1132 null, -- source_distribution_id_char_2
1133 null, -- source_distribution_id_char_3
1134 null, -- source_distribution_id_char_4
1135 null, -- source_distribution_id_char_5
1136 l_trx_reference_id_tbl(i), -- source_distribution_id_num_1
1137 l_adj_line_id_tbl(j), -- source_distribution_id_num_2
1138 null, -- source_distribution_id_num_3
1139 null, -- source_distribution_id_num_4
1140 null, -- source_distribution_id_num_5
1141 'N', -- merge_duplicate_code
1142 null, -- statistical_amount
1143 l_debit_amount_tbl(j), -- unrounded_entered_dr
1144 l_credit_amount_tbl(j), -- unrounded_entered_cr
1145 l_debit_amount_tbl(j), -- unrounded_accounted_dr
1146 l_credit_amount_tbl(j), -- unrounded_accounted_cr
1147 l_ae_header_id, -- ref_ae_header_id
1148 null, -- ref_temp_line_num
1149 null, -- ref_event_id
1150 l_ae_line_num_tbl(j), -- temp_line_num
1151 null, -- tax_line_ref_id
1152 null, -- tax_summary_line_ref_id
1153 null, -- tax_rec_nrec_dist_ref_id
1154 null, -- line_definition_owner_code
1155 null, -- line_definition_code
1156 l_event_class_code_tbl(i), -- event_class_code
1157 l_event_class_code_tbl(i) -- event_type_code
1158 );
1159
1160 for j IN 1..l_xla_gl_sl_link_id_tbl.count loop
1161 if (l_je_batch_id_tbl(j) is not null) then
1162 insert into gl_import_references (
1163 je_batch_id,
1164 je_header_id,
1165 je_line_num,
1166 last_update_date,
1167 last_updated_by,
1168 creation_date,
1169 created_by,
1170 last_update_login,
1171 reference_1,
1172 reference_2,
1173 reference_3,
1174 reference_4,
1175 reference_5,
1176 reference_6,
1177 reference_7,
1178 reference_8,
1179 reference_9,
1180 reference_10,
1181 subledger_doc_sequence_id,
1182 subledger_doc_sequence_value,
1183 gl_sl_link_id,
1184 gl_sl_link_table
1185 ) values (
1186 l_je_batch_id_tbl(j), -- je_batch_id
1187 l_je_header_id_tbl(j), -- je_header_id
1188 l_je_line_num_tbl(j), -- je_line_num
1189 sysdate, -- last_update_date
1190 c_fnd_user, -- last_updated_by
1191 sysdate, -- creation_date
1192 c_fnd_user, -- created_by
1193 c_upgrade_bugno, -- last_update_login
1194 to_char(l_src_thid_tbl(i)),
1195 -- reference_1
1196 to_char(l_src_asset_id_tbl(i)),
1197 -- reference_2
1198 to_char(l_distribution_id_tbl(j)),
1199 -- reference_3
1200 to_char(l_adj_line_id_tbl(j)),
1201 -- reference_4
1202 l_book_type_code_tbl(i), -- reference_5
1203 to_char(l_period_counter_tbl(i)),
1204 -- reference_6
1205 null, -- reference_7
1206 null, -- reference_8
1207 null, -- reference_9
1208 null, -- reference_10
1209 null, -- subledger_doc_seq_id
1210 null, -- subledger_doc_seq_value
1211 l_xla_gl_sl_link_id_tbl(j), -- gl_sl_link_id
1212 'XLAJEL' -- gl_sl_link_table
1213 );
1214 end if;
1215 end loop;
1216
1217 l_adj_line_id_tbl.delete;
1218 l_xla_gl_sl_link_id_tbl.delete;
1219 l_ae_line_num_tbl.delete;
1220 l_debit_amount_tbl.delete;
1221 l_credit_amount_tbl.delete;
1222 l_ccid_tbl.delete;
1223 l_acct_class_code_tbl.delete;
1224 l_currency_code_tbl.delete;
1225 l_line_def_owner_code_tbl.delete;
1226 l_line_def_code_tbl.delete;
1227 l_line_desc_tbl.delete;
1228 l_gl_transfer_status_code_tbl.delete;
1229 l_je_batch_id_tbl.delete;
1230 l_je_header_id_tbl.delete;
1231 l_je_line_num_tbl.delete;
1232 l_distribution_id_tbl.delete;
1233
1234 open c_mc_books (l_book_type_code_tbl(i));
1235 fetch c_mc_books bulk collect
1236 into l_rep_set_of_books_id_tbl;
1237 close c_mc_books;
1238
1239 for k IN 1..l_rep_set_of_books_id_tbl.count loop
1240
1241 open c_mc_adj (l_book_type_code_tbl(i),
1242 l_src_asset_id_tbl(i),
1243 l_rep_set_of_books_id_tbl(k),
1244 l_src_thid_tbl(i),
1245 l_date_effective_tbl(i));
1246 fetch c_mc_adj bulk collect
1247 into l_adj_line_id_tbl,
1248 l_debit_amount_tbl,
1249 l_credit_amount_tbl,
1250 l_ccid_tbl,
1251 l_currency_code_tbl,
1252 l_acct_class_code_tbl,
1253 l_line_desc_tbl,
1254 l_gl_transfer_status_code_tbl,
1255 l_je_batch_id_tbl,
1256 l_je_header_id_tbl,
1257 l_je_line_num_tbl,
1258 l_distribution_id_tbl;
1259 close c_mc_adj;
1260
1261 FOR j IN 1..l_adj_line_id_tbl.count LOOP
1262 l_ae_line_num_tbl(j) := j;
1263
1264 select xla_gl_sl_link_id_s.nextval
1265 into l_xla_gl_sl_link_id_tbl(j)
1266 from dual;
1267 END LOOP;
1268
1269 select xla_ae_headers_s.nextval
1270 into l_ae_header_id
1271 from dual;
1272
1273 -- Business Rules for xla_ae_headers
1274 -- * amb_context_code is DEFAULT
1275 -- * reference_date must be null
1276 -- * balance_type_code:
1277 -- A: Actual
1278 -- B: Budget
1279 -- E: Encumbrance
1280 -- * gl_transfer_status_code:
1281 -- Y: already transferred to GL
1282 -- N: not transferred to GL
1283 -- * gl_transfer_date is date entry transferred to GL
1284 -- * accounting_entry_status_code must be F
1285 -- * accounting_entry_type_code must be STANDARD
1286 -- * product_rule_* not relevant for upgrade
1287
1288 insert into xla_ae_headers (
1289 upg_batch_id,
1290 application_id,
1291 amb_context_code,
1292 entity_id,
1293 event_id,
1294 event_type_code,
1295 ae_header_id,
1296 ledger_id,
1297 accounting_date,
1298 period_name,
1299 reference_date,
1300 balance_type_code,
1301 je_category_name,
1302 gl_transfer_status_code,
1303 gl_transfer_date,
1304 accounting_entry_status_code,
1305 accounting_entry_type_code,
1306 description,
1307 budget_version_id,
1308 funds_status_code,
1309 encumbrance_type_id,
1310 completed_date,
1311 doc_sequence_id,
1312 doc_sequence_value,
1313 doc_category_code,
1314 packet_id,
1315 group_id,
1316 creation_date,
1317 created_by,
1318 last_update_date,
1319 last_updated_by,
1320 last_update_login,
1321 program_id,
1322 program_application_id,
1323 program_update_date,
1324 request_id,
1325 close_acct_seq_assign_id,
1326 close_acct_seq_version_id,
1327 close_acct_seq_value,
1328 completion_acct_seq_assign_id,
1329 completion_acct_seq_version_id,
1330 completion_acct_seq_value,
1331 accounting_batch_id,
1332 product_rule_type_code,
1333 product_rule_code,
1334 product_rule_version,
1335 upg_source_application_id,
1336 upg_valid_flag
1337 ) values (
1338 l_upg_batch_id, -- upg_batch_id
1339 c_application_id, -- application_id
1340 c_amb_context_code, -- amb_context_code
1341 l_entity_id_tbl(i), -- entity_id
1342 l_event_id_tbl(i), -- event_id,
1343 l_event_class_code_tbl(i), -- event_type_code
1344 l_ae_header_id, -- ae_header_id,
1345 l_rep_set_of_books_id_tbl(k), -- ledger_id/sob_id
1346 l_cal_period_close_date_tbl(i),
1347 -- accounting_date,
1348 l_period_name_tbl(i), -- period_name,
1349 null, -- reference_date
1350 'A', -- balance_type_code,
1351 l_je_category_name_tbl(i), -- je_category_name
1352 'Y', -- gl_transfer_status_code
1353 null, -- gl_transfer_date
1354 'F', -- accounting_entry_status_code
1355 'STANDARD', -- accounting_entry_type_code
1356 l_src_hdr_desc_tbl(i), -- description
1357 null, -- budget_version_id
1358 null, -- funds_status_code
1359 null, -- encumbrance_type_id
1360 null, -- completed_date
1361 null, -- doc_sequence_id
1362 null, -- doc_sequence_value
1363 null, -- doc_category_code
1364 null, -- packet_id,
1365 null, -- group_id
1366 sysdate, -- creation_date
1367 c_fnd_user, -- created_by
1368 sysdate, -- last_update_date
1369 c_fnd_user, -- last_updated_by
1370 c_upgrade_bugno, -- last_update_login
1371 null, -- program_id
1372 c_application_id, -- program_application_id
1373 sysdate, -- program_update_date
1374 null, -- request_id
1375 null, -- close_acct_seq_assign_id
1376 null, -- close_acct_seq_version_id
1377 null, -- close_acct_seq_value
1378 null, -- compl_acct_seq_assign_id
1379 null, -- compl_acct_seq_version_id
1380 null, -- compl_acct_seq_value
1381 null, -- accounting_batch_id
1382 null, -- product_rule_type_code
1383 null, -- product_rule_code
1384 null, -- product_rule_version
1385 c_application_id, -- upg_souce_application_id
1386 null -- upg_valid_flag
1387 );
1388
1389 -- Business Rules for xla_ae_lines
1390 -- * gl_transfer_mode_code:
1391 -- D: Detailed mode when transferred to GL
1392 -- S: Summary mode when transferred to GL
1393 -- * gl_sl_link_table must be XLAJEL
1394 -- * currency_conversion_* needs to be populated only if
1395 -- different from ledger currency
1396
1397 forall j IN 1..l_xla_gl_sl_link_id_tbl.count
1398 insert into xla_ae_lines (
1399 upg_batch_id,
1400 ae_header_id,
1401 ae_line_num,
1402 displayed_line_number,
1403 application_id,
1404 code_combination_id,
1405 gl_transfer_mode_code,
1406 accounted_dr,
1407 accounted_cr,
1408 currency_code,
1409 currency_conversion_date,
1410 currency_conversion_rate,
1411 currency_conversion_type,
1412 entered_dr,
1413 entered_cr,
1414 description,
1415 accounting_class_code,
1416 gl_sl_link_id,
1417 gl_sl_link_table,
1418 party_type_code,
1419 party_id,
1420 party_site_id,
1421 statistical_amount,
1422 ussgl_transaction_code,
1423 jgzz_recon_ref,
1424 control_balance_flag,
1425 analytical_balance_flag,
1426 upg_tax_reference_id1,
1427 upg_tax_reference_id2,
1428 upg_tax_reference_id3,
1429 creation_date,
1430 created_by,
1431 last_update_date,
1432 last_updated_by,
1433 last_update_login,
1434 program_update_date,
1435 program_id,
1436 program_application_id,
1437 request_id,
1438 gain_or_loss_flag,
1439 accounting_date,
1440 ledger_id
1441 ) values (
1442 l_upg_batch_id, -- upg_batch_id
1443 l_ae_header_id, -- ae_header_id
1444 l_ae_line_num_tbl(j), -- ae_line_num
1445 l_ae_line_num_tbl(j), -- displayed_line_num
1446 c_application_id, -- application_id
1447 l_ccid_tbl(j), -- code_combination_id
1448 'S', -- gl_transfer_mode_code
1449 l_debit_amount_tbl(j), -- accounted_dr
1450 l_credit_amount_tbl(j), -- accounted_cr
1451 l_currency_code_tbl(j), -- currency_code
1452 null, -- currency_conversion_date
1453 null, -- currency_conversion_rate
1454 null, -- currency_conversion_type
1455 l_debit_amount_tbl(j), -- entered_dr
1456 l_credit_amount_tbl(j), -- entered_cr
1457 l_line_desc_tbl(j) || ' - ' ||
1458 to_char(l_cal_period_close_date_tbl(i), 'DD-MON-RR'),
1459 -- description
1460 l_acct_class_code_tbl(j), -- accounting_class_code
1461 l_xla_gl_sl_link_id_tbl(j), -- gl_sl_link_id
1462 'XLAJEL', -- gl_sl_link_table
1463 null, -- party_type_code
1464 null, -- party_id
1465 null, -- party_site_id
1466 null, -- statistical_amount
1467 null, -- ussgl_transaction_code
1468 null, -- glzz_recon_ref
1469 null, -- control_balance_flag
1470 null, -- analytical_balance_flag
1471 null, -- upg_tax_reference_id1
1472 null, -- upg_tax_reference_id2
1473 null, -- upg_tax_reference_id3
1474 sysdate, -- creation_date
1475 c_fnd_user, -- created_by
1476 sysdate, -- last_update_date
1477 c_fnd_user, -- last_updated_by
1478 c_upgrade_bugno, -- last_update_login
1479 null, -- program_update_date
1480 null, -- program_id
1481 c_application_id, -- program_application_id
1482 null, -- request_id
1483 'N', -- gain_or_loss_flag
1484 l_cal_period_close_date_tbl(i), -- accounting_date,
1485 l_rep_set_of_books_id_tbl(k) -- ledger_id/sob_id
1486 );
1487
1488 -- Business Rules for xla_distribution_links
1489 -- * accounting_line_code is similar to adjustment_type
1490 -- * accounting_line_type_code is S
1491 -- * merge_duplicate_code is N
1492 -- * source_distribution_type is TRX
1493 -- * source_distribution_id_num_1 is trx_reference_id
1494 -- * source_distribution_id_num_2 is event_id
1495
1496 forall j IN 1..l_xla_gl_sl_link_id_tbl.count
1497 insert into xla_distribution_links (
1498 upg_batch_id,
1499 application_id,
1500 event_id,
1501 ae_header_id,
1502 ae_line_num,
1503 accounting_line_code,
1504 accounting_line_type_code,
1505 source_distribution_type,
1506 source_distribution_id_char_1,
1507 source_distribution_id_char_2,
1508 source_distribution_id_char_3,
1509 source_distribution_id_char_4,
1510 source_distribution_id_char_5,
1511 source_distribution_id_num_1,
1512 source_distribution_id_num_2,
1513 source_distribution_id_num_3,
1514 source_distribution_id_num_4,
1515 source_distribution_id_num_5,
1516 merge_duplicate_code,
1517 statistical_amount,
1518 unrounded_entered_dr,
1519 unrounded_entered_cr,
1520 unrounded_accounted_dr,
1521 unrounded_accounted_cr,
1522 ref_ae_header_id,
1523 ref_temp_line_num,
1524 ref_event_id,
1525 temp_line_num,
1526 tax_line_ref_id,
1527 tax_summary_line_ref_id,
1528 tax_rec_nrec_dist_ref_id,
1529 line_definition_owner_code,
1530 line_definition_code,
1531 event_class_code,
1532 event_type_code
1533 ) values (
1534 l_upg_batch_id, -- upg_batch_id
1535 c_application_id, -- application_id
1536 l_event_id_tbl(i), -- event_id
1537 l_ae_header_id, -- ae_header_id
1538 l_ae_line_num_tbl(j), -- ae_line_num
1539 null, -- accounting_line_code
1540 'S', -- accounting_line_type_code
1541 'TRX', -- source_distribution_type
1542 null, -- source_distribution_id_char_1
1543 null, -- source_distribution_id_char_2
1544 null, -- source_distribution_id_char_3
1545 null, -- source_distribution_id_char_4
1546
1547 null, -- source_distribution_id_char_5
1548 l_trx_reference_id_tbl(i), -- source_distribution_id_num_1
1549 l_adj_line_id_tbl(j), -- source_distribution_id_num_2
1550 null, -- source_distribution_id_num_3
1551 null, -- source_distribution_id_num_4
1552 null, -- source_distribution_id_num_5
1553 'N', -- merge_duplicate_code
1554 null, -- statistical_amount
1555 l_debit_amount_tbl(j), -- unrounded_entered_dr
1556 l_credit_amount_tbl(j), -- unrounded_entered_cr
1557 l_debit_amount_tbl(j), -- unrounded_accounted_dr
1558 l_credit_amount_tbl(j), -- unrounded_accounted_cr
1559 l_ae_header_id, -- ref_ae_header_id
1560 null, -- ref_temp_line_num
1561 null, -- ref_event_id
1562 l_ae_line_num_tbl(j), -- temp_line_num
1563 null, -- tax_line_ref_id
1564 null, -- tax_summary_line_ref_id
1565 null, -- tax_rec_nrec_dist_ref_id
1566 null, -- line_definition_owner_code
1567 null, -- line_definition_code
1568 l_event_class_code_tbl(i), -- event_class_code
1569 l_event_class_code_tbl(i) -- event_type_code
1570 );
1571
1572 for j IN 1..l_xla_gl_sl_link_id_tbl.count loop
1573 if (l_je_batch_id_tbl(j) is not null) then
1574 insert into gl_import_references (
1575 je_batch_id,
1576 je_header_id,
1577 je_line_num,
1578 last_update_date,
1579 last_updated_by,
1580 creation_date,
1581 created_by,
1582 last_update_login,
1583 reference_1,
1584 reference_2,
1585 reference_3,
1586 reference_4,
1587 reference_5,
1588 reference_6,
1589 reference_7,
1590 reference_8,
1591 reference_9,
1592 reference_10,
1593 subledger_doc_sequence_id,
1594 subledger_doc_sequence_value,
1595 gl_sl_link_id,
1596 gl_sl_link_table
1597 ) values (
1598 l_je_batch_id_tbl(j), -- je_batch_id
1599 l_je_header_id_tbl(j), -- je_header_id
1600 l_je_line_num_tbl(j), -- je_line_num
1601 sysdate, -- last_update_date
1602 c_upgrade_bugno, -- last_updated_by
1603 sysdate, -- creation_date
1604 c_fnd_user, -- created_by
1605 c_upgrade_bugno, -- last_update_login
1606 to_char(l_src_thid_tbl(i)),
1607 -- reference_1
1608 to_char(l_src_asset_id_tbl(i)),
1609 -- reference_2
1610 to_char(l_distribution_id_tbl(j)),
1611 -- reference_3
1612 to_char(l_adj_line_id_tbl(j)),
1613 -- reference_4
1614 l_book_type_code_tbl(i), -- reference_5
1615 to_char(l_period_counter_tbl(i)),
1616 -- reference_6
1617 null, -- reference_7
1618 null, -- reference_8
1619 null, -- reference_9
1620 null, -- reference_10
1621 null, -- subledger_doc_seq_id
1622 null, -- subledger_doc_seq_value
1623 l_xla_gl_sl_link_id_tbl(j), -- gl_sl_link_id
1624 'XLAJEL' -- gl_sl_link_table
1625 );
1626 end if;
1627 end loop;
1628
1629 l_adj_line_id_tbl.delete;
1630 l_xla_gl_sl_link_id_tbl.delete;
1631 l_ae_line_num_tbl.delete;
1632 l_debit_amount_tbl.delete;
1633 l_credit_amount_tbl.delete;
1634 l_ccid_tbl.delete;
1635 l_acct_class_code_tbl.delete;
1636 l_currency_code_tbl.delete;
1637 l_line_def_owner_code_tbl.delete;
1638 l_line_def_code_tbl.delete;
1639 l_line_desc_tbl.delete;
1640 l_gl_transfer_status_code_tbl.delete;
1641 l_je_batch_id_tbl.delete;
1642 l_je_header_id_tbl.delete;
1643 l_je_line_num_tbl.delete;
1644 l_distribution_id_tbl.delete;
1645
1646 end loop;
1647
1648 l_rep_set_of_books_id_tbl.delete;
1649
1650 open c_adj (l_book_type_code_tbl(i),
1651 l_dest_asset_id_tbl(i),
1652 l_dest_thid_tbl(i),
1653 l_date_effective_tbl(i));
1654 fetch c_adj bulk collect
1655 into l_adj_line_id_tbl,
1656 l_debit_amount_tbl,
1657 l_credit_amount_tbl,
1658 l_ccid_tbl,
1659 l_currency_code_tbl,
1660 l_acct_class_code_tbl,
1661 l_line_desc_tbl,
1662 l_gl_transfer_status_code_tbl,
1663 l_je_batch_id_tbl,
1664 l_je_header_id_tbl,
1665 l_je_line_num_tbl,
1666 l_distribution_id_tbl;
1667 close c_adj;
1668
1669 FOR j IN 1..l_adj_line_id_tbl.count LOOP
1670 l_ae_line_num_tbl(j) := j;
1671
1672 select xla_gl_sl_link_id_s.nextval
1673 into l_xla_gl_sl_link_id_tbl(j)
1674 from dual;
1675 END LOOP;
1676
1677 select xla_ae_headers_s.nextval
1678 into l_ae_header_id
1679 from dual;
1680
1681 -- Business Rules for xla_ae_lines
1682 -- * gl_transfer_mode_code:
1683 -- D: Detailed mode when transferred to GL
1684 -- S: Summary mode when transferred to GL
1685 -- * gl_sl_link_table must be XLAJEL
1686 -- * currency_conversion_* needs to be populated only if
1687 -- different from ledger currency
1688
1689 forall j IN 1..l_xla_gl_sl_link_id_tbl.count
1690 insert into xla_ae_lines (
1691 upg_batch_id,
1692 ae_header_id,
1693 ae_line_num,
1694 displayed_line_number,
1695 application_id,
1696 code_combination_id,
1697 gl_transfer_mode_code,
1698 accounted_dr,
1699 accounted_cr,
1700 currency_code,
1701 currency_conversion_date,
1702 currency_conversion_rate,
1703 currency_conversion_type,
1704 entered_dr,
1705 entered_cr,
1706 description,
1707 accounting_class_code,
1708 gl_sl_link_id,
1709 gl_sl_link_table,
1710 party_type_code,
1711 party_id,
1712 party_site_id,
1713 statistical_amount,
1714 ussgl_transaction_code,
1715 jgzz_recon_ref,
1716 control_balance_flag,
1717 analytical_balance_flag,
1718 upg_tax_reference_id1,
1719 upg_tax_reference_id2,
1720 upg_tax_reference_id3,
1721 creation_date,
1722 created_by,
1723 last_update_date,
1724 last_updated_by,
1725 last_update_login,
1726 program_update_date,
1727 program_id,
1728 program_application_id,
1729 request_id,
1730 gain_or_loss_flag,
1731 accounting_date,
1732 ledger_id
1733 ) values (
1734 l_upg_batch_id, -- upg_batch_id
1735 l_ae_header_id, -- ae_header_id
1736 l_ae_line_num_tbl(j), -- ae_line_num
1737 l_ae_line_num_tbl(j), -- displayed_line_num
1738 c_application_id, -- application_id
1739 l_ccid_tbl(j), -- code_combination_id
1740 'S', -- gl_transfer_mode_code
1741 l_debit_amount_tbl(j), -- accounted_dr
1742 l_credit_amount_tbl(j), -- accounted_cr
1743 l_currency_code_tbl(j), -- currency_code
1744 null, -- currency_conversion_date
1745 null, -- currency_conversion_rate
1746 null, -- currency_conversion_type
1747 l_debit_amount_tbl(j), -- entered_dr
1748 l_credit_amount_tbl(j), -- entered_cr
1749 l_line_desc_tbl(j) || ' - ' ||
1750 to_char(l_cal_period_close_date_tbl(i), 'DD-MON-RR'),
1751 -- description
1752 l_acct_class_code_tbl(j), -- accounting_class_code
1753 l_xla_gl_sl_link_id_tbl(j), -- gl_sl_link_id
1754 'XLAJEL', -- gl_sl_link_table
1755 null, -- party_type_code
1756 null, -- party_id
1757 null, -- party_site_id
1758 null, -- statistical_amount
1759 null, -- ussgl_transaction_code
1760 null, -- glzz_recon_ref
1761 null, -- control_balance_flag
1762 null, -- analytical_balance_flag
1763 null, -- upg_tax_reference_id1
1764 null, -- upg_tax_reference_id2
1765 null, -- upg_tax_reference_id3
1766 sysdate, -- creation_date
1767 c_fnd_user, -- created_by
1768 sysdate, -- last_update_date
1769 c_fnd_user, -- last_updated_by
1770 c_upgrade_bugno, -- last_update_login
1771 null, -- program_update_date
1772 null, -- program_id
1773 c_application_id, -- program_application_id
1774 null, -- request_id
1775 'N', -- gain_or_loss_flag
1776 l_cal_period_close_date_tbl(i), -- accounting_date,
1777 l_primary_set_of_books_id_tbl(i)
1778 -- ledger_id/sob_id
1779 );
1780
1781 -- Business Rules for xla_distribution_links
1782 -- * accounting_line_code is similar to adjustment_type
1783 -- * accounting_line_type_code is S
1784 -- * merge_duplicate_code is N
1785 -- * source_distribution_type is TRX
1786 -- * source_distribution_id_num_1 is transaction_header_id
1787 -- * source_distribution_id_num_2 is event_id
1788
1789 forall j IN 1..l_xla_gl_sl_link_id_tbl.count
1790 insert into xla_distribution_links (
1791 upg_batch_id,
1792 application_id,
1793 event_id,
1794 ae_header_id,
1795 ae_line_num,
1796 accounting_line_code,
1797 accounting_line_type_code,
1798 source_distribution_type,
1799 source_distribution_id_char_1,
1800 source_distribution_id_char_2,
1801 source_distribution_id_char_3,
1802 source_distribution_id_char_4,
1803 source_distribution_id_char_5,
1804 source_distribution_id_num_1,
1805 source_distribution_id_num_2,
1806 source_distribution_id_num_3,
1807 source_distribution_id_num_4,
1808 source_distribution_id_num_5,
1809 merge_duplicate_code,
1810 statistical_amount,
1811 unrounded_entered_dr,
1812 unrounded_entered_cr,
1813 unrounded_accounted_dr,
1814 unrounded_accounted_cr,
1815 ref_ae_header_id,
1816 ref_temp_line_num,
1817 ref_event_id,
1818 temp_line_num,
1819 tax_line_ref_id,
1820 tax_summary_line_ref_id,
1821 tax_rec_nrec_dist_ref_id,
1822 line_definition_owner_code,
1823 line_definition_code,
1824 event_class_code,
1825 event_type_code
1826 ) values (
1827 l_upg_batch_id, -- upg_batch_id
1828 c_application_id, -- application_id
1829 l_event_id_tbl(i), -- event_id
1830 l_ae_header_id, -- ae_header_id
1831 l_ae_line_num_tbl(j), -- ae_line_num
1832 null, -- accounting_line_code
1833 'S', -- accounting_line_type_code
1834 'TRX', -- source_distribution_type
1835 null, -- source_distribution_id_char_1
1836 null, -- source_distribution_id_char_2
1837 null, -- source_distribution_id_char_3
1838 null, -- source_distribution_id_char_4
1839 null, -- source_distribution_id_char_5
1840 l_trx_reference_id_tbl(i), -- source_distribution_id_num_1
1841 l_adj_line_id_tbl(j), -- source_distribution_id_num_2
1842 null, -- source_distribution_id_num_3
1843 null, -- source_distribution_id_num_4
1844 null, -- source_distribution_id_num_5
1845 'N', -- merge_duplicate_code
1846 null, -- statistical_amount
1847 l_debit_amount_tbl(j), -- unrounded_entered_dr
1848 l_credit_amount_tbl(j), -- unrounded_entered_cr
1849 l_debit_amount_tbl(j), -- unrounded_accounted_dr
1850 l_credit_amount_tbl(j), -- unrounded_accounted_cr
1851 l_ae_header_id, -- ref_ae_header_id
1852 null, -- ref_temp_line_num
1853 null, -- ref_event_id
1854 l_ae_line_num_tbl(j), -- temp_line_num
1855 null, -- tax_line_ref_id
1856 null, -- tax_summary_line_ref_id
1857 null, -- tax_rec_nrec_dist_ref_id
1858 null, -- line_definition_owner_code
1859 null, -- line_definition_code
1860 l_event_class_code_tbl(i), -- event_class_code
1861 l_event_class_code_tbl(i) -- event_type_code
1862 );
1863
1864 for j IN 1..l_xla_gl_sl_link_id_tbl.count loop
1865 if (l_je_batch_id_tbl(j) is not null) then
1866 insert into gl_import_references (
1867 je_batch_id,
1868 je_header_id,
1869 je_line_num,
1870 last_update_date,
1871 last_updated_by,
1872 creation_date,
1873 created_by,
1874 last_update_login,
1875 reference_1,
1876 reference_2,
1877 reference_3,
1878 reference_4,
1879 reference_5,
1880 reference_6,
1881 reference_7,
1882 reference_8,
1883 reference_9,
1884 reference_10,
1885 subledger_doc_sequence_id,
1886 subledger_doc_sequence_value,
1887 gl_sl_link_id,
1888 gl_sl_link_table
1889 ) values (
1890 l_je_batch_id_tbl(j), -- je_batch_id
1891 l_je_header_id_tbl(j), -- je_header_id
1892 l_je_line_num_tbl(j), -- je_line_num
1893 sysdate, -- last_update_date
1894 c_fnd_user, -- last_updated_by
1895 sysdate, -- creation_date
1896 c_fnd_user, -- created_by
1897 c_upgrade_bugno, -- last_update_login
1898 to_char(l_dest_thid_tbl(i)),
1899 -- reference_1
1900 to_char(l_dest_asset_id_tbl(i)),
1901 -- reference_2
1902 to_char(l_distribution_id_tbl(j)),
1903 -- reference_3
1904 to_char(l_adj_line_id_tbl(j)),
1905 -- reference_4
1906 l_book_type_code_tbl(i), -- reference_5
1907 to_char(l_period_counter_tbl(i)),
1908 -- reference_6
1909 null, -- reference_7
1910 null, -- reference_8
1911 null, -- reference_9
1912 null, -- reference_10
1913 null, -- subledger_doc_seq_id
1914 null, -- subledger_doc_seq_value
1915 l_xla_gl_sl_link_id_tbl(j), -- gl_sl_link_id
1916 'XLAJEL' -- gl_sl_link_table
1917 );
1918 end if;
1919 end loop;
1920
1921 l_adj_line_id_tbl.delete;
1922 l_xla_gl_sl_link_id_tbl.delete;
1923 l_ae_line_num_tbl.delete;
1924 l_debit_amount_tbl.delete;
1925 l_credit_amount_tbl.delete;
1926 l_ccid_tbl.delete;
1927 l_acct_class_code_tbl.delete;
1928 l_currency_code_tbl.delete;
1929 l_line_def_owner_code_tbl.delete;
1930 l_line_def_code_tbl.delete;
1931 l_line_desc_tbl.delete;
1932 l_gl_transfer_status_code_tbl.delete;
1933 l_je_batch_id_tbl.delete;
1934 l_je_header_id_tbl.delete;
1935 l_je_line_num_tbl.delete;
1936 l_distribution_id_tbl.delete;
1937
1938 open c_mc_books (l_book_type_code_tbl(i));
1939 fetch c_mc_books bulk collect
1940 into l_rep_set_of_books_id_tbl;
1941 close c_mc_books;
1942
1943 for k IN 1..l_rep_set_of_books_id_tbl.count loop
1944
1945 open c_mc_adj (l_book_type_code_tbl(i),
1946 l_dest_asset_id_tbl(i),
1947 l_rep_set_of_books_id_tbl(k),
1948 l_dest_thid_tbl(i),
1949 l_date_effective_tbl(i));
1950 fetch c_mc_adj bulk collect
1951 into l_adj_line_id_tbl,
1952 l_debit_amount_tbl,
1953 l_credit_amount_tbl,
1954 l_ccid_tbl,
1955 l_currency_code_tbl,
1956 l_acct_class_code_tbl,
1957 l_line_desc_tbl,
1958 l_gl_transfer_status_code_tbl,
1959 l_je_batch_id_tbl,
1960 l_je_header_id_tbl,
1961 l_je_line_num_tbl,
1962 l_distribution_id_tbl;
1963 close c_mc_adj;
1964
1965 FOR j IN 1..l_adj_line_id_tbl.count LOOP
1966 l_ae_line_num_tbl(j) := j;
1967
1968 select xla_gl_sl_link_id_s.nextval
1969 into l_xla_gl_sl_link_id_tbl(j)
1970 from dual;
1971 END LOOP;
1972
1973 select xla_ae_headers_s.nextval
1974 into l_ae_header_id
1975 from dual;
1976
1977 -- Business Rules for xla_ae_headers
1978 -- * amb_context_code is DEFAULT
1979 -- * reference_date must be null
1980 -- * balance_type_code:
1981 -- A: Actual
1982 -- B: Budget
1983 -- E: Encumbrance
1984 -- * gl_transfer_status_code:
1985 -- Y: already transferred to GL
1986 -- N: not transferred to GL
1987 -- * gl_transfer_date is date entry transferred to GL
1988 -- * accounting_entry_status_code must be F
1989 -- * accounting_entry_type_code must be STANDARD
1990 -- * product_rule_* not relevant for upgrade
1991
1992 insert into xla_ae_headers (
1993 upg_batch_id,
1994 application_id,
1995 amb_context_code,
1996 entity_id,
1997 event_id,
1998 event_type_code,
1999 ae_header_id,
2000 ledger_id,
2001 accounting_date,
2002 period_name,
2003 reference_date,
2004 balance_type_code,
2005 je_category_name,
2006 gl_transfer_status_code,
2007 gl_transfer_date,
2008 accounting_entry_status_code,
2009 accounting_entry_type_code,
2010 description,
2011 budget_version_id,
2012 funds_status_code,
2013 encumbrance_type_id,
2014 completed_date,
2015 doc_sequence_id,
2016 doc_sequence_value,
2017 doc_category_code,
2018 packet_id,
2019 group_id,
2020 creation_date,
2021 created_by,
2022 last_update_date,
2023 last_updated_by,
2024 last_update_login,
2025 program_id,
2026 program_application_id,
2027 program_update_date,
2028 request_id,
2029 close_acct_seq_assign_id,
2030 close_acct_seq_version_id,
2031 close_acct_seq_value,
2032 completion_acct_seq_assign_id,
2033 completion_acct_seq_version_id,
2034 completion_acct_seq_value,
2035 accounting_batch_id,
2036 product_rule_type_code,
2037 product_rule_code,
2038 product_rule_version,
2039 upg_source_application_id,
2040 upg_valid_flag
2041 ) values (
2042 l_upg_batch_id, -- upg_batch_id
2043 c_application_id, -- application_id
2044 c_amb_context_code, -- amb_context_code
2045 l_entity_id_tbl(i), -- entity_id
2046 l_event_id_tbl(i), -- event_id,
2047 l_event_class_code_tbl(i), -- event_type_code
2048 l_ae_header_id, -- ae_header_id,
2049 l_rep_set_of_books_id_tbl(k), -- ledger_id/sob_id
2050 l_cal_period_close_date_tbl(i),
2051 -- accounting_date,
2052 l_period_name_tbl(i), -- period_name,
2053 null, -- reference_date
2054 'A', -- balance_type_code,
2055 l_je_category_name_tbl(i), -- je_category_name
2056 'Y', -- gl_transfer_status_code
2057 null, -- gl_transfer_date
2058 'F', -- accounting_entry_status_code
2059 'STANDARD', -- accounting_entry_type_code
2060 l_src_hdr_desc_tbl(i), -- description
2061 null, -- budget_version_id
2062 null, -- funds_status_code
2063 null, -- encumbrance_type_id
2064 null, -- completed_date
2065 null, -- doc_sequence_id
2066 null, -- doc_sequence_value
2067 null, -- doc_category_code
2068 null, -- packet_id,
2069 null, -- group_id
2070 sysdate, -- creation_date
2071 c_fnd_user, -- created_by
2072 sysdate, -- last_update_date
2073 c_fnd_user, -- last_updated_by
2074 c_upgrade_bugno, -- last_update_login
2075 null, -- program_id
2076 c_application_id, -- program_application_id
2077 sysdate, -- program_update_date
2078 null, -- request_id
2079 null, -- close_acct_seq_assign_id
2080 null, -- close_acct_seq_version_id
2081 null, -- close_acct_seq_value
2082 null, -- compl_acct_seq_assign_id
2083 null, -- compl_acct_seq_version_id
2084 null, -- compl_acct_seq_value
2085 null, -- accounting_batch_id
2086 null, -- product_rule_type_code
2087 null, -- product_rule_code
2088 null, -- product_rule_version
2089 c_application_id, -- upg_souce_application_id
2090 null -- upg_valid_flag
2091 );
2092
2093 -- Business Rules for xla_ae_lines
2094 -- * gl_transfer_mode_code:
2095 -- D: Detailed mode when transferred to GL
2096 -- S: Summary mode when transferred to GL
2097 -- * gl_sl_link_table must be XLAJEL
2098 -- * currency_conversion_* needs to be populated only if
2099 -- different from ledger currency
2100
2101 forall j IN 1..l_xla_gl_sl_link_id_tbl.count
2102 insert into xla_ae_lines (
2103 upg_batch_id,
2104 ae_header_id,
2105 ae_line_num,
2106 displayed_line_number,
2107 application_id,
2108 code_combination_id,
2109 gl_transfer_mode_code,
2110 accounted_dr,
2111 accounted_cr,
2112 currency_code,
2113 currency_conversion_date,
2114 currency_conversion_rate,
2115 currency_conversion_type,
2116 entered_dr,
2117 entered_cr,
2118 description,
2119 accounting_class_code,
2120 gl_sl_link_id,
2121 gl_sl_link_table,
2122 party_type_code,
2123 party_id,
2124 party_site_id,
2125 statistical_amount,
2126 ussgl_transaction_code,
2127 jgzz_recon_ref,
2128 control_balance_flag,
2129 analytical_balance_flag,
2130 upg_tax_reference_id1,
2131 upg_tax_reference_id2,
2132 upg_tax_reference_id3,
2133 creation_date,
2134 created_by,
2135 last_update_date,
2136 last_updated_by,
2137 last_update_login,
2138 program_update_date,
2139 program_id,
2140 program_application_id,
2141 request_id,
2142 gain_or_loss_flag,
2143 accounting_date,
2144 ledger_id
2145 ) values (
2146 l_upg_batch_id, -- upg_batch_id
2147 l_ae_header_id, -- ae_header_id
2148 l_ae_line_num_tbl(j), -- ae_line_num
2149 l_ae_line_num_tbl(j), -- displayed_line_num
2150 c_application_id, -- application_id
2151 l_ccid_tbl(j), -- code_combination_id
2152 'S', -- gl_transfer_mode_code
2153 l_debit_amount_tbl(j), -- accounted_dr
2154 l_credit_amount_tbl(j), -- accounted_cr
2155 l_currency_code_tbl(j), -- currency_code
2156 null, -- currency_conversion_date
2157 null, -- currency_conversion_rate
2158 null, -- currency_conversion_type
2159 l_debit_amount_tbl(j), -- entered_dr
2160 l_credit_amount_tbl(j), -- entered_cr
2161 l_line_desc_tbl(j) || ' - ' ||
2162 to_char(l_cal_period_close_date_tbl(i), 'DD-MON-RR'),
2163 -- description
2164 l_acct_class_code_tbl(j), -- accounting_class_code
2165 l_xla_gl_sl_link_id_tbl(j), -- gl_sl_link_id
2166 'XLAJEL', -- gl_sl_link_table
2167 null, -- party_type_code
2168 null, -- party_id
2169 null, -- party_site_id
2170 null, -- statistical_amount
2171 null, -- ussgl_transaction_code
2172 null, -- glzz_recon_ref
2173 null, -- control_balance_flag
2174 null, -- analytical_balance_flag
2175 null, -- upg_tax_reference_id1
2176 null, -- upg_tax_reference_id2
2177 null, -- upg_tax_reference_id3
2178 sysdate, -- creation_date
2179 c_fnd_user, -- created_by
2180 sysdate, -- last_update_date
2181 c_fnd_user, -- last_updated_by
2182 c_upgrade_bugno, -- last_update_login
2183 null, -- program_update_date
2184 null, -- program_id
2185 c_application_id, -- program_application_id
2186 null, -- request_id
2187 'N', -- gain_or_loss_flag
2188 l_cal_period_close_date_tbl(i), -- accounting_date,
2189 l_rep_set_of_books_id_tbl(k) -- ledger_id/sob_id
2190 );
2191
2192 -- Business Rules for xla_distribution_links
2193 -- * accounting_line_code is similar to adjustment_type
2194 -- * accounting_line_type_code is S
2195 -- * merge_duplicate_code is N
2196 -- * source_distribution_type is TRX
2197 -- * source_distribution_id_num_1 is trx_reference_id
2198 -- * source_distribution_id_num_2 is event_id
2199
2200 forall j IN 1..l_xla_gl_sl_link_id_tbl.count
2201 insert into xla_distribution_links (
2202 upg_batch_id,
2203 application_id,
2204 event_id,
2205 ae_header_id,
2206 ae_line_num,
2207 accounting_line_code,
2208 accounting_line_type_code,
2209 source_distribution_type,
2210 source_distribution_id_char_1,
2211 source_distribution_id_char_2,
2212 source_distribution_id_char_3,
2213 source_distribution_id_char_4,
2214 source_distribution_id_char_5,
2215 source_distribution_id_num_1,
2216 source_distribution_id_num_2,
2217 source_distribution_id_num_3,
2218 source_distribution_id_num_4,
2219 source_distribution_id_num_5,
2220 merge_duplicate_code,
2221 statistical_amount,
2222 unrounded_entered_dr,
2223 unrounded_entered_cr,
2224 unrounded_accounted_dr,
2225 unrounded_accounted_cr,
2226 ref_ae_header_id,
2227 ref_temp_line_num,
2228 ref_event_id,
2229 temp_line_num,
2230 tax_line_ref_id,
2231 tax_summary_line_ref_id,
2232 tax_rec_nrec_dist_ref_id,
2233 line_definition_owner_code,
2234 line_definition_code,
2235 event_class_code,
2236 event_type_code
2237 ) values (
2238 l_upg_batch_id, -- upg_batch_id
2239 c_application_id, -- application_id
2240 l_event_id_tbl(i), -- event_id
2241 l_ae_header_id, -- ae_header_id
2242 l_ae_line_num_tbl(j), -- ae_line_num
2243 null, -- accounting_line_code
2244 'S', -- accounting_line_type_code
2245 'TRX', -- source_distribution_type
2246 null, -- source_distribution_id_char_1
2247 null, -- source_distribution_id_char_2
2248 null, -- source_distribution_id_char_3
2249 null, -- source_distribution_id_char_4
2250
2251 null, -- source_distribution_id_char_5
2252 l_trx_reference_id_tbl(i), -- source_distribution_id_num_1
2253 l_adj_line_id_tbl(j), -- source_distribution_id_num_2
2254 null, -- source_distribution_id_num_3
2255 null, -- source_distribution_id_num_4
2256 null, -- source_distribution_id_num_5
2257 'N', -- merge_duplicate_code
2258 null, -- statistical_amount
2259 l_debit_amount_tbl(j), -- unrounded_entered_dr
2260 l_credit_amount_tbl(j), -- unrounded_entered_cr
2261 l_debit_amount_tbl(j), -- unrounded_accounted_dr
2262 l_credit_amount_tbl(j), -- unrounded_accounted_cr
2263 l_ae_header_id, -- ref_ae_header_id
2264 null, -- ref_temp_line_num
2265 null, -- ref_event_id
2266 l_ae_line_num_tbl(j), -- temp_line_num
2267 null, -- tax_line_ref_id
2268 null, -- tax_summary_line_ref_id
2269 null, -- tax_rec_nrec_dist_ref_id
2270 null, -- line_definition_owner_code
2271 null, -- line_definition_code
2272 l_event_class_code_tbl(i), -- event_class_code
2273 l_event_class_code_tbl(i) -- event_type_code
2274 );
2275
2276 for j IN 1..l_xla_gl_sl_link_id_tbl.count loop
2277 if (l_je_batch_id_tbl(j) is not null) then
2278 insert into gl_import_references (
2279 je_batch_id,
2280 je_header_id,
2281 je_line_num,
2282 last_update_date,
2283 last_updated_by,
2284 creation_date,
2285 created_by,
2286 last_update_login,
2287 reference_1,
2288 reference_2,
2289 reference_3,
2290 reference_4,
2291 reference_5,
2292 reference_6,
2293 reference_7,
2294 reference_8,
2295 reference_9,
2296 reference_10,
2297 subledger_doc_sequence_id,
2298 subledger_doc_sequence_value,
2299 gl_sl_link_id,
2300 gl_sl_link_table
2301 ) values (
2302 l_je_batch_id_tbl(j), -- je_batch_id
2303 l_je_header_id_tbl(j), -- je_header_id
2304 l_je_line_num_tbl(j), -- je_line_num
2305 sysdate, -- last_update_date
2306 c_fnd_user, -- last_updated_by
2307 sysdate, -- creation_date
2308 c_fnd_user, -- created_by
2309 c_upgrade_bugno, -- last_update_login
2310 to_char(l_src_thid_tbl(i)),
2311 -- reference_1
2312 to_char(l_src_asset_id_tbl(i)),
2313 -- reference_2
2314 to_char(l_distribution_id_tbl(j)),
2315 -- reference_3
2316 to_char(l_adj_line_id_tbl(j)),
2317 -- reference_4
2318 l_book_type_code_tbl(i), -- reference_5
2319 to_char(l_period_counter_tbl(i)),
2320 -- reference_6
2321 null, -- reference_7
2322 null, -- reference_8
2323 null, -- reference_9
2324 null, -- reference_10
2325 null, -- subledger_doc_seq_id
2326 null, -- subledger_doc_seq_value
2327 l_xla_gl_sl_link_id_tbl(j), -- gl_sl_link_id
2328 'XLAJEL' -- gl_sl_link_table
2329 );
2330 end if;
2331 end loop;
2332
2333 l_adj_line_id_tbl.delete;
2334 l_xla_gl_sl_link_id_tbl.delete;
2335 l_ae_line_num_tbl.delete;
2336 l_debit_amount_tbl.delete;
2337 l_credit_amount_tbl.delete;
2338 l_ccid_tbl.delete;
2339 l_acct_class_code_tbl.delete;
2340 l_currency_code_tbl.delete;
2341 l_line_def_owner_code_tbl.delete;
2342 l_line_def_code_tbl.delete;
2343 l_line_desc_tbl.delete;
2344 l_gl_transfer_status_code_tbl.delete;
2345 l_je_batch_id_tbl.delete;
2346 l_je_header_id_tbl.delete;
2347 l_je_line_num_tbl.delete;
2348 l_distribution_id_tbl.delete;
2349
2350 end loop;
2351
2352 l_rep_set_of_books_id_tbl.delete;
2353
2354 END LOOP;
2355
2356 l_src_rowid_tbl.delete;
2357 l_dest_rowid_tbl.delete;
2358 l_event_id_tbl.delete;
2359 l_src_asset_id_tbl.delete;
2360 l_dest_asset_id_tbl.delete;
2361 l_book_type_code_tbl.delete;
2362 l_primary_set_of_books_id_tbl.delete;
2363 l_org_id_tbl.delete;
2364 l_src_trans_type_code_tbl.delete;
2365 l_dest_trans_type_code_tbl.delete;
2366 l_transaction_date_entered_tbl.delete;
2367 l_src_thid_tbl.delete;
2368 l_dest_thid_tbl.delete;
2369 l_period_counter_tbl.delete;
2370 l_period_name_tbl.delete;
2371 l_cal_period_close_date_tbl.delete;
2372 l_entity_id_tbl.delete;
2373 l_event_class_code_tbl.delete;
2374 l_trx_reference_id_tbl.delete;
2375 l_src_hdr_desc_tbl.delete;
2376 l_dest_hdr_desc_tbl.delete;
2377 l_je_category_name_tbl.delete;
2378 l_date_effective_tbl.delete;
2379
2380 commit;
2381
2382 if (l_rows_processed < l_batch_size) then exit; end if;
2383
2384 end loop;
2385 close c_trans;
2386
2387 EXCEPTION
2388 WHEN OTHERS THEN
2389 rollback;
2390 raise;
2391
2392 END Upgrade_Inv_Events;
2393
2394 Procedure Upgrade_Group_Trxn_Events (
2395 p_start_rowid IN rowid,
2396 p_end_rowid IN rowid,
2397 p_batch_size IN number,
2398 x_success_count OUT NOCOPY number,
2399 x_failure_count OUT NOCOPY number,
2400 x_return_status OUT NOCOPY number
2401 ) IS
2402
2403 c_application_id constant number(15) := 140;
2404 c_upgrade_bugno constant number(15) := -4107161;
2405 c_fnd_user constant number(15) := 2;
2406
2407 c_entity_code constant varchar2(30) := 'TRANSACTIONS';
2408 c_amb_context_code constant varchar2(30) := 'DEFAULT';
2409
2410 -- this value can be altered in order to process more of less per batch
2411 l_batch_size NUMBER;
2412
2413 l_rows_processed NUMBER;
2414
2415 -- type for table variable
2416 type num_tbl_type is table of number index by binary_integer;
2417 type char_tbl_type is table of varchar2(150) index by binary_integer;
2418 type date_tbl_type is table of date index by binary_integer;
2419 type rowid_tbl_type is table of rowid index by binary_integer;
2420
2421 -- used for bulk fetching
2422 -- main cursor
2423 l_event_id_tbl num_tbl_type;
2424 l_asset_id_tbl num_tbl_type;
2425 l_book_type_code_tbl char_tbl_type;
2426 l_primary_set_of_books_id_tbl num_tbl_type;
2427 l_org_id_tbl num_tbl_type;
2428 l_transaction_type_code_tbl char_tbl_type;
2429 l_transaction_date_entered_tbl date_tbl_type;
2430 l_transaction_header_id_tbl num_tbl_type;
2431 l_period_counter_tbl num_tbl_type;
2432 l_period_name_tbl char_tbl_type;
2433 l_cal_period_close_date_tbl date_tbl_type;
2434 l_rowid_tbl rowid_tbl_type;
2435 l_member_thid_tbl num_tbl_type;
2436
2437 l_upg_batch_id number;
2438 l_ae_header_id number;
2439
2440 l_entity_id_tbl num_tbl_type;
2441 l_event_class_code_tbl char_tbl_type;
2442 l_rep_set_of_books_id_tbl num_tbl_type;
2443 l_currency_code_tbl char_tbl_type;
2444 l_hdr_desc_tbl char_tbl_type;
2445 l_je_category_name_tbl char_tbl_type;
2446 l_date_effective_tbl date_tbl_type;
2447
2448 l_adj_line_id_tbl num_tbl_type;
2449 l_xla_gl_sl_link_id_tbl num_tbl_type;
2450 l_ae_line_num_tbl num_tbl_type;
2451 l_debit_amount_tbl num_tbl_type;
2452 l_credit_amount_tbl num_tbl_type;
2453 l_ccid_tbl num_tbl_type;
2454 l_acct_class_code_tbl char_tbl_type;
2455 l_line_def_owner_code_tbl char_tbl_type;
2456 l_line_def_code_tbl char_tbl_type;
2457 l_line_desc_tbl char_tbl_type;
2458 l_gl_transfer_status_code_tbl char_tbl_type;
2459 l_je_batch_id_tbl num_tbl_type;
2460 l_je_header_id_tbl num_tbl_type;
2461 l_je_line_num_tbl num_tbl_type;
2462 l_distribution_id_tbl num_tbl_type;
2463
2464 l_error_level_tbl char_tbl_type;
2465 l_err_entity_id_tbl num_tbl_type;
2466 l_err_event_id_tbl num_tbl_type;
2467 l_err_ae_header_id_tbl num_tbl_type;
2468 l_err_ae_line_num_tbl num_tbl_type;
2469 l_err_temp_line_num_tbl num_tbl_type;
2470 l_error_message_name_tbl char_tbl_type;
2471
2472 CURSOR c_trans IS
2473 select /*+ leading(th) rowid(th) */
2474 th.asset_id,
2475 th.book_type_code,
2476 bc.set_of_books_id,
2477 bc.org_id,
2478 th.transaction_type_code,
2479 th.transaction_date_entered,
2480 th.transaction_header_id,
2481 th.rowid,
2482 decode(th.transaction_type_code,
2483 'ADDITION', decode (ah.asset_type,
2484 'CIP', 'CAPITALIZATIONS',
2485 'ADDITIONS'),
2486 'ADJUSTMENT', 'ADJUSTMENTS',
2487 'CIP ADDITION', 'CIP_ADDITIONS',
2488 'CIP ADJUSTMENT', 'CIP_ADJUSTMENTS',
2489 'CIP REVERSE', 'REVERSE CAPITALIZATIONS',
2490 'CIP REINSTATEMENT', 'CIP_REINSTATEMENTS',
2491 'CIP RETIREMENT', 'CIP_RETIREMENTS',
2492 'CIP TRANSFER', 'CIP_TRANSFERS',
2493 'CIP UNIT ADJUSTMENTS', 'CIP_UNIT_ADJUSTMENTS',
2494 'FULL RETIREMENT', 'RETIREMENTS',
2495 'PARTIAL RETIREMENT', 'RETIREMENTS',
2496 'RECLASS', 'CATEGORY_RECLASS',
2497 'REINSTATEMENT', 'REINSTATEMENTS',
2498 'REVALUATION', 'REVALUATIONS',
2499 'TRANSFER', 'TRANSFERS',
2500 'TRANSFER IN', 'TRANSFERS',
2501 'TRANSFER IN/VOID', 'TRANSFERS',
2502 'TRANSFER OUT', 'TRANSFERS',
2503 'UNIT ADJUSTMENT', 'UNIT_ADJUSTMENTS',
2504 'UNPLANNED DEPRN', 'UNPLANNED_DEPRECIATION',
2505 'TAX', 'DEPRECIATION_ADJUSTMENTS',
2506 'OTHER'
2507 ) event_class_code,
2508 dp.period_name,
2509 dp.period_counter,
2510 dp.calendar_period_close_date,
2511 th.member_transaction_header_id,
2512 lk.description || ' - ' ||
2513 to_char(dp.calendar_period_close_date, 'DD-MON-RR'),
2514 nvl (decode(th.transaction_type_code,
2515 'ADDITION', bc.je_addition_category,
2516 'ADJUSTMENT', bc.je_adjustment_category,
2517 'CIP ADDITION', bc.je_cip_addition_category,
2518 'CIP ADJUSTMENT', bc.je_cip_adjustment_category,
2519 'CIP REVERSE', bc.je_cip_addition_category,
2520 'CIP REINSTATEMENT', bc.je_cip_retirement_category,
2521 'CIP RETIREMENT', bc.je_cip_retirement_category,
2522 'CIP TRANSFER', bc.je_cip_transfer_category,
2523 'CIP UNIT ADJUSTMENTS', bc.je_cip_transfer_category,
2524 'FULL RETIREMENT', bc.je_retirement_category,
2525 'PARTIAL RETIREMENT', bc.je_retirement_category,
2526 'RECLASS', bc.je_reclass_category,
2527 'REINSTATEMENT', bc.je_retirement_category,
2528 'REVALUATION', bc.je_reval_category,
2529 'TRANSFER', bc.je_transfer_category,
2530 'TRANSFER IN', bc.je_transfer_category,
2531 'TRANSFER IN/VOID', bc.je_transfer_category,
2532 'TRANSFER OUT', bc.je_transfer_category,
2533 'UNIT ADJUSTMENT', bc.je_transfer_category,
2534 'UNPLANNED DEPRN', bc.je_depreciation_category,
2535 'TAX', bc.je_deprn_adjustment_category
2536 ), 'OTHER') je_category_name,
2537 th.date_effective
2538 from fa_transaction_headers th,
2539 fa_asset_history ah,
2540 fa_deprn_periods dp,
2541 gl_sets_of_books glsob,
2542 fa_book_controls bc,
2543 fa_lookups_tl lk,
2544 gl_period_statuses ps
2545 where th.rowid between p_start_rowid and p_end_rowid
2546 and ps.application_id = 101
2547 and ((ps.migration_status_code in ('P', 'U')) or
2548 (dp.period_close_date is null))
2549 and substr(dp.xla_conversion_status, 1, 1) in
2550 ('H', 'U', 'E', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9')
2551 and dp.xla_conversion_status not in ('UT', 'UA')
2552 and ps.set_of_books_id = bc.set_of_books_id
2553 and ps.period_name = dp.period_name
2554 and th.book_type_code = bc.book_type_code
2555 and bc.allow_group_deprn_flag = 'Y'
2556 and bc.set_of_books_id = glsob.set_of_books_id
2557 and dp.book_type_code = bc.book_type_code
2558 and th.book_type_code = bc.book_type_code
2559 and th.date_effective between
2560 dp.period_open_date and nvl(dp.period_close_date, sysdate)
2561 and th.member_transaction_header_id is not null
2562 and th.transaction_subtype not in ('GA', 'M%', 'GC', 'GV')
2563 and th.asset_id = ah.asset_id (+)
2564 and th.transaction_header_id = ah.transaction_header_id_out (+)
2565 and th.event_id is null
2566 and th.transaction_type_code = lk.lookup_code
2567 and lk.lookup_type = 'FAXOLTRX'
2568 and userenv('LANG') = lk.language
2569 and exists
2570 (
2571 select 'x'
2572 from fa_adjustments adj
2573 where th.transaction_header_id = adj.transaction_header_id
2574 and th.book_type_code = adj.book_type_code
2575 and th.asset_id = adj.asset_id
2576 )
2577 UNION ALL
2578 select /*+ leading(th) rowid(th) */
2579 th.asset_id,
2580 th.book_type_code,
2581 bc.set_of_books_id,
2582 bc.org_id,
2583 th.transaction_type_code,
2584 dp.calendar_period_close_date,
2585 th.transaction_header_id,
2586 th.rowid,
2587 decode(th.transaction_type_code,
2588 'CIP TRANSFER', 'CIP_TRANSFERS',
2589 'CIP UNIT ADJUSTMENTS', 'CIP_UNIT_ADJUSTMENTS',
2590 'CIP REINSTATEMENT', 'CIP_TRANSFERS',
2591 'RECLASS', 'CATEGORY_RECLASS',
2592 'REINSTATEMENT', 'REINSTATEMENTS',
2593 'TRANSFER', 'TRANSFERS',
2594 'TRANSFER OUT', 'TRANSFERS',
2595 'UNIT ADJUSTMENT', 'UNIT_ADJUSTMENTS',
2596 'OTHER'
2597 ) event_class_code,
2598 dp.period_name,
2599 dp.period_counter,
2600 dp.calendar_period_close_date,
2601 th.member_transaction_header_id,
2602 lk.description || ' - ' ||
2603 to_char(dp.calendar_period_close_date, 'DD-MON-RR'),
2604 nvl (decode(th.transaction_type_code,
2605 'CIP REINSTATEMENT', bc.je_cip_transfer_category,
2606 'CIP TRANSFER', bc.je_cip_transfer_category,
2607 'CIP UNIT ADJUSTMENTS', bc.je_cip_transfer_category,
2608 'RECLASS', bc.je_reclass_category,
2609 'REINSTATEMENT', bc.je_transfer_category,
2610 'TRANSFER', bc.je_transfer_category,
2611 'TRANSFER OUT', bc.je_transfer_category,
2612 'UNIT ADJUSTMENT', bc.je_transfer_category),
2613 'OTHER') je_category_name,
2614 th.date_effective
2615 from fa_transaction_headers th,
2616 fa_deprn_periods dp,
2617 gl_sets_of_books glsob,
2618 fa_book_controls bc,
2619 fa_lookups_tl lk,
2620 gl_period_statuses ps
2621 where th.rowid between p_start_rowid and p_end_rowid
2622 and ps.application_id = 101
2623 and ((ps.migration_status_code in ('P', 'U')) or
2624 (dp.period_close_date is null))
2625 and substr(dp.xla_conversion_status, 1, 1) in
2626 ('H', 'U', 'E', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9')
2627 and dp.xla_conversion_status not in ('UT', 'UA')
2628 and ps.set_of_books_id = bc.set_of_books_id
2629 and ps.period_name = dp.period_name
2630 and th.transaction_type_code in ('TRANSFER', 'TRANSFER OUT',
2631 'RECLASS', 'UNIT ADJUSTMENT', 'REINSTATEMENT',
2632 'CIP REINSTATEMENT', 'CIP TRANSFER', 'CIP UNIT ADJUSTMENTS')
2633 and th.book_type_code = bc.distribution_source_book
2634 and bc.book_class = 'TAX'
2635 and bc.allow_group_deprn_flag = 'Y'
2636 and bc.set_of_books_id = glsob.set_of_books_id
2637 and dp.book_type_code = bc.book_type_code
2638 and th.date_effective between
2639 dp.period_open_date and nvl(dp.period_close_date, sysdate)
2640 and th.member_transaction_header_id is not null
2641 and th.transaction_subtype not in ('GA', 'M%', 'GC', 'GV')
2642 and th.event_id is null
2643 and th.transaction_type_code = lk.lookup_code
2644 and lk.lookup_type = 'FAXOLTRX'
2645 and userenv('LANG') = lk.language
2646 and exists
2647 (
2648 select 'x'
2649 from fa_adjustments adj
2650 where th.transaction_header_id = adj.transaction_header_id
2651 and bc.book_type_code = adj.book_type_code
2652 and th.asset_id = adj.asset_id
2653 );
2654
2655 CURSOR c_adj (l_book_type_code varchar2,
2656 l_asset_id number,
2657 l_transaction_header_id number,
2658 l_date_effective date) IS
2659 select adj.adjustment_line_id,
2660 decode (adj.debit_credit_flag,
2661 'DR', adj.adjustment_amount, null),
2662 decode (adj.debit_credit_flag,
2663 'CR', adj.adjustment_amount, null),
2664 adj.code_combination_id,
2665 glsob.currency_code,
2666 decode (adj.adjustment_type,
2667 'BONUS EXPENSE', 'EXPENSE',
2668 'BONUS RESERVE', 'ASSET',
2669 'CIP COST', 'ASSET',
2670 'COST', 'ASSET',
2671 'COST CLEARING', 'ASSET',
2672 'DEPRN ADJUST', 'EXPENSE',
2673 'EXPENSE', 'EXPENSE',
2674 'GRP COR RESERVE', 'ASSET',
2675 'GRP PRC RESERVE', 'ASSET',
2676 'INTERCO AP', 'LIABILITY',
2677 'INTERCO AR', 'ASSET',
2678 'NBV RETIRED', 'ASSET',
2679 'PROCEEDS', 'ASSET',
2680 'PROCEEDS CLR', 'ASSET',
2681 'REMOVALCOST', 'ASSET',
2682 'REMOVALCOST CLR', 'ASSET',
2683 'RESERVE', 'ASSET',
2684 'REVAL RESERVE', 'ASSET',
2685 'REVAL RSV RET', 'ASSET',
2686 'REVAL AMORT', 'EXPENSE',
2687 'REVAL EXPENSE', 'EXPENSE',
2688 'ASSET'),
2689 lk.description,
2690 decode (adj.je_header_id, null, 'N', 'Y'),
2691 gljh.je_batch_id,
2692 adj.je_header_id,
2693 nvl(adj.je_line_num, 0),
2694 adj.distribution_id
2695 from fa_adjustments adj,
2696 fa_lookups_tl lk,
2697 gl_je_headers gljh,
2698 fa_book_controls bc,
2699 gl_sets_of_books glsob
2700 where bc.book_type_code = l_book_type_code
2701 and bc.set_of_books_id = glsob.set_of_books_id
2702 and bc.book_type_code = adj.book_type_code
2703 and adj.asset_id = l_asset_id
2704 and adj.transaction_header_id = l_transaction_header_id
2705 and adj.code_combination_id is not null
2706 and nvl(adj.track_member_flag, 'N') = 'N'
2707 and lk.lookup_type = 'JOURNAL ENTRIES'
2708 and lk.lookup_code = decode (adj.adjustment_type,
2709 'BONUS EXPENSE', 'BONUS DEPRECIATION EXPENSE',
2710 'BONUS RESERVE', 'BONUS DEPRECIATION RESERVE',
2711 'CIP COST', adj.source_type_code ||' COST',
2712 adj.source_type_code ||' '|| adj.adjustment_type)
2713 and userenv('LANG') = lk.language
2714 and adj.je_header_id = gljh.je_header_id (+)
2715 UNION ALL
2716 select adj.adjustment_line_id,
2717 decode (adj.debit_credit_flag,
2718 'DR', adj.adjustment_amount, null),
2719 decode (adj.debit_credit_flag,
2720 'CR', adj.adjustment_amount, null),
2721 nvl(nvl(gljl.code_combination_id, da.deprn_reserve_account_ccid),
2722 cb.reserve_account_ccid),
2723 glsob.currency_code,
2724 decode (adj.adjustment_type,
2725 'BONUS EXPENSE', 'EXPENSE',
2726 'BONUS RESERVE', 'ASSET',
2727 'CIP COST', 'ASSET',
2728 'COST', 'ASSET',
2729 'COST CLEARING', 'ASSET',
2730 'DEPRN ADJUST', 'EXPENSE',
2731 'EXPENSE', 'EXPENSE',
2732 'GRP COR RESERVE', 'ASSET',
2733 'GRP PRC RESERVE', 'ASSET',
2734 'INTERCO AP', 'LIABILITY',
2735 'INTERCO AR', 'ASSET',
2736 'NBV RETIRED', 'ASSET',
2737 'PROCEEDS', 'ASSET',
2738 'PROCEEDS CLR', 'ASSET',
2739 'REMOVALCOST', 'ASSET',
2740 'REMOVALCOST CLR', 'ASSET',
2741 'RESERVE', 'ASSET',
2742 'REVAL RESERVE', 'ASSET',
2743 'REVAL RSV RET', 'ASSET',
2744 'REVAL AMORT', 'EXPENSE',
2745 'REVAL EXPENSE', 'EXPENSE',
2746 'ASSET'),
2747 lk.description,
2748 decode (dd.je_header_id, null, 'N', 'Y'),
2749 gljh.je_batch_id,
2750 dd.je_header_id,
2751 nvl(dd.deprn_reserve_je_line_num, 0),
2752 adj.distribution_id
2753 from fa_adjustments adj,
2754 gl_sets_of_books glsob,
2755 fa_book_controls bc,
2756 fa_lookups_tl lk,
2757 gl_je_headers gljh,
2758 fa_deprn_detail dd,
2759 gl_je_lines gljl,
2760 fa_distribution_accounts da,
2761 fa_asset_history ah,
2762 fa_category_books cb
2763 where bc.book_type_code = l_book_type_code
2764 and bc.set_of_books_id = glsob.set_of_books_id
2765 and bc.book_type_code = adj.book_type_code
2766 and adj.asset_id = l_asset_id
2767 and adj.transaction_header_id = l_transaction_header_id
2768 and adj.adjustment_type = 'EXPENSE'
2769 and adj.source_type_code in ('DEPRECIATION', 'CIP RETIREMENT',
2770 'RETIREMENT')
2771 and adj.code_combination_id is not null
2772 and nvl(adj.track_member_flag, 'N') = 'N'
2773 and lk.lookup_type = 'JOURNAL ENTRIES'
2774 and lk.lookup_code = adj.source_type_code ||' RESERVE'
2775 and userenv('LANG') = lk.language
2776 and adj.asset_id = dd.asset_id (+)
2777 and adj.book_type_code = dd.book_type_code (+)
2778 and adj.distribution_id = dd.distribution_id (+)
2779 and adj.period_counter_created = dd.period_counter (+)
2780 and dd.je_header_id = gljl.je_header_id
2781 and dd.deprn_reserve_je_line_num = gljl.je_line_num
2782 and dd.je_header_id = gljh.je_header_id
2783 and adj.book_type_code = da.book_type_code (+)
2784 and adj.distribution_id = da.distribution_id (+)
2785 and adj.asset_id = ah.asset_id
2786 and l_date_effective >= ah.date_effective
2787 and l_date_effective < nvl(ah.date_ineffective, sysdate+1)
2788 and ah.category_id = cb.category_id
2789 and bc.book_type_code = cb.book_type_code
2790 UNION ALL
2791 select adj.adjustment_line_id,
2792 decode (adj.debit_credit_flag,
2793 'DR', adj.adjustment_amount, null),
2794 decode (adj.debit_credit_flag,
2795 'CR', adj.adjustment_amount, null),
2796 nvl(nvl(gljl.code_combination_id, da.deprn_reserve_account_ccid),
2797 cb.reserve_account_ccid),
2798 glsob.currency_code,
2799 decode (adj.adjustment_type,
2800 'BONUS EXPENSE', 'EXPENSE',
2801 'BONUS RESERVE', 'ASSET',
2802 'CIP COST', 'ASSET',
2803 'COST', 'ASSET',
2804 'COST CLEARING', 'ASSET',
2805 'DEPRN ADJUST', 'EXPENSE',
2806 'EXPENSE', 'EXPENSE',
2807 'GRP COR RESERVE', 'ASSET',
2808 'GRP PRC RESERVE', 'ASSET',
2809 'INTERCO AP', 'LIABILITY',
2810 'INTERCO AR', 'ASSET',
2811 'NBV RETIRED', 'ASSET',
2812 'PROCEEDS', 'ASSET',
2813 'PROCEEDS CLR', 'ASSET',
2814 'REMOVALCOST', 'ASSET',
2815 'REMOVALCOST CLR', 'ASSET',
2816 'RESERVE', 'ASSET',
2817 'REVAL RESERVE', 'ASSET',
2818 'REVAL RSV RET', 'ASSET',
2819 'REVAL AMORT', 'EXPENSE',
2820 'REVAL EXPENSE', 'EXPENSE',
2821 'ASSET'),
2822 lk.description,
2823 decode (dd.je_header_id, null, 'N', 'Y'),
2824 gljh.je_batch_id,
2825 dd.je_header_id,
2826 nvl(dd.deprn_reserve_je_line_num, 0),
2827 adj.distribution_id
2828 from fa_adjustments adj,
2829 gl_sets_of_books glsob,
2830 fa_book_controls bc,
2831 fa_lookups_tl lk,
2832 gl_je_headers gljh,
2833 fa_deprn_detail dd,
2834 gl_je_lines gljl,
2835 fa_distribution_accounts da,
2836 fa_asset_history ah,
2837 fa_category_books cb
2838 where bc.book_type_code = l_book_type_code
2839 and bc.set_of_books_id = glsob.set_of_books_id
2840 and bc.book_type_code = adj.book_type_code
2841 and adj.asset_id = l_asset_id
2842 and adj.transaction_header_id = l_transaction_header_id
2843 and adj.adjustment_type = 'BONUS EXPENSE'
2844 and adj.source_type_code = 'DEPRECIATION'
2845 and adj.code_combination_id is not null
2846 and nvl(adj.track_member_flag, 'N') = 'N'
2847 and lk.lookup_type = 'JOURNAL ENTRIES'
2848 and lk.lookup_code = 'BONUS DEPRECIATION RESERVE'
2849 and userenv('LANG') = lk.language
2850 and adj.asset_id = dd.asset_id (+)
2851 and adj.book_type_code = dd.book_type_code (+)
2852 and adj.distribution_id = dd.distribution_id (+)
2853 and adj.period_counter_created = dd.period_counter (+)
2854 and dd.je_header_id = gljl.je_header_id
2855 and dd.bonus_deprn_rsv_je_line_num = gljl.je_line_num
2856 and dd.je_header_id = gljh.je_header_id
2857 and adj.book_type_code = da.book_type_code (+)
2858 and adj.distribution_id = da.distribution_id (+)
2859 and adj.asset_id = ah.asset_id
2860 and l_date_effective >= ah.date_effective
2861 and l_date_effective < nvl(ah.date_ineffective, sysdate+1)
2862 and ah.category_id = cb.category_id
2863 and bc.book_type_code = cb.book_type_code;
2864
2865 CURSOR c_mc_books (l_book_type_code varchar2) IS
2866 select set_of_books_id
2867 from fa_mc_book_controls
2868 where book_type_code = l_book_type_code
2869 and enabled_flag = 'Y';
2870
2871 CURSOR c_mc_adj (l_book_type_code varchar2,
2872 l_asset_id number,
2873 l_set_of_books_id number,
2874 l_transaction_header_id number,
2875 l_date_effective date) IS
2876 select adj.adjustment_line_id,
2877 decode (adj.debit_credit_flag,
2878 'DR', adj.adjustment_amount, null),
2879 decode (adj.debit_credit_flag,
2880 'CR', adj.adjustment_amount, null),
2881 adj.code_combination_id,
2882 glsob.currency_code,
2883 decode (adj.adjustment_type,
2884 'BONUS EXPENSE', 'EXPENSE',
2885 'BONUS RESERVE', 'ASSET',
2886 'CIP COST', 'ASSET',
2887 'COST', 'ASSET',
2888 'COST CLEARING', 'ASSET',
2889 'DEPRN ADJUST', 'EXPENSE',
2890 'EXPENSE', 'EXPENSE',
2891 'GRP COR RESERVE', 'ASSET',
2892 'GRP PRC RESERVE', 'ASSET',
2893 'INTERCO AP', 'LIABILITY',
2894 'INTERCO AR', 'ASSET',
2895 'NBV RETIRED', 'ASSET',
2896 'PROCEEDS', 'ASSET',
2897 'PROCEEDS CLR', 'ASSET',
2898 'REMOVALCOST', 'ASSET',
2899 'REMOVALCOST CLR', 'ASSET',
2900 'RESERVE', 'ASSET',
2901 'REVAL RESERVE', 'ASSET',
2902 'REVAL RSV RET', 'ASSET',
2903 'REVAL AMORT', 'EXPENSE',
2904 'REVAL EXPENSE', 'EXPENSE',
2905 'ASSET'),
2906 lk.description,
2907 decode (adj.je_header_id, null, 'N', 'Y'),
2908 gljh.je_batch_id,
2909 adj.je_header_id,
2910 nvl(adj.je_line_num, 0),
2911 adj.distribution_id
2912 from fa_mc_adjustments adj,
2913 fa_lookups_tl lk,
2914 gl_je_headers gljh,
2915 fa_mc_book_controls bc,
2916 gl_sets_of_books glsob
2917 where bc.book_type_code = l_book_type_code
2918 and bc.set_of_books_id = l_set_of_books_id
2919 and bc.enabled_flag = 'Y'
2920 and bc.set_of_books_id = glsob.set_of_books_id
2921 and bc.book_type_code = adj.book_type_code
2922 and bc.set_of_books_id = adj.set_of_books_id
2923 and adj.asset_id = l_asset_id
2924 and adj.transaction_header_id = l_transaction_header_id
2925 and adj.code_combination_id is not null
2926 and nvl(adj.track_member_flag, 'N') = 'N'
2927 and lk.lookup_type = 'JOURNAL ENTRIES'
2928 and lk.lookup_code = decode (adj.adjustment_type,
2929 'BONUS EXPENSE', 'BONUS DEPRECIATION EXPENSE',
2930 'BONUS RESERVE', 'BONUS DEPRECIATION RESERVE',
2931 'CIP COST', adj.source_type_code ||' COST',
2932 adj.source_type_code ||' '|| adj.adjustment_type)
2933 and userenv('LANG') = lk.language
2934 and adj.je_header_id = gljh.je_header_id (+)
2935 UNION ALL
2936 select adj.adjustment_line_id,
2937 decode (adj.debit_credit_flag,
2938 'DR', adj.adjustment_amount, null),
2939 decode (adj.debit_credit_flag,
2940 'CR', adj.adjustment_amount, null),
2941 nvl(nvl(gljl.code_combination_id, da.deprn_reserve_account_ccid),
2942 cb.reserve_account_ccid),
2943 glsob.currency_code,
2944 decode (adj.adjustment_type,
2945 'BONUS EXPENSE', 'EXPENSE',
2946 'BONUS RESERVE', 'ASSET',
2947 'CIP COST', 'ASSET',
2948 'COST', 'ASSET',
2949 'COST CLEARING', 'ASSET',
2950 'DEPRN ADJUST', 'EXPENSE',
2951 'EXPENSE', 'EXPENSE',
2952 'GRP COR RESERVE', 'ASSET',
2953 'GRP PRC RESERVE', 'ASSET',
2954 'INTERCO AP', 'LIABILITY',
2955 'INTERCO AR', 'ASSET',
2956 'NBV RETIRED', 'ASSET',
2957 'PROCEEDS', 'ASSET',
2958 'PROCEEDS CLR', 'ASSET',
2959 'REMOVALCOST', 'ASSET',
2960 'REMOVALCOST CLR', 'ASSET',
2961 'RESERVE', 'ASSET',
2962 'REVAL RESERVE', 'ASSET',
2963 'REVAL RSV RET', 'ASSET',
2964 'REVAL AMORT', 'EXPENSE',
2965 'REVAL EXPENSE', 'EXPENSE',
2966 'ASSET'),
2967 lk.description,
2968 decode (dd.je_header_id, null, 'N', 'Y'),
2969 gljh.je_batch_id,
2970 dd.je_header_id,
2971 nvl(dd.deprn_reserve_je_line_num, 0),
2972 adj.distribution_id
2973 from fa_mc_adjustments adj,
2974 gl_sets_of_books glsob,
2975 fa_mc_book_controls bc,
2976 fa_lookups_tl lk,
2977 gl_je_headers gljh,
2978 fa_mc_deprn_detail dd,
2979 gl_je_lines gljl,
2980 fa_distribution_accounts da,
2981 fa_asset_history ah,
2982 fa_category_books cb
2983 where bc.book_type_code = l_book_type_code
2984 and bc.set_of_books_id = l_set_of_books_id
2985 and bc.enabled_flag = 'Y'
2986 and bc.set_of_books_id = glsob.set_of_books_id
2987 and bc.book_type_code = adj.book_type_code
2988 and bc.set_of_books_id = adj.set_of_books_id
2989 and adj.asset_id = l_asset_id
2990 and adj.transaction_header_id = l_transaction_header_id
2991 and adj.adjustment_type = 'EXPENSE'
2992 and adj.source_type_code in ('DEPRECIATION', 'CIP RETIREMENT',
2993 'RETIREMENT')
2994 and adj.code_combination_id is not null
2995 and nvl(adj.track_member_flag, 'N') = 'N'
2996 and lk.lookup_type = 'JOURNAL ENTRIES'
2997 and lk.lookup_code = adj.source_type_code ||' RESERVE'
2998 and userenv('LANG') = lk.language
2999 and adj.asset_id = dd.asset_id (+)
3000 and adj.book_type_code = dd.book_type_code (+)
3001 and adj.set_of_books_id = dd.set_of_books_id (+)
3002 and adj.distribution_id = dd.distribution_id (+)
3003 and adj.period_counter_created = dd.period_counter (+)
3004 and dd.je_header_id = gljl.je_header_id
3005 and dd.deprn_reserve_je_line_num = gljl.je_line_num
3006 and dd.je_header_id = gljh.je_header_id
3007 and adj.book_type_code = da.book_type_code (+)
3008 and adj.distribution_id = da.distribution_id (+)
3009 and adj.asset_id = ah.asset_id
3010 and l_date_effective >= ah.date_effective
3011 and l_date_effective < nvl(ah.date_ineffective, sysdate+1)
3012 and ah.category_id = cb.category_id
3013 and bc.book_type_code = cb.book_type_code
3014 UNION ALL
3015 select adj.adjustment_line_id,
3016 decode (adj.debit_credit_flag,
3017 'DR', adj.adjustment_amount, null),
3018 decode (adj.debit_credit_flag,
3019 'CR', adj.adjustment_amount, null),
3020 nvl(nvl(gljl.code_combination_id, da.deprn_reserve_account_ccid),
3021 cb.reserve_account_ccid),
3022 glsob.currency_code,
3023 decode (adj.adjustment_type,
3024 'BONUS EXPENSE', 'EXPENSE',
3025 'BONUS RESERVE', 'ASSET',
3026 'CIP COST', 'ASSET',
3027 'COST', 'ASSET',
3028 'COST CLEARING', 'ASSET',
3029 'DEPRN ADJUST', 'EXPENSE',
3030 'EXPENSE', 'EXPENSE',
3031 'GRP COR RESERVE', 'ASSET',
3032 'GRP PRC RESERVE', 'ASSET',
3033 'INTERCO AP', 'LIABILITY',
3034 'INTERCO AR', 'ASSET',
3035 'NBV RETIRED', 'ASSET',
3036 'PROCEEDS', 'ASSET',
3037 'PROCEEDS CLR', 'ASSET',
3038 'REMOVALCOST', 'ASSET',
3039 'REMOVALCOST CLR', 'ASSET',
3040 'RESERVE', 'ASSET',
3041 'REVAL RESERVE', 'ASSET',
3042 'REVAL RSV RET', 'ASSET',
3043 'REVAL AMORT', 'EXPENSE',
3044 'REVAL EXPENSE', 'EXPENSE',
3045 'ASSET'),
3046 lk.description,
3047 decode (dd.je_header_id, null, 'N', 'Y'),
3048 gljh.je_batch_id,
3049 dd.je_header_id,
3050 nvl(dd.deprn_reserve_je_line_num, 0),
3051 adj.distribution_id
3052 from fa_mc_adjustments adj,
3053 gl_sets_of_books glsob,
3054 fa_mc_book_controls bc,
3055 fa_lookups_tl lk,
3056 gl_je_headers gljh,
3057 fa_mc_deprn_detail dd,
3058 gl_je_lines gljl,
3059 fa_distribution_accounts da,
3060 fa_asset_history ah,
3061 fa_category_books cb
3062 where bc.book_type_code = l_book_type_code
3063 and bc.set_of_books_id = l_set_of_books_id
3064 and bc.enabled_flag = 'Y'
3065 and bc.set_of_books_id = glsob.set_of_books_id
3066 and bc.book_type_code = adj.book_type_code
3067 and bc.set_of_books_id = adj.set_of_books_id
3068 and adj.asset_id = l_asset_id
3069 and adj.transaction_header_id = l_transaction_header_id
3070 and adj.adjustment_type = 'BONUS EXPENSE'
3071 and adj.source_type_code = 'DEPRECIATION'
3072 and adj.code_combination_id is not null
3073 and nvl(adj.track_member_flag, 'N') = 'N'
3074 and lk.lookup_type = 'JOURNAL ENTRIES'
3075 and lk.lookup_code = 'BONUS DEPRECIATION RESERVE'
3076 and userenv('LANG') = lk.language
3077 and adj.asset_id = dd.asset_id (+)
3078 and adj.book_type_code = dd.book_type_code (+)
3079 and adj.set_of_books_id = dd.set_of_books_id (+)
3080 and adj.distribution_id = dd.distribution_id (+)
3081 and adj.period_counter_created = dd.period_counter (+)
3082 and dd.je_header_id = gljl.je_header_id
3083 and dd.bonus_deprn_rsv_je_line_num = gljl.je_line_num
3084 and dd.je_header_id = gljh.je_header_id
3085 and adj.book_type_code = da.book_type_code (+)
3086 and adj.distribution_id = da.distribution_id (+)
3087 and adj.asset_id = ah.asset_id
3088 and l_date_effective >= ah.date_effective
3089 and l_date_effective < nvl(ah.date_ineffective, sysdate+1)
3090 and ah.category_id = cb.category_id
3091 and bc.book_type_code = cb.book_type_code;
3092
3093 BEGIN
3094
3095 x_success_count := 0;
3096 x_failure_count := 0;
3097
3098 l_batch_size := nvl(nvl(p_batch_size, fa_cache_pkg.fa_batch_size), 1000);
3099
3100 open c_trans;
3101 loop
3102
3103 fetch c_trans bulk collect
3104 into l_asset_id_tbl,
3105 l_book_type_code_tbl,
3106 l_primary_set_of_books_id_tbl,
3107 l_org_id_tbl,
3108 l_transaction_type_code_tbl,
3109 l_transaction_date_entered_tbl,
3110 l_transaction_header_id_tbl,
3111 l_rowid_tbl,
3112 l_event_class_code_tbl,
3113 l_period_name_tbl,
3114 l_period_counter_tbl,
3115 l_cal_period_close_date_tbl,
3116 l_member_thid_tbl,
3117 l_hdr_desc_tbl,
3118 l_je_category_name_tbl,
3119 l_date_effective_tbl
3120 limit l_batch_size;
3121
3122 if (l_event_id_tbl.count = 0) then exit; end if;
3123
3124 -- Select upg_batch_id
3125 select xla_upg_batches_s.nextval
3126 into l_upg_batch_id
3127 from dual;
3128
3129 FOR i IN 1..l_rowid_tbl.count LOOP
3130 select xla_events_s.nextval, xla_transaction_entities_s.nextval
3131 into l_event_id_tbl(i), l_entity_id_tbl(i)
3132 from dual;
3133 END LOOP;
3134
3135 -- Update table with event_id
3136 FORALL l_count IN 1..l_event_id_tbl.count
3137 update fa_transaction_headers th
3138 set th.event_id = l_event_id_tbl(l_count)
3139 where th.rowid = l_rowid_tbl(l_count);
3140
3141 l_rows_processed := l_event_id_tbl.count;
3142
3143 FORALL l_count IN 1..l_event_id_tbl.count
3144 update fa_transaction_headers th
3145 set th.event_id = l_event_id_tbl(l_count)
3146 where th.transaction_header_id = l_member_thid_tbl(l_count);
3147
3148 -- Business Rules for xla_transaction_entities
3149 -- * ledger_id is the same as set_of_books_id
3150 -- * legal_entity_id is null
3151 -- * entity_code can be TRANSACTIONS or DEPRECIATION
3152 -- * for TRANSACTIONS:
3153 -- source_id_int_1 is transaction_header_id
3154 -- transaction_number is transaction_header_id
3155 -- * for DEPRECIATION:
3156 -- source_id_int is asset_id
3157 -- source_id_int_2 is period_counter
3158 -- source_id_int_3 is deprn_run_id
3159 -- transaction_number is set_of_books_id
3160 -- * source_char_id_1 is book_type_code
3161 -- * valuation_method is book_type_code
3162
3163 FORALL i IN 1..l_event_id_tbl.count
3164 INSERT INTO xla_transaction_entities_upg (
3165 upg_batch_id,
3166 application_id,
3167 ledger_id,
3168 legal_entity_id,
3169 entity_code,
3170 source_id_int_1,
3171 source_id_int_2,
3172 source_id_int_3,
3173 source_id_int_4,
3174 source_id_char_1,
3175 source_id_char_2,
3176 source_id_char_3,
3177 source_id_char_4,
3178 security_id_int_1,
3179 security_id_int_2,
3180 security_id_int_3,
3181 security_id_char_1,
3182 security_id_char_2,
3183 security_id_char_3,
3184 transaction_number,
3185 valuation_method,
3186 source_application_id,
3187 creation_date,
3188 created_by,
3189 last_update_date,
3190 last_updated_by,
3191 last_update_login,
3192 entity_id,
3193 upg_source_application_id
3194 ) values (
3195 l_upg_batch_id, -- upg_batch_id
3196 c_application_id, -- application_id
3197 l_primary_set_of_books_id_tbl(i), -- ledger_id
3198 null, -- legal_entity_id,
3199 c_entity_code, -- entity_code
3200 l_transaction_header_id_tbl(i), -- source_id_int_1
3201 null, -- source_id_int_2
3202 null, -- source_id_int_3
3203 null, -- source_id_int_4
3204 null, -- source_id_char_1
3205 null, -- source_id_char_2
3206 null, -- source_id_char_3
3207 null, -- source_id_char_4
3208 null, -- security_id_int_1
3209 null, -- security_id_int_2
3210 null, -- security_id_int_3
3211 l_book_type_code_tbl(i), -- security_id_char_1
3212 null, -- security_id_char_2
3213 null, -- security_id_char_3
3214 l_transaction_header_id_tbl(i), -- transaction number
3215 l_book_type_code_tbl(i), -- valuation_method
3216 c_application_id, -- source_application_id
3217 sysdate, -- creation_date
3218 c_fnd_user, -- created_by
3219 sysdate, -- last_update_date
3220 c_upgrade_bugno, -- last_update_by
3221 c_upgrade_bugno, -- last_update_login
3222 l_entity_id_tbl(i), -- entity_id
3223 c_application_id -- upg_source_application_id
3224 );
3225
3226 -- Business Rules for xla_events
3227 -- * event_type_code is similar to transaction_type_code
3228 -- * event_number is 1, but is the serial event for chronological order
3229 -- * event_status_code: N if event creates no journal entries
3230 -- P if event would ultimately yield journals
3231 -- I if event is not ready to be processed
3232 -- U never use this value for upgrade
3233 -- * process_status_code: E if error and journals not yet created
3234 -- P if processed and journals already generated
3235 -- U if unprocessed and journals not generated
3236 -- D only used for Global Accounting Engine
3237 -- I do not use for upgrade
3238 -- * on_hold_flag: N should always be this value for upgraded entries
3239 -- * event_date is basically transaction_date_entered
3240
3241 FORALL i IN 1..l_event_id_tbl.count
3242 insert into xla_events (
3243 upg_batch_id,
3244 application_id,
3245 event_type_code,
3246 event_number,
3247 event_status_code,
3248 process_status_code,
3249 on_hold_flag,
3250 event_date,
3251 creation_date,
3252 created_by,
3253 last_update_date,
3254 last_updated_by,
3255 last_update_login,
3256 program_update_date,
3257 program_id,
3258 program_application_id,
3259 request_id,
3260 entity_id,
3261 event_id,
3262 upg_source_application_id,
3263 transaction_date
3264 ) values (
3265 l_upg_batch_id, -- upg_batch_id
3266 c_application_id, -- application_id
3267 l_event_class_code_tbl(i), -- event_type_code
3268 '1', -- event_number
3269 'P', -- event_status_code
3270 'P', -- process_status_code
3271 'N', -- on_hold_flag
3272 l_transaction_date_entered_tbl(i), -- event_date
3273 sysdate, -- creation_date
3274 c_fnd_user, -- created_by
3275 sysdate, -- last_update_date
3276 c_upgrade_bugno, -- last_update_by
3277 c_upgrade_bugno, -- last_update_login
3278 null, -- program_update_date
3279 null, -- program_id
3280 null, -- program_application_id
3281 null, -- program_update_date
3282 l_entity_id_tbl(i), -- entity_id
3283 l_event_id_tbl(i), -- event_id
3284 c_application_id, -- upg_source_appl_id
3285 l_transaction_date_entered_tbl(i) -- transaction_date
3286 );
3287
3288 FOR i IN 1..l_event_id_tbl.count LOOP
3289
3290 open c_adj (l_book_type_code_tbl(i),
3291 l_asset_id_tbl(i),
3292 l_transaction_header_id_tbl(i),
3293 l_date_effective_tbl(i));
3294 fetch c_adj bulk collect
3295 into l_adj_line_id_tbl,
3296 l_debit_amount_tbl,
3297 l_credit_amount_tbl,
3298 l_ccid_tbl,
3299 l_currency_code_tbl,
3300 l_acct_class_code_tbl,
3301 l_line_desc_tbl,
3302 l_gl_transfer_status_code_tbl,
3303 l_je_batch_id_tbl,
3304 l_je_header_id_tbl,
3305 l_je_line_num_tbl,
3306 l_distribution_id_tbl;
3307 close c_adj;
3308
3309 FOR j IN 1..l_adj_line_id_tbl.count LOOP
3310 l_ae_line_num_tbl(j) := j;
3311
3312 select xla_gl_sl_link_id_s.nextval
3313 into l_xla_gl_sl_link_id_tbl(j)
3314 from dual;
3315 END LOOP;
3316
3317 select xla_ae_headers_s.nextval
3318 into l_ae_header_id
3319 from dual;
3320
3321 -- Business Rules for xla_ae_headers
3322 -- * amb_context_code is DEFAULT
3323 -- * reference_date must be null
3324 -- * balance_type_code:
3325 -- A: Actual
3326 -- B: Budget
3327 -- E: Encumbrance
3328 -- * gl_transfer_status_code:
3329 -- Y: already transferred to GL
3330 -- N: not transferred to GL
3331 -- * gl_transfer_date is date entry transferred to GL
3332 -- * accounting_entry_status_code must be F
3333 -- * accounting_entry_type_code must be STANDARD
3334 -- * product_rule_* not relevant for upgrade
3335
3336 insert into xla_ae_headers (
3337 upg_batch_id,
3338 application_id,
3339 amb_context_code,
3340 entity_id,
3341 event_id,
3342 event_type_code,
3343 ae_header_id,
3344 ledger_id,
3345 accounting_date,
3346 period_name,
3347 reference_date,
3348 balance_type_code,
3349 je_category_name,
3350 gl_transfer_status_code,
3351 gl_transfer_date,
3352 accounting_entry_status_code,
3353 accounting_entry_type_code,
3354 description,
3355 budget_version_id,
3356 funds_status_code,
3357 encumbrance_type_id,
3358 completed_date,
3359 doc_sequence_id,
3360 doc_sequence_value,
3361 doc_category_code,
3362 packet_id,
3363 group_id,
3364 creation_date,
3365 created_by,
3366 last_update_date,
3367 last_updated_by,
3368 last_update_login,
3369 program_id,
3370 program_application_id,
3371 program_update_date,
3372 request_id,
3373 close_acct_seq_assign_id,
3374 close_acct_seq_version_id,
3375 close_acct_seq_value,
3376 completion_acct_seq_assign_id,
3377 completion_acct_seq_version_id,
3378 completion_acct_seq_value,
3379 accounting_batch_id,
3380 product_rule_type_code,
3381 product_rule_code,
3382 product_rule_version,
3383 upg_source_application_id,
3384 upg_valid_flag
3385 ) values (
3386 l_upg_batch_id, -- upg_batch_id
3387 c_application_id, -- application_id
3388 c_amb_context_code, -- amb_context_code
3389 l_entity_id_tbl(i), -- entity_id
3390 l_event_id_tbl(i), -- event_id,
3391 l_event_class_code_tbl(i), -- event_type_code
3392 l_ae_header_id, -- ae_header_id,
3393 l_primary_set_of_books_id_tbl(i), -- ledger_id/sob_id
3394 l_cal_period_close_date_tbl(i), -- accounting_date,
3395 l_period_name_tbl(i), -- period_name,
3396 null, -- reference_date
3397 'A', -- balance_type_code,
3398 l_je_category_name_tbl(i), -- je_category_name
3399 'Y', -- gl_transfer_status_code
3400 null, -- gl_transfer_date
3401 'F', -- accounting_entry_status_code
3402 'STANDARD', -- accounting_entry_type_code
3403 l_hdr_desc_tbl(i), -- description
3404 null, -- budget_version_id
3405 null, -- funds_status_code
3406 null, -- encumbrance_type_id
3407 null, -- completed_date
3408 null, -- doc_sequence_id
3409 null, -- doc_sequence_value
3410 null, -- doc_category_code
3411 null, -- packet_id,
3412 null, -- group_id
3413 sysdate, -- creation_date
3414 c_fnd_user, -- created_by
3415 sysdate, -- last_update_date
3416 c_fnd_user, -- last_updated_by
3417 c_upgrade_bugno, -- last_update_login
3418 null, -- program_id
3419 c_application_id, -- program_application_id
3420 sysdate, -- program_update_date
3421 null, -- request_id
3422 null, -- close_acct_seq_assign_id
3423 null, -- close_acct_seq_version_id
3424 null, -- close_acct_seq_value
3425 null, -- compl_acct_seq_assign_id
3426 null, -- compl_acct_seq_version_id
3427 null, -- compl_acct_seq_value
3428 null, -- accounting_batch_id
3429 null, -- product_rule_type_code
3430 null, -- product_rule_code
3431 null, -- product_rule_version
3432 c_application_id, -- upg_souce_application_id
3433 null -- upg_valid_flag
3434 );
3435
3436 -- Business Rules for xla_ae_lines
3437 -- * gl_transfer_mode_code:
3438 -- D: Detailed mode when transferred to GL
3439 -- S: Summary mode when transferred to GL
3440 -- * gl_sl_link_table must be XLAJEL
3441 -- * currency_conversion_* needs to be populated only if
3442 -- different from ledger currency
3443
3444 forall j IN 1..l_xla_gl_sl_link_id_tbl.count
3445 insert into xla_ae_lines (
3446 upg_batch_id,
3447 ae_header_id,
3448 ae_line_num,
3449 displayed_line_number,
3450 application_id,
3451 code_combination_id,
3452 gl_transfer_mode_code,
3453 accounted_dr,
3454 accounted_cr,
3455 currency_code,
3456 currency_conversion_date,
3457 currency_conversion_rate,
3458 currency_conversion_type,
3459 entered_dr,
3460 entered_cr,
3461 description,
3462 accounting_class_code,
3463 gl_sl_link_id,
3464 gl_sl_link_table,
3465 party_type_code,
3466 party_id,
3467 party_site_id,
3468 statistical_amount,
3469 ussgl_transaction_code,
3470 jgzz_recon_ref,
3471 control_balance_flag,
3472 analytical_balance_flag,
3473 upg_tax_reference_id1,
3474 upg_tax_reference_id2,
3475 upg_tax_reference_id3,
3476 creation_date,
3477 created_by,
3478 last_update_date,
3479 last_updated_by,
3480 last_update_login,
3481 program_update_date,
3482 program_id,
3483 program_application_id,
3484 request_id,
3485 gain_or_loss_flag,
3486 accounting_date,
3487 ledger_id
3488 ) values (
3489 l_upg_batch_id, -- upg_batch_id
3490 l_ae_header_id, -- ae_header_id
3491 l_ae_line_num_tbl(j), -- ae_line_num
3492 l_ae_line_num_tbl(j), -- displayed_line_num
3493 c_application_id, -- application_id
3494 l_ccid_tbl(j), -- code_combination_id
3495 'S', -- gl_transfer_mode_code
3496 l_debit_amount_tbl(j), -- accounted_dr
3497 l_credit_amount_tbl(j), -- accounted_cr
3498 l_currency_code_tbl(j), -- currency_code
3499 null, -- currency_conversion_date
3500 null, -- currency_conversion_rate
3501 null, -- currency_conversion_type
3502 l_debit_amount_tbl(j), -- entered_dr
3503 l_credit_amount_tbl(j), -- entered_cr
3504 l_line_desc_tbl(j) || ' - ' ||
3505 to_char(l_cal_period_close_date_tbl(i), 'DD-MON-RR'),
3506 -- description
3507 l_acct_class_code_tbl(j), -- accounting_class_code
3508 l_xla_gl_sl_link_id_tbl(j), -- gl_sl_link_id
3509 'XLAJEL', -- gl_sl_link_table
3510 null, -- party_type_code
3511 null, -- party_id
3512 null, -- party_site_id
3513 null, -- statistical_amount
3514 null, -- ussgl_transaction_code
3515 null, -- glzz_recon_ref
3516 null, -- control_balance_flag
3517 null, -- analytical_balance_flag
3518 null, -- upg_tax_reference_id1
3519 null, -- upg_tax_reference_id2
3520 null, -- upg_tax_reference_id3
3521 sysdate, -- creation_date
3522 c_fnd_user, -- created_by
3523 sysdate, -- last_update_date
3524 c_fnd_user, -- last_updated_by
3525 c_upgrade_bugno, -- last_update_login
3526 null, -- program_update_date
3527 null, -- program_id
3528 c_application_id, -- program_application_id
3529 null, -- request_id
3530 'N', -- gain_or_loss_flag
3531 l_cal_period_close_date_tbl(i), -- accounting_date,
3532 l_primary_set_of_books_id_tbl(i)
3533 -- ledger_id/sob_id
3534 );
3535
3536 -- Business Rules for xla_distribution_links
3537 -- * accounting_line_code is similar to adjustment_type
3538 -- * accounting_line_type_code is S
3539 -- * merge_duplicate_code is N
3540 -- * source_distribution_type is TRX
3541 -- * source_distribution_id_num_1 is transaction_header_id
3542 -- * source_distribution_id_num_2 is event_id
3543
3544 forall j IN 1..l_xla_gl_sl_link_id_tbl.count
3545 insert into xla_distribution_links (
3546 upg_batch_id,
3547 application_id,
3548 event_id,
3549 ae_header_id,
3550 ae_line_num,
3551 accounting_line_code,
3552 accounting_line_type_code,
3553 source_distribution_type,
3554 source_distribution_id_char_1,
3555 source_distribution_id_char_2,
3556 source_distribution_id_char_3,
3557 source_distribution_id_char_4,
3558 source_distribution_id_char_5,
3559 source_distribution_id_num_1,
3560 source_distribution_id_num_2,
3561 source_distribution_id_num_3,
3562 source_distribution_id_num_4,
3563 source_distribution_id_num_5,
3564 merge_duplicate_code,
3565 statistical_amount,
3566 unrounded_entered_dr,
3567 unrounded_entered_cr,
3568 unrounded_accounted_dr,
3569 unrounded_accounted_cr,
3570 ref_ae_header_id,
3571 ref_temp_line_num,
3572 ref_event_id,
3573 temp_line_num,
3574 tax_line_ref_id,
3575 tax_summary_line_ref_id,
3576 tax_rec_nrec_dist_ref_id,
3577 line_definition_owner_code,
3578 line_definition_code,
3579 event_class_code,
3580 event_type_code
3581 ) values (
3582 l_upg_batch_id, -- upg_batch_id
3583 c_application_id, -- application_id
3584 l_event_id_tbl(i), -- event_id
3585 l_ae_header_id, -- ae_header_id
3586 l_ae_line_num_tbl(j), -- ae_line_num
3587 null, -- accounting_line_code
3588 'S', -- accounting_line_type_code
3589 'TRX', -- source_distribution_type
3590 null, -- source_distribution_id_char_1
3591 null, -- source_distribution_id_char_2
3592 null, -- source_distribution_id_char_3
3593 null, -- source_distribution_id_char_4
3594 null, -- source_distribution_id_char_5
3595 l_transaction_header_id_tbl(i),
3596 -- source_distribution_id_num_1
3597 l_adj_line_id_tbl(j), -- source_distribution_id_num_2
3598 null, -- source_distribution_id_num_3
3599 null, -- source_distribution_id_num_4
3600 null, -- source_distribution_id_num_5
3601 'N', -- merge_duplicate_code
3602 null, -- statistical_amount
3603 l_debit_amount_tbl(j), -- unrounded_entered_dr
3604 l_credit_amount_tbl(j), -- unrounded_entered_cr
3605 l_debit_amount_tbl(j), -- unrounded_accounted_dr
3606 l_credit_amount_tbl(j), -- unrounded_accounted_cr
3607 l_ae_header_id, -- ref_ae_header_id
3608 null, -- ref_temp_line_num
3609 null, -- ref_event_id
3610 l_ae_line_num_tbl(j), -- temp_line_num
3611 null, -- tax_line_ref_id
3612 null, -- tax_summary_line_ref_id
3613 null, -- tax_rec_nrec_dist_ref_id
3614 null, -- line_definition_owner_code
3615 null, -- line_definition_code
3616 l_event_class_code_tbl(i), -- event_class_code
3617 l_event_class_code_tbl(i) -- event_type_code
3618 );
3619
3620 for j IN 1..l_xla_gl_sl_link_id_tbl.count loop
3621 if (l_je_batch_id_tbl(j) is not null) then
3622 insert into gl_import_references (
3623 je_batch_id,
3624 je_header_id,
3625 je_line_num,
3626 last_update_date,
3627 last_updated_by,
3628 creation_date,
3629 created_by,
3630 last_update_login,
3631 reference_1,
3632 reference_2,
3633 reference_3,
3634 reference_4,
3635 reference_5,
3636 reference_6,
3637 reference_7,
3638 reference_8,
3639 reference_9,
3640 reference_10,
3641 subledger_doc_sequence_id,
3642 subledger_doc_sequence_value,
3643 gl_sl_link_id,
3644 gl_sl_link_table
3645 ) values (
3646 l_je_batch_id_tbl(j), -- je_batch_id
3647 l_je_header_id_tbl(j), -- je_header_id
3648 l_je_line_num_tbl(j), -- je_line_num
3649 sysdate, -- last_update_date
3650 c_fnd_user, -- last_updated_by
3651 sysdate, -- creation_date
3652 c_fnd_user, -- created_by
3653 c_upgrade_bugno, -- last_update_login
3654 to_char(l_transaction_header_id_tbl(i)),
3655 -- reference_1
3656 to_char(l_asset_id_tbl(i)), -- reference_2
3657 to_char(l_distribution_id_tbl(j)),
3658 -- reference_3
3659 to_char(l_adj_line_id_tbl(j)),
3660 -- reference_4
3661 l_book_type_code_tbl(i), -- reference_5
3662 to_char(l_period_counter_tbl(i)),
3663 -- reference_6
3664 null, -- reference_7
3665 null, -- reference_8
3666 null, -- reference_9
3667 null, -- reference_10
3668 null, -- subledger_doc_seq_id
3669 null, -- subledger_doc_seq_value
3670 l_xla_gl_sl_link_id_tbl(j), -- gl_sl_link_id
3671 'XLAJEL' -- gl_sl_link_table
3672 );
3673 end if;
3674 end loop;
3675
3676 l_adj_line_id_tbl.delete;
3677 l_xla_gl_sl_link_id_tbl.delete;
3678 l_ae_line_num_tbl.delete;
3679 l_debit_amount_tbl.delete;
3680 l_credit_amount_tbl.delete;
3681 l_ccid_tbl.delete;
3682 l_currency_code_tbl.delete;
3683 l_acct_class_code_tbl.delete;
3684 l_line_def_owner_code_tbl.delete;
3685 l_line_def_code_tbl.delete;
3686 l_line_desc_tbl.delete;
3687 l_gl_transfer_status_code_tbl.delete;
3688 l_je_batch_id_tbl.delete;
3689 l_je_header_id_tbl.delete;
3690 l_je_line_num_tbl.delete;
3691 l_distribution_id_tbl.delete;
3692
3693 open c_mc_books (l_book_type_code_tbl(i));
3694 fetch c_mc_books bulk collect
3695 into l_rep_set_of_books_id_tbl;
3696 close c_mc_books;
3697
3698 for k IN 1..l_rep_set_of_books_id_tbl.count loop
3699
3700 open c_mc_adj (l_book_type_code_tbl(i),
3701 l_asset_id_tbl(i),
3702 l_rep_set_of_books_id_tbl(k),
3703 l_transaction_header_id_tbl(i),
3704 l_date_effective_tbl(i));
3705 fetch c_mc_adj bulk collect
3706 into l_adj_line_id_tbl,
3707 l_debit_amount_tbl,
3708 l_credit_amount_tbl,
3709 l_ccid_tbl,
3710 l_currency_code_tbl,
3711 l_acct_class_code_tbl,
3712 l_line_desc_tbl,
3713 l_gl_transfer_status_code_tbl,
3714 l_je_batch_id_tbl,
3715 l_je_header_id_tbl,
3716 l_je_line_num_tbl,
3717 l_distribution_id_tbl;
3718 close c_mc_adj;
3719
3720 FOR j IN 1..l_adj_line_id_tbl.count LOOP
3721 l_ae_line_num_tbl(j) := j;
3722
3723 select xla_gl_sl_link_id_s.nextval
3724 into l_xla_gl_sl_link_id_tbl(j)
3725 from dual;
3726 END LOOP;
3727
3728 select xla_ae_headers_s.nextval
3729 into l_ae_header_id
3730 from dual;
3731
3732 -- Business Rules for xla_ae_headers
3733 -- * amb_context_code is DEFAULT
3734 -- * reference_date must be null
3735 -- * balance_type_code:
3736 -- A: Actual
3737 -- B: Budget
3738 -- E: Encumbrance
3739 -- * gl_transfer_status_code:
3740 -- Y: already transferred to GL
3741 -- N: not transferred to GL
3742 -- * gl_transfer_date is date entry transferred to GL
3743 -- * accounting_entry_status_code must be F
3744 -- * accounting_entry_type_code must be STANDARD
3745 -- * product_rule_* not relevant for upgrade
3746
3747 insert into xla_ae_headers (
3748 upg_batch_id,
3749 application_id,
3750 amb_context_code,
3751 entity_id,
3752 event_id,
3753 event_type_code,
3754 ae_header_id,
3755 ledger_id,
3756 accounting_date,
3757 period_name,
3758 reference_date,
3759 balance_type_code,
3760 je_category_name,
3761 gl_transfer_status_code,
3762 gl_transfer_date,
3763 accounting_entry_status_code,
3764 accounting_entry_type_code,
3765 description,
3766 budget_version_id,
3767 funds_status_code,
3768 encumbrance_type_id,
3769 completed_date,
3770 doc_sequence_id,
3771 doc_sequence_value,
3772 doc_category_code,
3773 packet_id,
3774 group_id,
3775 creation_date,
3776 created_by,
3777 last_update_date,
3778 last_updated_by,
3779 last_update_login,
3780 program_id,
3781 program_application_id,
3782 program_update_date,
3783 request_id,
3784 close_acct_seq_assign_id,
3785 close_acct_seq_version_id,
3786 close_acct_seq_value,
3787 completion_acct_seq_assign_id,
3788 completion_acct_seq_version_id,
3789 completion_acct_seq_value,
3790 accounting_batch_id,
3791 product_rule_type_code,
3792 product_rule_code,
3793 product_rule_version,
3794 upg_source_application_id,
3795 upg_valid_flag
3796 ) values (
3797 l_upg_batch_id, -- upg_batch_id
3798 c_application_id, -- application_id
3799 c_amb_context_code, -- amb_context_code
3800 l_entity_id_tbl(i), -- entity_id
3801 l_event_id_tbl(i), -- event_id,
3802 l_event_class_code_tbl(i), -- event_type_code
3803 l_ae_header_id, -- ae_header_id,
3804 l_rep_set_of_books_id_tbl(k), -- ledger_id/sob_id
3805 l_cal_period_close_date_tbl(i), -- accounting_date,
3806 l_period_name_tbl(i), -- period_name,
3807 null, -- reference_date
3808 'A', -- balance_type_code,
3809 l_je_category_name_tbl(i), -- je_category_name
3810 'Y', -- gl_transfer_status_code
3811 null, -- gl_transfer_date
3812 'F', -- accounting_entry_status_code
3813 'STANDARD', -- accounting_entry_type_code
3814 l_hdr_desc_tbl(i), -- description
3815 null, -- budget_version_id
3816 null, -- funds_status_code
3817 null, -- encumbrance_type_id
3818 null, -- completed_date
3819
3820 null, -- doc_sequence_id
3821 null, -- doc_sequence_value
3822 null, -- doc_category_code
3823 null, -- packet_id,
3824 null, -- group_id
3825 sysdate, -- creation_date
3826 c_fnd_user, -- created_by
3827 sysdate, -- last_update_date
3828 c_fnd_user, -- last_updated_by
3829 c_upgrade_bugno, -- last_update_login
3830 null, -- program_id
3831 c_application_id, -- program_application_id
3832 sysdate, -- program_update_date
3833 null, -- request_id
3834 null, -- close_acct_seq_assign_id
3835 null, -- close_acct_seq_version_id
3836 null, -- close_acct_seq_value
3837 null, -- compl_acct_seq_assign_id
3838 null, -- compl_acct_seq_version_id
3839 null, -- compl_acct_seq_value
3840 null, -- accounting_batch_id
3841 null, -- product_rule_type_code
3842 null, -- product_rule_code
3843 null, -- product_rule_version
3844 c_application_id, -- upg_souce_application_id
3845 null -- upg_valid_flag
3846 );
3847
3848 -- Business Rules for xla_ae_lines
3849 -- * gl_transfer_mode_code:
3850 -- D: Detailed mode when transferred to GL
3851 -- S: Summary mode when transferred to GL
3852 -- * gl_sl_link_table must be XLAJEL
3853 -- * currency_conversion_* needs to be populated only if
3854 -- different from ledger currency
3855
3856 forall j IN 1..l_xla_gl_sl_link_id_tbl.count
3857 insert into xla_ae_lines (
3858 upg_batch_id,
3859 ae_header_id,
3860 ae_line_num,
3861 displayed_line_number,
3862 application_id,
3863 code_combination_id,
3864 gl_transfer_mode_code,
3865 accounted_dr,
3866 accounted_cr,
3867 currency_code,
3868 currency_conversion_date,
3869 currency_conversion_rate,
3870 currency_conversion_type,
3871 entered_dr,
3872 entered_cr,
3873 description,
3874 accounting_class_code,
3875 gl_sl_link_id,
3876 gl_sl_link_table,
3877 party_type_code,
3878 party_id,
3879 party_site_id,
3880 statistical_amount,
3881 ussgl_transaction_code,
3882 jgzz_recon_ref,
3883 control_balance_flag,
3884 analytical_balance_flag,
3885 upg_tax_reference_id1,
3886 upg_tax_reference_id2,
3887 upg_tax_reference_id3,
3888 creation_date,
3889 created_by,
3890 last_update_date,
3891 last_updated_by,
3892 last_update_login,
3893 program_update_date,
3894 program_id,
3895 program_application_id,
3896 request_id,
3897 gain_or_loss_flag,
3898 accounting_date,
3899 ledger_id
3900 ) values (
3901 l_upg_batch_id, -- upg_batch_id
3902 l_ae_header_id, -- ae_header_id
3903 l_ae_line_num_tbl(j), -- ae_line_num
3904 l_ae_line_num_tbl(j), -- displayed_line_num
3905 c_application_id, -- application_id
3906 l_ccid_tbl(j), -- code_combination_id
3907 'S', -- gl_transfer_mode_code
3908 l_debit_amount_tbl(j), -- accounted_dr
3909 l_credit_amount_tbl(j), -- accounted_cr
3910 l_currency_code_tbl(j), -- currency_code
3911 null, -- currency_conversion_date
3912 null, -- currency_conversion_rate
3913 null, -- currency_conversion_type
3914 l_debit_amount_tbl(j), -- entered_dr
3915 l_credit_amount_tbl(j), -- entered_cr
3916 l_line_desc_tbl(j) || ' - ' ||
3917 to_char(l_cal_period_close_date_tbl(i), 'DD-MON-RR'),
3918 -- description
3919 l_acct_class_code_tbl(j), -- accounting_class_code
3920 l_xla_gl_sl_link_id_tbl(j), -- gl_sl_link_id
3921 'XLAJEL', -- gl_sl_link_table
3922 null, -- party_type_code
3923 null, -- party_id
3924 null, -- party_site_id
3925 null, -- statistical_amount
3926 null, -- ussgl_transaction_code
3927 null, -- glzz_recon_ref
3928 null, -- control_balance_flag
3929 null, -- analytical_balance_flag
3930 null, -- upg_tax_reference_id1
3931 null, -- upg_tax_reference_id2
3932 null, -- upg_tax_reference_id3
3933 sysdate, -- creation_date
3934 c_fnd_user, -- created_by
3935 sysdate, -- last_update_date
3936 c_fnd_user, -- last_updated_by
3937 c_upgrade_bugno, -- last_update_login
3938 null, -- program_update_date
3939 null, -- program_id
3940 c_application_id, -- program_application_id
3941 null, -- request_id
3942 'N', -- gain_or_loss_flag
3943 l_cal_period_close_date_tbl(i), -- accounting_date,
3944 l_rep_set_of_books_id_tbl(k) -- ledger_id/sob_id
3945 );
3946
3947 -- Business Rules for xla_distribution_links
3948 -- * accounting_line_code is similar to adjustment_type
3949 -- * accounting_line_type_code is S
3950 -- * merge_duplicate_code is N
3951 -- * source_distribution_type is TRX
3952 -- * source_distribution_id_num_1 is transaction_header_id
3953 -- * source_distribution_id_num_2 is event_id
3954
3955 forall j IN 1..l_xla_gl_sl_link_id_tbl.count
3956 insert into xla_distribution_links (
3957 upg_batch_id,
3958 application_id,
3959 event_id,
3960 ae_header_id,
3961 ae_line_num,
3962 accounting_line_code,
3963 accounting_line_type_code,
3964 source_distribution_type,
3965 source_distribution_id_char_1,
3966 source_distribution_id_char_2,
3967 source_distribution_id_char_3,
3968 source_distribution_id_char_4,
3969 source_distribution_id_char_5,
3970 source_distribution_id_num_1,
3971 source_distribution_id_num_2,
3972 source_distribution_id_num_3,
3973 source_distribution_id_num_4,
3974 source_distribution_id_num_5,
3975 merge_duplicate_code,
3976 statistical_amount,
3977 unrounded_entered_dr,
3978 unrounded_entered_cr,
3979 unrounded_accounted_dr,
3980 unrounded_accounted_cr,
3981 ref_ae_header_id,
3982 ref_temp_line_num,
3983 ref_event_id,
3984 temp_line_num,
3985 tax_line_ref_id,
3986 tax_summary_line_ref_id,
3987 tax_rec_nrec_dist_ref_id,
3988 line_definition_owner_code,
3989 line_definition_code,
3990 event_class_code,
3991 event_type_code
3992 ) values (
3993 l_upg_batch_id, -- upg_batch_id
3994 c_application_id, -- application_id
3995 l_event_id_tbl(i), -- event_id
3996 l_ae_header_id, -- ae_header_id
3997 l_ae_line_num_tbl(j), -- ae_line_num
3998 null, -- accounting_line_code
3999 'S', -- accounting_line_type_code
4000 'TRX', -- source_distribution_type
4001 null, -- source_distribution_id_char_1
4002 null, -- source_distribution_id_char_2
4003 null, -- source_distribution_id_char_3
4004 null, -- source_distribution_id_char_4
4005 null, -- source_distribution_id_char_5
4006 l_transaction_header_id_tbl(i),
4007 -- source_distribution_id_num_1
4008 l_adj_line_id_tbl(j), -- source_distribution_id_num_2
4009 null, -- source_distribution_id_num_3
4010 null, -- source_distribution_id_num_4
4011 null, -- source_distribution_id_num_5
4012 'N', -- merge_duplicate_code
4013 null, -- statistical_amount
4014 l_debit_amount_tbl(j), -- unrounded_entered_dr
4015 l_credit_amount_tbl(j), -- unrounded_entered_cr
4016 l_debit_amount_tbl(j), -- unrounded_accounted_dr
4017 l_credit_amount_tbl(j), -- unrounded_accounted_cr
4018 l_ae_header_id, -- ref_ae_header_id
4019 null, -- ref_temp_line_num
4020 null, -- ref_event_id
4021 l_ae_line_num_tbl(j), -- temp_line_num
4022 null, -- tax_line_ref_id
4023 null, -- tax_summary_line_ref_id
4024 null, -- tax_rec_nrec_dist_ref_id
4025 null, -- line_definition_owner_code
4026 null, -- line_definition_code
4027 l_event_class_code_tbl(i), -- event_class_code
4028 l_event_class_code_tbl(i) -- event_type_code
4029 );
4030
4031 for j IN 1..l_xla_gl_sl_link_id_tbl.count loop
4032 if (l_je_batch_id_tbl(j) is not null) then
4033 insert into gl_import_references (
4034 je_batch_id,
4035 je_header_id,
4036 je_line_num,
4037 last_update_date,
4038 last_updated_by,
4039 creation_date,
4040 created_by,
4041 last_update_login,
4042 reference_1,
4043 reference_2,
4044 reference_3,
4045 reference_4,
4046 reference_5,
4047 reference_6,
4048 reference_7,
4049 reference_8,
4050 reference_9,
4051 reference_10,
4052 subledger_doc_sequence_id,
4053 subledger_doc_sequence_value,
4054 gl_sl_link_id,
4055 gl_sl_link_table
4056 ) values (
4057 l_je_batch_id_tbl(j), -- je_batch_id
4058 l_je_header_id_tbl(j), -- je_header_id
4059 l_je_line_num_tbl(j), -- je_line_num
4060 sysdate, -- last_update_date
4061 c_fnd_user, -- last_updated_by
4062 sysdate, -- creation_date
4063 c_fnd_user, -- created_by
4064 c_upgrade_bugno, -- last_update_login
4065 to_char(l_transaction_header_id_tbl(i)),
4066 -- reference_1
4067 to_char(l_asset_id_tbl(i)), -- reference_2
4068 to_char(l_distribution_id_tbl(j)),
4069 -- reference_3
4070 to_char(l_adj_line_id_tbl(j)),
4071 -- reference_4
4072 l_book_type_code_tbl(i), -- reference_5
4073 to_char(l_period_counter_tbl(i)),
4074 -- reference_6
4075 null, -- reference_7
4076 null, -- reference_8
4077 null, -- reference_9
4078 null, -- reference_10
4079 null, -- subledger_doc_seq_id
4080 null, -- subledger_doc_seq_value
4081 l_xla_gl_sl_link_id_tbl(j), -- gl_sl_link_id
4082 'XLAJEL' -- gl_sl_link_table
4083 );
4084 end if;
4085 end loop;
4086
4087 l_adj_line_id_tbl.delete;
4088 l_xla_gl_sl_link_id_tbl.delete;
4089 l_ae_line_num_tbl.delete;
4090 l_debit_amount_tbl.delete;
4091 l_credit_amount_tbl.delete;
4092 l_ccid_tbl.delete;
4093 l_currency_code_tbl.delete;
4094 l_acct_class_code_tbl.delete;
4095 l_line_def_owner_code_tbl.delete;
4096 l_line_def_code_tbl.delete;
4097 l_line_desc_tbl.delete;
4098 l_gl_transfer_status_code_tbl.delete;
4099 l_je_batch_id_tbl.delete;
4100 l_je_header_id_tbl.delete;
4101 l_je_line_num_tbl.delete;
4102 l_distribution_id_tbl.delete;
4103
4104 end loop;
4105
4106 l_rep_set_of_books_id_tbl.delete;
4107
4108 END LOOP;
4109
4110 l_rowid_tbl.delete;
4111 l_event_id_tbl.delete;
4112 l_asset_id_tbl.delete;
4113 l_book_type_code_tbl.delete;
4114 l_primary_set_of_books_id_tbl.delete;
4115 l_org_id_tbl.delete;
4116 l_transaction_type_code_tbl.delete;
4117 l_transaction_date_entered_tbl.delete;
4118 l_transaction_header_id_tbl.delete;
4119 l_period_counter_tbl.delete;
4120 l_period_name_tbl.delete;
4121 l_cal_period_close_date_tbl.delete;
4122 l_entity_id_tbl.delete;
4123 l_event_class_code_tbl.delete;
4124 l_member_thid_tbl.delete;
4125 l_hdr_desc_tbl.delete;
4126 l_je_category_name_tbl.delete;
4127 l_date_effective_tbl.delete;
4128
4129 commit;
4130
4131 if (l_rows_processed < l_batch_size) then exit; end if;
4132
4133 end loop;
4134 close c_trans;
4135
4136 EXCEPTION
4137 WHEN OTHERS THEN
4138 rollback;
4139 raise;
4140
4141 End Upgrade_Group_Trxn_Events;
4142
4143 Procedure Upgrade_Trxn_Events (
4144 p_start_rowid IN rowid,
4145 p_end_rowid IN rowid,
4146 p_batch_size IN number,
4147 x_success_count OUT NOCOPY number,
4148 x_failure_count OUT NOCOPY number,
4149 x_return_status OUT NOCOPY number
4150 ) IS
4151
4152 c_application_id constant number(15) := 140;
4153 c_upgrade_bugno constant number(15) := -4107161;
4154 c_fnd_user constant number(15) := 2;
4155
4156
4157 c_entity_code constant varchar2(30) := 'TRANSACTIONS';
4158 c_amb_context_code constant varchar2(30) := 'DEFAULT';
4159
4160 -- this value can be altered in order to process more of less per batch
4161 l_batch_size NUMBER;
4162
4163 l_rows_processed NUMBER;
4164
4165 l_upg_batch_id NUMBER(15);
4166 l_bonus_deprn_rsv_desc VARCHAR2(80);
4167 l_mc_books NUMBER;
4168
4169 BEGIN
4170
4171 x_success_count := 0;
4172 x_failure_count := 0;
4173
4174 l_batch_size := nvl(nvl(p_batch_size, fa_cache_pkg.fa_batch_size), 1000);
4175
4176 -- Select upg_batch_id
4177 select xla_upg_batches_s.nextval
4178 into l_upg_batch_id
4179 from dual;
4180
4181 -- Save value into a variable
4182 select description
4183 into l_bonus_deprn_rsv_desc
4184 from fa_lookups
4185 where lookup_type = 'JOURNAL ENTRIES'
4186 and lookup_code = 'BONUS DEPRECIATION RESERVE';
4187
4188 insert all
4189 when 1 = 1 then
4190 into fa_xla_upg_events_gt (
4191 event_id,
4192 entity_id,
4193 transaction_header_id,
4194 set_of_books_id,
4195 period_name,
4196 calendar_period_close_date,
4197 date_effective,
4198 je_category_name,
4199 description,
4200 event_type_code,
4201 event_class_code,
4202 asset_id,
4203 book_type_code,
4204 period_counter
4205 ) values (
4206 xla_events_s.nextval,
4207 xla_transaction_entities_s.nextval,
4208 transaction_header_id,
4209 set_of_books_id,
4210 period_name,
4211 calendar_period_close_date,
4212 date_effective,
4213 je_category_name,
4214 description,
4215 event_type_code,
4216 event_class_code,
4217 asset_id,
4218 book_type_code,
4219 period_counter
4220 )
4221 when 1 = 1 then
4222 into xla_transaction_entities_upg (
4223 upg_batch_id,
4224 application_id,
4225 ledger_id,
4226 legal_entity_id,
4227 entity_code,
4228 source_id_int_1,
4229 source_id_int_2,
4230 source_id_int_3,
4231 source_id_int_4,
4232 source_id_char_1,
4233 source_id_char_2,
4234 source_id_char_3,
4235 source_id_char_4,
4236 security_id_int_1,
4237 security_id_int_2,
4238 security_id_int_3,
4239 security_id_char_1,
4240 security_id_char_2,
4241 security_id_char_3,
4242 transaction_number,
4243 valuation_method,
4244 source_application_id,
4245 creation_date,
4246 created_by,
4247 last_update_date,
4248 last_updated_by,
4249 last_update_login,
4250 entity_id,
4251 upg_source_application_id
4252 ) values (
4253 l_upg_batch_id, -- upg_batch_id
4254 c_application_id, -- application_id
4255 set_of_books_id, -- ledger_id
4256 null, -- legal_entity_id
4257 c_entity_code, -- entity_code
4258 transaction_header_id, -- source_id_int_1
4259 null, -- source_id_int_2
4260 null, -- source_id_int_3
4261 null, -- source_id_int_4
4262 null, -- source_id_char_1
4263 null, -- source_id_char_2
4264 null, -- source_id_char_3
4265 null, -- source_id_char_4
4266 null, -- security_id_int_1
4267 null, -- security_id_int_2
4268 null, -- security_id_int_3
4269 null, -- security_id_char_1
4270 null, -- security_id_char_2
4271 null, -- security_id_char_3
4272 to_char(transaction_header_id),
4273 -- transaction_number
4274 book_type_code, -- valuation_method
4275 c_application_id, -- source_application_id
4276 sysdate, -- creation_date
4277 c_fnd_user, -- created_by
4278 sysdate, -- last_update_date
4279 c_fnd_user, -- last_updated_by
4280 c_upgrade_bugno, -- last_update_login
4281 xla_transaction_entities_s.currval,
4282 -- entity_id
4283 c_application_id -- upg_source_application_id
4284 )
4285 when 1 = 1 then
4286 into xla_events (
4287 upg_batch_id,
4288 application_id,
4289 event_type_code,
4290 event_number,
4291 event_status_code,
4292 process_status_code,
4293 on_hold_flag,
4294 event_date,
4295 creation_date,
4296 created_by,
4297 last_update_date,
4298 last_updated_by,
4299 last_update_login,
4300 program_update_date,
4301 program_id,
4302 program_application_id,
4303 request_id,
4304 entity_id,
4305 event_id,
4306 upg_source_application_id,
4307 transaction_date
4308 ) values (
4309 l_upg_batch_id, -- upg_batch_id
4310 c_application_id, -- application_id
4311 event_type_code,
4312 1, -- event_number
4313 'P', -- event_status_code
4314 'P', -- process_status_code
4315 'N', -- on_hold_flag
4316 transaction_date_entered,
4317 -- event_date
4318 sysdate, -- creation_date
4319 c_fnd_user, -- created_by
4320 sysdate, -- last_update_date
4321 c_fnd_user, -- last_updated_by
4322 c_upgrade_bugno, -- last_update_login
4323 null, -- program_update_date
4324 null, -- program_id
4325 null, -- program_application_id
4326 null, -- request_id
4327 xla_transaction_entities_s.currval,
4328 -- entity_id
4329 xla_events_s.currval, -- event_id
4330 c_application_id, -- upg_source_application_id
4331 transaction_date_entered
4332 -- transaction_date
4333 )
4334 when 1 = 1 then
4335 into fa_xla_upg_headers_gt (
4336 ae_header_id,
4337 event_id,
4338 set_of_books_id
4339 ) values (
4340 xla_ae_headers_s.nextval,
4341 xla_events_s.currval,
4342 set_of_books_id
4343 )
4344 when 1 = 1 then
4345 into xla_ae_headers (
4346 upg_batch_id,
4347 application_id,
4348 amb_context_code,
4349 entity_id,
4350 event_id,
4351 event_type_code,
4352 ae_header_id,
4353 ledger_id,
4354 accounting_date,
4355 period_name,
4356 reference_date,
4357 balance_type_code,
4358 je_category_name,
4359 gl_transfer_status_code,
4360 gl_transfer_date,
4361 accounting_entry_status_code,
4362 accounting_entry_type_code,
4363 description,
4364 budget_version_id,
4365 funds_status_code,
4366 encumbrance_type_id,
4367 completed_date,
4368 doc_sequence_id,
4369 doc_sequence_value,
4370 doc_category_code,
4371 packet_id,
4372 group_id,
4373 creation_date,
4374 created_by,
4375 last_update_date,
4376 last_updated_by,
4377 last_update_login,
4378 program_id,
4379 program_application_id,
4380 program_update_date,
4381 request_id,
4382 close_acct_seq_assign_id,
4383 close_acct_seq_version_id,
4384 close_acct_seq_value,
4385 completion_acct_seq_assign_id,
4386 completion_acct_seq_version_id,
4387 completion_acct_seq_value,
4388 accounting_batch_id,
4389 product_rule_type_code,
4390 product_rule_code,
4391 product_rule_version,
4392 upg_source_application_id,
4393 upg_valid_flag
4394 ) values (
4395 l_upg_batch_id, -- upg_batch_id
4396 c_application_id, -- application_id
4397 c_amb_context_code, -- amb_context_code
4398 xla_transaction_entities_s.currval,
4399 -- entity_id
4400 xla_events_s.currval, -- event_id
4401 event_type_code, -- event_type_code
4402 xla_ae_headers_s.currval, -- ae_header_id
4403 set_of_books_id, -- ledger_id
4404 calendar_period_close_date, -- accounting_date
4405 period_name, -- period_name
4406 null, -- reference_date
4407 'A', -- balance_type_code
4408 je_category_name, -- je_category_name
4409 'Y', -- gl_transfer_status_code
4410 null, -- gl_transfer_date
4411 'F', -- accounting_entry_status_code
4412 'STANDARD', -- accounting_entry_type_code
4413 description, -- description
4414 null, -- budget_version_id
4415 null, -- funds_status_code
4416 null, -- encumbrance_type_id
4417 null, -- completed_date
4418 null, -- doc_sequence_id
4419 null, -- doc_sequence_value
4420 null, -- doc_category_code
4421 null, -- packet_id
4422 null, -- group_id
4423 sysdate, -- creation_date
4424 c_fnd_user, -- created_by
4425 sysdate, -- last_update_date
4426 c_fnd_user, -- last_updated_by
4427 c_upgrade_bugno, -- last_update_login
4428 null, -- program_id
4429 c_application_id, -- program_application_id
4430 sysdate, -- program_update_date
4431 null, -- request_id
4432 null, -- close_acct_seq_assign_id
4433 null, -- close_acct_seq_version_id
4434 null, -- close_acct_seq_value
4435 null, -- completion_acct_seq_assign_id
4436 null, -- completion_acct_seq_version_id
4437 null, -- completion_acct_seq_value
4438 null, -- accounting_batch_id
4439 null, -- product_rule_type_code
4440 null, -- product_rule_code
4441 null, -- product_rule_version
4442 c_application_id, -- upg_source_application_id
4443 null -- upg_valid_flag
4444 )
4445 select /*+ leading(th bc dp ps) rowid(th) swap_join_inputs(bc) swap_join_inputs(dp) */
4446 bc.set_of_books_id set_of_books_id,
4447 th.transaction_header_id transaction_header_id,
4448 bc.book_type_code book_type_code,
4449 bc.org_id org_id,
4450 decode(th.transaction_type_code,
4451 'ADDITION', decode (ah.asset_type,
4452 'CIP', 'CAPITALIZATIONS',
4453 'ADDITIONS'),
4454 'ADJUSTMENT', 'ADJUSTMENTS',
4455 'CIP ADDITION', 'CIP_ADDITIONS',
4456 'CIP ADJUSTMENT', 'CIP_ADJUSTMENTS',
4457 'CIP REVERSE', 'REVERSE CAPITALIZATIONS',
4458 'CIP REINSTATEMENT', 'CIP_REINSTATEMENTS',
4459 'CIP RETIREMENT', 'CIP_RETIREMENTS',
4460 'CIP TRANSFER', 'CIP_TRANSFERS',
4461 'CIP UNIT ADJUSTMENTS', 'CIP_UNIT_ADJUSTMENTS',
4462 'FULL RETIREMENT', 'RETIREMENTS',
4463 'PARTIAL RETIREMENT', 'RETIREMENTS',
4464 'RECLASS', 'CATEGORY_RECLASS',
4465 'REINSTATEMENT', 'REINSTATEMENTS',
4466 'REVALUATION', 'REVALUATIONS',
4467 'TRANSFER', 'TRANSFERS',
4468 'TRANSFER IN', 'TRANSFERS',
4469 'TRANSFER IN/VOID', 'TRANSFERS',
4470 'TRANSFER OUT', 'TRANSFERS',
4471 'UNIT ADJUSTMENT', 'UNIT_ADJUSTMENTS',
4472 'UNPLANNED DEPRN', 'UNPLANNED_DEPRECIATION',
4473 'TAX', 'DEPRECIATION_ADJUSTMENTS',
4474 'OTHER'
4475 ) event_class_code,
4476 decode(th.transaction_type_code,
4477 'ADDITION', decode (ah.asset_type,
4478 'CIP', 'CAPITALIZATIONS',
4479 'ADDITIONS'),
4480 'ADJUSTMENT', 'ADJUSTMENTS',
4481 'CIP ADDITION', 'CIP_ADDITIONS',
4482 'CIP ADJUSTMENT', 'CIP_ADJUSTMENTS',
4483 'CIP REVERSE', 'REVERSE CAPITALIZATIONS',
4484 'CIP REINSTATEMENT', 'CIP_REINSTATEMENTS',
4485 'CIP RETIREMENT', 'CIP_RETIREMENTS',
4486 'CIP TRANSFER', 'CIP_TRANSFERS',
4487 'CIP UNIT ADJUSTMENTS', 'CIP_UNIT_ADJUSTMENTS',
4488 'FULL RETIREMENT', 'RETIREMENTS',
4489 'PARTIAL RETIREMENT', 'RETIREMENTS',
4490 'RECLASS', 'CATEGORY_RECLASS',
4491 'REINSTATEMENT', 'REINSTATEMENTS',
4492 'REVALUATION', 'REVALUATIONS',
4493 'TRANSFER', 'TRANSFERS',
4494 'TRANSFER IN', 'TRANSFERS',
4495 'TRANSFER IN/VOID', 'TRANSFERS',
4496 'TRANSFER OUT', 'TRANSFERS',
4497 'UNIT ADJUSTMENT', 'UNIT_ADJUSTMENTS',
4498 'UNPLANNED DEPRN', 'UNPLANNED_DEPRECIATION',
4499 'TAX', 'DEPRECIATION_ADJUSTMENTS',
4500 'OTHER'
4501 ) event_type_code,
4502 th.transaction_date_entered transaction_date_entered,
4503 dp.period_name period_name,
4504 dp.calendar_period_close_date calendar_period_close_date,
4505 th.date_effective date_effective,
4506 nvl (decode(th.transaction_type_code,
4507 'ADDITION', bc.je_addition_category,
4508 'ADJUSTMENT', bc.je_adjustment_category,
4509 'CIP ADDITION', bc.je_cip_addition_category,
4510 'CIP ADJUSTMENT', bc.je_cip_adjustment_category,
4511 'CIP REVERSE', bc.je_cip_addition_category,
4512 'CIP REINSTATEMENT', bc.je_cip_retirement_category,
4513 'CIP RETIREMENT', bc.je_cip_retirement_category,
4514 'CIP TRANSFER', bc.je_cip_transfer_category,
4515 'CIP UNIT ADJUSTMENTS', bc.je_cip_transfer_category,
4516 'FULL RETIREMENT', bc.je_retirement_category,
4517 'PARTIAL RETIREMENT', bc.je_retirement_category,
4518 'RECLASS', bc.je_reclass_category,
4519 'REINSTATEMENT', bc.je_retirement_category,
4520 'REVALUATION', bc.je_reval_category,
4521 'TRANSFER', bc.je_transfer_category,
4522 'TRANSFER IN', bc.je_transfer_category,
4523 'TRANSFER IN/VOID', bc.je_transfer_category,
4524 'TRANSFER OUT', bc.je_transfer_category,
4525 'UNIT ADJUSTMENT', bc.je_transfer_category,
4526 'UNPLANNED DEPRN', bc.je_depreciation_category,
4527 'TAX', bc.je_deprn_adjustment_category
4528 ), 'OTHER') je_category_name,
4529 lk.description || ' - ' ||
4530 to_char(dp.calendar_period_close_date, 'DD-MON-RR')
4531 description,
4532 dp.period_counter period_counter,
4533 th.asset_id asset_id
4534 from fa_transaction_headers th,
4535 fa_book_controls bc,
4536 fa_deprn_periods dp,
4537 gl_period_statuses ps,
4538 fa_lookups_tl lk,
4539 fa_asset_history ah
4540 where th.rowid between p_start_rowid and p_end_rowid
4541 and th.member_transaction_header_id is null
4542 and th.event_id is null
4543 and ps.application_id = 101
4544 and ((ps.migration_status_code in ('P', 'U')) or
4545 (dp.period_close_date is null))
4546 and substr (dp.xla_conversion_status, 1, 1) in
4547 ('H', 'U', 'E', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9')
4548 and dp.xla_conversion_status not in ('UT', 'UA')
4549 and ps.set_of_books_id = bc.set_of_books_id
4550 and ps.period_name = dp.period_name
4551 and th.book_type_code = bc.book_type_code
4552 and dp.book_type_code = bc.book_type_code
4553 and th.date_effective between dp.period_open_date and
4554 nvl(dp.period_close_date, sysdate)
4555 and th.asset_id = ah.asset_id (+)
4556 and th.transaction_header_id = ah.transaction_header_id_out (+)
4557 and th.transaction_type_code = lk.lookup_code
4558 and lk.lookup_type = 'FAXOLTRX'
4559 and userenv('LANG') = lk.language
4560 and exists
4561 (
4562 select /*+ index(adj, FA_ADJUSTMENTS_U1) */
4563 'x'
4564 from fa_adjustments adj
4565 where th.transaction_header_id = adj.transaction_header_id
4566 and bc.book_type_code = adj.book_type_code
4567 and th.asset_id = adj.asset_id
4568 )
4569 union all -- Added for bug6820729
4570 select /*+ leading(th bc dp ps) rowid(th) swap_join_inputs(bc) swap_join_inputs(dp) */
4571 bc.set_of_books_id set_of_books_id,
4572 th.transaction_header_id transaction_header_id,
4573 bc.book_type_code book_type_code,
4574 bc.org_id org_id,
4575 decode(th.transaction_type_code,
4576 'CIP REINSTATEMENT', 'CIP_REINSTATEMENTS',
4577 'CIP TRANSFER', 'CIP_TRANSFERS',
4578 'CIP UNIT ADJUSTMENTS', 'CIP_UNIT_ADJUSTMENTS',
4579 'RECLASS', 'CATEGORY_RECLASS',
4580 'REINSTATEMENT', 'REINSTATEMENTS',
4581 'TRANSFER', 'TRANSFERS',
4582 'TRANSFER OUT', 'TRANSFERS',
4583 'UNIT ADJUSTMENT', 'UNIT_ADJUSTMENTS',
4584 'OTHER'
4585 ) event_class_code,
4586 decode(th.transaction_type_code,
4587 'CIP REINSTATEMENT', 'CIP_REINSTATEMENTS',
4588 'CIP TRANSFER', 'CIP_TRANSFERS',
4589 'CIP UNIT ADJUSTMENTS', 'CIP_UNIT_ADJUSTMENTS',
4590 'RECLASS', 'CATEGORY_RECLASS',
4591 'REINSTATEMENT', 'REINSTATEMENTS',
4592 'TRANSFER', 'TRANSFERS',
4593 'TRANSFER OUT', 'TRANSFERS',
4594 'UNIT ADJUSTMENT', 'UNIT_ADJUSTMENTS',
4595 'OTHER'
4596 ) event_type_code,
4597 th.transaction_date_entered transaction_date_entered,
4598 dp.period_name period_name,
4599 dp.calendar_period_close_date calendar_period_close_date,
4600 th.date_effective date_effective,
4601 nvl (decode(th.transaction_type_code,
4602 'CIP REINSTATEMENT', bc.je_cip_retirement_category,
4603 'CIP TRANSFER', bc.je_cip_transfer_category,
4604 'CIP UNIT ADJUSTMENTS', bc.je_cip_transfer_category,
4605 'RECLASS', bc.je_reclass_category,
4606 'REINSTATEMENT', bc.je_retirement_category,
4607 'TRANSFER', bc.je_transfer_category,
4608 'TRANSFER OUT', bc.je_transfer_category,
4609 'UNIT ADJUSTMENT', bc.je_transfer_category),
4610 'OTHER') je_category_name,
4611 lk.description || ' - ' ||
4612 to_char(dp.calendar_period_close_date, 'DD-MON-RR')
4613 description,
4614 dp.period_counter period_counter,
4615 th.asset_id asset_id
4616 from fa_transaction_headers th,
4617 fa_book_controls bc,
4618 fa_deprn_periods dp,
4619 gl_period_statuses ps,
4620 fa_lookups_tl lk
4621 where th.rowid between p_start_rowid and p_end_rowid
4622 and th.member_transaction_header_id is null
4623 and th.event_id is null
4624 and ps.application_id = 101
4625 and ((ps.migration_status_code in ('P', 'U')) or
4626 (dp.period_close_date is null))
4627 and substr (dp.xla_conversion_status, 1, 1) in
4628 ('H', 'U', 'E', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9')
4629 and dp.xla_conversion_status not in ('UT', 'UA')
4630 and ps.set_of_books_id = bc.set_of_books_id
4631 and ps.period_name = dp.period_name
4632 and th.transaction_type_code in('TRANSFER','TRANSFER OUT',
4633 'RECLASS','UNIT ADJUSTMENT','REINSTATEMENT',
4634 'CIP REINSTATEMENT','CIP TRANSFER','CIP UNIT ADJUSTMENTS')
4635 and th.book_type_code = bc.distribution_source_book
4636 and bc.book_class = 'TAX'
4637 and dp.book_type_code = bc.book_type_code
4638 and th.date_effective between dp.period_open_date and
4639 nvl(dp.period_close_date, sysdate)
4640 and th.transaction_type_code = lk.lookup_code
4641 and lk.lookup_type = 'FAXOLTRX'
4642 and userenv('LANG') = lk.language
4643 and exists
4644 (
4645 select /*+ index(adj, FA_ADJUSTMENTS_U1) */
4646 'x'
4647 from fa_adjustments adj
4648 where th.transaction_header_id = adj.transaction_header_id
4649 and bc.book_type_code = adj.book_type_code
4650 and th.asset_id = adj.asset_id
4651 );
4652
4653 update /*+ rowid(th) */
4654 fa_transaction_headers th
4655 set th.event_id = nvl(
4656 ( select ev.event_id
4657 from fa_xla_upg_events_gt ev
4658 where ev.transaction_header_id = th.transaction_header_id
4659 and ev.book_type_code = th.book_type_code
4660 ), th.event_id)
4661 where th.rowid between p_start_rowid and p_end_rowid;
4662
4663 insert all
4664 when (adj_row = 1) then
4665 into xla_ae_lines (
4666 upg_batch_id,
4667 ae_header_id,
4668 ae_line_num,
4669 displayed_line_number,
4670 application_id,
4671 code_combination_id,
4672 gl_transfer_mode_code,
4673 accounted_dr,
4674 accounted_cr,
4675 currency_code,
4676 currency_conversion_date,
4677 currency_conversion_rate,
4678 currency_conversion_type,
4679 entered_dr,
4680 entered_cr,
4681 description,
4682 accounting_class_code,
4683 gl_sl_link_id,
4684 gl_sl_link_table,
4685 party_type_code,
4686 party_id,
4687 party_site_id,
4688 statistical_amount,
4689 ussgl_transaction_code,
4690 jgzz_recon_ref,
4691 control_balance_flag,
4692 analytical_balance_flag,
4693 upg_tax_reference_id1,
4694 upg_tax_reference_id2,
4695 upg_tax_reference_id3,
4696 creation_date,
4697 created_by,
4698 last_update_date,
4699 last_updated_by,
4700 last_update_login,
4701 program_update_date,
4702 program_id,
4703 program_application_id,
4704 request_id,
4705 gain_or_loss_flag,
4706 accounting_date,
4707 ledger_id
4708 ) values (
4709 l_upg_batch_id, -- upg_batch_id
4710 ae_header_id, -- ae_header_id
4711 ae_line_num, -- ae_line_num
4712 ae_line_num, -- displayed_line_num
4713 c_application_id, -- application_id
4714 ccid1, -- code_combination_id
4715 'S', -- gl_transfer_mode_code
4716 debit_amount, -- accounted_dr
4717 credit_amount, -- accounted_cr
4718 currency_code, -- currency_code
4719 null, -- currency_conversion_date
4720 null, -- currency_conversion_rate
4721 null, -- currency_conversion_type
4722 debit_amount, -- entered_dr
4723 credit_amount, -- entered_cr
4724 line_desc1 || ' - ' ||
4725 to_char(cal_period_close_date, 'DD-MON-RR'),
4726 -- description
4727 accounting_class_code, -- accounting_class_code
4728 xla_gl_sl_link_id_s.nextval, -- gl_sl_link_id
4729 'XLAJEL', -- gl_sl_link_table
4730 null, -- party_type_code
4731 null, -- party_id
4732 null, -- party_site_id
4733 null, -- statistical_amount
4734 null, -- ussgl_transaction_code
4735 null, -- glzz_recon_ref
4736 null, -- control_balance_flag
4737 null, -- analytical_balance_flag
4738 null, -- upg_tax_reference_id1
4739 null, -- upg_tax_reference_id2
4740 null, -- upg_tax_reference_id3
4741 sysdate, -- creation_date
4742 c_fnd_user, -- created_by
4743 sysdate, -- last_update_date
4744 c_fnd_user, -- last_updated_by
4745 c_upgrade_bugno, -- last_update_login
4746 null, -- program_update_date
4747 null, -- program_id
4748 c_application_id, -- program_application_id
4749 null, -- request_id
4750 'N', -- gain_or_loss_flag
4751 cal_period_close_date, -- accounting_date
4752 set_of_books_id -- ledger_id
4753 )
4754 when (adj_row = 1) then
4755 into xla_distribution_links (
4756 upg_batch_id,
4757 application_id,
4758 event_id,
4759 ae_header_id,
4760 ae_line_num,
4761 accounting_line_code,
4762 accounting_line_type_code,
4763 source_distribution_type,
4764 source_distribution_id_char_1,
4765 source_distribution_id_char_2,
4766 source_distribution_id_char_3,
4767 source_distribution_id_char_4,
4768 source_distribution_id_char_5,
4769 source_distribution_id_num_1,
4770 source_distribution_id_num_2,
4771 source_distribution_id_num_3,
4772 source_distribution_id_num_4,
4773 source_distribution_id_num_5,
4774 merge_duplicate_code,
4775 statistical_amount,
4776 unrounded_entered_dr,
4777 unrounded_entered_cr,
4778 unrounded_accounted_dr,
4779 unrounded_accounted_cr,
4780 ref_ae_header_id,
4781 ref_temp_line_num,
4782 ref_event_id,
4783 temp_line_num,
4784 tax_line_ref_id,
4785 tax_summary_line_ref_id,
4786 tax_rec_nrec_dist_ref_id,
4787 line_definition_owner_code,
4788 line_definition_code,
4789 event_class_code,
4790 event_type_code
4791 ) values (
4792 l_upg_batch_id, -- upg_batch_id
4793 c_application_id, -- application_id
4794 event_id, -- event_id
4795 ae_header_id, -- ae_header_id
4796 ae_line_num, -- ae_line_num
4797 null, -- accounting_line_code
4798 'S', -- accounting_line_type_code
4799 'TRX', -- source_distribution_type
4800 null, -- source_distribution_id_char_1
4801 null, -- source_distribution_id_char_2
4802 null, -- source_distribution_id_char_3
4803 null, -- source_distribution_id_char_4
4804 null, -- source_distribution_id_char_5
4805 transaction_header_id, -- source_distribution_id_num_1
4806 adj_line_id, -- source_distribution_id_num_2
4807 null, -- source_distribution_id_num_3
4808 null, -- source_distribution_id_num_4
4809 null, -- source_distribution_id_num_5
4810 'N', -- merge_duplicate_code
4811 null, -- statistical_amount
4812 debit_amount, -- unrounded_entered_dr
4813 credit_amount, -- unrounded_entered_cr
4814 debit_amount, -- unrounded_accounted_dr
4815 credit_amount, -- unrounded_accounted_cr
4816 ae_header_id, -- ref_ae_header_id
4817 null, -- ref_temp_line_num
4818 null, -- ref_event_id
4819 ae_line_num, -- temp_line_num
4820 null, -- tax_line_ref_id
4821 null, -- tax_summary_line_ref_id
4822 null, -- tax_rec_nrec_dist_ref_id
4823 null, -- line_definition_owner_code
4824 null, -- line_definition_code
4825 event_class_code, -- event_class_code
4826 event_type_code -- event_type_code
4827 )
4828 when (adj_row = 1) and (je_batch_id1 is not null) then
4829 into gl_import_references (
4830 je_batch_id,
4831 je_header_id,
4832 je_line_num,
4833 last_update_date,
4834 last_updated_by,
4835 creation_date,
4836 created_by,
4837 last_update_login,
4838 reference_1,
4839 reference_2,
4840 reference_3,
4841 reference_4,
4842 reference_5,
4843 reference_6,
4844 reference_7,
4845 reference_8,
4846 reference_9,
4847 reference_10,
4848 subledger_doc_sequence_id,
4849 subledger_doc_sequence_value,
4850 gl_sl_link_id,
4851 gl_sl_link_table
4852 ) values (
4853 je_batch_id1, -- je_batch_id
4854 je_header_id1, -- je_header_id
4855 je_line_num1, -- je_line_num
4856 sysdate, -- last_update_date
4857 c_fnd_user, -- last_updated_by
4858 sysdate, -- creation_date
4859 c_fnd_user, -- created_by
4860 c_upgrade_bugno, -- last_update_login
4861 to_char(transaction_header_id),
4862 -- reference_1
4863 to_char(asset_id), -- reference_2
4864 to_char(distribution_id), -- reference_3
4865 to_char(adj_line_id), -- reference_4
4866 book_type_code, -- reference_5
4867 to_char(period_counter), -- reference_6
4868 null, -- reference_7
4869 null, -- reference_8
4870 null, -- reference_9
4871 null, -- reference_10
4872 null, -- subledger_doc_seq_id
4873 null, -- subledger_doc_seq_value
4874 xla_gl_sl_link_id_s.currval, -- gl_sl_link_id
4875 'XLAJEL' -- gl_sl_link_table
4876 )
4877 when (adj_row = 2) then
4878 into xla_ae_lines (
4879 upg_batch_id,
4880 ae_header_id,
4881 ae_line_num,
4882 displayed_line_number,
4883 application_id,
4884 code_combination_id,
4885 gl_transfer_mode_code,
4886 accounted_dr,
4887 accounted_cr,
4888 currency_code,
4889 currency_conversion_date,
4890 currency_conversion_rate,
4891 currency_conversion_type,
4892 entered_dr,
4893 entered_cr,
4894 description,
4895 accounting_class_code,
4896 gl_sl_link_id,
4897 gl_sl_link_table,
4898 party_type_code,
4899 party_id,
4900 party_site_id,
4901 statistical_amount,
4902 ussgl_transaction_code,
4903 jgzz_recon_ref,
4904 control_balance_flag,
4905 analytical_balance_flag,
4906 upg_tax_reference_id1,
4907 upg_tax_reference_id2,
4908 upg_tax_reference_id3,
4909 creation_date,
4910 created_by,
4911 last_update_date,
4912 last_updated_by,
4913 last_update_login,
4914 program_update_date,
4915 program_id,
4916 program_application_id,
4917 request_id,
4918 gain_or_loss_flag,
4919 accounting_date,
4920 ledger_id
4921 ) values (
4922 l_upg_batch_id, -- upg_batch_id
4923 ae_header_id, -- ae_header_id
4924 ae_line_num, -- ae_line_num
4925 ae_line_num, -- displayed_line_num
4926 c_application_id, -- application_id
4927 ccid2, -- code_combination_id
4928 'S', -- gl_transfer_mode_code
4929 -- Fix for Bug #5131737. Need to switch CR/DR for pseudo-row
4930 credit_amount, -- accounted_dr
4931 debit_amount, -- accounted_cr
4932 currency_code, -- currency_code
4933 null, -- currency_conversion_date
4934 null, -- currency_conversion_rate
4935 null, -- currency_conversion_type
4936 credit_amount, -- entered_dr
4937 debit_amount, -- entered_cr
4938 line_desc2 || ' - ' ||
4939 to_char(cal_period_close_date, 'DD-MON-RR'),
4940 -- description
4941 'ASSET', -- accounting_class_code
4942 xla_gl_sl_link_id_s.nextval, -- gl_sl_link_id
4943 'XLAJEL', -- gl_sl_link_table
4944 null, -- party_type_code
4945 null, -- party_id
4946 null, -- party_site_id
4947 null, -- statistical_amount
4948 null, -- ussgl_transaction_code
4949 null, -- glzz_recon_ref
4950 null, -- control_balance_flag
4951 null, -- analytical_balance_flag
4952 null, -- upg_tax_reference_id1
4953 null, -- upg_tax_reference_id2
4954 null, -- upg_tax_reference_id3
4955 sysdate, -- creation_date
4956 c_fnd_user, -- created_by
4957 sysdate, -- last_update_date
4958 c_fnd_user, -- last_updated_by
4959 c_upgrade_bugno, -- last_update_login
4960 null, -- program_update_date
4961 null, -- program_id
4962 c_application_id, -- program_application_id
4963 null, -- request_id
4964 'N', -- gain_or_loss_flag
4965 cal_period_close_date, -- accounting_date
4966 set_of_books_id -- ledger_id
4967 )
4968 when (adj_row = 2) then
4969 into xla_distribution_links (
4970 upg_batch_id,
4971 application_id,
4972 event_id,
4973 ae_header_id,
4974 ae_line_num,
4975 accounting_line_code,
4976 accounting_line_type_code,
4977 source_distribution_type,
4978 source_distribution_id_char_1,
4979 source_distribution_id_char_2,
4980 source_distribution_id_char_3,
4981 source_distribution_id_char_4,
4982 source_distribution_id_char_5,
4983 source_distribution_id_num_1,
4984 source_distribution_id_num_2,
4985 source_distribution_id_num_3,
4986 source_distribution_id_num_4,
4987 source_distribution_id_num_5,
4988 merge_duplicate_code,
4989 statistical_amount,
4990 unrounded_entered_dr,
4991 unrounded_entered_cr,
4992 unrounded_accounted_dr,
4993 unrounded_accounted_cr,
4994 ref_ae_header_id,
4995 ref_temp_line_num,
4996 ref_event_id,
4997 temp_line_num,
4998 tax_line_ref_id,
4999 tax_summary_line_ref_id,
5000 tax_rec_nrec_dist_ref_id,
5001 line_definition_owner_code,
5002 line_definition_code,
5003 event_class_code,
5004 event_type_code
5005 ) values (
5006 l_upg_batch_id, -- upg_batch_id
5007 c_application_id, -- application_id
5008 event_id, -- event_id
5009 ae_header_id, -- ae_header_id
5010 ae_line_num, -- ae_line_num
5011 null, -- accounting_line_code
5012 'S', -- accounting_line_type_code
5013 'TRX', -- source_distribution_type
5014 null, -- source_distribution_id_char_1
5015 null, -- source_distribution_id_char_2
5016 null, -- source_distribution_id_char_3
5017 null, -- source_distribution_id_char_4
5018 null, -- source_distribution_id_char_5
5019 transaction_header_id, -- source_distribution_id_num_1
5020 adj_line_id, -- source_distribution_id_num_2
5021 null, -- source_distribution_id_num_3
5022 null, -- source_distribution_id_num_4
5023 null, -- source_distribution_id_num_5
5024 'N', -- merge_duplicate_code
5025 null, -- statistical_amount
5026 -- Fix for Bug #5131737. Need to switch CR/DR for pseudo-row
5027 credit_amount, -- unrounded_entered_dr
5028 debit_amount, -- unrounded_entered_cr
5029 credit_amount, -- unrounded_accounted_dr
5030 debit_amount, -- unrounded_accounted_cr
5031 ae_header_id, -- ref_ae_header_id
5032 null, -- ref_temp_line_num
5033 null, -- ref_event_id
5034 ae_line_num, -- temp_line_num
5035 null, -- tax_line_ref_id
5036 null, -- tax_summary_line_ref_id
5037 null, -- tax_rec_nrec_dist_ref_id
5038 null, -- line_definition_owner_code
5039 null, -- line_definition_code
5040 event_class_code, -- event_class_code
5041 event_type_code -- event_type_code
5042 )
5043 when (adj_row = 2) and (je_batch_id2 is not null) then
5044 into gl_import_references (
5045 je_batch_id,
5046 je_header_id,
5047 je_line_num,
5048 last_update_date,
5049 last_updated_by,
5050 creation_date,
5051 created_by,
5052 last_update_login,
5053 reference_1,
5054 reference_2,
5055 reference_3,
5056 reference_4,
5057 reference_5,
5058 reference_6,
5059 reference_7,
5060 reference_8,
5061 reference_9,
5062 reference_10,
5063 subledger_doc_sequence_id,
5064 subledger_doc_sequence_value,
5065 gl_sl_link_id,
5066 gl_sl_link_table
5067 ) values (
5068 je_batch_id2, -- je_batch_id
5069 je_header_id2, -- je_header_id
5070 je_line_num2, -- je_line_num
5071 sysdate, -- last_update_date
5072 c_fnd_user, -- last_updated_by
5073 sysdate, -- creation_date
5074 c_fnd_user, -- created_by
5075 c_upgrade_bugno, -- last_update_login
5076 to_char(transaction_header_id),
5077 -- reference_1
5078 to_char(asset_id), -- reference_2
5079 to_char(distribution_id), -- reference_3
5080 to_char(adj_line_id), -- reference_4
5081 book_type_code, -- reference_5
5082 to_char(period_counter), -- reference_6
5083 null, -- reference_7
5084 null, -- reference_8
5085 null, -- reference_9
5086 null, -- reference_10
5087 null, -- subledger_doc_seq_id
5088 null, -- subledger_doc_seq_value
5089 xla_gl_sl_link_id_s.currval, -- gl_sl_link_id
5090 'XLAJEL' -- gl_sl_link_table
5091 )
5092 when (adj_row = 3) then
5093 into xla_ae_lines (
5094 upg_batch_id,
5095 ae_header_id,
5096 ae_line_num,
5097 displayed_line_number,
5098 application_id,
5099 code_combination_id,
5100 gl_transfer_mode_code,
5101 accounted_dr,
5102 accounted_cr,
5103 currency_code,
5104 currency_conversion_date,
5105 currency_conversion_rate,
5106 currency_conversion_type,
5107 entered_dr,
5108 entered_cr,
5109 description,
5110 accounting_class_code,
5111 gl_sl_link_id,
5112 gl_sl_link_table,
5113 party_type_code,
5114 party_id,
5115 party_site_id,
5116 statistical_amount,
5117 ussgl_transaction_code,
5118 jgzz_recon_ref,
5119 control_balance_flag,
5120 analytical_balance_flag,
5121 upg_tax_reference_id1,
5122 upg_tax_reference_id2,
5123 upg_tax_reference_id3,
5124 creation_date,
5125 created_by,
5126 last_update_date,
5127 last_updated_by,
5128 last_update_login,
5129 program_update_date,
5130 program_id,
5131 program_application_id,
5132 request_id,
5133 gain_or_loss_flag,
5134 accounting_date,
5135 ledger_id
5136 ) values (
5137 l_upg_batch_id, -- upg_batch_id
5138 ae_header_id, -- ae_header_id
5139 ae_line_num, -- ae_line_num
5140 ae_line_num, -- displayed_line_num
5141 c_application_id, -- application_id
5142 ccid3, -- code_combination_id
5143 'S', -- gl_transfer_mode_code
5144 -- Fix for Bug #5131737. Need to switch CR/DR for pseudo-row
5145 credit_amount, -- accounted_dr
5146 debit_amount, -- accounted_cr
5147 currency_code, -- currency_code
5148 null, -- currency_conversion_date
5149 null, -- currency_conversion_rate
5150 null, -- currency_conversion_type
5151 credit_amount, -- entered_dr
5152 debit_amount, -- entered_cr
5153 l_bonus_deprn_rsv_desc || ' - ' ||
5154 to_char(cal_period_close_date, 'DD-MON-RR'),
5155 -- description
5156 'ASSET', -- accounting_class_code
5157 xla_gl_sl_link_id_s.nextval, -- gl_sl_link_id
5158 'XLAJEL', -- gl_sl_link_table
5159 null, -- party_type_code
5160 null, -- party_id
5161 null, -- party_site_id
5162 null, -- statistical_amount
5163 null, -- ussgl_transaction_code
5164 null, -- glzz_recon_ref
5165 null, -- control_balance_flag
5166 null, -- analytical_balance_flag
5167 null, -- upg_tax_reference_id1
5168 null, -- upg_tax_reference_id2
5169 null, -- upg_tax_reference_id3
5170 sysdate, -- creation_date
5171 c_fnd_user, -- created_by
5172 sysdate, -- last_update_date
5173 c_fnd_user, -- last_updated_by
5174 c_upgrade_bugno, -- last_update_login
5175 null, -- program_update_date
5176 null, -- program_id
5177 c_application_id, -- program_application_id
5178 null, -- request_id
5179 'N', -- gain_or_loss_flag
5180 cal_period_close_date, -- accounting_date
5181 set_of_books_id -- ledger_id
5182 )
5183 when (adj_row = 3) then
5184 into xla_distribution_links (
5185 upg_batch_id,
5186 application_id,
5187 event_id,
5188 ae_header_id,
5189 ae_line_num,
5190 accounting_line_code,
5191 accounting_line_type_code,
5192 source_distribution_type,
5193 source_distribution_id_char_1,
5194 source_distribution_id_char_2,
5195 source_distribution_id_char_3,
5196 source_distribution_id_char_4,
5197 source_distribution_id_char_5,
5198 source_distribution_id_num_1,
5199 source_distribution_id_num_2,
5200 source_distribution_id_num_3,
5201 source_distribution_id_num_4,
5202 source_distribution_id_num_5,
5203 merge_duplicate_code,
5204 statistical_amount,
5205 unrounded_entered_dr,
5206 unrounded_entered_cr,
5207 unrounded_accounted_dr,
5208 unrounded_accounted_cr,
5209 ref_ae_header_id,
5210 ref_temp_line_num,
5211 ref_event_id,
5212 temp_line_num,
5213 tax_line_ref_id,
5214 tax_summary_line_ref_id,
5215 tax_rec_nrec_dist_ref_id,
5216 line_definition_owner_code,
5217 line_definition_code,
5218 event_class_code,
5219 event_type_code
5220 ) values (
5221 l_upg_batch_id, -- upg_batch_id
5222 c_application_id, -- application_id
5223 event_id, -- event_id
5224 ae_header_id, -- ae_header_id
5225 ae_line_num, -- ae_line_num
5226 null, -- accounting_line_code
5227 'S', -- accounting_line_type_code
5228 'TRX', -- source_distribution_type
5229 null, -- source_distribution_id_char_1
5230 null, -- source_distribution_id_char_2
5231 null, -- source_distribution_id_char_3
5232 null, -- source_distribution_id_char_4
5233 null, -- source_distribution_id_char_5
5234 transaction_header_id, -- source_distribution_id_num_1
5235 adj_line_id, -- source_distribution_id_num_2
5236 null, -- source_distribution_id_num_3
5237 null, -- source_distribution_id_num_4
5238 null, -- source_distribution_id_num_5
5239 'N', -- merge_duplicate_code
5240 null, -- statistical_amount
5241 -- Fix for Bug #5131737. Need to switch CR/DR for pseudo-row
5242 credit_amount, -- unrounded_entered_dr
5243 debit_amount, -- unrounded_entered_cr
5244 credit_amount, -- unrounded_accounted_dr
5245 debit_amount, -- unrounded_accounted_cr
5246 ae_header_id, -- ref_ae_header_id
5247 null, -- ref_temp_line_num
5248 null, -- ref_event_id
5249 ae_line_num, -- temp_line_num
5250 null, -- tax_line_ref_id
5251 null, -- tax_summary_line_ref_id
5252 null, -- tax_rec_nrec_dist_ref_id
5253 null, -- line_definition_owner_code
5254 null, -- line_definition_code
5255 event_class_code, -- event_class_code
5256 event_type_code -- event_type_code
5257 )
5258 when (adj_row = 3) and (je_batch_id3 is not null) then
5259 into gl_import_references (
5260 je_batch_id,
5261 je_header_id,
5262 je_line_num,
5263 last_update_date,
5264 last_updated_by,
5265 creation_date,
5266 created_by,
5267 last_update_login,
5268 reference_1,
5269 reference_2,
5270 reference_3,
5271 reference_4,
5272 reference_5,
5273 reference_6,
5274 reference_7,
5275 reference_8,
5276 reference_9,
5277 reference_10,
5278 subledger_doc_sequence_id,
5279 subledger_doc_sequence_value,
5280 gl_sl_link_id,
5281 gl_sl_link_table
5282 ) values (
5283 je_batch_id3, -- je_batch_id
5284 je_header_id3, -- je_header_id
5285 je_line_num3, -- je_line_num
5286 sysdate, -- last_update_date
5287 c_fnd_user, -- last_updated_by
5288 sysdate, -- creation_date
5289 c_fnd_user, -- created_by
5290 c_upgrade_bugno, -- last_update_login
5291 to_char(transaction_header_id),
5292 -- reference_1
5293 to_char(asset_id), -- reference_2
5294 to_char(distribution_id), -- reference_3
5295 to_char(adj_line_id), -- reference_4
5296 book_type_code, -- reference_5
5297 to_char(period_counter), -- reference_6
5298 null, -- reference_7
5299 null, -- reference_8
5300 null, -- reference_9
5301 null, -- reference_10
5302 null, -- subledger_doc_seq_id
5303 null, -- subledger_doc_seq_value
5304 xla_gl_sl_link_id_s.currval, -- gl_sl_link_id
5305 'XLAJEL' -- gl_sl_link_table
5306 )
5307 select /*+ ordered index(adj, FA_ADJUSTMENTS_U1) use_nl(cb) index(cb, fa_category_books_u1) */
5308 adj.adjustment_line_id adj_line_id,
5309 decode(adj.debit_credit_flag,
5310 'DR', adj.adjustment_amount, null) debit_amount,
5311 decode(adj.debit_credit_flag,
5312 'CR', adj.adjustment_amount, null) credit_amount,
5313 adj.code_combination_id ccid1,
5314 nvl(nvl(gljl2.code_combination_id,
5315 da.deprn_reserve_account_ccid),
5316 cb.reserve_account_ccid) ccid2,
5317 nvl(nvl(gljl3.code_combination_id,
5318 da.deprn_reserve_account_ccid),
5319 cb.reserve_account_ccid) ccid3,
5320 glsob.currency_code currency_code,
5321 decode (adj.adjustment_type,
5322 'BONUS EXPENSE', 'EXPENSE',
5323 'BONUS RESERVE', 'ASSET',
5324 'CIP COST', 'ASSET',
5325 'COST', 'ASSET',
5326 'COST CLEARING', 'ASSET',
5327 'DEPRN ADJUST', 'EXPENSE',
5328 'EXPENSE', 'EXPENSE',
5329 'GRP COR RESERVE', 'ASSET',
5330 'GRP PRC RESERVE', 'ASSET',
5331 'INTERCO AP', 'LIABILITY',
5332 'INTERCO AR', 'ASSET',
5333 'NBV RETIRED', 'ASSET',
5334 'PROCEEDS', 'ASSET',
5335 'PROCEEDS CLR', 'ASSET',
5336 'REMOVALCOST', 'ASSET',
5337 'REMOVALCOST CLR', 'ASSET',
5338 'RESERVE', 'ASSET',
5339 'REVAL RESERVE', 'ASSET',
5340 'REVAL RSV RET', 'ASSET',
5341 'REVAL AMORT', 'EXPENSE',
5342 'REVAL EXPENSE', 'EXPENSE',
5343 'ASSET') accounting_class_code,
5344 lk.description line_desc1,
5345 lk2.description line_desc2,
5346 decode(adj.je_header_id, null, 'N', 'Y') gl_transfer_status_code,
5347 gljh.je_batch_id je_batch_id1,
5348 gljh2.je_batch_id je_batch_id2,
5349 gljh2.je_batch_id je_batch_id3,
5350 adj.je_header_id je_header_id1,
5351 dd.je_header_id je_header_id2,
5352 dd.je_header_id je_header_id3,
5353 nvl(adj.je_line_num, 0) je_line_num1,
5354 nvl(dd.deprn_reserve_je_line_num,
5355 nvl(adj.je_line_num, 0)) je_line_num2,
5356 nvl(dd.bonus_deprn_rsv_je_line_num,
5357 nvl(adj.je_line_num, 0)) je_line_num3,
5358 adj.distribution_id distribution_id,
5359 ev.event_id event_id,
5360 he.ae_header_id ae_header_id,
5361 ev.calendar_period_close_date cal_period_close_date,
5362 ev.transaction_header_id transaction_header_id,
5363 ev.event_type_code event_type_code,
5364 ev.event_class_code event_class_code,
5365 ev.asset_id asset_id,
5366 ev.book_type_code book_type_code,
5367 he.set_of_books_id set_of_books_id,
5368 ev.period_counter period_counter,
5369 adj.source_type_code source_type_code,
5370 adj.adjustment_type adjustment_type,
5371 row_number() over
5372 (partition by ev.transaction_header_id
5373 order by adj.adjustment_line_id, mult.adj_row) ae_line_num,
5374 mult.adj_row adj_row
5375 from
5376 fa_xla_upg_events_gt ev,
5377 fa_xla_upg_headers_gt he,
5378 fa_adjustments adj,
5379 fa_lookups_tl lk,
5380 fa_lookups_tl lk2,
5381 gl_je_headers gljh,
5382 fa_deprn_detail dd,
5383 gl_je_headers gljh2,
5384 gl_je_lines gljl2,
5385 gl_je_lines gljl3,
5386 fa_book_controls bc,
5387 gl_sets_of_books glsob,
5388 fa_distribution_accounts da,
5389 fa_asset_history ah,
5390 fa_category_books cb,
5391 (select 1 adj_row from dual
5392 union all
5393 select 2 adj_row from dual
5394 union all
5395 select 3 adj_row from dual) mult
5396 where ev.event_id = he.event_id
5397 and bc.book_type_code = ev.book_type_code
5398 and bc.set_of_books_id = glsob.set_of_books_id
5399 and bc.book_type_code = adj.book_type_code
5400 and he.set_of_books_id = bc.set_of_books_id
5401 and adj.asset_id = ev.asset_id
5402 and adj.book_type_code = ev.book_type_code
5403 and adj.period_counter_created = ev.period_counter
5404 and adj.transaction_header_id = ev.transaction_header_id
5405 and adj.code_combination_id is not null
5406 and nvl(adj.track_member_flag, 'N') = 'N'
5407 and lk.lookup_type = 'JOURNAL ENTRIES'
5408 and lk.lookup_code = decode (adj.adjustment_type,
5409 'BONUS EXPENSE', 'BONUS DEPRECIATION EXPENSE',
5410 'BONUS RESERVE', 'BONUS DEPRECIATION RESERVE',
5411 'CIP COST', adj.source_type_code ||' COST',
5412 adj.source_type_code ||' '|| adj.adjustment_type)
5413 and lk2.lookup_type = 'JOURNAL ENTRIES'
5414 and lk2.lookup_code = decode(adj.adjustment_type,
5415 'EXPENSE', adj.source_type_code ||' RESERVE',
5416 'BONUS EXPENSE', 'BONUS DEPRECIATION RESERVE',
5417 'BONUS RESERVE', 'BONUS DEPRECIATION RESERVE',
5418 'CIP COST', adj.source_type_code ||' COST',
5419 adj.source_type_code ||' '||adj.adjustment_type)
5420 and userenv('LANG') = lk.language
5421 and userenv('LANG') = lk2.language
5422 and adj.je_header_id = gljh.je_header_id (+)
5423 and adj.asset_id = dd.asset_id (+)
5424 and adj.book_type_code = dd.book_type_code (+)
5425 and adj.distribution_id = dd.distribution_id (+)
5426 and adj.period_counter_created = dd.period_counter (+)
5427 and dd.je_header_id = gljl2.je_header_id (+)
5428 and dd.deprn_reserve_je_line_num = gljl2.je_line_num (+)
5429 and dd.je_header_id = gljh2.je_header_id (+)
5430 and dd.je_header_id = gljl3.je_header_id (+)
5431 and dd.bonus_deprn_rsv_je_line_num = gljl3.je_line_num (+)
5432 and adj.book_type_code = da.book_type_code (+)
5433 and adj.distribution_id = da.distribution_id (+)
5434 and ev.asset_id = ah.asset_id
5435 and ev.date_effective >= ah.date_effective
5436 and ev.date_effective < nvl(ah.date_ineffective, sysdate+1)
5437 and ah.category_id = cb.category_id
5438 and bc.book_type_code = cb.book_type_code
5439 and ((mult.adj_row = 1)
5440 or ((mult.adj_row = 2) and
5441 (adjustment_type = 'EXPENSE') and
5442 (source_type_code in
5443 ('DEPRECIATION', 'CIP RETIREMENT', 'RETIREMENT')))
5444 or ((mult.adj_row = 3) and
5445 (adjustment_type = 'BONUS EXPENSE') and
5446 (source_type_code = 'DEPRECIATION')));
5447
5448 select count(*)
5449 into l_mc_books
5450 from fa_mc_book_controls
5451 where enabled_flag = 'Y'
5452 and rownum = 1;
5453
5454 if (l_mc_books > 0) then
5455
5456 insert all
5457 when 1 = 1 then
5458 into fa_xla_upg_headers_gt (
5459 ae_header_id,
5460 event_id,
5461 set_of_books_id
5462 ) values (
5463 xla_ae_headers_s.nextval,
5464 event_id,
5465 set_of_books_id
5466 )
5467 when 1 = 1 then
5468 into xla_ae_headers (
5469 upg_batch_id,
5470 application_id,
5471 amb_context_code,
5472 entity_id,
5473 event_id,
5474 event_type_code,
5475 ae_header_id,
5476 ledger_id,
5477 accounting_date,
5478 period_name,
5479 reference_date,
5480 balance_type_code,
5481 je_category_name,
5482 gl_transfer_status_code,
5483 gl_transfer_date,
5484 accounting_entry_status_code,
5485 accounting_entry_type_code,
5486 description,
5487 budget_version_id,
5488 funds_status_code,
5489 encumbrance_type_id,
5490 completed_date,
5491 doc_sequence_id,
5492 doc_sequence_value,
5493 doc_category_code,
5494 packet_id,
5495 group_id,
5496 creation_date,
5497 created_by,
5498 last_update_date,
5499 last_updated_by,
5500 last_update_login,
5501 program_id,
5502 program_application_id,
5503 program_update_date,
5504 request_id,
5505 close_acct_seq_assign_id,
5506 close_acct_seq_version_id,
5507 close_acct_seq_value,
5508 completion_acct_seq_assign_id,
5509 completion_acct_seq_version_id,
5510 completion_acct_seq_value,
5511 accounting_batch_id,
5512 product_rule_type_code,
5513 product_rule_code,
5514 product_rule_version,
5515 upg_source_application_id,
5516 upg_valid_flag
5517 ) values (
5518 l_upg_batch_id, -- upg_batch_id
5519 c_application_id, -- application_id
5520 c_amb_context_code, -- amb_context_code
5521 entity_id, -- entity_id
5522 event_id, -- event_id
5523 event_type_code, -- event_type_code
5524 xla_ae_headers_s.currval, -- ae_header_id
5525 set_of_books_id, -- ledger_id
5526 calendar_period_close_date, -- accounting_date
5527 period_name, -- period_name
5528 null, -- reference_date
5529 'A', -- balance_type_code
5530 je_category_name, -- je_category_name
5531 'Y', -- gl_transfer_status_code
5532 null, -- gl_transfer_date
5533 'F', -- accounting_entry_status_code
5534 'STANDARD', -- accounting_entry_type_code
5535 description, -- description
5536 null, -- budget_version_id
5537 null, -- funds_status_code
5538 null, -- encumbrance_type_id
5539 null, -- completed_date
5540 null, -- doc_sequence_id
5541 null, -- doc_sequence_value
5542 null, -- doc_category_code
5543 null, -- packet_id
5544 null, -- group_id
5545 sysdate, -- creation_date
5546 c_fnd_user, -- created_by
5547 sysdate, -- last_update_date
5548 c_fnd_user, -- last_updated_by
5549 c_upgrade_bugno, -- last_update_login
5550 null, -- program_id
5551 c_application_id, -- program_application_id
5552 sysdate, -- program_update_date
5553 null, -- request_id
5554 null, -- close_acct_seq_assign_id
5555 null, -- close_acct_seq_version_id
5556 null, -- close_acct_seq_value
5557 null, -- completion_acct_seq_assign_id
5558 null, -- completion_acct_seq_version_id
5559 null, -- completion_acct_seq_value
5560 null, -- accounting_batch_id
5561 null, -- product_rule_type_code
5562 null, -- product_rule_code
5563 null, -- product_rule_version
5564 c_application_id, -- upg_source_application_id
5565 null -- upg_valid_flag
5566 )
5567 select faev.entity_id entity_id,
5568 faev.event_id event_id,
5569 faev.event_type_code event_type_code,
5570 mc.set_of_books_id set_of_books_id,
5571 faev.calendar_period_close_date
5572 calendar_period_close_date,
5573 faev.period_name period_name,
5574 faev.je_category_name je_category_name,
5575 faev.description description
5576 from fa_xla_upg_events_gt faev,
5577 fa_mc_book_controls mc
5578 where mc.book_type_code = faev.book_type_code
5579 and mc.enabled_flag = 'Y';
5580
5581 insert all
5582 when (adj_row = 1) then
5583 into xla_ae_lines (
5584 upg_batch_id,
5585 ae_header_id,
5586 ae_line_num,
5587 displayed_line_number,
5588 application_id,
5589 code_combination_id,
5590 gl_transfer_mode_code,
5591 accounted_dr,
5592 accounted_cr,
5593 currency_code,
5594 currency_conversion_date,
5595 currency_conversion_rate,
5596 currency_conversion_type,
5597 entered_dr,
5598 entered_cr,
5599 description,
5600 accounting_class_code,
5601 gl_sl_link_id,
5602 gl_sl_link_table,
5603 party_type_code,
5604 party_id,
5605 party_site_id,
5606 statistical_amount,
5607 ussgl_transaction_code,
5608 jgzz_recon_ref,
5609 control_balance_flag,
5610 analytical_balance_flag,
5611 upg_tax_reference_id1,
5612 upg_tax_reference_id2,
5613 upg_tax_reference_id3,
5614 creation_date,
5615 created_by,
5616 last_update_date,
5617 last_updated_by,
5618 last_update_login,
5619 program_update_date,
5620 program_id,
5621 program_application_id,
5622 request_id,
5623 gain_or_loss_flag,
5624 accounting_date,
5625 ledger_id
5626 ) values (
5627 l_upg_batch_id, -- upg_batch_id
5628 ae_header_id, -- ae_header_id
5629 ae_line_num, -- ae_line_num
5630 ae_line_num, -- displayed_line_num
5631 c_application_id, -- application_id
5632 ccid1, -- code_combination_id
5633 'S', -- gl_transfer_mode_code
5634 debit_amount, -- accounted_dr
5635 credit_amount, -- accounted_cr
5636 currency_code, -- currency_code
5637 null, -- currency_conversion_date
5638 null, -- currency_conversion_rate
5639 null, -- currency_conversion_type
5640 debit_amount, -- entered_dr
5641 credit_amount, -- entered_cr
5642 line_desc1 || ' - ' ||
5643 to_char(cal_period_close_date, 'DD-MON-RR'),
5644 -- description
5645 accounting_class_code, -- accounting_class_code
5646 xla_gl_sl_link_id_s.nextval, -- gl_sl_link_id
5647 'XLAJEL', -- gl_sl_link_table
5648 null, -- party_type_code
5649 null, -- party_id
5650 null, -- party_site_id
5651 null, -- statistical_amount
5652 null, -- ussgl_transaction_code
5653 null, -- glzz_recon_ref
5654 null, -- control_balance_flag
5655 null, -- analytical_balance_flag
5656 null, -- upg_tax_reference_id1
5657 null, -- upg_tax_reference_id2
5658 null, -- upg_tax_reference_id3
5659 sysdate, -- creation_date
5660 c_fnd_user, -- created_by
5661 sysdate, -- last_update_date
5662 c_fnd_user, -- last_updated_by
5663 c_upgrade_bugno, -- last_update_login
5664 null, -- program_update_date
5665 null, -- program_id
5666 c_application_id, -- program_application_id
5667 null, -- request_id
5668 'N', -- gain_or_loss_flag
5669 cal_period_close_date, -- accounting_date
5670 set_of_books_id -- ledger_id
5671 )
5672 when (adj_row = 1) then
5673 into xla_distribution_links (
5674 upg_batch_id,
5675 application_id,
5676 event_id,
5677 ae_header_id,
5678 ae_line_num,
5679 accounting_line_code,
5680 accounting_line_type_code,
5681 source_distribution_type,
5682 source_distribution_id_char_1,
5683 source_distribution_id_char_2,
5684 source_distribution_id_char_3,
5685 source_distribution_id_char_4,
5686 source_distribution_id_char_5,
5687 source_distribution_id_num_1,
5688 source_distribution_id_num_2,
5689 source_distribution_id_num_3,
5690 source_distribution_id_num_4,
5691 source_distribution_id_num_5,
5692 merge_duplicate_code,
5693 statistical_amount,
5694 unrounded_entered_dr,
5695 unrounded_entered_cr,
5696 unrounded_accounted_dr,
5697 unrounded_accounted_cr,
5698 ref_ae_header_id,
5699 ref_temp_line_num,
5700 ref_event_id,
5701 temp_line_num,
5702 tax_line_ref_id,
5703 tax_summary_line_ref_id,
5704 tax_rec_nrec_dist_ref_id,
5705 line_definition_owner_code,
5706 line_definition_code,
5707 event_class_code,
5708 event_type_code
5709 ) values (
5710 l_upg_batch_id, -- upg_batch_id
5711 c_application_id, -- application_id
5712 event_id, -- event_id
5713 ae_header_id, -- ae_header_id
5714 ae_line_num, -- ae_line_num
5715 null, -- accounting_line_code
5716 'S', -- accounting_line_type_code
5717 'TRX', -- source_distribution_type
5718 null, -- source_distribution_id_char_1
5719 null, -- source_distribution_id_char_2
5720 null, -- source_distribution_id_char_3
5721 null, -- source_distribution_id_char_4
5722 null, -- source_distribution_id_char_5
5723 transaction_header_id, -- source_distribution_id_num_1
5724 adj_line_id, -- source_distribution_id_num_2
5725 null, -- source_distribution_id_num_3
5726 null, -- source_distribution_id_num_4
5727 null, -- source_distribution_id_num_5
5728 'N', -- merge_duplicate_code
5729 null, -- statistical_amount
5730 debit_amount, -- unrounded_entered_dr
5731 credit_amount, -- unrounded_entered_cr
5732 debit_amount, -- unrounded_accounted_dr
5733 credit_amount, -- unrounded_accounted_cr
5734 ae_header_id, -- ref_ae_header_id
5735 null, -- ref_temp_line_num
5736 null, -- ref_event_id
5737 ae_line_num, -- temp_line_num
5738 null, -- tax_line_ref_id
5739 null, -- tax_summary_line_ref_id
5740 null, -- tax_rec_nrec_dist_ref_id
5741 null, -- line_definition_owner_code
5742 null, -- line_definition_code
5743 event_class_code, -- event_class_code
5744 event_type_code -- event_type_code
5745 )
5746 when (adj_row = 1) and (je_batch_id1 is not null) then
5747 into gl_import_references (
5748 je_batch_id,
5749 je_header_id,
5750 je_line_num,
5751 last_update_date,
5752 last_updated_by,
5753 creation_date,
5754 created_by,
5755 last_update_login,
5756 reference_1,
5757 reference_2,
5758 reference_3,
5759 reference_4,
5760 reference_5,
5761 reference_6,
5762 reference_7,
5763 reference_8,
5764 reference_9,
5765 reference_10,
5766 subledger_doc_sequence_id,
5767 subledger_doc_sequence_value,
5768 gl_sl_link_id,
5769 gl_sl_link_table
5770 ) values (
5771 je_batch_id1, -- je_batch_id
5772 je_header_id1, -- je_header_id
5773 je_line_num1, -- je_line_num
5774 sysdate, -- last_update_date
5775 c_fnd_user, -- last_updated_by
5776 sysdate, -- creation_date
5777 c_fnd_user, -- created_by
5778 c_upgrade_bugno, -- last_update_login
5779 to_char(transaction_header_id),
5780 -- reference_1
5781 to_char(asset_id), -- reference_2
5782 to_char(distribution_id), -- reference_3
5783 to_char(adj_line_id), -- reference_4
5784 book_type_code, -- reference_5
5785 to_char(period_counter), -- reference_6
5786 null, -- reference_7
5787 null, -- reference_8
5788 null, -- reference_9
5789 null, -- reference_10
5790 null, -- subledger_doc_seq_id
5791 null, -- subledger_doc_seq_value
5792 xla_gl_sl_link_id_s.currval, -- gl_sl_link_id
5793 'XLAJEL' -- gl_sl_link_table
5794 )
5795 when (adj_row = 2) then
5796 into xla_ae_lines (
5797 upg_batch_id,
5798 ae_header_id,
5799 ae_line_num,
5800 displayed_line_number,
5801 application_id,
5802 code_combination_id,
5803 gl_transfer_mode_code,
5804 accounted_dr,
5805 accounted_cr,
5806 currency_code,
5807 currency_conversion_date,
5808 currency_conversion_rate,
5809 currency_conversion_type,
5810 entered_dr,
5811 entered_cr,
5812 description,
5813 accounting_class_code,
5814 gl_sl_link_id,
5815 gl_sl_link_table,
5816 party_type_code,
5817 party_id,
5818 party_site_id,
5819 statistical_amount,
5820 ussgl_transaction_code,
5821 jgzz_recon_ref,
5822 control_balance_flag,
5823 analytical_balance_flag,
5824 upg_tax_reference_id1,
5825 upg_tax_reference_id2,
5826 upg_tax_reference_id3,
5827 creation_date,
5828 created_by,
5829 last_update_date,
5830 last_updated_by,
5831 last_update_login,
5832 program_update_date,
5833 program_id,
5834 program_application_id,
5835 request_id,
5836 gain_or_loss_flag,
5837 accounting_date,
5838 ledger_id
5839 ) values (
5840 l_upg_batch_id, -- upg_batch_id
5841 ae_header_id, -- ae_header_id
5842 ae_line_num, -- ae_line_num
5843 ae_line_num, -- displayed_line_num
5844 c_application_id, -- application_id
5845 ccid2, -- code_combination_id
5846 'S', -- gl_transfer_mode_code
5847 -- Fix for Bug #5131737. Need to switch CR/DR for pseudo-row
5848 credit_amount, -- accounted_dr
5849 debit_amount, -- accounted_cr
5850 currency_code, -- currency_code
5851 null, -- currency_conversion_date
5852 null, -- currency_conversion_rate
5853 null, -- currency_conversion_type
5854 credit_amount, -- entered_dr
5855 debit_amount, -- entered_cr
5856 line_desc2 || ' - ' ||
5857 to_char(cal_period_close_date, 'DD-MON-RR'),
5858 -- description
5859 'ASSET', -- accounting_class_code
5860 xla_gl_sl_link_id_s.nextval, -- gl_sl_link_id
5861 'XLAJEL', -- gl_sl_link_table
5862 null, -- party_type_code
5863 null, -- party_id
5864 null, -- party_site_id
5865 null, -- statistical_amount
5866 null, -- ussgl_transaction_code
5867 null, -- glzz_recon_ref
5868 null, -- control_balance_flag
5869 null, -- analytical_balance_flag
5870 null, -- upg_tax_reference_id1
5871 null, -- upg_tax_reference_id2
5872 null, -- upg_tax_reference_id3
5873 sysdate, -- creation_date
5874 c_fnd_user, -- created_by
5875 sysdate, -- last_update_date
5876 c_fnd_user, -- last_updated_by
5877 c_upgrade_bugno, -- last_update_login
5878 null, -- program_update_date
5879 null, -- program_id
5880 c_application_id, -- program_application_id
5881 null, -- request_id
5882 'N', -- gain_or_loss_flag
5883 cal_period_close_date, -- accounting_date
5884 set_of_books_id -- ledger_id
5885 )
5886 when (adj_row = 2) then
5887 into xla_distribution_links (
5888 upg_batch_id,
5889 application_id,
5890 event_id,
5891 ae_header_id,
5892 ae_line_num,
5893 accounting_line_code,
5894 accounting_line_type_code,
5895 source_distribution_type,
5896 source_distribution_id_char_1,
5897 source_distribution_id_char_2,
5898 source_distribution_id_char_3,
5899 source_distribution_id_char_4,
5900 source_distribution_id_char_5,
5901 source_distribution_id_num_1,
5902 source_distribution_id_num_2,
5903 source_distribution_id_num_3,
5904 source_distribution_id_num_4,
5905 source_distribution_id_num_5,
5906 merge_duplicate_code,
5907 statistical_amount,
5908 unrounded_entered_dr,
5909 unrounded_entered_cr,
5910 unrounded_accounted_dr,
5911 unrounded_accounted_cr,
5912 ref_ae_header_id,
5913 ref_temp_line_num,
5914 ref_event_id,
5915 temp_line_num,
5916 tax_line_ref_id,
5917 tax_summary_line_ref_id,
5918 tax_rec_nrec_dist_ref_id,
5919 line_definition_owner_code,
5920 line_definition_code,
5921 event_class_code,
5922 event_type_code
5923 ) values (
5924 l_upg_batch_id, -- upg_batch_id
5925 c_application_id, -- application_id
5926 event_id, -- event_id
5927 ae_header_id, -- ae_header_id
5928 ae_line_num, -- ae_line_num
5929 null, -- accounting_line_code
5930 'S', -- accounting_line_type_code
5931 'TRX', -- source_distribution_type
5932 null, -- source_distribution_id_char_1
5933 null, -- source_distribution_id_char_2
5934 null, -- source_distribution_id_char_3
5935 null, -- source_distribution_id_char_4
5936 null, -- source_distribution_id_char_5
5937 transaction_header_id, -- source_distribution_id_num_1
5938 adj_line_id, -- source_distribution_id_num_2
5939 null, -- source_distribution_id_num_3
5940 null, -- source_distribution_id_num_4
5941 null, -- source_distribution_id_num_5
5942 'N', -- merge_duplicate_code
5943 null, -- statistical_amount
5944 -- Fix for Bug #5131737. Need to switch CR/DR for pseudo-row
5945 credit_amount, -- unrounded_entered_dr
5946 debit_amount, -- unrounded_entered_cr
5947 credit_amount, -- unrounded_accounted_dr
5948 debit_amount, -- unrounded_accounted_cr
5949 ae_header_id, -- ref_ae_header_id
5950 null, -- ref_temp_line_num
5951 null, -- ref_event_id
5952 ae_line_num, -- temp_line_num
5953 null, -- tax_line_ref_id
5954 null, -- tax_summary_line_ref_id
5955 null, -- tax_rec_nrec_dist_ref_id
5956 null, -- line_definition_owner_code
5957 null, -- line_definition_code
5958 event_class_code, -- event_class_code
5959 event_type_code -- event_type_code
5960 )
5961 when (adj_row = 2) and (je_batch_id2 is not null) then
5962 into gl_import_references (
5963 je_batch_id,
5964 je_header_id,
5965 je_line_num,
5966 last_update_date,
5967 last_updated_by,
5968 creation_date,
5969 created_by,
5970 last_update_login,
5971 reference_1,
5972 reference_2,
5973 reference_3,
5974 reference_4,
5975 reference_5,
5976 reference_6,
5977 reference_7,
5978 reference_8,
5979 reference_9,
5980 reference_10,
5981 subledger_doc_sequence_id,
5982 subledger_doc_sequence_value,
5983 gl_sl_link_id,
5984 gl_sl_link_table
5985 ) values (
5986 je_batch_id2, -- je_batch_id
5987 je_header_id2, -- je_header_id
5988 je_line_num2, -- je_line_num
5989 sysdate, -- last_update_date
5990 c_fnd_user, -- last_updated_by
5991 sysdate, -- creation_date
5992 c_fnd_user, -- created_by
5993 c_upgrade_bugno, -- last_update_login
5994 to_char(transaction_header_id),
5995 -- reference_1
5996 to_char(asset_id), -- reference_2
5997 to_char(distribution_id), -- reference_3
5998 to_char(adj_line_id), -- reference_4
5999 book_type_code, -- reference_5
6000 to_char(period_counter), -- reference_6
6001 null, -- reference_7
6002 null, -- reference_8
6003 null, -- reference_9
6004 null, -- reference_10
6005 null, -- subledger_doc_seq_id
6006 null, -- subledger_doc_seq_value
6007 xla_gl_sl_link_id_s.currval, -- gl_sl_link_id
6008 'XLAJEL' -- gl_sl_link_table
6009 )
6010 when (adj_row = 3) then
6011 into xla_ae_lines (
6012 upg_batch_id,
6013 ae_header_id,
6014 ae_line_num,
6015 displayed_line_number,
6016 application_id,
6017 code_combination_id,
6018 gl_transfer_mode_code,
6019 accounted_dr,
6020 accounted_cr,
6021 currency_code,
6022 currency_conversion_date,
6023 currency_conversion_rate,
6024 currency_conversion_type,
6025 entered_dr,
6026 entered_cr,
6027 description,
6028 accounting_class_code,
6029 gl_sl_link_id,
6030 gl_sl_link_table,
6031 party_type_code,
6032 party_id,
6033 party_site_id,
6034 statistical_amount,
6035 ussgl_transaction_code,
6036 jgzz_recon_ref,
6037 control_balance_flag,
6038 analytical_balance_flag,
6039 upg_tax_reference_id1,
6040 upg_tax_reference_id2,
6041 upg_tax_reference_id3,
6042 creation_date,
6043 created_by,
6044 last_update_date,
6045 last_updated_by,
6046 last_update_login,
6047 program_update_date,
6048 program_id,
6049 program_application_id,
6050 request_id,
6051 gain_or_loss_flag,
6052 accounting_date,
6053 ledger_id
6054 ) values (
6055 l_upg_batch_id, -- upg_batch_id
6056 ae_header_id, -- ae_header_id
6057 ae_line_num, -- ae_line_num
6058 ae_line_num, -- displayed_line_num
6059 c_application_id, -- application_id
6060 ccid3, -- code_combination_id
6061 'S', -- gl_transfer_mode_code
6062 -- Fix for Bug #5131737. Need to switch CR/DR for pseudo-row
6063 credit_amount, -- accounted_dr
6064 debit_amount, -- accounted_cr
6065 currency_code, -- currency_code
6066 null, -- currency_conversion_date
6067 null, -- currency_conversion_rate
6068 null, -- currency_conversion_type
6069 credit_amount, -- entered_dr
6070 debit_amount, -- entered_cr
6071 l_bonus_deprn_rsv_desc || ' - ' ||
6072 to_char(cal_period_close_date, 'DD-MON-RR'),
6073 -- description
6074 'ASSET', -- accounting_class_code
6075 xla_gl_sl_link_id_s.nextval, -- gl_sl_link_id
6076 'XLAJEL', -- gl_sl_link_table
6077 null, -- party_type_code
6078 null, -- party_id
6079 null, -- party_site_id
6080 null, -- statistical_amount
6081 null, -- ussgl_transaction_code
6082 null, -- glzz_recon_ref
6083 null, -- control_balance_flag
6084 null, -- analytical_balance_flag
6085 null, -- upg_tax_reference_id1
6086 null, -- upg_tax_reference_id2
6087 null, -- upg_tax_reference_id3
6088 sysdate, -- creation_date
6089 c_fnd_user, -- created_by
6090 sysdate, -- last_update_date
6091 c_fnd_user, -- last_updated_by
6092 c_upgrade_bugno, -- last_update_login
6093 null, -- program_update_date
6094 null, -- program_id
6095 c_application_id, -- program_application_id
6096 null, -- request_id
6097 'N', -- gain_or_loss_flag
6098 cal_period_close_date, -- accounting_date
6099 set_of_books_id -- ledger_id
6100 )
6101 when (adj_row = 3) then
6102 into xla_distribution_links (
6103 upg_batch_id,
6104 application_id,
6105 event_id,
6106 ae_header_id,
6107 ae_line_num,
6108 accounting_line_code,
6109 accounting_line_type_code,
6110 source_distribution_type,
6111 source_distribution_id_char_1,
6112 source_distribution_id_char_2,
6113 source_distribution_id_char_3,
6114 source_distribution_id_char_4,
6115 source_distribution_id_char_5,
6116 source_distribution_id_num_1,
6117 source_distribution_id_num_2,
6118 source_distribution_id_num_3,
6119 source_distribution_id_num_4,
6120 source_distribution_id_num_5,
6121 merge_duplicate_code,
6122 statistical_amount,
6123 unrounded_entered_dr,
6124 unrounded_entered_cr,
6125 unrounded_accounted_dr,
6126 unrounded_accounted_cr,
6127 ref_ae_header_id,
6128 ref_temp_line_num,
6129 ref_event_id,
6130 temp_line_num,
6131 tax_line_ref_id,
6132 tax_summary_line_ref_id,
6133 tax_rec_nrec_dist_ref_id,
6134 line_definition_owner_code,
6135 line_definition_code,
6136 event_class_code,
6137 event_type_code
6138 ) values (
6139 l_upg_batch_id, -- upg_batch_id
6140 c_application_id, -- application_id
6141 event_id, -- event_id
6142 ae_header_id, -- ae_header_id
6143 ae_line_num, -- ae_line_num
6144 null, -- accounting_line_code
6145 'S', -- accounting_line_type_code
6146 'TRX', -- source_distribution_type
6147 null, -- source_distribution_id_char_1
6148 null, -- source_distribution_id_char_2
6149 null, -- source_distribution_id_char_3
6150 null, -- source_distribution_id_char_4
6151 null, -- source_distribution_id_char_5
6152 transaction_header_id, -- source_distribution_id_num_1
6153 adj_line_id, -- source_distribution_id_num_2
6154 null, -- source_distribution_id_num_3
6155 null, -- source_distribution_id_num_4
6156 null, -- source_distribution_id_num_5
6157 'N', -- merge_duplicate_code
6158 null, -- statistical_amount
6159 -- Fix for Bug #5131737. Need to switch CR/DR for pseudo-row
6160 credit_amount, -- unrounded_entered_dr
6161 debit_amount, -- unrounded_entered_cr
6162 credit_amount, -- unrounded_accounted_dr
6163 debit_amount, -- unrounded_accounted_cr
6164 ae_header_id, -- ref_ae_header_id
6165 null, -- ref_temp_line_num
6166 null, -- ref_event_id
6167 ae_line_num, -- temp_line_num
6168 null, -- tax_line_ref_id
6169 null, -- tax_summary_line_ref_id
6170 null, -- tax_rec_nrec_dist_ref_id
6171 null, -- line_definition_owner_code
6172 null, -- line_definition_code
6173 event_class_code, -- event_class_code
6174 event_type_code -- event_type_code
6175 )
6176 when (adj_row = 3) and (je_batch_id3 is not null) then
6177 into gl_import_references (
6178 je_batch_id,
6179 je_header_id,
6180 je_line_num,
6181 last_update_date,
6182 last_updated_by,
6183 creation_date,
6184 created_by,
6185 last_update_login,
6186 reference_1,
6187 reference_2,
6188 reference_3,
6189 reference_4,
6190 reference_5,
6191 reference_6,
6192 reference_7,
6193 reference_8,
6194 reference_9,
6195 reference_10,
6196 subledger_doc_sequence_id,
6197 subledger_doc_sequence_value,
6198 gl_sl_link_id,
6199 gl_sl_link_table
6200 ) values (
6201 je_batch_id3, -- je_batch_id
6202 je_header_id3, -- je_header_id
6203 je_line_num3, -- je_line_num
6204 sysdate, -- last_update_date
6205 c_fnd_user, -- last_updated_by
6206 sysdate, -- creation_date
6207 c_fnd_user, -- created_by
6208 c_upgrade_bugno, -- last_update_login
6209 to_char(transaction_header_id),
6210 -- reference_1
6211 to_char(asset_id), -- reference_2
6212 to_char(distribution_id), -- reference_3
6213 to_char(adj_line_id), -- reference_4
6214 book_type_code, -- reference_5
6215 to_char(period_counter), -- reference_6
6216 null, -- reference_7
6217 null, -- reference_8
6218 null, -- reference_9
6219 null, -- reference_10
6220 null, -- subledger_doc_seq_id
6221 null, -- subledger_doc_seq_value
6222 xla_gl_sl_link_id_s.currval, -- gl_sl_link_id
6223 'XLAJEL' -- gl_sl_link_table
6224 )
6225 select /*+ ordered index(adj, FA_MC_ADJUSTMENTS_U1) use_nl(cb) index(cb, fa_category_books_u1) */
6226 adj.adjustment_line_id adj_line_id,
6227 decode(adj.debit_credit_flag,
6228 'DR', adj.adjustment_amount, null) debit_amount,
6229 decode(adj.debit_credit_flag,
6230 'CR', adj.adjustment_amount, null) credit_amount,
6231 adj.code_combination_id ccid1,
6232 nvl(nvl(gljl2.code_combination_id,
6233 da.deprn_reserve_account_ccid),
6234 cb.reserve_account_ccid) ccid2,
6235 nvl(nvl(gljl3.code_combination_id,
6236 da.deprn_reserve_account_ccid),
6237 cb.reserve_account_ccid) ccid3,
6238 glsob.currency_code currency_code,
6239 decode (adj.adjustment_type,
6240 'BONUS EXPENSE', 'EXPENSE',
6241 'BONUS RESERVE', 'ASSET',
6242 'CIP COST', 'ASSET',
6243 'COST', 'ASSET',
6244 'COST CLEARING', 'ASSET',
6245 'DEPRN ADJUST', 'EXPENSE',
6246 'EXPENSE', 'EXPENSE',
6247 'GRP COR RESERVE', 'ASSET',
6248 'GRP PRC RESERVE', 'ASSET',
6249 'INTERCO AP', 'LIABILITY',
6250 'INTERCO AR', 'ASSET',
6251 'NBV RETIRED', 'ASSET',
6252 'PROCEEDS', 'ASSET',
6253 'PROCEEDS CLR', 'ASSET',
6254 'REMOVALCOST', 'ASSET',
6255 'REMOVALCOST CLR', 'ASSET',
6256 'RESERVE', 'ASSET',
6257 'REVAL RESERVE', 'ASSET',
6258 'REVAL RSV RET', 'ASSET',
6259 'REVAL AMORT', 'EXPENSE',
6260 'REVAL EXPENSE', 'EXPENSE',
6261 'ASSET') accounting_class_code,
6262 lk.description line_desc1,
6263 lk2.description line_desc2,
6264 decode(adj.je_header_id, null, 'N', 'Y') gl_transfer_status_code,
6265 gljh.je_batch_id je_batch_id1,
6266 gljh2.je_batch_id je_batch_id2,
6267 gljh2.je_batch_id je_batch_id3,
6268 adj.je_header_id je_header_id1,
6269 dd.je_header_id je_header_id2,
6270 dd.je_header_id je_header_id3,
6271 nvl(adj.je_line_num, 0) je_line_num1,
6272 nvl(dd.deprn_reserve_je_line_num,
6273 nvl(adj.je_line_num, 0)) je_line_num2,
6274 nvl(dd.bonus_deprn_rsv_je_line_num,
6275 nvl(adj.je_line_num, 0)) je_line_num3,
6276 adj.distribution_id distribution_id,
6277 ev.event_id event_id,
6278 he.ae_header_id ae_header_id,
6279 ev.calendar_period_close_date cal_period_close_date,
6280 ev.transaction_header_id transaction_header_id,
6281 ev.event_type_code event_type_code,
6282 ev.event_class_code event_class_code,
6283 ev.asset_id asset_id,
6284 ev.book_type_code book_type_code,
6285 he.set_of_books_id set_of_books_id,
6286 ev.period_counter period_counter,
6287 adj.source_type_code source_type_code,
6288 adj.adjustment_type adjustment_type,
6289 row_number() over
6290 (partition by ev.transaction_header_id,
6291 adj.set_of_books_id
6292 order by adj.adjustment_line_id, mult.adj_row) ae_line_num,
6293 mult.adj_row adj_row
6294 from
6295 fa_xla_upg_events_gt ev,
6296 fa_xla_upg_headers_gt he,
6297 fa_mc_adjustments adj,
6298 fa_lookups_tl lk,
6299 fa_lookups_tl lk2,
6300 gl_je_headers gljh,
6301 fa_mc_deprn_detail dd,
6302 gl_je_headers gljh2,
6303 gl_je_lines gljl2,
6304 gl_je_lines gljl3,
6305 fa_mc_book_controls bc,
6306 gl_sets_of_books glsob,
6307 fa_distribution_accounts da,
6308 fa_asset_history ah,
6309 fa_category_books cb,
6310 (select 1 adj_row from dual
6311 union all
6312 select 2 adj_row from dual
6313 union all
6314 select 3 adj_row from dual) mult
6315 where ev.event_id = he.event_id
6316 and bc.book_type_code = ev.book_type_code
6317 and bc.set_of_books_id = glsob.set_of_books_id
6318 and bc.book_type_code = adj.book_type_code
6319 and bc.enabled_flag = 'Y'
6320 and he.set_of_books_id = bc.set_of_books_id
6321 and adj.set_of_books_id = bc.set_of_books_id
6322 and adj.asset_id = ev.asset_id
6323 and adj.book_type_code = ev.book_type_code
6324 and adj.period_counter_created = ev.period_counter
6325 and adj.transaction_header_id = ev.transaction_header_id
6326 and adj.code_combination_id is not null
6327 and nvl(adj.track_member_flag, 'N') = 'N'
6328 and lk.lookup_type = 'JOURNAL ENTRIES'
6329 and lk.lookup_code = decode (adj.adjustment_type,
6330 'BONUS EXPENSE', 'BONUS DEPRECIATION EXPENSE',
6331 'BONUS RESERVE', 'BONUS DEPRECIATION RESERVE',
6332 'CIP COST', adj.source_type_code ||' COST',
6333 adj.source_type_code ||' '|| adj.adjustment_type)
6334 and lk2.lookup_type = 'JOURNAL ENTRIES'
6335 and lk2.lookup_code = decode(adj.adjustment_type,
6336 'EXPENSE', adj.source_type_code ||' RESERVE',
6337 'BONUS EXPENSE', 'BONUS DEPRECIATION RESERVE',
6338 'BONUS RESERVE', 'BONUS DEPRECIATION RESERVE',
6339 'CIP COST', adj.source_type_code ||' COST',
6340 adj.source_type_code ||' '||adj.adjustment_type)
6341 and userenv('LANG') = lk.language
6342 and userenv('LANG') = lk2.language
6343 and adj.je_header_id = gljh.je_header_id (+)
6344 and adj.asset_id = dd.asset_id (+)
6345 and adj.book_type_code = dd.book_type_code (+)
6346 and adj.distribution_id = dd.distribution_id (+)
6347 and adj.period_counter_created = dd.period_counter (+)
6348 and adj.set_of_books_id = dd.set_of_books_id (+)
6349 and dd.je_header_id = gljl2.je_header_id (+)
6350 and dd.deprn_reserve_je_line_num = gljl2.je_line_num (+)
6351 and dd.je_header_id = gljh2.je_header_id (+)
6352 and dd.je_header_id = gljl3.je_header_id (+)
6353 and dd.bonus_deprn_rsv_je_line_num = gljl3.je_line_num (+)
6354 and adj.book_type_code = da.book_type_code (+)
6355 and adj.distribution_id = da.distribution_id (+)
6356 and ev.asset_id = ah.asset_id
6357 and ev.date_effective >= ah.date_effective
6358 and ev.date_effective < nvl(ah.date_ineffective, sysdate+1)
6359 and ah.category_id = cb.category_id
6360 and bc.book_type_code = cb.book_type_code
6361 and ((mult.adj_row = 1)
6362 or ((mult.adj_row = 2) and
6363 (adjustment_type = 'EXPENSE') and
6364 (source_type_code in
6365 ('DEPRECIATION', 'CIP RETIREMENT', 'RETIREMENT')))
6366 or ((mult.adj_row = 3) and
6367 (adjustment_type = 'BONUS EXPENSE') and
6368 (source_type_code = 'DEPRECIATION')));
6369
6370 end if;
6371
6372 commit;
6373
6374 EXCEPTION
6375 WHEN OTHERS THEN
6376 rollback;
6377 raise;
6378
6379 End Upgrade_Trxn_Events;
6380
6381 Procedure Upgrade_Deprn_Events (
6382 p_mode IN varchar,
6383 p_start_rowid IN rowid,
6384 p_end_rowid IN rowid,
6385 p_batch_size IN number,
6386 x_success_count OUT NOCOPY number,
6387 x_failure_count OUT NOCOPY number,
6388 x_return_status OUT NOCOPY number
6389 ) IS
6390
6391 c_application_id constant number(15) := 140;
6392 c_upgrade_bugno constant number(15) := -4107161;
6393 c_fnd_user constant number(15) := 2;
6394
6395
6396 c_entity_code constant varchar2(30) := 'DEPRECIATION';
6397 c_amb_context_code constant varchar2(30) := 'DEFAULT';
6398
6399 -- this value can be altered in order to process more of less per batch
6400 l_batch_size NUMBER;
6401
6402 l_rows_processed NUMBER;
6403 l_deprn_rows_processed NUMBER;
6404
6405 -- type for table variable
6406 type num_tbl_type is table of number index by binary_integer;
6407 type char_tbl_type is table of varchar2(150) index by binary_integer;
6408 type date_tbl_type is table of date index by binary_integer;
6409 type rowid_tbl_type is table of rowid index by binary_integer;
6410
6411 l_upg_batch_id number;
6412 l_mc_books number;
6413
6414 l_de_description varchar2(80);
6415 l_dr_description varchar2(80);
6416 l_be_description varchar2(80);
6417 l_br_description varchar2(80);
6418 l_ra_description varchar2(80);
6419 l_rr_description varchar2(80);
6420
6421 l_event_id_tbl num_tbl_type;
6422 l_asset_id_tbl num_tbl_type;
6423 l_book_type_code_tbl char_tbl_type;
6424 l_period_counter_tbl num_tbl_type;
6425
6426 l_err_entity_id_tbl num_tbl_type;
6427 l_err_event_id_tbl num_tbl_type;
6428 l_err_ae_header_id_tbl num_tbl_type;
6429 l_err_ae_line_num_tbl num_tbl_type;
6430 l_err_temp_line_num_tbl num_tbl_type;
6431 l_error_message_name_tbl char_tbl_type;
6432
6433 BEGIN
6434
6435 x_success_count := 0;
6436 x_failure_count := 0;
6437
6438 l_batch_size := nvl(nvl(p_batch_size, fa_cache_pkg.fa_batch_size), 1000);
6439
6440 -- Select upg_batch_id
6441 select xla_upg_batches_s.nextval
6442 into l_upg_batch_id
6443 from dual;
6444
6445 select lk_de.description
6446 into l_de_description
6447 from fa_lookups_tl lk_de
6448 where lk_de.lookup_type = 'JOURNAL ENTRIES'
6449 and lk_de.lookup_code = 'DEPRECIATION EXPENSE'
6450 and userenv('LANG') = lk_de.language;
6451
6452 select lk_dr.description
6453 into l_dr_description
6454 from fa_lookups_tl lk_dr
6455 where lk_dr.lookup_type = 'JOURNAL ENTRIES'
6456 and lk_dr.lookup_code = 'DEPRECIATION RESERVE'
6457 and userenv('LANG') = lk_dr.language;
6458
6459 select lk_be.description
6460 into l_be_description
6461 from fa_lookups_tl lk_be
6462 where lk_be.lookup_type = 'JOURNAL ENTRIES'
6463 and lk_be.lookup_code = 'BONUS DEPRECIATION EXPENSE'
6464 and userenv('LANG') = lk_be.language;
6465
6466 select lk_br.description
6467 into l_br_description
6468 from fa_lookups_tl lk_br
6469 where lk_br.lookup_type = 'JOURNAL ENTRIES'
6470 and lk_br.lookup_code = 'BONUS DEPRECIATION RESERVE'
6471 and userenv('LANG') = lk_br.language;
6472
6473 select lk_ra.description
6474 into l_ra_description
6475 from fa_lookups_tl lk_ra
6476 where lk_ra.lookup_type = 'JOURNAL ENTRIES'
6477 and lk_ra.lookup_code = 'DEPRECIATION REVAL AMORT'
6478 and userenv('LANG') = lk_ra.language;
6479
6480 select lk_rr.description
6481 into l_rr_description
6482 from fa_lookups_tl lk_rr
6483 where lk_rr.lookup_type = 'JOURNAL ENTRIES'
6484 and lk_rr.lookup_code = 'DEPRECIATION REVAL RESERVE'
6485 and userenv('LANG') = lk_rr.language;
6486
6487 select count(*)
6488 into l_mc_books
6489 from fa_mc_book_controls
6490 where enabled_flag = 'Y'
6491 and rownum = 1;
6492
6493 if (p_mode = 'downtime') then
6494
6495 insert all
6496 when 1 = 1 then
6497 into fa_xla_upg_events_gt (
6498 event_id,
6499 entity_id,
6500 set_of_books_id,
6501 period_name,
6502 calendar_period_close_date,
6503 je_category_name,
6504 event_type_code,
6505 event_class_code,
6506 ds_asset_id,
6507 ds_book_type_code,
6508 ds_period_counter,
6509 reserve_acct_ccid,
6510 bonus_reserve_acct_ccid,
6511 reval_amort_acct_ccid,
6512 reval_reserve_acct_ccid
6513 ) values (
6514 xla_events_s.nextval,
6515 xla_transaction_entities_s.nextval,
6516 set_of_books_id,
6517 period_name,
6518 calendar_period_close_date,
6519 je_category_name,
6520 event_type_code,
6521 event_class_code,
6522 asset_id,
6523 book_type_code,
6524 period_counter,
6525 default_rsv_ccid,
6526 default_bonus_rsv_ccid,
6527 default_reval_amort_ccid,
6528 default_reval_rsv_ccid
6529 )
6530 when 1 = 1 then
6531 into fa_deprn_events (
6532 asset_id,
6533 book_type_code,
6534 period_counter,
6535 deprn_run_date,
6536 deprn_run_id,
6537 event_id,
6538 reversal_event_id,
6539 reversal_date,
6540 creation_date,
6541 created_by,
6542 last_update_date,
6543 last_updated_by,
6544 last_update_login
6545 ) values (
6546 asset_id,
6547 book_type_code,
6548 period_counter,
6549 transaction_date_entered,
6550 1,
6551 xla_events_s.currval,
6552 null,
6553 null,
6554 sysdate,
6555 c_upgrade_bugno,
6556 sysdate,
6557 c_upgrade_bugno,
6558 c_upgrade_bugno
6559 )
6560 when 1 = 1 then
6561 into xla_transaction_entities_upg (
6562 upg_batch_id,
6563 application_id,
6564 ledger_id,
6565 legal_entity_id,
6566 entity_code,
6567 source_id_int_1,
6568 source_id_int_2,
6569 source_id_int_3,
6570 source_id_int_4,
6571 source_id_char_1,
6572 source_id_char_2,
6573 source_id_char_3,
6574 source_id_char_4,
6575 security_id_int_1,
6576 security_id_int_2,
6577 security_id_int_3,
6578 security_id_char_1,
6579 security_id_char_2,
6580 security_id_char_3,
6581 transaction_number,
6582 valuation_method,
6583 source_application_id,
6584 creation_date,
6585 created_by,
6586 last_update_date,
6587 last_updated_by,
6588 last_update_login,
6589 entity_id,
6590 upg_source_application_id
6591 ) values (
6592 l_upg_batch_id, -- upg_batch_id
6593 c_application_id, -- application_id
6594 set_of_books_id, -- ledger_id
6595 null, -- legal_entity_id
6596 c_entity_code, -- entity_code
6597 asset_id, -- source_id_int_1
6598 period_counter, -- source_id_int_2
6599 1, -- source_id_int_3
6600 null, -- source_id_int_4
6601 book_type_code, -- source_id_char_1
6602 null, -- source_id_char_2
6603 null, -- source_id_char_3
6604 null, -- source_id_char_4
6605 null, -- security_id_int_1
6606 null, -- security_id_int_2
6607 null, -- security_id_int_3
6608 null, -- security_id_char_1
6609 null, -- security_id_char_2
6610 null, -- security_id_char_3
6611 set_of_books_id, -- transaction_number
6612 book_type_code, -- valuation_method
6613 c_application_id, -- source_application_id
6614 sysdate, -- creation_date
6615 c_fnd_user, -- created_by
6616 sysdate, -- last_update_date
6617 c_fnd_user, -- last_updated_by
6618 c_upgrade_bugno, -- last_update_login
6619 xla_transaction_entities_s.currval,
6620 -- entity_id
6621 c_application_id -- upg_source_application_id
6622 )
6623 when 1 = 1 then
6624 into xla_events (
6625 upg_batch_id,
6626 application_id,
6627 event_type_code,
6628 event_number,
6629 event_status_code,
6630 process_status_code,
6631 on_hold_flag,
6632 event_date,
6633 creation_date,
6634 created_by,
6635 last_update_date,
6636 last_updated_by,
6637 last_update_login,
6638 program_update_date,
6639 program_id,
6640 program_application_id,
6641 request_id,
6642 entity_id,
6643 event_id,
6644 upg_source_application_id,
6645 transaction_date
6646 ) values (
6647 l_upg_batch_id, -- upg_batch_id
6648 c_application_id, -- application_id
6649 event_type_code, -- event_type_code
6650 1, -- event_number
6651 'P', -- event_status_code
6652 'P', -- process_status_code
6653 'N', -- on_hold_flag
6654 transaction_date_entered,
6655 -- event_date
6656 sysdate, -- creation_date
6657 c_fnd_user, -- created_by
6658 sysdate, -- last_update_date
6659 c_fnd_user, -- last_updated_by
6660 c_upgrade_bugno, -- last_update_login
6661 null, -- program_update_date
6662 null, -- program_id
6663 null, -- program_application_id
6664 null, -- request_id
6665 xla_transaction_entities_s.currval,
6666 -- entity_id
6667 xla_events_s.currval, -- event_id
6668 c_application_id, -- upg_source_application_id
6669 transaction_date_entered
6670 -- transaction_date
6671 )
6672 when 1 = 1 then
6673 into fa_xla_upg_headers_gt (
6674 ae_header_id,
6675 event_id,
6676 set_of_books_id
6677 ) values (
6678 xla_ae_headers_s.nextval,
6679 xla_events_s.currval,
6680 set_of_books_id
6681 )
6682 when 1 = 1 then
6683 into xla_ae_headers (
6684 upg_batch_id,
6685 application_id,
6686 amb_context_code,
6687 entity_id,
6688 event_id,
6689 event_type_code,
6690 ae_header_id,
6691 ledger_id,
6692 accounting_date,
6693 period_name,
6694 reference_date,
6695 balance_type_code,
6696 je_category_name,
6697 gl_transfer_status_code,
6698 gl_transfer_date,
6699 accounting_entry_status_code,
6700 accounting_entry_type_code,
6701 description,
6702 budget_version_id,
6703 funds_status_code,
6704 encumbrance_type_id,
6705 completed_date,
6706 doc_sequence_id,
6707 doc_sequence_value,
6708 doc_category_code,
6709 packet_id,
6710 group_id,
6711 creation_date,
6712 created_by,
6713 last_update_date,
6714 last_updated_by,
6715 last_update_login,
6716 program_id,
6717 program_application_id,
6718 program_update_date,
6719 request_id,
6720 close_acct_seq_assign_id,
6721 close_acct_seq_version_id,
6722 close_acct_seq_value,
6723 completion_acct_seq_assign_id,
6724 completion_acct_seq_version_id,
6725 completion_acct_seq_value,
6726 accounting_batch_id,
6727 product_rule_type_code,
6728 product_rule_code,
6729 product_rule_version,
6730 upg_source_application_id,
6731 upg_valid_flag
6732 ) values (
6733 l_upg_batch_id, -- upg_batch_id
6734 c_application_id, -- application_id
6735 c_amb_context_code, -- amb_context_code
6736 xla_transaction_entities_s.currval,
6737 -- entity_id
6738 xla_events_s.currval, -- event_id
6739 event_type_code, -- event_type_code
6740 xla_ae_headers_s.currval, -- ae_header_id
6741 set_of_books_id, -- ledger_id
6742 calendar_period_close_date, -- accounting_date
6743 period_name, -- period_name
6744 null, -- reference_date
6745 'A', -- balance_type_code
6746 je_category_name, -- je_category_name
6747 'Y', -- gl_transfer_status_code
6748 null, -- gl_transfer_date
6749 'F', -- accounting_entry_status_code
6750 'STANDARD', -- accounting_entry_type_code
6751 'Depreciation - ' ||
6752 to_char(calendar_period_close_date, 'DD-MON-RR'),
6753 -- description
6754 null, -- budget_version_id
6755 null, -- funds_status_code
6756 null, -- encumbrance_type_id
6757 null, -- completed_date
6758 null, -- doc_sequence_id
6759 null, -- doc_sequence_value
6760 null, -- doc_category_code
6761 null, -- packet_id
6762 null, -- group_id
6763 sysdate, -- creation_date
6764 c_fnd_user, -- created_by
6765 sysdate, -- last_update_date
6766 c_fnd_user, -- last_updated_by
6767 c_upgrade_bugno, -- last_update_login
6768 null, -- program_id
6769 c_application_id, -- program_application_id
6770 sysdate, -- program_update_date
6771 null, -- request_id
6772 null, -- close_acct_seq_assign_id
6773 null, -- close_acct_seq_version_id
6774 null, -- close_acct_seq_value
6775 null, -- completion_acct_seq_assign_id
6776 null, -- completion_acct_seq_version_id
6777 null, -- completion_acct_seq_value
6778 null, -- accounting_batch_id
6779 null, -- product_rule_type_code
6780 null, -- product_rule_code
6781 null, -- product_rule_version
6782 c_application_id, -- upg_source_application_id
6783 null -- upg_valid_flag
6784 )
6785 select /*+ ordered leading(dp) index(dp fa_deprn_periods_u3) rowid(ds) index(ah fa_asset_history_n2) */
6786 ds.asset_id asset_id,
6787 ds.book_type_code book_type_code,
6788 bc.set_of_books_id set_of_books_id,
6789 ds.deprn_run_date transaction_date_entered,
6790 'DEPRECIATION' event_type_code,
6791 'DEPRECIATION' event_class_code,
6792 dp.period_name period_name,
6793 dp.period_counter period_counter,
6794 dp.calendar_period_close_date
6795 calendar_period_close_date,
6796 nvl(cb.reserve_account_ccid, -1)
6797 default_rsv_ccid,
6798 nvl(cb.bonus_reserve_acct_ccid, -1)
6799 default_bonus_rsv_ccid,
6800 nvl(cb.reval_amort_account_ccid, -1)
6801 default_reval_amort_ccid,
6802 nvl(cb.reval_reserve_account_ccid, -1)
6803 default_reval_rsv_ccid,
6804 nvl(bc.je_depreciation_category, 'OTHER')
6805 je_category_name
6806 from fa_deprn_summary ds,
6807 fa_book_controls bc,
6808 gl_sets_of_books glsob,
6809 fa_deprn_periods dp,
6810 fa_asset_history ah,
6811 fa_category_books cb
6812 where ds.rowid between p_start_rowid and p_end_rowid
6813 and ds.book_type_code = bc.book_type_code
6814 and bc.set_of_books_id = glsob.set_of_books_id
6815 and dp.book_type_code = ds.book_type_code
6816 and dp.period_counter = ds.period_counter
6817 and dp.period_close_date is null
6818 and ds.event_id is null
6819 and ds.deprn_source_code <> 'TRACK'
6820 and ds.asset_id = ah.asset_id
6821 and nvl(dp.period_close_date, sysdate) >= ah.date_effective
6822 and nvl(dp.period_close_date, sysdate) <
6823 nvl(ah.date_ineffective, sysdate+1)
6824 and ah.category_id = cb.category_id
6825 and bc.book_type_code = cb.book_type_code;
6826
6827 else
6828
6829 insert all
6830 when 1 = 1 then
6831 into fa_xla_upg_events_gt (
6832 event_id,
6833 entity_id,
6834 set_of_books_id,
6835 period_name,
6836 calendar_period_close_date,
6837 je_category_name,
6838 event_type_code,
6839 event_class_code,
6840 ds_asset_id,
6841 ds_book_type_code,
6842 ds_period_counter,
6843 reserve_acct_ccid,
6844 bonus_reserve_acct_ccid,
6845 reval_amort_acct_ccid,
6846 reval_reserve_acct_ccid
6847 ) values (
6848 xla_events_s.nextval,
6849 xla_transaction_entities_s.nextval,
6850 set_of_books_id,
6851 period_name,
6852 calendar_period_close_date,
6853 je_category_name,
6854 event_type_code,
6855 event_class_code,
6856 asset_id,
6857 book_type_code,
6858 period_counter,
6859 default_rsv_ccid,
6860 default_bonus_rsv_ccid,
6861 default_reval_amort_ccid,
6862 default_reval_rsv_ccid
6863 )
6864 when 1 = 1 then
6865 into fa_deprn_events (
6866 asset_id,
6867 book_type_code,
6868 period_counter,
6869 deprn_run_date,
6870 deprn_run_id,
6871 event_id,
6872 reversal_event_id,
6873 reversal_date,
6874 creation_date,
6875 created_by,
6876 last_update_date,
6877 last_updated_by,
6878 last_update_login
6879 ) values (
6880 asset_id,
6881 book_type_code,
6882 period_counter,
6883 transaction_date_entered,
6884 1,
6885 xla_events_s.currval,
6886 null,
6887 null,
6888 sysdate,
6889 c_upgrade_bugno,
6890 sysdate,
6891 c_upgrade_bugno,
6892 c_upgrade_bugno
6893 )
6894 when 1 = 1 then
6895 into xla_transaction_entities_upg (
6896 upg_batch_id,
6897 application_id,
6898 ledger_id,
6899 legal_entity_id,
6900 entity_code,
6901 source_id_int_1,
6902 source_id_int_2,
6903 source_id_int_3,
6904 source_id_int_4,
6905 source_id_char_1,
6906 source_id_char_2,
6907 source_id_char_3,
6908 source_id_char_4,
6909 security_id_int_1,
6910 security_id_int_2,
6911 security_id_int_3,
6912 security_id_char_1,
6913 security_id_char_2,
6914 security_id_char_3,
6915 transaction_number,
6916 valuation_method,
6917 source_application_id,
6918 creation_date,
6919 created_by,
6920 last_update_date,
6921 last_updated_by,
6922 last_update_login,
6923 entity_id,
6924 upg_source_application_id
6925 ) values (
6926 l_upg_batch_id, -- upg_batch_id
6927 c_application_id, -- application_id
6928 set_of_books_id, -- ledger_id
6929 null, -- legal_entity_id
6930 c_entity_code, -- entity_code
6931 asset_id, -- source_id_int_1
6932 period_counter, -- source_id_int_2
6933 1, -- source_id_int_3
6934 null, -- source_id_int_4
6935 book_type_code, -- source_id_char_1
6936 null, -- source_id_char_2
6937 null, -- source_id_char_3
6938 null, -- source_id_char_4
6939 null, -- security_id_int_1
6940 null, -- security_id_int_2
6941 null, -- security_id_int_3
6942 null, -- security_id_char_1
6943 null, -- security_id_char_2
6944 null, -- security_id_char_3
6945 set_of_books_id, -- transaction_number
6946 book_type_code, -- valuation_method
6947 c_application_id, -- source_application_id
6948 sysdate, -- creation_date
6949 c_fnd_user, -- created_by
6950 sysdate, -- last_update_date
6951 c_fnd_user, -- last_updated_by
6952 c_upgrade_bugno, -- last_update_login
6953 xla_transaction_entities_s.currval,
6954 -- entity_id
6955 c_application_id -- upg_source_application_id
6956 )
6957 when 1 = 1 then
6958 into xla_events (
6959 upg_batch_id,
6960 application_id,
6961 event_type_code,
6962 event_number,
6963 event_status_code,
6964 process_status_code,
6965 on_hold_flag,
6966 event_date,
6967 creation_date,
6968 created_by,
6969 last_update_date,
6970 last_updated_by,
6971 last_update_login,
6972 program_update_date,
6973 program_id,
6974 program_application_id,
6975 request_id,
6976 entity_id,
6977 event_id,
6978 upg_source_application_id,
6979 transaction_date
6980 ) values (
6981 l_upg_batch_id, -- upg_batch_id
6982 c_application_id, -- application_id
6983 event_type_code, -- event_type_code
6984 1, -- event_number
6985 'P', -- event_status_code
6986 'P', -- process_status_code
6987 'N', -- on_hold_flag
6988 transaction_date_entered,
6989 -- event_date
6990 sysdate, -- creation_date
6991 c_fnd_user, -- created_by
6992 sysdate, -- last_update_date
6993 c_fnd_user, -- last_updated_by
6994 c_upgrade_bugno, -- last_update_login
6995 null, -- program_update_date
6996 null, -- program_id
6997 null, -- program_application_id
6998 null, -- request_id
6999 xla_transaction_entities_s.currval,
7000 -- entity_id
7001 xla_events_s.currval, -- event_id
7002 c_application_id, -- upg_source_application_id
7003 transaction_date_entered
7004 -- transaction_date
7005 )
7006 when 1 = 1 then
7007 into fa_xla_upg_headers_gt (
7008 ae_header_id,
7009 event_id,
7010 set_of_books_id
7011 ) values (
7012 xla_ae_headers_s.nextval,
7013 xla_events_s.currval,
7014 set_of_books_id
7015 )
7016 when 1 = 1 then
7017 into xla_ae_headers (
7018 upg_batch_id,
7019 application_id,
7020 amb_context_code,
7021 entity_id,
7022 event_id,
7023 event_type_code,
7024 ae_header_id,
7025 ledger_id,
7026 accounting_date,
7027 period_name,
7028 reference_date,
7029 balance_type_code,
7030 je_category_name,
7031 gl_transfer_status_code,
7032 gl_transfer_date,
7033 accounting_entry_status_code,
7034 accounting_entry_type_code,
7035 description,
7036 budget_version_id,
7037 funds_status_code,
7038 encumbrance_type_id,
7039 completed_date,
7040 doc_sequence_id,
7041 doc_sequence_value,
7042 doc_category_code,
7043 packet_id,
7044 group_id,
7045 creation_date,
7046 created_by,
7047 last_update_date,
7048 last_updated_by,
7049 last_update_login,
7050 program_id,
7051 program_application_id,
7052 program_update_date,
7053 request_id,
7054 close_acct_seq_assign_id,
7055 close_acct_seq_version_id,
7056 close_acct_seq_value,
7057 completion_acct_seq_assign_id,
7058 completion_acct_seq_version_id,
7059 completion_acct_seq_value,
7060 accounting_batch_id,
7061 product_rule_type_code,
7062 product_rule_code,
7063 product_rule_version,
7064 upg_source_application_id,
7065 upg_valid_flag
7066 ) values (
7067 l_upg_batch_id, -- upg_batch_id
7068 c_application_id, -- application_id
7069 c_amb_context_code, -- amb_context_code
7070 xla_transaction_entities_s.currval,
7071 -- entity_id
7072 xla_events_s.currval, -- event_id
7073 event_type_code, -- event_type_code
7074 xla_ae_headers_s.currval, -- ae_header_id
7075 set_of_books_id, -- ledger_id
7076 calendar_period_close_date, -- accounting_date
7077 period_name, -- period_name
7078 null, -- reference_date
7079 'A', -- balance_type_code
7080 je_category_name, -- je_category_name
7081 'Y', -- gl_transfer_status_code
7082 null, -- gl_transfer_date
7083 'F', -- accounting_entry_status_code
7084 'STANDARD', -- accounting_entry_type_code
7085 'Depreciation - ' ||
7086 to_char(calendar_period_close_date, 'DD-MON-RR'),
7087 -- description
7088 null, -- budget_version_id
7089 null, -- funds_status_code
7090 null, -- encumbrance_type_id
7091 null, -- completed_date
7092 null, -- doc_sequence_id
7093 null, -- doc_sequence_value
7094 null, -- doc_category_code
7095 null, -- packet_id
7096 null, -- group_id
7097 sysdate, -- creation_date
7098 c_fnd_user, -- created_by
7099 sysdate, -- last_update_date
7100 c_fnd_user, -- last_updated_by
7101 c_upgrade_bugno, -- last_update_login
7102 null, -- program_id
7103 c_application_id, -- program_application_id
7104 sysdate, -- program_update_date
7105 null, -- request_id
7106 null, -- close_acct_seq_assign_id
7107 null, -- close_acct_seq_version_id
7108 null, -- close_acct_seq_value
7109 null, -- completion_acct_seq_assign_id
7110 null, -- completion_acct_seq_version_id
7111 null, -- completion_acct_seq_value
7112 null, -- accounting_batch_id
7113 null, -- product_rule_type_code
7114 null, -- product_rule_code
7115 null, -- product_rule_version
7116 c_application_id, -- upg_source_application_id
7117 null -- upg_valid_flag
7118 )
7119 select /*+ ordered leading(dp) index(dp fa_deprn_periods_u3) rowid(ds) index(ah fa_asset_history_n2) */
7120 ds.asset_id asset_id,
7121 ds.book_type_code book_type_code,
7122 bc.set_of_books_id set_of_books_id,
7123 ds.deprn_run_date transaction_date_entered,
7124 'DEPRECIATION' event_type_code,
7125 'DEPRECIATION' event_class_code,
7126 dp.period_name period_name,
7127 dp.period_counter period_counter,
7128 dp.calendar_period_close_date
7129 calendar_period_close_date,
7130 nvl(cb.reserve_account_ccid, -1)
7131 default_rsv_ccid,
7132 nvl(cb.bonus_reserve_acct_ccid, -1)
7133 default_bonus_rsv_ccid,
7134 nvl(cb.reval_amort_account_ccid, -1)
7135 default_reval_amort_ccid,
7136 nvl(cb.reval_reserve_account_ccid, -1)
7137 default_reval_rsv_ccid,
7138 nvl(bc.je_depreciation_category, 'OTHER')
7139 je_category_name
7140 from fa_deprn_summary ds,
7141 fa_book_controls bc,
7142 gl_sets_of_books glsob,
7143 fa_deprn_periods dp,
7144 fa_asset_history ah,
7145 fa_category_books cb,
7146 gl_period_statuses ps
7147 where ds.rowid between p_start_rowid and p_end_rowid
7148 and ds.book_type_code = bc.book_type_code
7149 and bc.set_of_books_id = glsob.set_of_books_id
7150 and dp.book_type_code = ds.book_type_code
7151 and dp.period_counter = ds.period_counter
7152 and dp.period_close_date is not null
7153 and ds.event_id is null
7154 and ds.deprn_source_code <> 'TRACK'
7155 and ds.asset_id = ah.asset_id
7156 and dp.period_close_date >= ah.date_effective
7157 and dp.period_close_date < nvl(ah.date_ineffective, sysdate+1)
7158 and ah.category_id = cb.category_id
7159 and bc.book_type_code = cb.book_type_code
7160 and ps.application_id = 101
7161 and ps.migration_status_code in ('P', 'U')
7162 and ps.set_of_books_id = bc.set_of_books_id
7163 and ps.period_name = dp.period_name
7164 and substr(dp.xla_conversion_status, 1, 1) in
7165 ('H','U','E','0','1','2','3','4','5','6','7','8','9')
7166 and dp.xla_conversion_status not in ('UD', 'UA')
7167 and dp.xla_conversion_status is not null;
7168
7169 end if;
7170
7171 -- Update fa_deprn_summary table with event_id
7172 update /*+ rowid(ds) */
7173 fa_deprn_summary ds
7174 set ds.event_id =
7175 ( select ev.event_id
7176 from fa_xla_upg_events_gt ev
7177 where ev.ds_asset_id = ds.asset_id
7178 and ev.ds_book_type_code = ds.book_type_code
7179 and ev.ds_period_counter = ds.period_counter
7180 ),
7181 ds.deprn_run_id = nvl(ds.deprn_run_id, 1)
7182 where ds.rowid between p_start_rowid and p_end_rowid
7183 and ds.event_id is null
7184 and ds.deprn_source_code <> 'TRACK'
7185 returning ds.event_id,
7186 ds.asset_id,
7187 ds.book_type_code,
7188 ds.period_counter
7189 bulk collect
7190 into l_event_id_tbl,
7191 l_asset_id_tbl,
7192 l_book_type_code_tbl,
7193 l_period_counter_tbl;
7194
7195 if (l_mc_books > 0) then
7196 FORALL l_count IN 1..l_event_id_tbl.count
7197 update fa_mc_deprn_summary
7198 set event_id = l_event_id_tbl(l_count),
7199 deprn_run_id = nvl(deprn_run_id, 1)
7200 where asset_id = l_asset_id_tbl(l_count)
7201 and book_type_code = l_book_type_code_tbl(l_count)
7202 and period_counter = l_period_counter_tbl(l_count)
7203 and event_id is null;
7204
7205 end if;
7206
7207 insert all
7208 when (1 = 1) then
7209 into xla_ae_lines (
7210 upg_batch_id,
7211 ae_header_id,
7212 ae_line_num,
7213 displayed_line_number,
7214 application_id,
7215 code_combination_id,
7216 gl_transfer_mode_code,
7217 accounted_dr,
7218 accounted_cr,
7219 currency_code,
7220 currency_conversion_date,
7221 currency_conversion_rate,
7222 currency_conversion_type,
7223 entered_dr,
7224 entered_cr,
7225 description,
7226 accounting_class_code,
7227 gl_sl_link_id,
7228 gl_sl_link_table,
7229 party_type_code,
7230 party_id,
7231 party_site_id,
7232 statistical_amount,
7233 ussgl_transaction_code,
7234 jgzz_recon_ref,
7235 control_balance_flag,
7236 analytical_balance_flag,
7237 upg_tax_reference_id1,
7238 upg_tax_reference_id2,
7239 upg_tax_reference_id3,
7240 creation_date,
7241 created_by,
7242 last_update_date,
7243 last_updated_by,
7244 last_update_login,
7245 program_update_date,
7246 program_id,
7247 program_application_id,
7248 request_id,
7249 gain_or_loss_flag,
7250 accounting_date,
7251 ledger_id
7252 ) values (
7253 l_upg_batch_id, -- upg_batch_id
7254 ae_header_id, -- ae_header_id
7255 ae_line_num, -- ae_line_num
7256 ae_line_num, -- displayed_line_num
7257 c_application_id, -- application_id
7258 decode(multiplier, -- code_combination_id
7259 1, nvl(deprn_exp_ccid, default_ccid),
7260 2, nvl(deprn_rsv_ccid,default_rsv_ccid),
7261 3, nvl(bonus_exp_ccid, default_ccid),
7262 4, nvl(bonus_rsv_ccid, default_bonus_rsv_ccid),
7263 5, nvl(reval_amort_ccid, default_reval_amort_ccid),
7264 6, nvl(reval_rsv_ccid, default_reval_rsv_ccid)),
7265 'S', -- gl_transfer_mode_code
7266 decode(multiplier, -- accounted_dr
7267 1, deprn_amount,
7268 2, null,
7269 3, bonus_amount,
7270 4, null,
7271 5, reval_amount,
7272 6, null),
7273 decode(multiplier, -- accounted_cr
7274 1, null,
7275 2, deprn_amount,
7276 3, null,
7277 4, bonus_amount,
7278 5, null,
7279 6, reval_amount),
7280 currency_code, -- currency_code
7281 null, -- currency_conversion_date
7282 null, -- currency_conversion_rate
7283 null, -- currency_conversion_type
7284 decode(multiplier, -- entered_dr
7285 1, deprn_amount,
7286 2, null,
7287 3, bonus_amount,
7288 4, null,
7289 5, reval_amount,
7290 6, null),
7291 decode(multiplier, -- entered_cr
7292 1, null,
7293 2, deprn_amount,
7294 3, null,
7295 4, bonus_amount,
7296 5, null,
7297 6, reval_amount),
7298 decode(multiplier, -- description
7299 1, l_de_description,
7300 2, l_dr_description,
7301 3, l_be_description,
7302 4, l_br_description,
7303 5, l_ra_description,
7304 6, l_rr_description) || ' - ' ||
7305 to_char(cal_period_close_date, 'DD-MON-RR'),
7306 decode(multiplier, -- accounting_class_code
7307 1, 'EXPENSE',
7308 2, 'ASSET',
7309 3, 'EXPENSE',
7310 4, 'ASSET',
7311 5, 'EXPENSE',
7312 6, 'ASSET'),
7313 xla_gl_sl_link_id_s.nextval, -- gl_sl_link_id
7314 'XLAJEL', -- gl_sl_link_table
7315 null, -- party_type_code
7316 null, -- party_id
7317 null, -- party_site_id
7318 null, -- statistical_amount
7319 null, -- ussgl_transaction_code
7320 null, -- glzz_recon_ref
7321 null, -- control_balance_flag
7322 null, -- analytical_balance_flag
7323 null, -- upg_tax_reference_id1
7324 null, -- upg_tax_reference_id2
7325 null, -- upg_tax_reference_id3
7326 sysdate, -- creation_date
7327 c_fnd_user, -- created_by
7328 sysdate, -- last_update_date
7329 c_fnd_user, -- last_updated_by
7330 c_upgrade_bugno, -- last_update_login
7331 null, -- program_update_date
7332 null, -- program_id
7333 c_application_id, -- program_application_id
7334 null, -- request_id
7335 'N', -- gain_or_loss_flag
7336 cal_period_close_date, -- accounting_date,
7337 set_of_books_id -- ledger_id/sob_id
7338 )
7339 when (1 = 1) then
7340 into xla_distribution_links (
7341 upg_batch_id,
7342 application_id,
7343 event_id,
7344 ae_header_id,
7345 ae_line_num,
7346 accounting_line_code,
7347 accounting_line_type_code,
7348 source_distribution_type,
7349 source_distribution_id_char_1,
7350 source_distribution_id_char_2,
7351 source_distribution_id_char_3,
7352 source_distribution_id_char_4,
7353 source_distribution_id_char_5,
7354 source_distribution_id_num_1,
7355 source_distribution_id_num_2,
7356 source_distribution_id_num_3,
7357 source_distribution_id_num_4,
7358 source_distribution_id_num_5,
7359 merge_duplicate_code,
7360 statistical_amount,
7361 unrounded_entered_dr,
7362 unrounded_entered_cr,
7363 unrounded_accounted_dr,
7364 unrounded_accounted_cr,
7365 ref_ae_header_id,
7366 ref_temp_line_num,
7367 ref_event_id,
7368 temp_line_num,
7369 tax_line_ref_id,
7370 tax_summary_line_ref_id,
7371 tax_rec_nrec_dist_ref_id,
7372 line_definition_owner_code,
7373 line_definition_code,
7374 event_class_code,
7375 event_type_code
7376 ) values (
7377 l_upg_batch_id, -- upg_batch_id
7378 c_application_id, -- application_id
7379 event_id, -- event_id
7380 ae_header_id, -- ae_header_id
7381 ae_line_num, -- ae_line_num
7382 null, -- accounting_line_code
7383 'S', -- accounting_line_type_code
7384 'DEPRN', -- source_distribution_type
7385 null, -- source_distribution_id_char_1
7386 null, -- source_distribution_id_char_2
7387 null, -- source_distribution_id_char_3
7388 book_type_code, -- source_distribution_id_char_4
7389 null, -- source_distribution_id_char_5
7390 asset_id, -- source_distribution_id_num_1
7391 period_counter, -- source_distribution_id_num_2
7392 1, -- source_distribution_id_num_3
7393 null, -- source_distribution_id_num_4
7394 distribution_id, -- source_distribution_id_num_5
7395 'N', -- merge_duplicate_code
7396 null, -- statistical_amount
7397 decode(multiplier, -- unrounded_entered_dr
7398 1, deprn_amount,
7399 2, null,
7400 3, bonus_amount,
7401 4, null,
7402 5, reval_amount,
7403 6, null),
7404 decode(multiplier, -- unrounded_entered_cr
7405 1, null,
7406 2, deprn_amount,
7407 3, null,
7408 4, bonus_amount,
7409 5, null,
7410 6, reval_amount),
7411 decode(multiplier, -- unrounded_accounted_dr
7412 1, deprn_amount,
7413 2, null,
7414 3, bonus_amount,
7415 4, null,
7416 5, reval_amount,
7417 6, null),
7418 decode(multiplier, -- unrounded_accounted_cr
7419 1, null,
7420 2, deprn_amount,
7421 3, null,
7422 4, bonus_amount,
7423 5, null,
7424 6, reval_amount),
7425 ae_header_id, -- ref_ae_header_id
7426 null, -- ref_temp_line_num
7427 null, -- ref_event_id
7428 ae_line_num, -- temp_line_num
7429 null, -- tax_line_ref_id
7430 null, -- tax_summary_line_ref_id
7431 null, -- tax_rec_nrec_dist_ref_id
7432 null, -- line_definition_owner_code
7433 null, -- line_definition_code
7434 event_class_code, -- event_class_code
7435 event_type_code -- event_type_code
7436 )
7437 when (je_batch_id is not null) then
7438 into gl_import_references (
7439 je_batch_id,
7440 je_header_id,
7441 je_line_num,
7442 last_update_date,
7443 last_updated_by,
7444 creation_date,
7445 created_by,
7446 last_update_login,
7447 reference_1,
7448 reference_2,
7449 reference_3,
7450 reference_4,
7451 reference_5,
7452 reference_6,
7453 reference_7,
7454 reference_8,
7455 reference_9,
7456 reference_10,
7457 subledger_doc_sequence_id,
7458 subledger_doc_sequence_value,
7459 gl_sl_link_id,
7460 gl_sl_link_table
7461 ) values (
7462 je_batch_id, -- je_batch_id
7463 je_header_id, -- je_header_id
7464 decode(multiplier, -- je_line_num
7465 1, de_je_line_num,
7466 2, dr_je_line_num,
7467 3, be_je_line_num,
7468 4, br_je_line_num,
7469 5, ra_je_line_num,
7470 6, rr_je_line_num),
7471 sysdate, -- last_update_date
7472 c_fnd_user, -- last_updated_by
7473 sysdate, -- creation_date
7474 c_fnd_user, -- created_by
7475 c_upgrade_bugno, -- last_update_login
7476 null, -- reference_1
7477 to_char(asset_id), -- reference_2
7478 to_char(distribution_id), -- reference_3
7479 null, -- reference_4
7480 book_type_code, -- reference_5
7481 to_char(period_counter), -- reference_6
7482 null, -- reference_7
7483 null, -- reference_8
7484 null, -- reference_9
7485 null, -- reference_10
7486 null, -- subledger_doc_seq_id
7487 null, -- subledger_doc_seq_value
7488 xla_gl_sl_link_id_s.nextval, -- gl_sl_link_id
7489 'XLAJEL' -- gl_sl_link_table
7490 )
7491 select /*+ leading(ev) index(dd, FA_DEPRN_DETAIL_N1) */
7492 ev.event_id event_id,
7493 he.ae_header_id ae_header_id,
7494 ev.calendar_period_close_date cal_period_close_date,
7495 ev.event_type_code event_type_code,
7496 ev.event_class_code event_class_code,
7497 ev.ds_asset_id asset_id,
7498 ev.ds_book_type_code book_type_code,
7499 he.set_of_books_id set_of_books_id,
7500 ev.ds_period_counter period_counter,
7501 dd.distribution_id distribution_id,
7502 glsob.currency_code currency_code,
7503 dd.deprn_amount - nvl(dd.deprn_adjustment_amount, 0)
7504 - nvl(dd.bonus_deprn_amount, 0)
7505 deprn_amount,
7506 nvl(dd.bonus_deprn_amount -
7507 nvl(dd.bonus_deprn_adjustment_amount, 0), 0)
7508 bonus_amount,
7509 nvl(dd.reval_amortization, 0) reval_amount,
7510 ev.reserve_acct_ccid default_rsv_ccid,
7511 ev.bonus_reserve_acct_ccid default_bonus_rsv_ccid,
7512 ev.reval_amort_acct_ccid default_reval_amort_ccid,
7513 ev.reval_reserve_acct_ccid default_reval_rsv_ccid,
7514 nvl(jl_de.code_combination_id, da.deprn_expense_account_ccid)
7515 deprn_exp_ccid,
7516 nvl(jl_dr.code_combination_id, da.deprn_reserve_account_ccid)
7517 deprn_rsv_ccid,
7518 nvl(jl_be.code_combination_id, da.bonus_exp_account_ccid)
7519 bonus_exp_ccid,
7520 nvl(jl_br.code_combination_id, da.bonus_rsv_account_ccid)
7521 bonus_rsv_ccid,
7522 nvl(jl_ra.code_combination_id, da.reval_amort_account_ccid)
7523 reval_amort_ccid,
7524 nvl(jl_rr.code_combination_id, da.reval_rsv_account_ccid)
7525 reval_rsv_ccid,
7526 nvl(dh.code_combination_id, -1) default_ccid,
7527 decode (dd.je_header_id, null, 'N', 'Y')
7528 gl_transfer_status_code,
7529 gljh.je_batch_id je_batch_id,
7530 dd.je_header_id je_header_id,
7531 nvl(dd.deprn_expense_je_line_num, 0)
7532 de_je_line_num,
7533 nvl(dd.deprn_reserve_je_line_num, 0)
7534 dr_je_line_num,
7535 nvl(dd.bonus_deprn_exp_je_line_num, 0)
7536 be_je_line_num,
7537 nvl(dd.bonus_deprn_rsv_je_line_num, 0)
7538 br_je_line_num,
7539 nvl(dd.reval_amort_je_line_num, 0)
7540 ra_je_line_num,
7541 nvl(dd.reval_reserve_je_line_num, 0)
7542 rr_je_line_num,
7543 row_number() over
7544 (partition by ev.event_id
7545 order by dd.distribution_id, mult.multiplier)
7546 ae_line_num,
7547 mult.multiplier multiplier
7548 from fa_xla_upg_events_gt ev,
7549 fa_xla_upg_headers_gt he,
7550 fa_deprn_detail dd,
7551 fa_distribution_history dh,
7552 fa_distribution_accounts da,
7553 gl_je_lines jl_de,
7554 gl_je_lines jl_dr,
7555 gl_je_lines jl_be,
7556 gl_je_lines jl_br,
7557 gl_je_lines jl_ra,
7558 gl_je_lines jl_rr,
7559 gl_je_headers gljh,
7560 fa_book_controls bc,
7561 gl_sets_of_books glsob,
7562 gl_row_multipliers mult
7563 where ev.event_id = he.event_id
7564 and bc.book_type_code = ev.ds_book_type_code
7565 and bc.set_of_books_id = glsob.set_of_books_id
7566 and bc.book_type_code = dd.book_type_code
7567 and he.set_of_books_id = bc.set_of_books_id
7568 and dd.book_type_code = ev.ds_book_type_code
7569 and dd.asset_id = ev.ds_asset_id
7570 and dd.period_counter = ev.ds_period_counter
7571 and dd.deprn_source_code <> 'T'
7572 and dd.je_header_id = jl_de.je_header_id (+)
7573 and dd.je_header_id = jl_dr.je_header_id (+)
7574 and dd.je_header_id = jl_be.je_header_id (+)
7575 and dd.je_header_id = jl_br.je_header_id (+)
7576 and dd.je_header_id = jl_ra.je_header_id (+)
7577 and dd.je_header_id = jl_rr.je_header_id (+)
7578 and dd.deprn_expense_je_line_num = jl_de.je_line_num (+)
7579 and dd.deprn_reserve_je_line_num = jl_dr.je_line_num (+)
7580 and dd.bonus_deprn_exp_je_line_num = jl_be.je_line_num (+)
7581 and dd.bonus_deprn_rsv_je_line_num = jl_br.je_line_num (+)
7582 and dd.reval_amort_je_line_num = jl_ra.je_line_num (+)
7583 and dd.reval_reserve_je_line_num = jl_rr.je_line_num (+)
7584 and dd.distribution_id = dh.distribution_id
7585 and da.book_type_code (+) = dd.book_type_code
7586 and da.distribution_id (+) = dd.distribution_id
7587 and dd.je_header_id = gljh.je_header_id (+)
7588 and mult.multiplier < 7
7589 and ((mult.multiplier in (1, 2))
7590 or ((mult.multiplier in (3, 4)) and
7591 (nvl(dd.bonus_deprn_amount -
7592 nvl(dd.bonus_deprn_adjustment_amount, 0), 0) <> 0))
7593 or ((mult.multiplier in (5, 6)) and
7594 (dd.reval_amortization <> 0)));
7595
7596 if (l_mc_books > 0) then
7597
7598 insert all
7599 when 1 = 1 then
7600 into fa_xla_upg_headers_gt (
7601 ae_header_id,
7602 event_id,
7603 set_of_books_id
7604 ) values (
7605 xla_ae_headers_s.nextval,
7606 event_id,
7607 set_of_books_id
7608 )
7609 when 1 = 1 then
7610 into xla_ae_headers (
7611 upg_batch_id,
7612 application_id,
7613 amb_context_code,
7614 entity_id,
7615 event_id,
7616 event_type_code,
7617 ae_header_id,
7618 ledger_id,
7619 accounting_date,
7620 period_name,
7621 reference_date,
7622 balance_type_code,
7623 je_category_name,
7624 gl_transfer_status_code,
7625 gl_transfer_date,
7626 accounting_entry_status_code,
7627 accounting_entry_type_code,
7628 description,
7629 budget_version_id,
7630 funds_status_code,
7631 encumbrance_type_id,
7632 completed_date,
7633 doc_sequence_id,
7634 doc_sequence_value,
7635 doc_category_code,
7636 packet_id,
7637 group_id,
7638 creation_date,
7639 created_by,
7640 last_update_date,
7641 last_updated_by,
7642 last_update_login,
7643 program_id,
7644 program_application_id,
7645 program_update_date,
7646 request_id,
7647 close_acct_seq_assign_id,
7648 close_acct_seq_version_id,
7649 close_acct_seq_value,
7650 completion_acct_seq_assign_id,
7651 completion_acct_seq_version_id,
7652 completion_acct_seq_value,
7653 accounting_batch_id,
7654 product_rule_type_code,
7655 product_rule_code,
7656 product_rule_version,
7657 upg_source_application_id,
7658 upg_valid_flag
7659 ) values (
7660 l_upg_batch_id, -- upg_batch_id
7661 c_application_id, -- application_id
7662 c_amb_context_code, -- amb_context_code
7663 entity_id, -- entity_id
7664 event_id, -- event_id
7665 event_type_code, -- event_type_code
7666 xla_ae_headers_s.currval, -- ae_header_id
7667 set_of_books_id, -- ledger_id
7668 calendar_period_close_date, -- accounting_date
7669 period_name, -- period_name
7670 null, -- reference_date
7671 'A', -- balance_type_code
7672 je_category_name, -- je_category_name
7673 'Y', -- gl_transfer_status_code
7674 null, -- gl_transfer_date
7675 'F', -- accounting_entry_status_code
7676 'STANDARD', -- accounting_entry_type_code
7677 description, -- description
7678 null, -- budget_version_id
7679 null, -- funds_status_code
7680 null, -- encumbrance_type_id
7681 null, -- completed_date
7682 null, -- doc_sequence_id
7683 null, -- doc_sequence_value
7684 null, -- doc_category_code
7685 null, -- packet_id
7686 null, -- group_id
7687 sysdate, -- creation_date
7688 c_fnd_user, -- created_by
7689 sysdate, -- last_update_date
7690 c_fnd_user, -- last_updated_by
7691 c_upgrade_bugno, -- last_update_login
7692 null, -- program_id
7693 c_application_id, -- program_application_id
7694 sysdate, -- program_update_date
7695 null, -- request_id
7696 null, -- close_acct_seq_assign_id
7697 null, -- close_acct_seq_version_id
7698 null, -- close_acct_seq_value
7699 null, -- completion_acct_seq_assign_id
7700 null, -- completion_acct_seq_version_id
7701 null, -- completion_acct_seq_value
7702 null, -- accounting_batch_id
7703 null, -- product_rule_type_code
7704 null, -- product_rule_code
7705 null, -- product_rule_version
7706 c_application_id, -- upg_source_application_id
7707 null -- upg_valid_flag
7708 )
7709 select faev.entity_id entity_id,
7710 faev.event_id event_id,
7711 faev.event_type_code event_type_code,
7712 mc.set_of_books_id set_of_books_id,
7713 faev.calendar_period_close_date
7714 calendar_period_close_date,
7715 faev.period_name period_name,
7716 faev.je_category_name je_category_name,
7717 faev.description description
7718 from fa_xla_upg_events_gt faev,
7719 fa_mc_book_controls mc
7720 where mc.book_type_code = faev.ds_book_type_code
7721 and mc.enabled_flag = 'Y';
7722
7723 insert all
7724 when (1 = 1) then
7725 into xla_ae_lines (
7726 upg_batch_id,
7727 ae_header_id,
7728 ae_line_num,
7729 displayed_line_number,
7730 application_id,
7731 code_combination_id,
7732 gl_transfer_mode_code,
7733 accounted_dr,
7734 accounted_cr,
7735 currency_code,
7736 currency_conversion_date,
7737 currency_conversion_rate,
7738 currency_conversion_type,
7739 entered_dr,
7740 entered_cr,
7741 description,
7742 accounting_class_code,
7743 gl_sl_link_id,
7744 gl_sl_link_table,
7745 party_type_code,
7746 party_id,
7747 party_site_id,
7748 statistical_amount,
7749 ussgl_transaction_code,
7750 jgzz_recon_ref,
7751 control_balance_flag,
7752 analytical_balance_flag,
7753 upg_tax_reference_id1,
7754 upg_tax_reference_id2,
7755 upg_tax_reference_id3,
7756 creation_date,
7757 created_by,
7758 last_update_date,
7759 last_updated_by,
7760 last_update_login,
7761 program_update_date,
7762 program_id,
7763 program_application_id,
7764 request_id,
7765 gain_or_loss_flag,
7766 accounting_date,
7767 ledger_id
7768 ) values (
7769 l_upg_batch_id, -- upg_batch_id
7770 ae_header_id, -- ae_header_id
7771 ae_line_num, -- ae_line_num
7772 ae_line_num, -- displayed_line_num
7773 c_application_id, -- application_id
7774 decode(multiplier, -- code_combination_id
7775 1, nvl(deprn_exp_ccid, default_ccid),
7776 2, nvl(deprn_rsv_ccid,default_rsv_ccid),
7777 3, nvl(bonus_exp_ccid, default_ccid),
7778 4, nvl(bonus_rsv_ccid, default_bonus_rsv_ccid),
7779 5, nvl(reval_amort_ccid, default_reval_amort_ccid),
7780 6, nvl(reval_rsv_ccid, default_reval_rsv_ccid)),
7781 'S', -- gl_transfer_mode_code
7782 decode(multiplier, -- accounted_dr
7783 1, deprn_amount,
7784 2, null,
7785 3, bonus_amount,
7786 4, null,
7787 5, reval_amount,
7788 6, null),
7789 decode(multiplier, -- accounted_cr
7790 1, null,
7791 2, deprn_amount,
7792 3, null,
7793 4, bonus_amount,
7794 5, null,
7795 6, reval_amount),
7796 currency_code, -- currency_code
7797 null, -- currency_conversion_date
7798 null, -- currency_conversion_rate
7799 null, -- currency_conversion_type
7800 decode(multiplier, -- entered_dr
7801 1, deprn_amount,
7802 2, null,
7803 3, bonus_amount,
7804 4, null,
7805 5, reval_amount,
7806 6, null),
7807 decode(multiplier, -- entered_cr
7808 1, null,
7809 2, deprn_amount,
7810 3, null,
7811 4, bonus_amount,
7812 5, null,
7813 6, reval_amount),
7814 decode(multiplier, -- description
7815 1, l_de_description,
7816 2, l_dr_description,
7817 3, l_be_description,
7818 4, l_br_description,
7819 5, l_ra_description,
7820 6, l_rr_description) || ' - ' ||
7821 to_char(cal_period_close_date, 'DD-MON-RR'),
7822 decode(multiplier, -- accounting_class_code
7823 1, 'EXPENSE',
7824 2, 'ASSET',
7825 3, 'EXPENSE',
7826 4, 'ASSET',
7827 5, 'EXPENSE',
7828 6, 'ASSET'),
7829 xla_gl_sl_link_id_s.nextval, -- gl_sl_link_id
7830 'XLAJEL', -- gl_sl_link_table
7831 null, -- party_type_code
7832 null, -- party_id
7833 null, -- party_site_id
7834 null, -- statistical_amount
7835 null, -- ussgl_transaction_code
7836 null, -- glzz_recon_ref
7837 null, -- control_balance_flag
7838 null, -- analytical_balance_flag
7839 null, -- upg_tax_reference_id1
7840 null, -- upg_tax_reference_id2
7841 null, -- upg_tax_reference_id3
7842 sysdate, -- creation_date
7843 c_fnd_user, -- created_by
7844 sysdate, -- last_update_date
7845 c_fnd_user, -- last_updated_by
7846 c_upgrade_bugno, -- last_update_login
7847 null, -- program_update_date
7848 null, -- program_id
7849 c_application_id, -- program_application_id
7850 null, -- request_id
7851 'N', -- gain_or_loss_flag
7852 cal_period_close_date, -- accounting_date,
7853 set_of_books_id -- ledger_id/sob_id
7854 )
7855 when (1 = 1) then
7856 into xla_distribution_links (
7857 upg_batch_id,
7858 application_id,
7859 event_id,
7860 ae_header_id,
7861 ae_line_num,
7862 accounting_line_code,
7863 accounting_line_type_code,
7864 source_distribution_type,
7865 source_distribution_id_char_1,
7866 source_distribution_id_char_2,
7867 source_distribution_id_char_3,
7868 source_distribution_id_char_4,
7869 source_distribution_id_char_5,
7870 source_distribution_id_num_1,
7871 source_distribution_id_num_2,
7872 source_distribution_id_num_3,
7873 source_distribution_id_num_4,
7874 source_distribution_id_num_5,
7875 merge_duplicate_code,
7876 statistical_amount,
7877 unrounded_entered_dr,
7878 unrounded_entered_cr,
7879 unrounded_accounted_dr,
7880 unrounded_accounted_cr,
7881 ref_ae_header_id,
7882 ref_temp_line_num,
7883 ref_event_id,
7884 temp_line_num,
7885 tax_line_ref_id,
7886 tax_summary_line_ref_id,
7887 tax_rec_nrec_dist_ref_id,
7888 line_definition_owner_code,
7889 line_definition_code,
7890 event_class_code,
7891 event_type_code
7892 ) values (
7893 l_upg_batch_id, -- upg_batch_id
7894 c_application_id, -- application_id
7895 event_id, -- event_id
7896 ae_header_id, -- ae_header_id
7897 ae_line_num, -- ae_line_num
7898 null, -- accounting_line_code
7899 'S', -- accounting_line_type_code
7900 'DEPRN', -- source_distribution_type
7901 null, -- source_distribution_id_char_1
7902 null, -- source_distribution_id_char_2
7903 null, -- source_distribution_id_char_3
7904 book_type_code, -- source_distribution_id_char_4
7905 null, -- source_distribution_id_char_5
7906 asset_id, -- source_distribution_id_num_1
7907 period_counter, -- source_distribution_id_num_2
7908 1, -- source_distribution_id_num_3
7909 null, -- source_distribution_id_num_4
7910 distribution_id, -- source_distribution_id_num_5
7911 'N', -- merge_duplicate_code
7912 null, -- statistical_amount
7913 decode(multiplier, -- unrounded_entered_dr
7914 1, deprn_amount,
7915 2, null,
7916 3, bonus_amount,
7917 4, null,
7918 5, reval_amount,
7919 6, null),
7920 decode(multiplier, -- unrounded_entered_cr
7921 1, null,
7922 2, deprn_amount,
7923 3, null,
7924 4, bonus_amount,
7925 5, null,
7926 6, reval_amount),
7927 decode(multiplier, -- unrounded_accounted_dr
7928 1, deprn_amount,
7929 2, null,
7930 3, bonus_amount,
7931 4, null,
7932 5, reval_amount,
7933 6, null),
7934 decode(multiplier, -- unrounded_accounted_cr
7935 1, null,
7936 2, deprn_amount,
7937 3, null,
7938 4, bonus_amount,
7939 5, null,
7940 6, reval_amount),
7941 ae_header_id, -- ref_ae_header_id
7942 null, -- ref_temp_line_num
7943 null, -- ref_event_id
7944 ae_line_num, -- temp_line_num
7945 null, -- tax_line_ref_id
7946 null, -- tax_summary_line_ref_id
7947 null, -- tax_rec_nrec_dist_ref_id
7948 null, -- line_definition_owner_code
7949 null, -- line_definition_code
7950 event_class_code, -- event_class_code
7951 event_type_code -- event_type_code
7952 )
7953 when (je_batch_id is not null) then
7954 into gl_import_references (
7955 je_batch_id,
7956 je_header_id,
7957 je_line_num,
7958 last_update_date,
7959 last_updated_by,
7960 creation_date,
7961 created_by,
7962 last_update_login,
7963 reference_1,
7964 reference_2,
7965 reference_3,
7966 reference_4,
7967 reference_5,
7968 reference_6,
7969 reference_7,
7970 reference_8,
7971 reference_9,
7972 reference_10,
7973 subledger_doc_sequence_id,
7974 subledger_doc_sequence_value,
7975 gl_sl_link_id,
7976 gl_sl_link_table
7977 ) values (
7978 je_batch_id, -- je_batch_id
7979 je_header_id, -- je_header_id
7980 decode(multiplier, -- je_line_num
7981 1, de_je_line_num,
7982 2, dr_je_line_num,
7983 3, be_je_line_num,
7984 4, br_je_line_num,
7985 5, ra_je_line_num,
7986 6, rr_je_line_num),
7987 sysdate, -- last_update_date
7988 c_fnd_user, -- last_updated_by
7989 sysdate, -- creation_date
7990 c_fnd_user, -- created_by
7991 c_upgrade_bugno, -- last_update_login
7992 null, -- reference_1
7993 to_char(asset_id), -- reference_2
7994 to_char(distribution_id), -- reference_3
7995 null, -- reference_4
7996 book_type_code, -- reference_5
7997 to_char(period_counter), -- reference_6
7998 null, -- reference_7
7999 null, -- reference_8
8000 null, -- reference_9
8001 null, -- reference_10
8002 null, -- subledger_doc_seq_id
8003 null, -- subledger_doc_seq_value
8004 xla_gl_sl_link_id_s.nextval, -- gl_sl_link_id
8005 'XLAJEL' -- gl_sl_link_table
8006 )
8007 select /*+ leading(ev) index(dd, FA_MC_DEPRN_DETAIL_N1) */
8008 ev.event_id event_id,
8009 he.ae_header_id ae_header_id,
8010 ev.calendar_period_close_date cal_period_close_date,
8011 ev.event_type_code event_type_code,
8012 ev.event_class_code event_class_code,
8013 ev.ds_asset_id asset_id,
8014 ev.ds_book_type_code book_type_code,
8015 he.set_of_books_id set_of_books_id,
8016 ev.ds_period_counter period_counter,
8017 dd.distribution_id distribution_id,
8018 glsob.currency_code currency_code,
8019 dd.deprn_amount - nvl(dd.deprn_adjustment_amount, 0)
8020 - nvl(dd.bonus_deprn_amount, 0)
8021 deprn_amount,
8022 nvl(dd.bonus_deprn_amount -
8023 nvl(dd.bonus_deprn_adjustment_amount, 0), 0)
8024 bonus_amount,
8025 nvl(dd.reval_amortization, 0) reval_amount,
8026 ev.reserve_acct_ccid default_rsv_ccid,
8027 ev.bonus_reserve_acct_ccid default_bonus_rsv_ccid,
8028 ev.reval_amort_acct_ccid default_reval_amort_ccid,
8029 ev.reval_reserve_acct_ccid default_reval_rsv_ccid,
8030 nvl(jl_de.code_combination_id, da.deprn_expense_account_ccid)
8031 deprn_exp_ccid,
8032 nvl(jl_dr.code_combination_id, da.deprn_reserve_account_ccid)
8033 deprn_rsv_ccid,
8034 nvl(jl_be.code_combination_id, da.bonus_exp_account_ccid)
8035 bonus_exp_ccid,
8036 nvl(jl_br.code_combination_id, da.bonus_rsv_account_ccid)
8037 bonus_rsv_ccid,
8038 nvl(jl_ra.code_combination_id, da.reval_amort_account_ccid)
8039 reval_amort_ccid,
8040 nvl(jl_rr.code_combination_id, da.reval_rsv_account_ccid)
8041 reval_rsv_ccid,
8042 nvl(dh.code_combination_id, -1) default_ccid,
8043 decode (dd.je_header_id, null, 'N', 'Y')
8044 gl_transfer_status_code,
8045 gljh.je_batch_id je_batch_id,
8046 dd.je_header_id je_header_id,
8047 nvl(dd.deprn_expense_je_line_num, 0)
8048 de_je_line_num,
8049 nvl(dd.deprn_reserve_je_line_num, 0)
8050 dr_je_line_num,
8051 nvl(dd.bonus_deprn_exp_je_line_num, 0)
8052 be_je_line_num,
8053 nvl(dd.bonus_deprn_rsv_je_line_num, 0)
8054 br_je_line_num,
8055 nvl(dd.reval_amort_je_line_num, 0)
8056 ra_je_line_num,
8057 nvl(dd.reval_reserve_je_line_num, 0)
8058 rr_je_line_num,
8059 row_number() over
8060 (partition by ev.event_id
8061 order by dd.distribution_id, mult.multiplier)
8062 ae_line_num,
8063 mult.multiplier multiplier
8064 from fa_xla_upg_events_gt ev,
8065 fa_xla_upg_headers_gt he,
8066 fa_mc_deprn_detail dd,
8067 fa_distribution_history dh,
8068 fa_distribution_accounts da,
8069 gl_je_lines jl_de,
8070 gl_je_lines jl_dr,
8071 gl_je_lines jl_be,
8072 gl_je_lines jl_br,
8073 gl_je_lines jl_ra,
8074 gl_je_lines jl_rr,
8075 gl_je_headers gljh,
8076 fa_mc_book_controls bc,
8077 gl_sets_of_books glsob,
8078 gl_row_multipliers mult
8079 where ev.event_id = he.event_id
8080 and bc.book_type_code = ev.ds_book_type_code
8081 and bc.set_of_books_id = glsob.set_of_books_id
8082 and bc.enabled_flag = 'Y'
8083 and he.set_of_books_id = bc.set_of_books_id
8084 and dd.set_of_books_id = bc.set_of_books_id
8085 and bc.book_type_code = dd.book_type_code
8086 and dd.book_type_code = ev.ds_book_type_code
8087 and dd.asset_id = ev.ds_asset_id
8088 and dd.period_counter = ev.ds_period_counter
8089 and dd.deprn_source_code <> 'T'
8090 and dd.je_header_id = jl_de.je_header_id (+)
8091 and dd.je_header_id = jl_dr.je_header_id (+)
8092 and dd.je_header_id = jl_be.je_header_id (+)
8093 and dd.je_header_id = jl_br.je_header_id (+)
8094 and dd.je_header_id = jl_ra.je_header_id (+)
8095 and dd.je_header_id = jl_rr.je_header_id (+)
8096 and dd.deprn_expense_je_line_num = jl_de.je_line_num (+)
8097 and dd.deprn_reserve_je_line_num = jl_dr.je_line_num (+)
8098 and dd.bonus_deprn_exp_je_line_num = jl_be.je_line_num (+)
8099 and dd.bonus_deprn_rsv_je_line_num = jl_br.je_line_num (+)
8100 and dd.reval_amort_je_line_num = jl_ra.je_line_num (+)
8101 and dd.reval_reserve_je_line_num = jl_rr.je_line_num (+)
8102 and dd.distribution_id = dh.distribution_id
8103 and da.book_type_code (+) = dd.book_type_code
8104 and da.distribution_id (+) = dd.distribution_id
8105 and dd.je_header_id = gljh.je_header_id (+)
8106 and mult.multiplier < 7
8107 and ((mult.multiplier in (1, 2))
8108 or ((mult.multiplier in (3, 4)) and
8109 (nvl(dd.bonus_deprn_amount -
8110 nvl(dd.bonus_deprn_adjustment_amount, 0), 0) <> 0))
8111 or ((mult.multiplier in (5, 6)) and
8112 (dd.reval_amortization <> 0)));
8113
8114 end if;
8115
8116 l_event_id_tbl.delete;
8117 l_asset_id_tbl.delete;
8118 l_book_type_code_tbl.delete;
8119 l_period_counter_tbl.delete;
8120
8121 commit;
8122
8123 EXCEPTION
8124 WHEN OTHERS THEN
8125 rollback;
8126 raise;
8127
8128 END Upgrade_Deprn_Events;
8129
8130 Procedure Upgrade_Deferred_Events (
8131 p_start_rowid IN rowid,
8132 p_end_rowid IN rowid,
8133 p_batch_size IN number,
8134 x_success_count OUT NOCOPY number,
8135 x_failure_count OUT NOCOPY number,
8136 x_return_status OUT NOCOPY number
8137 ) IS
8138
8139 c_application_id constant number(15) := 140;
8140 c_upgrade_bugno constant number(15) := -4107161;
8141 c_fnd_user constant number(15) := 2;
8142
8143
8144 c_entity_code constant varchar2(30) := 'DEFERRED_DEPRECIATION';
8145 c_amb_context_code constant varchar2(30) := 'DEFAULT';
8146
8147 -- this value can be altered in order to process more of less per batch
8148 l_batch_size NUMBER;
8149
8150 l_rows_processed NUMBER;
8151
8152 -- type for table variable
8153 type num_tbl_type is table of number index by binary_integer;
8154 type char_tbl_type is table of varchar2(150) index by binary_integer;
8155 type date_tbl_type is table of date index by binary_integer;
8156 type rowid_tbl_type is table of rowid index by binary_integer;
8157
8158 -- used for bulk fetching
8159 -- main cursor
8160 l_event_id_tbl num_tbl_type;
8161 l_asset_id_tbl num_tbl_type;
8162 l_corp_book_type_code_tbl char_tbl_type;
8163 l_tax_book_type_code_tbl char_tbl_type;
8164 l_corp_period_counter_tbl num_tbl_type;
8165 l_tax_period_counter_tbl num_tbl_type;
8166 l_set_of_books_id_tbl num_tbl_type;
8167 l_org_id_tbl num_tbl_type;
8168 l_transaction_type_code_tbl char_tbl_type;
8169 l_transaction_date_entered_tbl date_tbl_type;
8170 l_period_name_tbl char_tbl_type;
8171 l_cal_period_close_date_tbl date_tbl_type;
8172 l_rowid_tbl rowid_tbl_type;
8173
8174 l_upg_batch_id number;
8175 l_ae_header_id number;
8176
8177 l_entity_id_tbl num_tbl_type;
8178 l_event_class_code_tbl char_tbl_type;
8179 l_currency_code_tbl char_tbl_type;
8180 l_je_category_name_tbl char_tbl_type;
8181 l_ae_header_id_tbl num_tbl_type;
8182
8183 l_cr_ccid_tbl num_tbl_type;
8184 l_dr_ccid_tbl num_tbl_type;
8185 l_credit_amount_tbl num_tbl_type;
8186 l_debit_amount_tbl num_tbl_type;
8187 l_exp_xla_gl_sl_link_id_tbl num_tbl_type;
8188 l_rsv_xla_gl_sl_link_id_tbl num_tbl_type;
8189 l_line_def_owner_code_tbl char_tbl_type;
8190 l_line_def_code_tbl char_tbl_type;
8191 l_dfr_exp_desc_tbl char_tbl_type;
8192 l_dfr_rsv_desc_tbl char_tbl_type;
8193 l_gl_transfer_status_code_tbl char_tbl_type;
8194 l_je_batch_id_tbl num_tbl_type;
8195 l_je_header_id_tbl num_tbl_type;
8196 l_exp_je_line_num_tbl num_tbl_type;
8197 l_rsv_je_line_num_tbl num_tbl_type;
8198 l_distribution_id_tbl num_tbl_type;
8199 l_line_num_tbl num_tbl_type;
8200
8201 l_rep_set_of_books_id_tbl num_tbl_type;
8202
8203 l_error_level_tbl char_tbl_type;
8204 l_err_entity_id_tbl num_tbl_type;
8205 l_err_event_id_tbl num_tbl_type;
8206 l_err_ae_header_id_tbl num_tbl_type;
8207 l_err_ae_line_num_tbl num_tbl_type;
8208 l_err_temp_line_num_tbl num_tbl_type;
8209 l_error_message_name_tbl char_tbl_type;
8210
8211 CURSOR c_deferred_deprn IS
8212 select /*+ leading(df) rowid(df) */ distinct
8213 df.asset_id,
8214 df.corp_book_type_code,
8215 df.tax_book_type_code,
8216 bc.set_of_books_id,
8217 bc.org_id,
8218 'DEFERRED DEPRN',
8219 dp.calendar_period_close_date,
8220 'DEFERRED_DEPRECIATION' event_class_code,
8221 dp.period_name,
8222 dp.calendar_period_close_date,
8223 df.corp_period_counter,
8224 df.tax_period_counter,
8225 glsob.currency_code,
8226 nvl (bc.je_deferred_deprn_category, 'OTHER') je_category_name
8227 from fa_deferred_deprn df,
8228 fa_deprn_periods dp,
8229 gl_sets_of_books glsob,
8230 fa_book_controls bc,
8231 fa_lookups_tl lk_de,
8232 fa_lookups_tl lk_dr,
8233 gl_je_headers gljh,
8234 gl_period_statuses ps
8235 where df.rowid between p_start_rowid and p_end_rowid
8236 and df.corp_book_type_code = bc.book_type_code
8237 and bc.set_of_books_id = glsob.set_of_books_id
8238 and dp.book_type_code = df.corp_book_type_code
8239 and dp.period_counter = df.corp_period_counter
8240 and df.event_id is null
8241 and ps.application_id = 101
8242 and ((ps.migration_status_code in ('P', 'U')) or
8243 (dp.period_close_date is null))
8244 and substr(dp.xla_conversion_status, 1, 1) in
8245 ('H', 'U', 'E', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9')
8246 and ps.set_of_books_id = bc.set_of_books_id
8247 and ps.period_name = dp.period_name
8248 and lk_de.lookup_type = 'JOURNAL ENTRIES'
8249 and lk_dr.lookup_type = 'JOURNAL ENTRIES'
8250 and lk_de.lookup_code = 'DEFERRED DEPRN EXPENSE'
8251 and lk_dr.lookup_code = 'DEFERRED DEPRN RESERVE'
8252 and userenv('LANG') = lk_de.language
8253 and userenv('LANG') = lk_dr.language
8254 and df.je_header_id = gljh.je_header_id (+);
8255
8256 CURSOR c_detail (l_corp_book_type_code varchar2,
8257 l_tax_book_type_code varchar2,
8258 l_asset_id number,
8259 l_corp_period_counter number,
8260 l_tax_period_counter number) IS
8261 select df.distribution_id,
8262 df.deferred_deprn_expense_amount,
8263 df.deferred_deprn_reserve_amount,
8264 df.deferred_deprn_expense_ccid,
8265 df.deferred_deprn_reserve_ccid,
8266 nvl(df.expense_je_line_num, 0),
8267 nvl(df.reserve_je_line_num, 0),
8268 lk_de.description,
8269 lk_dr.description,
8270 gljh.je_batch_id,
8271 df.je_header_id,
8272 decode (df.je_header_id, null, 'N', 'Y')
8273 from fa_deferred_deprn df,
8274 fa_lookups_tl lk_de,
8275 fa_lookups_tl lk_dr,
8276 gl_je_headers gljh
8277 where df.corp_book_type_code = l_corp_book_type_code
8278 and df.tax_book_type_code = l_tax_book_type_code
8279 and df.asset_id = l_asset_id
8280 and df.corp_period_counter = l_corp_period_counter
8281 and df.tax_period_counter = l_tax_period_counter
8282 and lk_de.lookup_type = 'JOURNAL ENTRIES'
8283 and lk_dr.lookup_type = 'JOURNAL ENTRIES'
8284 and lk_de.lookup_code = 'DEFERRED DEPRN EXPENSE'
8285 and lk_dr.lookup_code = 'DEFERRED DEPRN RESERVE'
8286 and userenv('LANG') = lk_de.language
8287 and userenv('LANG') = lk_dr.language
8288 and df.je_header_id = gljh.je_header_id (+);
8289
8290 CURSOR c_mc_books (l_book_type_code varchar2) IS
8291 select set_of_books_id
8292 from fa_mc_book_controls
8293 where book_type_code = l_book_type_code
8294 and enabled_flag = 'Y';
8295
8296 CURSOR c_mc_detail (l_corp_book_type_code varchar2,
8297 l_tax_book_type_code varchar2,
8298 l_asset_id number,
8299 l_set_of_books_id number,
8300 l_corp_period_counter number,
8301 l_tax_period_counter number) IS
8302 select df.distribution_id,
8303 df.deferred_deprn_expense_amount,
8304 df.deferred_deprn_reserve_amount,
8305 df.deferred_deprn_expense_ccid,
8306 df.deferred_deprn_reserve_ccid,
8307 nvl(df.expense_je_line_num, 0),
8308 nvl(df.reserve_je_line_num, 0),
8309 lk_de.description,
8310 lk_dr.description,
8311 gljh.je_batch_id,
8312 df.je_header_id,
8313 decode (df.je_header_id, null, 'N', 'Y'),
8314 glsob.currency_code
8315 from fa_mc_deferred_deprn df,
8316 fa_lookups_tl lk_de,
8317 fa_lookups_tl lk_dr,
8318 gl_je_headers gljh,
8319 gl_sets_of_books glsob
8320 where df.corp_book_type_code = l_corp_book_type_code
8321 and df.tax_book_type_code = l_tax_book_type_code
8322 and df.asset_id = l_asset_id
8323 and df.set_of_books_id = l_set_of_books_id
8324 and df.corp_period_counter = l_corp_period_counter
8325 and df.tax_period_counter = l_tax_period_counter
8326 and lk_de.lookup_type = 'JOURNAL ENTRIES'
8327 and lk_dr.lookup_type = 'JOURNAL ENTRIES'
8328 and lk_de.lookup_code = 'DEFERRED DEPRN EXPENSE'
8329 and lk_dr.lookup_code = 'DEFERRED DEPRN RESERVE'
8330 and userenv('LANG') = lk_de.language
8331 and userenv('LANG') = lk_dr.language
8332 and df.je_header_id = gljh.je_header_id (+)
8333 and df.set_of_books_id = glsob.set_of_books_id;
8334
8335 BEGIN
8336
8337 x_success_count := 0;
8338 x_failure_count := 0;
8339
8340 l_batch_size := nvl(nvl(p_batch_size, fa_cache_pkg.fa_batch_size), 1000);
8341
8342 open c_deferred_deprn;
8343
8344 loop
8345
8346 fetch c_deferred_deprn bulk collect
8347 into
8348 l_asset_id_tbl,
8349 l_corp_book_type_code_tbl,
8350 l_tax_book_type_code_tbl,
8351 l_set_of_books_id_tbl,
8352 l_org_id_tbl,
8353 l_transaction_type_code_tbl,
8354 l_transaction_date_entered_tbl,
8355 l_event_class_code_tbl,
8356 l_period_name_tbl,
8357 l_cal_period_close_date_tbl,
8358 l_corp_period_counter_tbl,
8359 l_tax_period_counter_tbl,
8360 l_currency_code_tbl,
8361 l_je_category_name_tbl
8362 limit l_batch_size;
8363
8364 FOR i IN 1..l_asset_id_tbl.count LOOP
8365 select xla_transaction_entities_s.nextval,
8366 xla_events_s.nextval
8367 into l_entity_id_tbl(i),
8368 l_event_id_tbl(i)
8369 from dual;
8370
8371 END LOOP;
8372
8373 -- Update fa_deferred_deprn table with event_id
8374 FORALL l_count IN 1..l_event_id_tbl.count
8375 update fa_deferred_deprn
8376 set event_id = l_event_id_tbl(l_count)
8377 where rowid between p_start_rowid and p_end_rowid
8378 and asset_id = l_asset_id_tbl(l_count)
8379 and corp_book_type_code = l_corp_book_type_code_tbl(l_count)
8380 and tax_book_type_code = l_tax_book_type_code_tbl(l_count)
8381 and corp_period_counter = l_corp_period_counter_tbl(l_count)
8382 and event_id is null;
8383
8384
8385 l_rows_processed := l_event_id_tbl.count;
8386
8387 -- Update fa_mc_deferred_deprn table with event_id
8388 FORALL l_count IN 1..l_event_id_tbl.count
8389 update fa_mc_deferred_deprn
8390 set event_id = l_event_id_tbl(l_count)
8391 where asset_id = l_asset_id_tbl(l_count)
8392 and corp_book_type_code = l_corp_book_type_code_tbl(l_count)
8393 and tax_book_type_code = l_tax_book_type_code_tbl(l_count)
8394 and corp_period_counter = l_corp_period_counter_tbl(l_count)
8395 and event_id is null;
8396
8397 -- Add events to fa_deferred_deprn_events table
8398 FOR l_count IN 1..l_event_id_tbl.count LOOP
8399 insert into fa_deferred_deprn_events (
8400 asset_id,
8401 corp_book_type_code,
8402 tax_book_type_code,
8403 corp_period_counter,
8404 tax_period_counter,
8405 event_id,
8406 creation_date,
8407 created_by,
8408 last_update_date,
8409 last_updated_by,
8410 last_update_login
8411 ) select
8412 l_asset_id_tbl(l_count),
8413 l_corp_book_type_code_tbl(l_count),
8414 l_tax_book_type_code_tbl(l_count),
8415 l_corp_period_counter_tbl(l_count),
8416 l_tax_period_counter_tbl(l_count),
8417 l_event_id_tbl(l_count),
8418 sysdate,
8419 c_upgrade_bugno,
8420 sysdate,
8421 c_upgrade_bugno,
8422 c_upgrade_bugno
8423 from dual
8424 where not exists
8425 (
8426 select 'x'
8427 from fa_deferred_deprn_events
8428 where asset_id = l_asset_id_tbl(l_count)
8429 and corp_book_type_code = l_corp_book_type_code_tbl(l_count)
8430 and corp_period_counter = l_corp_period_counter_tbl(l_count)
8431 and tax_book_type_code = l_tax_book_type_code_tbl(l_count)
8432 and tax_period_counter = l_tax_period_counter_tbl(l_count)
8433 );
8434 END LOOP;
8435
8436 -- Business Rules for xla_transaction_entities
8437 -- * ledger_id is the same as set_of_books_id
8438 -- * legal_entity_id is null
8439 -- * entity_code can be TRANSACTIONS or DEPRECIATION
8440 -- * for TRANSACTIONS:
8441 -- source_id_int_1 is transaction_header_id
8442 -- transaction_number is transaction_header_id
8443 -- * for DEPRECIATION:
8444 -- source_id_int is asset_id
8445 -- source_id_int_2 is period_counter
8446 -- source_id_int_3 is deprn_run_id (always 1 for upgrade)
8447 -- transaction_number is set_of_books_id
8448 -- * source_char_id_1 is book_type_code
8449 -- * valuation_method is book_type_code
8450
8451 FORALL i IN 1..l_event_id_tbl.count
8452 INSERT INTO xla_transaction_entities_upg (
8453 upg_batch_id,
8454 application_id,
8455 ledger_id,
8456 legal_entity_id,
8457 entity_code,
8458 source_id_int_1,
8459 source_id_int_2,
8460 source_id_int_3,
8461 source_id_int_4,
8462 source_id_char_1,
8463 source_id_char_2,
8464 source_id_char_3,
8465 source_id_char_4,
8466 security_id_int_1,
8467 security_id_int_2,
8468 security_id_int_3,
8469 security_id_char_1,
8470 security_id_char_2,
8471 security_id_char_3,
8472 transaction_number,
8473 valuation_method,
8474 source_application_id,
8475 creation_date,
8476 created_by,
8477 last_update_date,
8478 last_updated_by,
8479 last_update_login,
8480 entity_id,
8481 upg_source_application_id
8482 ) values (
8483 l_upg_batch_id, -- upg_batch_id
8484 c_application_id, -- application_id
8485 l_set_of_books_id_tbl(i), -- ledger_id
8486 null, -- legal_entity_id,
8487 c_entity_code, -- entity_code
8488 l_asset_id_tbl(i), -- source_id_int_1
8489 null, -- source_id_int_2
8490 l_corp_period_counter_tbl(i), -- source_id_int_3
8491 null, -- source_id_int_4
8492 null, -- source_id_char_1
8493 l_corp_book_type_code_tbl(i), -- source_id_char_2
8494 null, -- source_id_char_3
8495 l_tax_book_type_code_tbl(i), -- source_id_char_4
8496 null, -- security_id_int_1
8497 null, -- security_id_int_2
8498 null, -- security_id_int_3
8499 null, -- security_id_char_1
8500 null, -- security_id_char_2
8501 null, -- security_id_char_3
8502 l_set_of_books_id_tbl(i), -- transaction number
8503 l_corp_book_type_code_tbl(i), -- valuation_method
8504 c_application_id, -- source_application_id
8505 sysdate, -- creation_date
8506 c_fnd_user, -- created_by
8507 sysdate, -- last_update_date
8508 c_upgrade_bugno, -- last_update_by
8509 c_upgrade_bugno, -- last_update_login
8510 l_entity_id_tbl(i), -- entity_id
8511 c_application_id -- upg_source_application_id
8512 );
8513
8514 -- Business Rules for xla_transaction_entities
8515 -- * event_type_code is similar to transaction_type_code
8516 -- * event_number is 1, but is the serial event for chronological order
8517 -- * event_status_code: N if event creates no journal entries
8518 -- P if event would ultimately yield journals
8519 -- I if event is not ready to be processed
8520 -- U never use this value for upgrade
8521 -- * process_status_code: E if error and journals not yet created
8522 -- P if processed and journals already generated
8523 -- U if unprocessed and journals not generated
8524 -- D only used for Global Accounting Engine
8525 -- I do not use for upgrade
8526 -- * on_hold_flag: N should always be this value for upgraded entries
8527 -- * event_date is basically transaction_date_entered
8528
8529 FORALL i IN 1..l_event_id_tbl.count
8530 insert into xla_events (
8531 upg_batch_id,
8532 application_id,
8533 event_type_code,
8534 event_number,
8535 event_status_code,
8536 process_status_code,
8537 on_hold_flag,
8538 event_date,
8539 creation_date,
8540 created_by,
8541 last_update_date,
8542 last_updated_by,
8543 last_update_login,
8544 program_update_date,
8545 program_id,
8546 program_application_id,
8547 request_id,
8548 entity_id,
8549 event_id,
8550 upg_source_application_id,
8551 transaction_date
8552 ) values (
8553 l_upg_batch_id, -- upg_batch_id
8554 c_application_id, -- application_id
8555 l_event_class_code_tbl(i), -- event_type_code
8556 '1', -- event_number
8557 'P', -- event_status_code
8558 'P', -- process_status_code
8559 'N', -- on_hold_flag
8560 l_transaction_date_entered_tbl(i), -- event_date
8561 sysdate, -- creation_date
8562 c_fnd_user, -- created_by
8563 sysdate, -- last_update_date
8564 c_upgrade_bugno, -- last_update_by
8565 c_upgrade_bugno, -- last_update_login
8566 null, -- program_update_date
8567 null, -- program_id
8568 null, -- program_application_id
8569 null, -- program_update_date
8570 l_entity_id_tbl(i), -- entity_id
8571 l_event_id_tbl(i), -- event_id
8572 c_application_id, -- upg_source_appl_id
8573 l_transaction_date_entered_tbl(i) -- transaction_date
8574 );
8575
8576 FOR i IN 1..l_event_id_tbl.count LOOP
8577
8578 open c_detail (l_corp_book_type_code_tbl(i),
8579 l_tax_book_type_code_tbl(i),
8580 l_asset_id_tbl(i),
8581 l_corp_period_counter_tbl(i),
8582 l_tax_period_counter_tbl(i));
8583 fetch c_detail bulk collect
8584 into l_distribution_id_tbl,
8585 l_debit_amount_tbl,
8586 l_credit_amount_tbl,
8587 l_dr_ccid_tbl,
8588 l_cr_ccid_tbl,
8589 l_exp_je_line_num_tbl,
8590 l_rsv_je_line_num_tbl,
8591 l_dfr_exp_desc_tbl,
8592 l_dfr_rsv_desc_tbl,
8593 l_je_batch_id_tbl,
8594 l_je_header_id_tbl,
8595 l_gl_transfer_status_code_tbl;
8596 close c_detail;
8597
8598 select xla_ae_headers_s.nextval
8599 into l_ae_header_id
8600 from dual;
8601
8602 FOR j IN 1..l_distribution_id_tbl.count LOOP
8603
8604 select xla_gl_sl_link_id_s.nextval
8605 into l_exp_xla_gl_sl_link_id_tbl(j)
8606 from dual;
8607
8608 select xla_gl_sl_link_id_s.nextval
8609 into l_rsv_xla_gl_sl_link_id_tbl(j)
8610 from dual;
8611
8612 l_line_num_tbl(j) := (j - 1) * 2;
8613 END LOOP;
8614
8615 -- Business Rules for xla_ae_headers
8616 -- * amb_context_code is DEFAULT
8617 -- * reference_date must be null
8618 -- * balance_type_code:
8619 -- A: Actual
8620 -- B: Budget
8621 -- E: Encumbrance
8622 -- * gl_transfer_status_code:
8623 -- Y: already transferred to GL
8624 -- N: not transferred to GL
8625 -- * gl_transfer_date is date entry transferred to GL
8626 -- * accounting_entry_status_code must be F
8627 -- * accounting_entry_type_code must be STANDARD
8628 -- * product_rule_* not relevant for upgrade
8629
8630 insert into xla_ae_headers (
8631 upg_batch_id,
8632 application_id,
8633 amb_context_code,
8634 entity_id,
8635 event_id,
8636 event_type_code,
8637 ae_header_id,
8638 ledger_id,
8639 accounting_date,
8640 period_name,
8641 reference_date,
8642 balance_type_code,
8643 je_category_name,
8644 gl_transfer_status_code,
8645 gl_transfer_date,
8646 accounting_entry_status_code,
8647 accounting_entry_type_code,
8648 description,
8649 budget_version_id,
8650 funds_status_code,
8651 encumbrance_type_id,
8652 completed_date,
8653 doc_sequence_id,
8654 doc_sequence_value,
8655 doc_category_code,
8656 packet_id,
8657 group_id,
8658 creation_date,
8659 created_by,
8660 last_update_date,
8661 last_updated_by,
8662 last_update_login,
8663 program_id,
8664 program_application_id,
8665 program_update_date,
8666 request_id,
8667 close_acct_seq_assign_id,
8668 close_acct_seq_version_id,
8669 close_acct_seq_value,
8670 completion_acct_seq_assign_id,
8671 completion_acct_seq_version_id,
8672 completion_acct_seq_value,
8673 accounting_batch_id,
8674 product_rule_type_code,
8675 product_rule_code,
8676 product_rule_version,
8677 upg_source_application_id,
8678 upg_valid_flag
8679 ) values (
8680 l_upg_batch_id, -- upg_batch_id
8681 c_application_id, -- application_id
8682 c_amb_context_code, -- amb_context_code
8683 l_entity_id_tbl(i), -- entity_id
8684 l_event_id_tbl(i), -- event_id,
8685 l_event_class_code_tbl(i), -- event_type_code
8686 l_ae_header_id, -- ae_header_id,
8687 l_set_of_books_id_tbl(i), -- ledger_id/sob_id
8688 l_cal_period_close_date_tbl(i), -- accounting_date,
8689 l_period_name_tbl(i), -- period_name,
8690 null, -- reference_date
8691 'A', -- balance_type_code,
8692 l_je_category_name_tbl(i), -- je_category_name
8693 l_gl_transfer_status_code_tbl(1), -- gl_transfer_status_code
8694 null, -- gl_transfer_date
8695 'F', -- accounting_entry_status_code
8696 'STANDARD', -- accounting_entry_type_code
8697 'Deferred Depreciation - ' ||
8698 to_char(l_cal_period_close_date_tbl(i), 'DD-MON-RR'),
8699 -- description
8700 null, -- budget_version_id
8701 null, -- funds_status_code
8702 null, -- encumbrance_type_id
8703 null, -- completed_date
8704 null, -- doc_sequence_id
8705 null, -- doc_sequence_value
8706 null, -- doc_category_code
8707 null, -- packet_id,
8708 null, -- group_id
8709 sysdate, -- creation_date
8710 c_fnd_user, -- created_by
8711 sysdate, -- last_update_date
8712 c_fnd_user, -- last_updated_by
8713 c_upgrade_bugno, -- last_update_login
8714 null, -- program_id
8715 c_application_id, -- program_application_id
8716 sysdate, -- program_update_date
8717 null, -- request_id
8718 null, -- close_acct_seq_assign_id
8719 null, -- close_acct_seq_version_id
8720 null, -- close_acct_seq_value
8721 null, -- compl_acct_seq_assign_id
8722 null, -- compl_acct_seq_version_id
8723 null, -- compl_acct_seq_value
8724 null, -- accounting_batch_id
8725 null, -- product_rule_type_code
8726 null, -- product_rule_code
8727 null, -- product_rule_version
8728 c_application_id, -- upg_souce_application_id
8729 null -- upg_valid_flag
8730 );
8731
8732 -- Business Rules for xla_ae_lines
8733 -- * gl_transfer_mode_code:
8734 -- D: Detailed mode when transferred to GL
8735 -- S: Summary mode when transferred to GL
8736 -- * gl_sl_link_table must be XLAJEL
8737 -- * currency_conversion_* needs to be populated only if different from
8738 -- ledger currency
8739
8740 FORALL j IN 1..l_distribution_id_tbl.count
8741 insert into xla_ae_lines (
8742 upg_batch_id,
8743 ae_header_id,
8744 ae_line_num,
8745 displayed_line_number,
8746 application_id,
8747 code_combination_id,
8748 gl_transfer_mode_code,
8749 accounted_dr,
8750 accounted_cr,
8751 currency_code,
8752 currency_conversion_date,
8753 currency_conversion_rate,
8754 currency_conversion_type,
8755 entered_dr,
8756 entered_cr,
8757 description,
8758 accounting_class_code,
8759 gl_sl_link_id,
8760 gl_sl_link_table,
8761 party_type_code,
8762 party_id,
8763 party_site_id,
8764 statistical_amount,
8765 ussgl_transaction_code,
8766 jgzz_recon_ref,
8767 control_balance_flag,
8768 analytical_balance_flag,
8769 upg_tax_reference_id1,
8770 upg_tax_reference_id2,
8771 upg_tax_reference_id3,
8772 creation_date,
8773 created_by,
8774 last_update_date,
8775 last_updated_by,
8776 last_update_login,
8777 program_update_date,
8778 program_id,
8779 program_application_id,
8780 request_id,
8781 gain_or_loss_flag,
8782 accounting_date,
8783 ledger_id
8784 ) values (
8785 l_upg_batch_id, -- upg_batch_id
8786 l_ae_header_id, -- ae_header_id
8787 l_line_num_tbl(j) + 1, -- ae_line_num
8788 l_line_num_tbl(j) + 1, -- displayed_line_num
8789 c_application_id, -- application_id
8790 l_dr_ccid_tbl(j), -- code_combination_id
8791 'S', -- gl_transfer_mode_code
8792 l_debit_amount_tbl(j), -- accounted_dr
8793 null, -- accounted_cr
8794 l_currency_code_tbl(i), -- currency_code
8795 null, -- currency_conversion_date
8796 null, -- currency_conversion_rate
8797 null, -- currency_conversion_type
8798 l_debit_amount_tbl(j), -- entered_dr
8799 null, -- entered_cr
8800 l_dfr_exp_desc_tbl(j) || ' - ' ||
8801 to_char(l_cal_period_close_date_tbl(i), 'DD-MON-RR'),
8802 -- description
8803 'EXPENSE', -- accounting_class_code
8804 l_exp_xla_gl_sl_link_id_tbl(j), -- gl_sl_link_id
8805 'XLAJEL', -- gl_sl_link_table
8806 null, -- party_type_code
8807 null, -- party_id
8808 null, -- party_site_id
8809 null, -- statistical_amount
8810 null, -- ussgl_transaction_code
8811 null, -- glzz_recon_ref
8812 null, -- control_balance_flag
8813 null, -- analytical_balance_flag
8814 null, -- upg_tax_reference_id1
8815 null, -- upg_tax_reference_id2
8816 null, -- upg_tax_reference_id3
8817 sysdate, -- creation_date
8818 c_fnd_user, -- created_by
8819 sysdate, -- last_update_date
8820 c_fnd_user, -- last_updated_by
8821 c_upgrade_bugno, -- last_update_login
8822 null, -- program_update_date
8823 null, -- program_id
8824 c_application_id, -- program_application_id
8825 null, -- request_id
8826 'N', -- gain_or_loss_flag
8827 l_cal_period_close_date_tbl(i), -- accounting_date,
8828 l_set_of_books_id_tbl(i) -- ledger_id/sob_id
8829 );
8830
8831 FORALL j IN 1..l_distribution_id_tbl.count
8832 insert into xla_ae_lines (
8833 upg_batch_id,
8834 ae_header_id,
8835 ae_line_num,
8836 displayed_line_number,
8837 application_id,
8838 code_combination_id,
8839 gl_transfer_mode_code,
8840 accounted_dr,
8841 accounted_cr,
8842 currency_code,
8843 currency_conversion_date,
8844 currency_conversion_rate,
8845 currency_conversion_type,
8846 entered_dr,
8847 entered_cr,
8848 description,
8849 accounting_class_code,
8850 gl_sl_link_id,
8851 gl_sl_link_table,
8852 party_type_code,
8853 party_id,
8854 party_site_id,
8855 statistical_amount,
8856 ussgl_transaction_code,
8857 jgzz_recon_ref,
8858 control_balance_flag,
8859 analytical_balance_flag,
8860 upg_tax_reference_id1,
8861 upg_tax_reference_id2,
8862 upg_tax_reference_id3,
8863 creation_date,
8864 created_by,
8865 last_update_date,
8866 last_updated_by,
8867 last_update_login,
8868 program_update_date,
8869 program_id,
8870 program_application_id,
8871 request_id,
8872 gain_or_loss_flag,
8873 accounting_date,
8874 ledger_id
8875 ) values (
8876 l_upg_batch_id, -- upg_batch_id
8877 l_ae_header_id, -- ae_header_id
8878 l_line_num_tbl(j) + 2, -- ae_line_num
8879 l_line_num_tbl(j) + 2, -- displayed_line_num
8880 c_application_id, -- application_id
8881 l_cr_ccid_tbl(j), -- code_combination_id
8882 'S', -- gl_transfer_mode_code
8883 null, -- accounted_dr
8884 l_credit_amount_tbl(j), -- accounted_cr
8885 l_currency_code_tbl(i), -- currency_code
8886 null, -- currency_conversion_date
8887 null, -- currency_conversion_rate
8888 null, -- currency_conversion_type
8889 null, -- entered_dr
8890 l_credit_amount_tbl(j), -- entered_cr
8891 l_dfr_rsv_desc_tbl(j) || ' - ' ||
8892 to_char(l_cal_period_close_date_tbl(i), 'DD-MON-RR'),
8893 'ASSET', -- accounting_class_code
8894 l_rsv_xla_gl_sl_link_id_tbl(j), -- gl_sl_link_id
8895 'XLAJEL', -- gl_sl_link_table
8896 null, -- party_type_code
8897 null, -- party_id
8898 null, -- party_site_id
8899 null, -- statistical_amount
8900 null, -- ussgl_transaction_code
8901 null, -- glzz_recon_ref
8902 null, -- control_balance_flag
8903 null, -- analytical_balance_flag
8904 null, -- upg_tax_reference_id1
8905 null, -- upg_tax_reference_id2
8906 null, -- upg_tax_reference_id3
8907 sysdate, -- creation_date
8908 c_fnd_user, -- created_by
8909 sysdate, -- last_update_date
8910 c_fnd_user, -- last_updated_by
8911 c_upgrade_bugno, -- last_update_login
8912 null, -- program_update_date
8913 null, -- program_id
8914 c_application_id, -- program_application_id
8915 null, -- request_id
8916 'N', -- gain_or_loss_flag
8917 l_cal_period_close_date_tbl(i), -- accounting_date,
8918 l_set_of_books_id_tbl(i) -- ledger_id/sob_id
8919 );
8920
8921 -- Business Rules for xla_distribution_links
8922 -- * accounting_line_code is similar to adjustment_type
8923 -- * accounting_line_type_code is S
8924 -- * merge_duplicate_code is N
8925 -- * source_distribution_type is DEFERRED
8926 -- * source_distribution_id_num_1 is transaction_header_id
8927 -- * source_distribution_id_num_2 is event_id
8928
8929 FORALL j IN 1..l_distribution_id_tbl.count
8930 insert into xla_distribution_links (
8931 upg_batch_id,
8932 application_id,
8933 event_id,
8934 ae_header_id,
8935 ae_line_num,
8936 accounting_line_code,
8937 accounting_line_type_code,
8938 source_distribution_type,
8939 source_distribution_id_char_1,
8940 source_distribution_id_char_2,
8941 source_distribution_id_char_3,
8942 source_distribution_id_char_4,
8943 source_distribution_id_char_5,
8944 source_distribution_id_num_1,
8945 source_distribution_id_num_2,
8946 source_distribution_id_num_3,
8947 source_distribution_id_num_4,
8948 source_distribution_id_num_5,
8949 merge_duplicate_code,
8950 statistical_amount,
8951 unrounded_entered_dr,
8952 unrounded_entered_cr,
8953 unrounded_accounted_dr,
8954 unrounded_accounted_cr,
8955 ref_ae_header_id,
8956 ref_temp_line_num,
8957 ref_event_id,
8958 temp_line_num,
8959 tax_line_ref_id,
8960 tax_summary_line_ref_id,
8961 tax_rec_nrec_dist_ref_id,
8962 line_definition_owner_code,
8963 line_definition_code,
8964 event_class_code,
8965 event_type_code
8966 ) values (
8967 l_upg_batch_id, -- upg_batch_id
8968 c_application_id, -- application_id
8969 l_event_id_tbl(i), -- event_id
8970 l_ae_header_id, -- ae_header_id
8971 l_line_num_tbl(j) + 1, -- ae_line_num
8972 null, -- accounting_line_code
8973 'S', -- accounting_line_type_code
8974 'DEFERRED', -- source_distribution_type
8975 null, -- source_distribution_id_char_1
8976 null, -- source_distribution_id_char_2
8977 null, -- source_distribution_id_char_3
8978 l_corp_book_type_code_tbl(i), -- source_distribution_id_char_4
8979 l_tax_book_type_code_tbl(i), -- source_distribution_id_char_5
8980 l_asset_id_tbl(i), -- source_distribution_id_num_1
8981 l_corp_period_counter_tbl(i), -- source_distribution_id_num_2
8982 l_distribution_id_tbl(j), -- source_distribution_id_num_3
8983 null, -- source_distribution_id_num_4
8984 null, -- source_distribution_id_num_5
8985 'N', -- merge_duplicate_code
8986 null, -- statistical_amount
8987 l_debit_amount_tbl(j), -- unrounded_entered_dr
8988 null, -- unrounded_entered_cr
8989 l_debit_amount_tbl(j), -- unrounded_accounted_dr
8990 null, -- unrounded_accounted_cr
8991 l_ae_header_id, -- ref_ae_header_id
8992 null, -- ref_temp_line_num
8993 null, -- ref_event_id
8994 l_line_num_tbl(j) + 1, -- temp_line_num
8995 null, -- tax_line_ref_id
8996 null, -- tax_summary_line_ref_id
8997 null, -- tax_rec_nrec_dist_ref_id
8998 null, -- line_definition_owner_code
8999 null, -- line_definition_code
9000 l_event_class_code_tbl(i), -- event_class_code
9001 l_event_class_code_tbl(i) -- event_type_code
9002 );
9003
9004 FORALL j IN 1..l_distribution_id_tbl.count
9005 insert into xla_distribution_links (
9006 upg_batch_id,
9007 application_id,
9008 event_id,
9009 ae_header_id,
9010 ae_line_num,
9011 accounting_line_code,
9012 accounting_line_type_code,
9013 source_distribution_type,
9014 source_distribution_id_char_1,
9015 source_distribution_id_char_2,
9016 source_distribution_id_char_3,
9017 source_distribution_id_char_4,
9018 source_distribution_id_char_5,
9019 source_distribution_id_num_1,
9020 source_distribution_id_num_2,
9021 source_distribution_id_num_3,
9022 source_distribution_id_num_4,
9023 source_distribution_id_num_5,
9024 merge_duplicate_code,
9025 statistical_amount,
9026 unrounded_entered_dr,
9027 unrounded_entered_cr,
9028 unrounded_accounted_dr,
9029 unrounded_accounted_cr,
9030 ref_ae_header_id,
9031 ref_temp_line_num,
9032 ref_event_id,
9033 temp_line_num,
9034 tax_line_ref_id,
9035 tax_summary_line_ref_id,
9036 tax_rec_nrec_dist_ref_id,
9037 line_definition_owner_code,
9038 line_definition_code,
9039 event_class_code,
9040 event_type_code
9041 ) values (
9042 l_upg_batch_id, -- upg_batch_id
9043 c_application_id, -- application_id
9044 l_event_id_tbl(i), -- event_id
9045 l_ae_header_id, -- ae_header_id
9046 l_line_num_tbl(j) + 2, -- ae_line_num
9047 null, -- accounting_line_code
9048 'S', -- accounting_line_type_code
9049 'DEFERRED', -- source_distribution_type
9050 null, -- source_distribution_id_char_1
9051 null, -- source_distribution_id_char_2
9052 null, -- source_distribution_id_char_3
9053 l_corp_book_type_code_tbl(i), -- source_distribution_id_char_4
9054 l_tax_book_type_code_tbl(i), -- source_distribution_id_char_5
9055 l_asset_id_tbl(i), -- source_distribution_id_num_1
9056 l_corp_period_counter_tbl(i), -- source_distribution_id_num_2
9057 l_distribution_id_tbl(j), -- source_distribution_id_num_3
9058 null, -- source_distribution_id_num_4
9059 null, -- source_distribution_id_num_5
9060 'N', -- merge_duplicate_code
9061 null, -- statistical_amount
9062 null, -- unrounded_entered_dr
9063 l_credit_amount_tbl(j), -- unrounded_entered_cr
9064 null, -- unrounded_accounted_dr
9065 l_credit_amount_tbl(j), -- unrounded_accounted_cr
9066 l_ae_header_id, -- ref_ae_header_id
9067 null, -- ref_temp_line_num
9068 null, -- ref_event_id
9069 l_line_num_tbl(j) + 2, -- temp_line_num
9070 null, -- tax_line_ref_id
9071 null, -- tax_summary_line_ref_id
9072 null, -- tax_rec_nrec_dist_ref_id
9073 null, -- line_definition_owner_code
9074 null, -- line_definition_code
9075 l_event_class_code_tbl(i), -- event_class_code
9076 l_event_class_code_tbl(i) -- event_type_code
9077 );
9078
9079 FOR j IN 1..l_distribution_id_tbl.count LOOP
9080 if (l_je_batch_id_tbl(j) is not null) then
9081 insert into gl_import_references (
9082 je_batch_id,
9083 je_header_id,
9084 je_line_num,
9085 last_update_date,
9086 last_updated_by,
9087 creation_date,
9088 created_by,
9089 last_update_login,
9090 reference_1,
9091 reference_2,
9092 reference_3,
9093 reference_4,
9094 reference_5,
9095 reference_6,
9096 reference_7,
9097 reference_8,
9098 reference_9,
9099 reference_10,
9100 subledger_doc_sequence_id,
9101 subledger_doc_sequence_value,
9102 gl_sl_link_id,
9103 gl_sl_link_table
9104 ) values (
9105 l_je_batch_id_tbl(j), -- je_batch_id
9106 l_je_header_id_tbl(j), -- je_header_id
9107 l_exp_je_line_num_tbl(j), -- je_line_num
9108 sysdate, -- last_update_date
9109 c_fnd_user, -- last_updated_by
9110 sysdate, -- creation_date
9111 c_fnd_user, -- created_by
9112 c_upgrade_bugno, -- last_update_login
9113 null, -- reference_1
9114 to_char(l_asset_id_tbl(i)), -- reference_2
9115 to_char(l_distribution_id_tbl(j)),
9116 -- reference_3
9117 null, -- reference_4
9118 l_corp_book_type_code_tbl(j),-- reference_5
9119 to_char(l_corp_period_counter_tbl(j)),
9120 -- reference_6
9121 null, -- reference_7
9122 null, -- reference_8
9123 null, -- reference_9
9124 null, -- reference_10
9125 null, -- subledger_doc_seq_id
9126 null, -- subledger_doc_seq_value
9127 l_exp_xla_gl_sl_link_id_tbl(j),
9128 -- gl_sl_link_id
9129 'XLAJEL' -- gl_sl_link_table
9130 );
9131
9132 insert into gl_import_references (
9133 je_batch_id,
9134 je_header_id,
9135 je_line_num,
9136 last_update_date,
9137 last_updated_by,
9138 creation_date,
9139 created_by,
9140 last_update_login,
9141 reference_1,
9142 reference_2,
9143 reference_3,
9144 reference_4,
9145 reference_5,
9146 reference_6,
9147 reference_7,
9148 reference_8,
9149 reference_9,
9150 reference_10,
9151 subledger_doc_sequence_id,
9152 subledger_doc_sequence_value,
9153 gl_sl_link_id,
9154 gl_sl_link_table
9155 ) values (
9156 l_je_batch_id_tbl(j), -- je_batch_id
9157 l_je_header_id_tbl(j), -- je_header_id
9158 l_rsv_je_line_num_tbl(j), -- je_line_num
9159 sysdate, -- last_update_date
9160 c_fnd_user, -- last_updated_by
9161 sysdate, -- creation_date
9162 c_fnd_user, -- created_by
9163 c_upgrade_bugno, -- last_update_login
9164 null, -- reference_1
9165 to_char(l_asset_id_tbl(i)), -- reference_2
9166 to_char(l_distribution_id_tbl(j)),
9167 -- reference_3
9168 null, -- reference_4
9169 l_corp_book_type_code_tbl(i),-- reference_5
9170 to_char(l_corp_period_counter_tbl(i)),
9171 -- reference_6
9172 null, -- reference_7
9173 null, -- reference_8
9174 null, -- reference_9
9175 null, -- reference_10
9176 null, -- subledger_doc_seq_id
9177 null, -- subledger_doc_seq_value
9178 l_rsv_xla_gl_sl_link_id_tbl(j),
9179 -- gl_sl_link_id
9180 'XLAJEL' -- gl_sl_link_table
9181 );
9182 end if;
9183 end loop;
9184
9185 l_ae_header_id_tbl.delete;
9186 l_cr_ccid_tbl.delete;
9187 l_dr_ccid_tbl.delete;
9188 l_credit_amount_tbl.delete;
9189 l_debit_amount_tbl.delete;
9190 l_exp_xla_gl_sl_link_id_tbl.delete;
9191 l_rsv_xla_gl_sl_link_id_tbl.delete;
9192 l_line_def_owner_code_tbl.delete;
9193 l_line_def_code_tbl.delete;
9194 l_dfr_exp_desc_tbl.delete;
9195 l_dfr_rsv_desc_tbl.delete;
9196 l_gl_transfer_status_code_tbl.delete;
9197 l_je_batch_id_tbl.delete;
9198 l_je_header_id_tbl.delete;
9199 l_exp_je_line_num_tbl.delete;
9200 l_rsv_je_line_num_tbl.delete;
9201 l_distribution_id_tbl.delete;
9202 l_line_num_tbl.delete;
9203
9204 open c_mc_books (l_corp_book_type_code_tbl(i));
9205 fetch c_mc_books bulk collect
9206 into l_rep_set_of_books_id_tbl;
9207 close c_mc_books;
9208
9209 for k IN 1..l_rep_set_of_books_id_tbl.count loop
9210
9211 open c_mc_detail (l_corp_book_type_code_tbl(i),
9212 l_tax_book_type_code_tbl(i),
9213 l_asset_id_tbl(i),
9214 l_rep_set_of_books_id_tbl(k),
9215 l_corp_period_counter_tbl(i),
9216 l_tax_period_counter_tbl(i));
9217 fetch c_mc_detail bulk collect
9218 into l_distribution_id_tbl,
9219 l_debit_amount_tbl,
9220 l_credit_amount_tbl,
9221 l_dr_ccid_tbl,
9222 l_cr_ccid_tbl,
9223 l_exp_je_line_num_tbl,
9224 l_rsv_je_line_num_tbl,
9225 l_dfr_exp_desc_tbl,
9226 l_dfr_rsv_desc_tbl,
9227 l_je_batch_id_tbl,
9228 l_je_header_id_tbl,
9229 l_gl_transfer_status_code_tbl,
9230 l_currency_code_tbl;
9231 close c_mc_detail;
9232
9233 select xla_ae_headers_s.nextval
9234 into l_ae_header_id
9235 from dual;
9236
9237 FOR j IN 1..l_distribution_id_tbl.count LOOP
9238
9239 select xla_gl_sl_link_id_s.nextval
9240 into l_exp_xla_gl_sl_link_id_tbl(j)
9241 from dual;
9242
9243 select xla_gl_sl_link_id_s.nextval
9244 into l_rsv_xla_gl_sl_link_id_tbl(j)
9245 from dual;
9246
9247 l_line_num_tbl(j) := (j - 1) * 2;
9248 END LOOP;
9249
9250 -- Business Rules for xla_ae_headers
9251 -- * amb_context_code is DEFAULT
9252 -- * reference_date must be null
9253 -- * balance_type_code:
9254 -- A: Actual
9255 -- B: Budget
9256 -- E: Encumbrance
9257 -- * gl_transfer_status_code:
9258 -- Y: already transferred to GL
9259 -- N: not transferred to GL
9260 -- * gl_transfer_date is date entry transferred to GL
9261 -- * accounting_entry_status_code must be F
9262 -- * accounting_entry_type_code must be STANDARD
9263 -- * product_rule_* not relevant for upgrade
9264
9265 insert into xla_ae_headers (
9266 upg_batch_id,
9267 application_id,
9268 amb_context_code,
9269 entity_id,
9270 event_id,
9271 event_type_code,
9272 ae_header_id,
9273 ledger_id,
9274 accounting_date,
9275 period_name,
9276 reference_date,
9277 balance_type_code,
9278 je_category_name,
9279 gl_transfer_status_code,
9280 gl_transfer_date,
9281 accounting_entry_status_code,
9282 accounting_entry_type_code,
9283 description,
9284 budget_version_id,
9285 funds_status_code,
9286 encumbrance_type_id,
9287 completed_date,
9288 doc_sequence_id,
9289 doc_sequence_value,
9290 doc_category_code,
9291 packet_id,
9292 group_id,
9293 creation_date,
9294 created_by,
9295 last_update_date,
9296 last_updated_by,
9297 last_update_login,
9298 program_id,
9299 program_application_id,
9300 program_update_date,
9301 request_id,
9302 close_acct_seq_assign_id,
9303 close_acct_seq_version_id,
9304 close_acct_seq_value,
9305 completion_acct_seq_assign_id,
9306 completion_acct_seq_version_id,
9307 completion_acct_seq_value,
9308 accounting_batch_id,
9309 product_rule_type_code,
9310 product_rule_code,
9311 product_rule_version,
9312 upg_source_application_id,
9313 upg_valid_flag
9314 ) values (
9315 l_upg_batch_id, -- upg_batch_id
9316 c_application_id, -- application_id
9317 c_amb_context_code, -- amb_context_code
9318 l_entity_id_tbl(i), -- entity_id
9319 l_event_id_tbl(i), -- event_id,
9320 l_event_class_code_tbl(i), -- event_type_code
9321 l_ae_header_id, -- ae_header_id,
9322 l_rep_set_of_books_id_tbl(k), -- ledger_id/sob_id
9323 l_cal_period_close_date_tbl(i), -- accounting_date,
9324 l_period_name_tbl(i), -- period_name,
9325 null, -- reference_date
9326 'A', -- balance_type_code,
9327 l_je_category_name_tbl(i), -- je_category_name
9328 l_gl_transfer_status_code_tbl(1), -- gl_transfer_status_code
9329 null, -- gl_transfer_date
9330 'F', -- accounting_entry_status_code
9331 'STANDARD', -- accounting_entry_type_code
9332 'Deferred Depreciation - ' ||
9333 to_char(l_cal_period_close_date_tbl(i), 'DD-MON-RR'),
9334 -- description
9335 null, -- budget_version_id
9336 null, -- funds_status_code
9337 null, -- encumbrance_type_id
9338 null, -- completed_date
9339 null, -- doc_sequence_id
9340 null, -- doc_sequence_value
9341 null, -- doc_category_code
9342 null, -- packet_id,
9343 null, -- group_id
9344 sysdate, -- creation_date
9345 c_fnd_user, -- created_by
9346 sysdate, -- last_update_date
9347 c_fnd_user, -- last_updated_by
9348 c_upgrade_bugno, -- last_update_login
9349 null, -- program_id
9350 c_application_id, -- program_application_id
9351 sysdate, -- program_update_date
9352 null, -- request_id
9353 null, -- close_acct_seq_assign_id
9354 null, -- close_acct_seq_version_id
9355 null, -- close_acct_seq_value
9356 null, -- compl_acct_seq_assign_id
9357 null, -- compl_acct_seq_version_id
9358 null, -- compl_acct_seq_value
9359 null, -- accounting_batch_id
9360 null, -- product_rule_type_code
9361 null, -- product_rule_code
9362 null, -- product_rule_version
9363 c_application_id, -- upg_souce_application_id
9364 null -- upg_valid_flag
9365 );
9366
9367 -- Business Rules for xla_ae_lines
9368 -- * gl_transfer_mode_code:
9369 -- D: Detailed mode when transferred to GL
9370 -- S: Summary mode when transferred to GL
9371 -- * gl_sl_link_table must be XLAJEL
9372 -- * currency_conversion_* needs to be populated only if different from
9373 -- ledger currency
9374
9375 FORALL j IN 1..l_distribution_id_tbl.count
9376 insert into xla_ae_lines (
9377 upg_batch_id,
9378 ae_header_id,
9379 ae_line_num,
9380 displayed_line_number,
9381 application_id,
9382 code_combination_id,
9383 gl_transfer_mode_code,
9384 accounted_dr,
9385 accounted_cr,
9386 currency_code,
9387 currency_conversion_date,
9388 currency_conversion_rate,
9389 currency_conversion_type,
9390 entered_dr,
9391 entered_cr,
9392 description,
9393 accounting_class_code,
9394 gl_sl_link_id,
9395 gl_sl_link_table,
9396 party_type_code,
9397 party_id,
9398 party_site_id,
9399 statistical_amount,
9400 ussgl_transaction_code,
9401 jgzz_recon_ref,
9402 control_balance_flag,
9403 analytical_balance_flag,
9404 upg_tax_reference_id1,
9405 upg_tax_reference_id2,
9406 upg_tax_reference_id3,
9407 creation_date,
9408 created_by,
9409 last_update_date,
9410 last_updated_by,
9411 last_update_login,
9412 program_update_date,
9413 program_id,
9414 program_application_id,
9415 request_id,
9416 gain_or_loss_flag,
9417 accounting_date,
9418 ledger_id
9419 ) values (
9420 l_upg_batch_id, -- upg_batch_id
9421 l_ae_header_id, -- ae_header_id
9422 l_line_num_tbl(j) + 1, -- ae_line_num
9423 l_line_num_tbl(j) + 1, -- displayed_line_num
9424 c_application_id, -- application_id
9425 l_dr_ccid_tbl(j), -- code_combination_id
9426 'S', -- gl_transfer_mode_code
9427 l_debit_amount_tbl(j), -- accounted_dr
9428 null, -- accounted_cr
9429 l_currency_code_tbl(j), -- currency_code
9430 null, -- currency_conversion_date
9431 null, -- currency_conversion_rate
9432 null, -- currency_conversion_type
9433 l_debit_amount_tbl(j), -- entered_dr
9434 null, -- entered_cr
9435 l_dfr_exp_desc_tbl(j) || ' - ' ||
9436 to_char(l_cal_period_close_date_tbl(i), 'DD-MON-RR'),
9437 -- description
9438 'EXPENSE', -- accounting_class_code
9439 l_exp_xla_gl_sl_link_id_tbl(j), -- gl_sl_link_id
9440 'XLAJEL', -- gl_sl_link_table
9441 null, -- party_type_code
9442 null, -- party_id
9443 null, -- party_site_id
9444 null, -- statistical_amount
9445 null, -- ussgl_transaction_code
9446 null, -- glzz_recon_ref
9447 null, -- control_balance_flag
9448 null, -- analytical_balance_flag
9449 null, -- upg_tax_reference_id1
9450 null, -- upg_tax_reference_id2
9451 null, -- upg_tax_reference_id3
9452 sysdate, -- creation_date
9453 c_fnd_user, -- created_by
9454 sysdate, -- last_update_date
9455 c_fnd_user, -- last_updated_by
9456 c_upgrade_bugno, -- last_update_login
9457 null, -- program_update_date
9458 null, -- program_id
9459 c_application_id, -- program_application_id
9460 null, -- request_id
9461 'N', -- gain_or_loss_flag
9462 l_cal_period_close_date_tbl(i), -- accounting_date,
9463 l_rep_set_of_books_id_tbl(k) -- ledger_id/sob_id
9464 );
9465
9466 FORALL j IN 1..l_distribution_id_tbl.count
9467 insert into xla_ae_lines (
9468 upg_batch_id,
9469 ae_header_id,
9470 ae_line_num,
9471 displayed_line_number,
9472 application_id,
9473 code_combination_id,
9474 gl_transfer_mode_code,
9475 accounted_dr,
9476 accounted_cr,
9477 currency_code,
9478 currency_conversion_date,
9479 currency_conversion_rate,
9480 currency_conversion_type,
9481 entered_dr,
9482 entered_cr,
9483 description,
9484 accounting_class_code,
9485 gl_sl_link_id,
9486 gl_sl_link_table,
9487 party_type_code,
9488 party_id,
9489 party_site_id,
9490 statistical_amount,
9491 ussgl_transaction_code,
9492 jgzz_recon_ref,
9493 control_balance_flag,
9494 analytical_balance_flag,
9495 upg_tax_reference_id1,
9496 upg_tax_reference_id2,
9497 upg_tax_reference_id3,
9498 creation_date,
9499 created_by,
9500 last_update_date,
9501 last_updated_by,
9502 last_update_login,
9503 program_update_date,
9504 program_id,
9505 program_application_id,
9506 request_id,
9507 gain_or_loss_flag,
9508 accounting_date,
9509 ledger_id
9510 ) values (
9511 l_upg_batch_id, -- upg_batch_id
9512 l_ae_header_id, -- ae_header_id
9513 l_line_num_tbl(j) + 2, -- ae_line_num
9514 l_line_num_tbl(j) + 2, -- displayed_line_num
9515 c_application_id, -- application_id
9516 l_cr_ccid_tbl(j), -- code_combination_id
9517 'S', -- gl_transfer_mode_code
9518 null, -- accounted_dr
9519 l_credit_amount_tbl(j), -- accounted_cr
9520 l_currency_code_tbl(j), -- currency_code
9521 null, -- currency_conversion_date
9522 null, -- currency_conversion_rate
9523 null, -- currency_conversion_type
9524 null, -- entered_dr
9525 l_credit_amount_tbl(j), -- entered_cr
9526 l_dfr_rsv_desc_tbl(j) || ' - ' ||
9527 to_char(l_cal_period_close_date_tbl(i), 'DD-MON-RR'),
9528 'ASSET', -- accounting_class_code
9529 l_rsv_xla_gl_sl_link_id_tbl(j), -- gl_sl_link_id
9530 'XLAJEL', -- gl_sl_link_table
9531 null, -- party_type_code
9532 null, -- party_id
9533 null, -- party_site_id
9534 null, -- statistical_amount
9535 null, -- ussgl_transaction_code
9536 null, -- glzz_recon_ref
9537 null, -- control_balance_flag
9538 null, -- analytical_balance_flag
9539 null, -- upg_tax_reference_id1
9540 null, -- upg_tax_reference_id2
9541 null, -- upg_tax_reference_id3
9542 sysdate, -- creation_date
9543 c_fnd_user, -- created_by
9544 sysdate, -- last_update_date
9545 c_fnd_user, -- last_updated_by
9546 c_upgrade_bugno, -- last_update_login
9547 null, -- program_update_date
9548 null, -- program_id
9549 c_application_id, -- program_application_id
9550 null, -- request_id
9551 'N', -- gain_or_loss_flag
9552 l_cal_period_close_date_tbl(i), -- accounting_date,
9553 l_rep_set_of_books_id_tbl(k) -- ledger_id/sob_id
9554 );
9555
9556 -- Business Rules for xla_distribution_links
9557 -- * accounting_line_code is similar to adjustment_type
9558 -- * accounting_line_type_code is S
9559 -- * merge_duplicate_code is N
9560 -- * source_distribution_type is DEFERRED
9561 -- * source_distribution_id_num_1 is transaction_header_id
9562 -- * source_distribution_id_num_2 is event_id
9563
9564 FORALL j IN 1..l_distribution_id_tbl.count
9565 insert into xla_distribution_links (
9566 upg_batch_id,
9567 application_id,
9568 event_id,
9569 ae_header_id,
9570 ae_line_num,
9571 accounting_line_code,
9572 accounting_line_type_code,
9573 source_distribution_type,
9574 source_distribution_id_char_1,
9575 source_distribution_id_char_2,
9576 source_distribution_id_char_3,
9577 source_distribution_id_char_4,
9578 source_distribution_id_char_5,
9579 source_distribution_id_num_1,
9580 source_distribution_id_num_2,
9581 source_distribution_id_num_3,
9582 source_distribution_id_num_4,
9583 source_distribution_id_num_5,
9584 merge_duplicate_code,
9585 statistical_amount,
9586 unrounded_entered_dr,
9587 unrounded_entered_cr,
9588 unrounded_accounted_dr,
9589 unrounded_accounted_cr,
9590 ref_ae_header_id,
9591 ref_temp_line_num,
9592 ref_event_id,
9593 temp_line_num,
9594 tax_line_ref_id,
9595 tax_summary_line_ref_id,
9596 tax_rec_nrec_dist_ref_id,
9597 line_definition_owner_code,
9598 line_definition_code,
9599 event_class_code,
9600 event_type_code
9601 ) values (
9602 l_upg_batch_id, -- upg_batch_id
9603 c_application_id, -- application_id
9604 l_event_id_tbl(i), -- event_id
9605 l_ae_header_id, -- ae_header_id
9606 l_line_num_tbl(j) + 1, -- ae_line_num
9607 null, -- accounting_line_code
9608 'S', -- accounting_line_type_code
9609 'DEFERRED', -- source_distribution_type
9610 /*
9611 null, -- source_distribution_id_char_1
9612 l_corp_book_type_code_tbl(i), -- source_distribution_id_char_2
9613 null, -- source_distribution_id_char_3
9614 l_tax_book_type_code_tbl(i), -- source_distribution_id_char_4
9615 null, -- source_distribution_id_char_5
9616 l_asset_id_tbl(i), -- source_distribution_id_num_1
9617 null, -- source_distribution_id_num_2
9618 l_corp_period_counter_tbl(i), -- source_distribution_id_num_3
9619 null, -- source_distribution_id_num_4
9620 l_distribution_id_tbl(j), -- source_distribution_id_num_5 */
9621 null, -- source_distribution_id_char_1
9622 null, -- source_distribution_id_char_2
9623 null, -- source_distribution_id_char_3
9624 l_corp_book_type_code_tbl(i), -- source_distribution_id_char_4
9625 l_tax_book_type_code_tbl(i), -- source_distribution_id_char_5
9626 l_asset_id_tbl(i), -- source_distribution_id_num_1
9627 l_corp_period_counter_tbl(i), -- source_distribution_id_num_2
9628 l_distribution_id_tbl(j), -- source_distribution_id_num_3
9629 null, -- source_distribution_id_num_4
9630 null, -- source_distribution_id_num_5
9631 'N', -- merge_duplicate_code
9632 null, -- statistical_amount
9633 l_debit_amount_tbl(j), -- unrounded_entered_dr
9634 null, -- unrounded_entered_cr
9635 l_debit_amount_tbl(j), -- unrounded_accounted_dr
9636 null, -- unrounded_accounted_cr
9637 l_ae_header_id, -- ref_ae_header_id
9638 null, -- ref_temp_line_num
9639 null, -- ref_event_id
9640 1, -- temp_line_num
9641 null, -- tax_line_ref_id
9642 null, -- tax_summary_line_ref_id
9643 null, -- tax_rec_nrec_dist_ref_id
9644 null, -- line_definition_owner_code
9645 null, -- line_definition_code
9646 l_event_class_code_tbl(i), -- event_class_code
9647 l_event_class_code_tbl(i) -- event_type_code
9648 );
9649
9650 FORALL j IN 1..l_distribution_id_tbl.count
9651 insert into xla_distribution_links (
9652 upg_batch_id,
9653 application_id,
9654 event_id,
9655 ae_header_id,
9656 ae_line_num,
9657 accounting_line_code,
9658 accounting_line_type_code,
9659 source_distribution_type,
9660 source_distribution_id_char_1,
9661 source_distribution_id_char_2,
9662 source_distribution_id_char_3,
9663 source_distribution_id_char_4,
9664 source_distribution_id_char_5,
9665 source_distribution_id_num_1,
9666 source_distribution_id_num_2,
9667 source_distribution_id_num_3,
9668 source_distribution_id_num_4,
9669 source_distribution_id_num_5,
9670 merge_duplicate_code,
9671 statistical_amount,
9672 unrounded_entered_dr,
9673 unrounded_entered_cr,
9674 unrounded_accounted_dr,
9675 unrounded_accounted_cr,
9676 ref_ae_header_id,
9677 ref_temp_line_num,
9678 ref_event_id,
9679 temp_line_num,
9680 tax_line_ref_id,
9681 tax_summary_line_ref_id,
9682 tax_rec_nrec_dist_ref_id,
9683 line_definition_owner_code,
9684 line_definition_code,
9685 event_class_code,
9686 event_type_code
9687 ) values (
9688 l_upg_batch_id, -- upg_batch_id
9689 c_application_id, -- application_id
9690 l_event_id_tbl(i), -- event_id
9691 l_ae_header_id, -- ae_header_id
9692 l_line_num_tbl(j) + 2, -- ae_line_num
9693 null, -- accounting_line_code
9694 'S', -- accounting_line_type_code
9695 'DEFERRED', -- source_distribution_type
9696 null, -- source_distribution_id_char_1
9697 null, -- source_distribution_id_char_2
9698 null, -- source_distribution_id_char_3
9699 l_corp_book_type_code_tbl(i), -- source_distribution_id_char_4
9700 l_tax_book_type_code_tbl(i), -- source_distribution_id_char_5
9701 l_asset_id_tbl(i), -- source_distribution_id_num_1
9702 l_corp_period_counter_tbl(i), -- source_distribution_id_num_2
9703 l_distribution_id_tbl(j), -- source_distribution_id_num_3
9704 null, -- source_distribution_id_num_4
9705 null, -- source_distribution_id_num_5
9706 'N', -- merge_duplicate_code
9707 null, -- statistical_amount
9708 null, -- unrounded_entered_dr
9709 l_credit_amount_tbl(j), -- unrounded_entered_cr
9710 null, -- unrounded_accounted_dr
9711 l_credit_amount_tbl(j), -- unrounded_accounted_cr
9712 l_ae_header_id, -- ref_ae_header_id
9713 null, -- ref_temp_line_num
9714 null, -- ref_event_id
9715 l_line_num_tbl(j) + 2, -- temp_line_num
9716 null, -- tax_line_ref_id
9717 null, -- tax_summary_line_ref_id
9718 null, -- tax_rec_nrec_dist_ref_id
9719 null, -- line_definition_owner_code
9720 null, -- line_definition_code
9721 l_event_class_code_tbl(i), -- event_class_code
9722 l_event_class_code_tbl(i) -- event_type_code
9723 );
9724
9725 FOR j IN 1..l_distribution_id_tbl.count LOOP
9726 if (l_je_batch_id_tbl(j) is not null) then
9727 insert into gl_import_references (
9728 je_batch_id,
9729 je_header_id,
9730 je_line_num,
9731 last_update_date,
9732 last_updated_by,
9733 creation_date,
9734 created_by,
9735 last_update_login,
9736 reference_1,
9737 reference_2,
9738 reference_3,
9739 reference_4,
9740 reference_5,
9741 reference_6,
9742 reference_7,
9743 reference_8,
9744 reference_9,
9745 reference_10,
9746 subledger_doc_sequence_id,
9747 subledger_doc_sequence_value,
9748 gl_sl_link_id,
9749 gl_sl_link_table
9750 ) values (
9751 l_je_batch_id_tbl(j), -- je_batch_id
9752 l_je_header_id_tbl(j), -- je_header_id
9753 l_exp_je_line_num_tbl(j), -- je_line_num
9754 sysdate, -- last_update_date
9755 c_fnd_user, -- last_updated_by
9756 sysdate, -- creation_date
9757 c_fnd_user, -- created_by
9758 c_upgrade_bugno, -- last_update_login
9759 null, -- reference_1
9760 to_char(l_asset_id_tbl(i)), -- reference_2
9761 to_char(l_distribution_id_tbl(j)),
9762 -- reference_3
9763 null, -- reference_4
9764 l_corp_book_type_code_tbl(j),-- reference_5
9765 to_char(l_corp_period_counter_tbl(j)),
9766 -- reference_6
9767 null, -- reference_7
9768 null, -- reference_8
9769 null, -- reference_9
9770 null, -- reference_10
9771 null, -- subledger_doc_seq_id
9772 null, -- subledger_doc_seq_value
9773 l_exp_xla_gl_sl_link_id_tbl(j),
9774 -- gl_sl_link_id
9775 'XLAJEL' -- gl_sl_link_table
9776 );
9777
9778 insert into gl_import_references (
9779 je_batch_id,
9780 je_header_id,
9781 je_line_num,
9782 last_update_date,
9783 last_updated_by,
9784 creation_date,
9785 created_by,
9786 last_update_login,
9787 reference_1,
9788 reference_2,
9789 reference_3,
9790 reference_4,
9791 reference_5,
9792 reference_6,
9793 reference_7,
9794 reference_8,
9795 reference_9,
9796 reference_10,
9797 subledger_doc_sequence_id,
9798 subledger_doc_sequence_value,
9799 gl_sl_link_id,
9800 gl_sl_link_table
9801 ) values (
9802 l_je_batch_id_tbl(j), -- je_batch_id
9803 l_je_header_id_tbl(j), -- je_header_id
9804 l_rsv_je_line_num_tbl(j), -- je_line_num
9805 sysdate, -- last_update_date
9806 c_fnd_user, -- last_updated_by
9807 sysdate, -- creation_date
9808 c_fnd_user, -- created_by
9809 c_upgrade_bugno, -- last_update_login
9810 null, -- reference_1
9811 to_char(l_asset_id_tbl(i)), -- reference_2
9812 to_char(l_distribution_id_tbl(j)),
9813 -- reference_3
9814 null, -- reference_4
9815 l_corp_book_type_code_tbl(i),-- reference_5
9816 to_char(l_corp_period_counter_tbl(i)),
9817 -- reference_6
9818 null, -- reference_7
9819 null, -- reference_8
9820 null, -- reference_9
9821 null, -- reference_10
9822 null, -- subledger_doc_seq_id
9823 null, -- subledger_doc_seq_value
9824 l_rsv_xla_gl_sl_link_id_tbl(j),
9825 -- gl_sl_link_id
9826 'XLAJEL' -- gl_sl_link_table
9827 );
9828 end if;
9829 end loop;
9830
9831 l_ae_header_id_tbl.delete;
9832 l_cr_ccid_tbl.delete;
9833 l_dr_ccid_tbl.delete;
9834 l_credit_amount_tbl.delete;
9835 l_debit_amount_tbl.delete;
9836 l_exp_xla_gl_sl_link_id_tbl.delete;
9837 l_rsv_xla_gl_sl_link_id_tbl.delete;
9838 l_line_def_owner_code_tbl.delete;
9839 l_line_def_code_tbl.delete;
9840 l_dfr_exp_desc_tbl.delete;
9841 l_dfr_rsv_desc_tbl.delete;
9842 l_gl_transfer_status_code_tbl.delete;
9843 l_je_batch_id_tbl.delete;
9844 l_je_header_id_tbl.delete;
9845 l_exp_je_line_num_tbl.delete;
9846 l_rsv_je_line_num_tbl.delete;
9847 l_distribution_id_tbl.delete;
9848 l_line_num_tbl.delete;
9849
9850 end loop;
9851
9852 l_rep_set_of_books_id_tbl.delete;
9853
9854 END LOOP;
9855
9856 l_rowid_tbl.delete;
9857 l_event_id_tbl.delete;
9858 l_asset_id_tbl.delete;
9859 l_corp_book_type_code_tbl.delete;
9860 l_tax_book_type_code_tbl.delete;
9861 l_set_of_books_id_tbl.delete;
9862 l_org_id_tbl.delete;
9863 l_transaction_type_code_tbl.delete;
9864 l_transaction_date_entered_tbl.delete;
9865 l_corp_period_counter_tbl.delete;
9866 l_tax_period_counter_tbl.delete;
9867 l_period_name_tbl.delete;
9868 l_cal_period_close_date_tbl.delete;
9869 l_entity_id_tbl.delete;
9870 l_event_class_code_tbl.delete;
9871 l_currency_code_tbl.delete;
9872
9873 commit;
9874
9875 if (l_rows_processed < l_batch_size) then exit; end if;
9876
9877 end loop;
9878
9879 close c_deferred_deprn;
9880
9881 EXCEPTION
9882 WHEN OTHERS THEN
9883 rollback;
9884 raise;
9885
9886 END Upgrade_Deferred_Events;
9887
9888 END FA_SLA_EVENTS_UPG_PKG;