[Home] [Help]
PACKAGE BODY: APPS.GMF_MIGRATION
Source
1 PACKAGE BODY GMF_MIGRATION AS
2 /* $Header: gmfmigrb.pls 120.56.12020000.3 2012/10/19 12:07:50 uskumari ship $ */
3
4 /**********************************************************************
5 * FUNCTION: *
6 * Get_Inventory_Item_Id *
7 * *
8 * DESCRIPTION: *
9 * This is an internal function used to retrieve the Inventory *
10 * Item Id value for the OPM Item Id passed *
11 * *
12 * PARAMETERS: *
13 * p_item_id - OPM Item Id to retrieve the value. *
14 * *
15 * SYNOPSIS: *
16 * Get_Inventory_Item_Id (p_Item_id => 12121); *
17 * *
18 * HISTORY *
19 * 27-Apr-2005 Created Anand Thiyagarajan *
20 **********************************************************************/
21 FUNCTION Get_Inventory_Item_Id
22 (
23 p_Item_id IN NUMBER
24 )
25 RETURN NUMBER
26 IS
27
28 /************************
29 * Local Variables *
30 ************************/
31
32 l_Inventory_item_id mtl_system_items_b.inventory_item_id%TYPE;
33
34 /****************
35 * Cursors *
36 ****************/
37
38 CURSOR cur_Inventory_item_id
39 (
40 p_Item_id IN NUMBER
41 )
42 IS
43 SELECT inventory_item_id
44 FROM ic_item_mst_b_mig
45 WHERE item_id = p_item_id
46 AND inventory_item_id IS NOT NULL
47 AND ROWNUM = 1;
48
49 BEGIN
50
51 OPEN Cur_Inventory_item_id(p_item_id);
52 FETCH Cur_Inventory_item_id INTO L_Inventory_item_id;
53
54 IF Cur_Inventory_item_id%NOTFOUND THEN
55 CLOSE Cur_Inventory_item_id;
56 RAISE NO_DATA_FOUND;
57 END IF;
58
59 CLOSE Cur_Inventory_item_id;
60
61 RETURN(L_Inventory_item_id);
62
63 EXCEPTION
64 WHEN OTHERS THEN
65
66 /********************************
67 * Migration Started Log Message *
68 ********************************/
69
70 GMA_COMMON_LOGGING.gma_migration_central_log
71 (
72 p_run_id => G_migration_run_id,
73 p_log_level => FND_LOG.LEVEL_ERROR,
74 p_message_token => 'GMA_MIG_ITEM_ERROR',
75 p_table_name => G_Table_name,
76 p_context => G_context,
77 p_token1 => 'ITEM_ID',
78 p_param1 => p_item_id,
79 p_db_error => NULL,
80 p_app_short_name => 'GMA'
81 );
82
83 RETURN NULL;
84
85 END Get_Inventory_item_id;
86
87 /****************************************************************************
88 * FUNCTION: *
89 * Get_Legal_entity_Id *
90 * *
91 * DESCRIPTION: *
92 * This is an internal function used to retrieve the Legal Entity Id *
93 * value for the Company Code passed *
94 * *
95 * PARAMETERS: *
96 * p_co_code - Company Code to retrieve the value. *
97 * *
98 * SYNOPSIS: *
99 * Get_Legal_entity_Id (p_co_code => 'PR1', *
100 * p_source_type => 'O'); *
101 * *
102 * HISTORY *
103 * 27-Apr-2005 Created Anand Thiyagarajan *
104 * *
105 ****************************************************************************/
106 FUNCTION Get_Legal_Entity_Id
107 (
108 p_co_code IN VARCHAR2,
109 p_source_type IN VARCHAR2
110 )
111 RETURN NUMBER
112 IS
113
114 /************************
115 * Local Variables *
116 ************************/
117
118 L_legal_entity_id gmf_fiscal_policies.legal_entity_id%TYPE;
119
120 /****************
121 * Cursors *
122 ****************/
123
124 CURSOR cur_legal_entity
125 (
126 p_co_code IN VARCHAR2,
127 p_source_type IN VARCHAR2
128 )
129 IS
130 SELECT to_number(a.org_information2) legal_entity_id
131 FROM hr_organization_information a, gl_plcy_mst b
132 WHERE a.organization_id = b.org_id
133 AND b.co_code = p_co_code
134 AND p_source_type = 'O'
135 and a.org_information_context = 'Operating Unit Information'
136 UNION
137 SELECT a.legal_entity_id
138 FROM gl_plcy_mst a
139 WHERE a.co_code = p_co_code
140 AND p_source_type = 'N';
141
142 BEGIN
143
144 OPEN Cur_legal_entity(p_co_code, p_source_type);
145 FETCH Cur_legal_entity INTO L_legal_entity_id;
146
147 IF Cur_legal_entity%NOTFOUND THEN
148 CLOSE Cur_legal_entity;
149 RAISE NO_DATA_FOUND;
150 END IF;
151
152 CLOSE Cur_legal_entity;
153
154 RETURN(L_legal_entity_id);
155
156 EXCEPTION
157 WHEN no_data_found THEN
158
159 /********************************
160 * Migration Started Log Message *
161 ********************************/
162
163 GMA_COMMON_LOGGING.gma_migration_central_log
164 (
165 p_run_id => G_migration_run_id,
166 p_log_level => FND_LOG.LEVEL_PROCEDURE,
167 p_message_token => 'GMA_MIG_LE_CO_ERROR',
168 p_table_name => G_Table_name,
169 p_context => G_context,
170 p_token1 => 'CO_CODE',
171 p_param1 => p_co_code,
172 p_db_error => NULL,
173 p_app_short_name => 'GMA'
174 );
175
176 RETURN NULL;
177
178 END Get_Legal_Entity_id;
179
180 /****************************************************************************
181 * FUNCTION: *
182 * Get_Legal_entity_Id *
183 * *
184 * DESCRIPTION: *
185 * This is a overhealoaded function used to retrieve the Legal Entity Id*
186 * value for the Organization Id passed *
187 * *
188 * PARAMETERS: *
189 * p_organization_id - Organization Id to retrieve the value. *
190 * *
191 * SYNOPSIS: *
192 * Get_Legal_entity_Id (p_organization_id => 1381); *
193 * *
194 * HISTORY *
195 * 27-Apr-2005 Created Anand Thiyagarajan *
196 * *
197 ****************************************************************************/
198 FUNCTION Get_Legal_Entity_Id
199 (
200 p_organization_id IN NUMBER
201 )
202 RETURN NUMBER
203 IS
204
205 /************************
206 * Local Variables *
207 ************************/
208
209 L_legal_entity_id gmf_fiscal_policies.legal_entity_id%TYPE;
210
211 /****************
212 * Cursors *
213 ****************/
214
215 CURSOR cur_legal_entity
216 (
217 p_organization_id IN NUMBER
218 )
219 IS
220 SELECT to_number(a.org_information2) legal_entity_id
221 FROM hr_organization_information a
222 WHERE a.organization_id = p_organization_id
223 AND a.org_information_context = 'Accounting Information';
224
225 BEGIN
226
227 OPEN Cur_legal_entity(p_organization_id);
228 FETCH Cur_legal_entity INTO L_legal_entity_id;
229
230 IF Cur_legal_entity%NOTFOUND THEN
231 CLOSE Cur_legal_entity;
232 RAISE NO_DATA_FOUND;
233 END IF;
234
235 CLOSE Cur_legal_entity;
236
237 RETURN(L_legal_entity_id);
238
239 EXCEPTION
240 WHEN no_data_found THEN
241
242 /********************************
243 * Migration Started Log Message *
244 ********************************/
245
246 GMA_COMMON_LOGGING.gma_migration_central_log
247 (
248 p_run_id => G_migration_run_id,
249 p_log_level => FND_LOG.LEVEL_PROCEDURE,
250 p_message_token => 'GMA_MIG_LE_ORG_ERROR',
251 p_table_name => G_Table_name,
252 p_context => G_context,
253 p_token1 => 'ORGANIZATION_ID',
254 p_param1 => p_organization_id,
255 p_db_error => NULL,
256 p_app_short_name => 'GMA'
257 );
258
259 RETURN NULL;
260
261 END Get_Legal_Entity_id;
262
263 /****************************************************************************
264 * FUNCTION: *
265 * Get_Legal_entity_Id *
266 * *
267 * DESCRIPTION: *
268 * This is a overhealoaded function used to retrieve the Legal Entity Id*
269 * value for the Warehouse Code passed *
270 * *
271 * PARAMETERS: *
272 * p_whse_code_id - Warehouse code to retrieve the value. *
273 * *
274 * SYNOPSIS: *
275 * Get_Legal_entity_Id (p_whse_code=> 'PR1'); *
276 * *
277 * HISTORY *
278 * 27-Apr-2005 Created Anand Thiyagarajan *
279 * *
280 ****************************************************************************/
281 FUNCTION Get_Legal_Entity_Id
282 (
283 p_whse_code IN VARCHAR2
284 )
285 RETURN NUMBER
286 IS
287
288 /************************
289 * Local Variables *
290 ************************/
291
292 L_legal_entity_id gmf_fiscal_policies.legal_entity_id%TYPE;
293
294 /****************
295 * Cursors *
296 ****************/
297
298 CURSOR cur_legal_entity
299 (
300 p_whse_code IN VARCHAR2
301 )
302 IS
303 SELECT to_number(a.org_information2) legal_entity_id
304 FROM hr_organization_information a, ic_whse_mst b
305 WHERE a.organization_id = decode(nvl(b.subinventory_ind_flag, 'N'), 'Y', b.organization_id, b.mtl_organization_id)
306 AND b.whse_code = p_whse_code
307 AND a.org_information_context = 'Accounting Information';
308
309 BEGIN
310
311 OPEN Cur_legal_entity(p_whse_code);
312 FETCH Cur_legal_entity INTO L_legal_entity_id;
313
314 IF Cur_legal_entity%NOTFOUND THEN
315 CLOSE Cur_legal_entity;
316 RAISE NO_DATA_FOUND;
317 END IF;
318
319 CLOSE Cur_legal_entity;
320
321 RETURN(L_legal_entity_id);
322
323 EXCEPTION
324 WHEN no_data_found THEN
325
326 /********************************
327 * Migration Started Log Message *
328 ********************************/
329
330 GMA_COMMON_LOGGING.gma_migration_central_log
331 (
332 p_run_id => G_migration_run_id,
333 p_log_level => FND_LOG.LEVEL_PROCEDURE,
334 p_message_token => 'GMA_MIG_LE_WHSE_ERROR',
335 p_table_name => G_Table_name,
336 p_context => G_context,
337 p_token1 => 'WHSE_CODE',
338 p_param1 => p_whse_code,
339 p_db_error => NULL,
340 p_app_short_name => 'GMA'
341 );
342
343 RETURN NULL;
344
345 END Get_Legal_Entity_id;
346
347 /**********************************************************************
348 * FUNCTION: *
349 * Get_Item_number *
350 * *
351 * DESCRIPTION: *
352 * This is an internal function used to retrieve the Item Number *
353 * *
354 * PARAMETERS: *
355 * p_inventory_item_id - ODM Item Id to retrieve the value. *
356 * *
357 * SYNOPSIS: *
358 * Get_Item_number (p_inventory_Item_id => 12121); *
359 * *
360 * HISTORY *
361 * 27-Apr-2005 Created Anand Thiyagarajan *
362 **********************************************************************/
363 FUNCTION Get_Item_Number
364 (
365 p_inventory_item_id IN NUMBER
366 )
367 RETURN VARCHAR2
368 IS
369
370 /************************
371 * Local Variables *
372 ************************/
373
374 l_Item_number mtl_item_flexfields.item_number%TYPE;
375
376 /****************
377 * Cursors *
378 ****************/
379
380 CURSOR cur_item_number
381 (
382 p_Inventory_item_id IN NUMBER
383 )
384 IS
385 SELECT item_number
386 FROM mtl_item_flexfields
387 WHERE inventory_item_id = p_inventory_item_id
388 AND ROWNUM = 1;
389
390 BEGIN
391
392 OPEN Cur_item_number(p_inventory_item_id);
393 FETCH Cur_item_number INTO L_item_number;
394
395 IF Cur_item_number%NOTFOUND THEN
396 CLOSE Cur_item_number;
397 RAISE NO_DATA_FOUND;
398 END IF;
399
400 CLOSE Cur_item_number;
401
402 RETURN(L_item_number);
403
404 EXCEPTION
405 WHEN OTHERS THEN
406
407 /********************************
408 * Migration Started Log Message *
409 ********************************/
410
411 GMA_COMMON_LOGGING.gma_migration_central_log
412 (
413 p_run_id => G_migration_run_id,
414 p_log_level => FND_LOG.LEVEL_ERROR,
415 p_message_token => 'GMA_MIG_ITEM_NO_ERROR',
416 p_table_name => G_Table_name,
417 p_context => G_context,
418 p_token1 => 'INVENTORY_ITEM_ID',
419 p_param1 => p_inventory_item_id,
420 p_db_error => NULL,
421 p_app_short_name => 'GMA'
422 );
423
424 RETURN NULL;
425
426 END Get_item_number;
427
428 /**********************************************************************
429 * FUNCTION: *
430 * Get_Customer_no *
431 * *
432 * DESCRIPTION: *
433 * This is an internal function used to retrieve the Customer No *
434 * *
435 * PARAMETERS: *
436 * p_cust_id - OPM Customer Id to retrieve the value. *
437 * *
438 * SYNOPSIS: *
439 * Get_Customer_no (p_cust_id => 12121); *
440 * *
441 * HISTORY *
442 * 27-Apr-2005 Created Anand Thiyagarajan *
443 **********************************************************************/
444 FUNCTION Get_Customer_no
445 (
446 p_cust_id IN NUMBER
447 )
448 RETURN VARCHAR2
449 IS
450
451 /************************
452 * Local Variables *
453 ************************/
454
455 l_customer_no op_cust_mst.cust_no%TYPE;
456
457 /****************
458 * Cursors *
459 ****************/
460
461 CURSOR cur_cust_no
462 (
463 p_cust_id IN NUMBER
464 )
465 IS
466 SELECT cust_no
467 FROM op_cust_mst
468 WHERE cust_id = p_cust_id;
469
470 BEGIN
471
472 OPEN Cur_cust_no(p_cust_id);
473 FETCH Cur_cust_no INTO l_customer_no;
474
475 IF Cur_cust_no%NOTFOUND THEN
476 CLOSE Cur_cust_no;
477 RAISE NO_DATA_FOUND;
478 END IF;
479
480 CLOSE Cur_cust_no;
481
482 RETURN(l_customer_no);
483
484 EXCEPTION
485 WHEN OTHERS THEN
486
487 /********************************
488 * Migration Started Log Message *
489 ********************************/
490
491 GMA_COMMON_LOGGING.gma_migration_central_log
492 (
493 p_run_id => G_migration_run_id,
494 p_log_level => FND_LOG.LEVEL_ERROR,
495 p_message_token => 'GMA_MIG_CUSTOMER_ERROR',
496 p_table_name => G_Table_name,
497 p_context => G_context,
498 p_token1 => 'CUST_ID',
499 p_param1 => p_cust_id,
500 p_db_error => NULL,
501 p_app_short_name => 'GMA'
502 );
503
504 RETURN NULL;
505
506 END Get_Customer_no;
507
508 /**********************************************************************
509 * FUNCTION: *
510 * Get_Vendor_id *
511 * *
512 * DESCRIPTION: *
513 * This is an internal function used to retrieve the Vendor No *
514 * *
515 * PARAMETERS: *
516 * p_vendor_id - OPM Vendor Id to retrieve the value. *
517 * *
518 * SYNOPSIS: *
519 * Get_Vendor_id (p_vendor_id => 12121); *
520 * *
521 * HISTORY *
522 * 27-Apr-2005 Created Anand Thiyagarajan *
523 * 12-Oct-2006 Modified Anand Thiyagarajan *
524 * Modified Procedure to fetch of_vendor_site_id *
525 **********************************************************************/
526 FUNCTION Get_Vendor_id
527 (
528 p_vendor_id IN NUMBER
529 )
530 RETURN NUMBER
531 IS
532
533 /************************
534 * Local Variables *
535 ************************/
536
537 l_vendor_site_id po_vend_mst.of_vendor_site_id%TYPE;
538
539 /****************
540 * Cursors *
541 ****************/
542
543 CURSOR cur_vendor_id
544 (
545 p_vendor_id IN NUMBER
546 )
547 IS
548 SELECT of_vendor_site_id
549 FROM po_vend_mst
550 WHERE vendor_id = p_vendor_id;
551
552 BEGIN
553 OPEN cur_vendor_id(p_vendor_id);
554 FETCH cur_vendor_id INTO l_vendor_site_id;
555 IF cur_vendor_id%NOTFOUND THEN
556 CLOSE cur_vendor_id;
557 RAISE NO_DATA_FOUND;
558 END IF;
559 CLOSE cur_vendor_id;
560 RETURN(l_vendor_site_id);
561 EXCEPTION
562 WHEN OTHERS THEN
563 /********************************
564 * Migration Started Log Message *
565 ********************************/
566 GMA_COMMON_LOGGING.gma_migration_central_log
567 (
568 p_run_id => G_migration_run_id,
569 p_log_level => FND_LOG.LEVEL_ERROR,
570 p_message_token => 'GMA_MIG_VENDOR_ERROR',
571 p_table_name => G_Table_name,
572 p_context => G_context,
573 p_token1 => 'VENDOR_ID',
574 p_param1 => p_vendor_id,
575 p_db_error => NULL,
576 p_app_short_name => 'GMA'
577 );
578 RETURN NULL;
579 END Get_Vendor_id;
580
581 /**********************************************************************
582 * FUNCTION: *
583 * Get_Vendor_no *
584 * *
585 * DESCRIPTION: *
586 * This is an internal function used to retrieve the Vendor No *
587 * *
588 * PARAMETERS: *
589 * p_vendor_id - OPM Vendor Id to retrieve the value. *
590 * *
591 * SYNOPSIS: *
592 * Get_Vendor_no (p_vendor_id => 12121); *
593 * *
594 * HISTORY *
595 * 27-Apr-2005 Created Anand Thiyagarajan *
596 **********************************************************************/
597 FUNCTION Get_Vendor_no
598 (
599 p_vendor_id IN NUMBER
600 )
601 RETURN VARCHAR2
602 IS
603 /************************
604 * Local Variables *
605 ************************/
606 l_vendor_no po_vend_mst.vendor_no%TYPE;
607 /****************
608 * Cursors *
609 ****************/
610 CURSOR cur_vendor_no
611 (
612 p_vendor_id IN NUMBER
613 )
614 IS
615 SELECT vendor_no
616 FROM po_vend_mst
617 WHERE vendor_id = p_vendor_id;
618 BEGIN
619 OPEN cur_vendor_no(p_vendor_id);
620 FETCH cur_vendor_no INTO l_vendor_no;
621 IF cur_vendor_no%NOTFOUND THEN
622 CLOSE cur_vendor_no;
623 RAISE NO_DATA_FOUND;
624 END IF;
625 CLOSE cur_vendor_no;
626 RETURN(l_vendor_no);
627 EXCEPTION
628 WHEN OTHERS THEN
629 /********************************
630 * Migration Started Log Message *
631 ********************************/
632 GMA_COMMON_LOGGING.gma_migration_central_log
633 (
634 p_run_id => G_migration_run_id,
635 p_log_level => FND_LOG.LEVEL_ERROR,
636 p_message_token => 'GMA_MIG_VENDOR_ERROR',
637 p_table_name => G_Table_name,
638 p_context => G_context,
639 p_token1 => 'VENDOR_ID',
640 p_param1 => p_vendor_id,
641 p_db_error => NULL,
642 p_app_short_name => 'GMA'
643 );
644 RETURN NULL;
645 END Get_Vendor_no;
646
647 /**********************************************************************
648 * FUNCTION: *
649 * Get_reason_id *
650 * *
651 * DESCRIPTION: *
652 * This is an internal function used to retrieve the Reason_id *
653 * *
654 * PARAMETERS: *
655 * p_reason_code - OPM Reason Code to retrieve the value. *
656 * *
657 * SYNOPSIS: *
658 * Get_Reason_id(p_reason_code => 'ADD'); *
659 * *
660 * HISTORY *
661 * 28-Sep-2006 Created Anand Thiyagarajan *
662 **********************************************************************/
663 FUNCTION Get_reason_id
664 (
665 p_reason_code IN VARCHAR2
666 )
667 RETURN NUMBER
668 IS
669
670 /************************
671 * Local Variables *
672 ************************/
673
674 l_reason_id mtl_transaction_Reasons.reason_id%TYPE;
675
676 /****************
677 * Cursors *
678 ****************/
679
680 CURSOR cur_reason_id
681 (
682 p_reason_Code IN VARCHAR2
683 )
684 IS
685 SELECT reason_id
686 FROM mtl_transaction_Reasons
687 WHERE reason_name = p_reason_code;
688
689 BEGIN
690
691 OPEN cur_reason_id(p_reason_code);
692 FETCH cur_reason_id INTO l_reason_id;
693
694 IF cur_reason_id%NOTFOUND THEN
695 CLOSE cur_reason_id;
696 RAISE NO_DATA_FOUND;
697 END IF;
698
699 CLOSE cur_reason_id;
700
701 RETURN(l_reason_id);
702
703 EXCEPTION
704 WHEN OTHERS THEN
705 RETURN NULL;
706 END Get_reason_id;
707
708 /**********************************************************************
709 * PROCEDURE *
710 * Get_Routing_no *
711 * *
712 * DESCRIPTION: *
713 * This is an internal procedure used to retrieve the routing No *
714 * *
715 * PARAMETERS: *
716 * p_routing_id - OPM routing Id to retrieve the value. *
717 * *
718 * SYNOPSIS: *
719 * Get_routing_no (p_routing_id => 12121); *
720 * *
721 * HISTORY *
722 * 27-Apr-2005 Created Anand Thiyagarajan *
723 **********************************************************************/
724 PROCEDURE Get_Routing_no
725 (
726 p_routing_id IN NUMBER,
727 x_routing_no OUT NOCOPY VARCHAR2,
728 x_routing_vers OUT NOCOPY NUMBER
729 )
730 IS
731
732 /************************
733 * Local Variables *
734 ************************/
735
736 l_routing_no GMD_ROUTINGS_B.routing_no%TYPE;
737 l_routing_vers GMD_ROUTINGS_B.routing_vers%TYPE;
738
739 /****************
740 * Cursors *
741 ****************/
742
743 CURSOR cur_routing_no
744 (
745 p_routing_id IN NUMBER
746 )
747 IS
748 SELECT routing_no,
749 routing_vers
750 FROM GMD_ROUTINGS_B
751 WHERE routing_id = p_routing_id;
752
753 BEGIN
754
755 OPEN cur_routing_no(p_routing_id);
756 FETCH cur_routing_no INTO l_routing_no, l_routing_vers;
757
758 IF cur_routing_no%NOTFOUND THEN
759 CLOSE cur_routing_no;
760 RAISE NO_DATA_FOUND;
761 END IF;
762
763 CLOSE cur_routing_no;
764
765 x_routing_no := l_routing_no;
766 x_routing_vers := l_routing_vers;
767
768 EXCEPTION
769 WHEN OTHERS THEN
770
771 /********************************
772 * Migration Started Log Message *
773 ********************************/
774
775 GMA_COMMON_LOGGING.gma_migration_central_log
776 (
777 p_run_id => G_migration_run_id,
778 p_log_level => FND_LOG.LEVEL_ERROR,
779 p_message_token => 'GMA_MIG_ROUTING_ERROR',
780 p_table_name => G_Table_name,
781 p_context => G_context,
782 p_token1 => 'ROUTING_ID',
783 p_param1 => p_routing_id,
784 p_db_error => NULL,
785 p_app_short_name => 'GMA'
786 );
787
788 x_routing_no := NULL;
789 x_routing_vers := NULL;
790
791 END Get_routing_no;
792
793 /**********************************************************************
794 * FUNCTION: *
795 * Get_aqui_cost_code *
796 * *
797 * DESCRIPTION: *
798 * This is an internal function used to retrieve aqui cost Code *
799 * *
800 * PARAMETERS: *
801 * p_aqui_cost_id - OPM aqui_cost Id to retrieve the value. *
802 * *
803 * SYNOPSIS: *
804 * Get_aqui_cost_code (p_aqui_cost_id => 12121); *
805 * *
806 * HISTORY *
807 * 27-Apr-2005 Created Anand Thiyagarajan *
808 **********************************************************************/
809 FUNCTION Get_price_element_Type_id
810 (
811 p_aqui_cost_id IN NUMBER
812 )
813 RETURN NUMBER
814 IS
815 /************************
816 * Local Variables *
817 ************************/
818 l_price_element_type_id po_cost_mst.price_element_type_id%TYPE;
819 /****************
820 * Cursors *
821 ****************/
822 CURSOR cur_price_element_type_id
823 (
824 p_aqui_cost_id IN NUMBER
825 )
826 IS
827 SELECT price_element_type_id
828 FROM po_cost_mst
829 WHERE aqui_cost_id = p_aqui_cost_id
830 AND nvl(migrated_ind, 0) = 1;
831
832 BEGIN
833
834 OPEN cur_price_element_type_id(p_aqui_cost_id);
835 FETCH cur_price_element_type_id INTO l_price_element_type_id;
836
837 IF cur_price_element_type_id%NOTFOUND THEN
838 CLOSE cur_price_element_type_id;
839 RAISE NO_DATA_FOUND;
840 END IF;
841 CLOSE cur_price_element_type_id;
842 RETURN(l_price_element_type_id);
843 EXCEPTION
844 WHEN OTHERS THEN
845 /********************************
846 * Migration Started Log Message *
847 ********************************/
848 GMA_COMMON_LOGGING.gma_migration_central_log
849 (
850 p_run_id => G_migration_run_id,
851 p_log_level => FND_LOG.LEVEL_ERROR,
852 p_message_token => 'GMA_MIG_AQUI_CODE_ERROR',
853 p_table_name => G_Table_name,
854 p_context => G_context,
855 p_token1 => 'AQUI_COST_ID',
856 p_param1 => p_aqui_cost_id,
857 p_db_error => NULL,
858 p_app_short_name => 'GMA'
859 );
860 RETURN NULL;
861 END Get_price_element_Type_id;
862
863 /**********************************************************************
864 * FUNCTION: *
865 * Get_cost_cmpntcls_code *
866 * *
867 * DESCRIPTION: *
868 * This is an internal function used to retrieve costcmpntcls Code*
869 * *
870 * PARAMETERS: *
871 * p_cost_cmpntcls_id - OPM cost_cmpntcls Id to retrieve the value*
872 * *
873 * SYNOPSIS: *
874 * Get_cost_cmpntcls_code (p_cost_cmpntcls_id => 12121); *
875 * *
876 * HISTORY *
877 * 27-Apr-2005 Created Anand Thiyagarajan *
878 **********************************************************************/
879 FUNCTION Get_Cost_cmpntcls_code
880 (
881 p_cost_cmpntcls_id IN NUMBER
882 )
883 RETURN VARCHAR2
884 IS
885
886 /************************
887 * Local Variables *
888 ************************/
889
890 l_cost_cmpntcls_code cm_cmpt_mst.cost_cmpntcls_code%TYPE;
891
892 /****************
893 * Cursors *
894 ****************/
895
896 CURSOR cur_cost_cmpntcls_code
897 (
898 p_cost_cmpntcls_id IN NUMBER
899 )
900 IS
901 SELECT cost_cmpntcls_code
902 FROM cm_cmpt_mst
903 WHERE cost_cmpntcls_id = p_cost_cmpntcls_id;
904
905 BEGIN
906
907 OPEN cur_cost_cmpntcls_code(p_cost_cmpntcls_id);
908 FETCH cur_cost_cmpntcls_code INTO l_cost_cmpntcls_code;
909
910 IF cur_cost_cmpntcls_code%NOTFOUND THEN
911 CLOSE cur_cost_cmpntcls_code;
912 RAISE NO_DATA_FOUND;
913 END IF;
914
915 CLOSE cur_cost_cmpntcls_code;
916
917 RETURN(l_cost_cmpntcls_code);
918
919 EXCEPTION
920 WHEN OTHERS THEN
921
922 /********************************
923 * Migration Started Log Message *
924 ********************************/
925
926 GMA_COMMON_LOGGING.gma_migration_central_log
927 (
928 p_run_id => G_migration_run_id,
929 p_log_level => FND_LOG.LEVEL_ERROR,
930 p_message_token => 'GMA_MIG_CMPNTCLS_ERROR',
931 p_table_name => G_Table_name,
932 p_context => G_context,
933 p_token1 => 'COST_CMPNTCLS_ID',
934 p_param1 => p_cost_cmpntcls_id,
935 p_db_error => NULL,
936 p_app_short_name => 'GMA'
937 );
938
939 RETURN NULL;
940
941 END Get_cost_cmpntcls_code;
942
943 /**********************************************************************
944 * FUNCTION: *
945 * Get_Order_type_code *
946 * *
947 * DESCRIPTION: *
948 * This is an internal function used to retrieve Order_type Code *
949 * *
950 * PARAMETERS: *
951 * p_Order_type_id - OPM Order_type Id to retrieve the value. *
952 * *
953 * SYNOPSIS: *
954 * Get_Order_type_code (p_Order_type_id => 12121); *
955 * *
956 * HISTORY *
957 * 27-Apr-2005 Created Anand Thiyagarajan *
958 **********************************************************************/
959 FUNCTION Get_Order_type_code
960 (
961 p_Order_type IN NUMBER,
962 p_source_type IN NUMBER
963 )
964 RETURN VARCHAR2
965 IS
966
967 /************************
968 * Local Variables *
969 ************************/
970
971 l_Order_type_code OP_ORDR_TYP.Order_type_code%TYPE;
972
973 /****************
974 * Cursors *
975 ****************/
976
977 CURSOR cur_Order_type_code
978 (
979 p_Order_type IN NUMBER,
980 p_source_type IN NUMBER
981 )
982 IS
983 SELECT order_type_code
984 FROM op_ordr_typ
985 WHERE lang_code = userenv('LANG')
986 AND nvl(p_source_type,0) = 0
987 AND order_type = p_Order_type
988 UNION ALL
989 SELECT tl.name
990 FROM oe_transaction_types_all t,
991 oe_transaction_types_tl tl
992 WHERE t.transaction_type_id = tl.transaction_type_id
993 AND tl.language = userenv('LANG')
994 AND nvl(p_source_type,0) = 11
995 AND t.transaction_type_code = 'ORDER'
996 AND t.transaction_type_id = p_Order_type;
997
998 BEGIN
999
1000 OPEN cur_Order_type_code(p_Order_type, p_source_type);
1001 FETCH cur_Order_type_code INTO l_Order_type_code;
1002
1003 IF cur_Order_type_code%NOTFOUND THEN
1004 CLOSE cur_Order_type_code;
1005 RAISE NO_DATA_FOUND;
1006 END IF;
1007
1008 CLOSE cur_Order_type_code;
1009
1010 RETURN(l_Order_type_code);
1011
1012 EXCEPTION
1013 WHEN OTHERS THEN
1014
1015 /********************************
1016 * Migration Started Log Message *
1017 ********************************/
1018
1019 GMA_COMMON_LOGGING.gma_migration_central_log
1020 (
1021 p_run_id => G_migration_run_id,
1022 p_log_level => FND_LOG.LEVEL_ERROR,
1023 p_message_token => 'GMA_MIG_ORDER_TYPE_ERROR',
1024 p_table_name => G_Table_name,
1025 p_context => G_context,
1026 p_token1 => 'ORDER_TYPE',
1027 p_param1 => p_Order_type,
1028 p_db_error => NULL,
1029 p_app_short_name => 'GMA'
1030 );
1031
1032 RETURN NULL;
1033
1034 END Get_Order_type_code;
1035
1036 /**********************************************************************
1037 * FUNCTION: *
1038 * Get_Line_type_code *
1039 * *
1040 * DESCRIPTION: *
1041 * This is an internal function used to retrieve Line_type Code *
1042 * *
1043 * PARAMETERS: *
1044 * p_Line_type_id - OPM Line_type Id to retrieve the value. *
1045 * *
1046 * SYNOPSIS: *
1047 * Get_Line_type_code (p_Line_type => 12121); *
1048 * *
1049 * HISTORY *
1050 * 27-Apr-2005 Created Anand Thiyagarajan *
1051 **********************************************************************/
1052 FUNCTION Get_Line_type_code
1053 (
1054 p_Line_type IN NUMBER
1055 )
1056 RETURN VARCHAR2
1057 IS
1058
1059 /************************
1060 * Local Variables *
1061 ************************/
1062
1063 l_Line_type_code gem_lookups.meaning%TYPE;
1064 l_om NUMBER;
1065 l_opm_om VARCHAR2(10);
1066
1067 /****************
1068 * Cursors *
1069 ****************/
1070
1071 CURSOR cur_Line_type_code
1072 (
1073 p_Line_type IN NUMBER
1074 )
1075 IS
1076 SELECT meaning
1077 FROM gem_lookups
1078 WHERE lookup_type = 'LINE_TYPE'
1079 AND nvl(start_date_active,sysdate) <= sysdate
1080 AND nvl(end_date_active,sysdate) >= sysdate
1081 AND enabled_flag = 'Y'
1082 AND lookup_code = p_line_type;
1083
1084 BEGIN
1085
1086 OPEN cur_Line_type_code(p_Line_type);
1087 FETCH cur_Line_type_code INTO l_Line_type_code;
1088
1089 IF cur_Line_type_code%NOTFOUND THEN
1090 CLOSE cur_Line_type_code;
1091 RAISE NO_DATA_FOUND;
1092 END IF;
1093
1094 CLOSE cur_Line_type_code;
1095
1096 RETURN(l_Line_type_code);
1097
1098 EXCEPTION
1099 WHEN OTHERS THEN
1100
1101 /********************************
1102 * Migration Started Log Message *
1103 ********************************/
1104
1105 GMA_COMMON_LOGGING.gma_migration_central_log
1106 (
1107 p_run_id => G_migration_run_id,
1108 p_log_level => FND_LOG.LEVEL_ERROR,
1109 p_message_token => 'GMA_MIG_LINE_TYPE_ERROR',
1110 p_table_name => G_Table_name,
1111 p_context => G_context,
1112 p_token1 => 'LINE_TYPE',
1113 p_param1 => p_Line_type,
1114 p_db_error => NULL,
1115 p_app_short_name => 'GMA'
1116 );
1117
1118 RETURN NULL;
1119
1120 END Get_Line_type_code;
1121
1122 /**********************************************************************
1123 * FUNCTION: *
1124 * Get_ar_trx_type_code *
1125 * *
1126 * DESCRIPTION: *
1127 * This is an internal function used to retrieve costcmpntcls Code*
1128 * *
1129 * PARAMETERS: *
1130 * p_ar_trx_type_id - OPM ar_trx_type Id to retrieve the value *
1131 * *
1132 * SYNOPSIS: *
1133 * Get_Ar_trx_type_code ( p_ar_trx_type_id => 12121, *
1134 * p_co_code = 'PRU'); *
1135 * *
1136 * HISTORY *
1137 * 27-Apr-2005 Created Anand Thiyagarajan *
1138 **********************************************************************/
1139 FUNCTION Get_Ar_trx_type_code
1140 (
1141 p_ar_trx_type_id IN NUMBER,
1142 p_legal_entity_id IN NUMBER
1143 )
1144 RETURN VARCHAR2
1145 IS
1146
1147 /************************
1148 * Local Variables *
1149 ************************/
1150
1151 l_ar_trx_type_code RA_CUST_TRX_TYPES_ALL.name%TYPE;
1152
1153 /****************
1154 * Cursors *
1155 ****************/
1156
1157 CURSOR cur_Ar_trx_type_code
1158 (
1159 p_Ar_trx_type_id IN NUMBER,
1160 p_legal_entity_id IN NUMBER
1161 )
1162 IS
1163 SELECT rctta.name
1164 FROM ra_cust_trx_types_all rctta, ar_lookups al, gl_plcy_mst plcy
1165 WHERE sysdate between nvl(rctta.start_date, sysdate-1) and nvl(rctta.end_date, sysdate+1)
1166 AND al.lookup_type = 'INV/CM'
1167 AND al.lookup_code = rctta.type
1168 AND rctta.org_id = plcy.org_id
1169 AND plcy.legal_entity_id = p_legal_entity_id
1170 AND rctta.cust_trx_type_id = p_Ar_trx_type_id;
1171
1172 BEGIN
1173
1174 OPEN cur_Ar_trx_type_code(p_Ar_trx_type_id, p_legal_entity_id);
1175 FETCH cur_Ar_trx_type_code INTO l_Ar_trx_type_code;
1176
1177 IF cur_Ar_trx_type_code%NOTFOUND THEN
1178 CLOSE cur_Ar_trx_type_code;
1179 RAISE NO_DATA_FOUND;
1180 END IF;
1181
1182 CLOSE cur_Ar_trx_type_code;
1183
1184 RETURN(l_Ar_trx_type_code);
1185
1186 EXCEPTION
1187 WHEN OTHERS THEN
1188
1189 /********************************
1190 * Migration Started Log Message *
1191 ********************************/
1192
1193 GMA_COMMON_LOGGING.gma_migration_central_log
1194 (
1195 p_run_id => G_migration_run_id,
1196 p_log_level => FND_LOG.LEVEL_ERROR,
1197 p_message_token => 'GMA_MIG_AR_TRX_TYPE_ERROR',
1198 p_table_name => G_Table_name,
1199 p_context => G_context,
1200 p_token1 => 'AR_TRX_TYPE_ID',
1201 p_param1 => p_Ar_trx_type_id,
1202 p_db_error => NULL,
1203 p_app_short_name => 'GMA'
1204 );
1205
1206 RETURN NULL;
1207
1208 END Get_Ar_trx_type_code;
1209
1210 /**********************************************************************
1211 * FUNCTION: *
1212 * Get_gl_business_class_cat *
1213 * *
1214 * DESCRIPTION: *
1215 * This is an internal function used to retrieve gl_business_class*
1216 * *
1217 * PARAMETERS: *
1218 * p_gl_business_class_cat_id - OPM gl_business_class_cat Id *
1219 * to retrieve the value *
1220 * *
1221 * SYNOPSIS: *
1222 * Get_gl_business_class_cat (p_gl_business_class_cat_id => 12121)*
1223 * *
1224 * HISTORY *
1225 * 27-Apr-2005 Created Anand Thiyagarajan *
1226 **********************************************************************/
1227 FUNCTION Get_Gl_business_class_cat
1228 (
1229 p_Gl_business_class_cat_id IN NUMBER
1230 )
1231 RETURN VARCHAR2
1232 IS
1233
1234 /************************
1235 * Local Variables *
1236 ************************/
1237
1238 l_Gl_business_class_cat MTL_CATEGORIES_VL.description%TYPE;
1239
1240 /****************
1241 * Cursors *
1242 ****************/
1243
1244 CURSOR cur_Gl_business_class_cat
1245 (
1246 p_Gl_business_class_cat_id IN NUMBER
1247 )
1248 IS
1249 SELECT description
1250 FROM mtl_categories_vl
1251 WHERE structure_id IN (
1252 SELECT fifs.id_flex_num
1253 FROM fnd_id_flex_structures_vl fifs
1254 WHERE fifs.application_id = 401
1255 AND fifs.id_flex_code = 'MCAT'
1256 AND fifs.id_flex_structure_code = 'GL_BUSINESS_CLASS'
1257 AND enabled_flag = 'Y'
1258 )
1259 AND category_id = p_Gl_business_class_cat_id;
1260
1261 BEGIN
1262
1263 OPEN cur_Gl_business_class_cat(p_Gl_business_class_cat_id);
1264 FETCH cur_Gl_business_class_cat INTO l_Gl_business_class_cat;
1265
1266 IF cur_Gl_business_class_cat%NOTFOUND THEN
1267 CLOSE cur_Gl_business_class_cat;
1268 RAISE NO_DATA_FOUND;
1269 END IF;
1270
1271 CLOSE cur_Gl_business_class_cat;
1272
1273 RETURN(l_Gl_business_class_cat);
1274
1275 EXCEPTION
1276 WHEN OTHERS THEN
1277
1278 /********************************
1279 * Migration Started Log Message *
1280 ********************************/
1281
1282 GMA_COMMON_LOGGING.gma_migration_central_log
1283 (
1284 p_run_id => G_migration_run_id,
1285 p_log_level => FND_LOG.LEVEL_ERROR,
1286 p_message_token => 'GMA_MIG_GL_BUS_CLASS_ERROR',
1287 p_table_name => G_Table_name,
1288 p_context => G_context,
1289 p_token1 => 'GL_BUSINESS_CLASS_CAT_ID',
1290 p_param1 => p_Gl_business_class_cat_id,
1291 p_db_error => NULL,
1292 p_app_short_name => 'GMA'
1293 );
1294
1295 RETURN NULL;
1296
1297 END Get_Gl_business_class_cat;
1298
1299 /**********************************************************************
1300 * FUNCTION: *
1301 * Get_gl_product_line_cat *
1302 * *
1303 * DESCRIPTION: *
1304 * This is an internal function used to retrieve gl_product_line*
1305 * *
1306 * PARAMETERS: *
1307 * p_gl_product_line_cat_id - OPM gl_product_line_cat Id *
1308 * to retrieve the value *
1309 * *
1310 * SYNOPSIS: *
1311 * Get_gl_product_line_cat (p_gl_product_line_cat_id => 12121)*
1312 * *
1313 * HISTORY *
1314 * 27-Apr-2005 Created Anand Thiyagarajan *
1315 **********************************************************************/
1316 FUNCTION Get_Gl_product_line_cat
1317 (
1318 p_Gl_product_line_cat_id IN NUMBER
1319 )
1320 RETURN VARCHAR2
1321 IS
1322
1323 /************************
1324 * Local Variables *
1325 ************************/
1326
1327 l_Gl_product_line_cat MTL_CATEGORIES_VL.description%TYPE;
1328
1329 /****************
1330 * Cursors *
1331 ****************/
1332
1333 CURSOR cur_Gl_product_line_cat
1334 (
1335 p_Gl_product_line_cat_id IN NUMBER
1336 )
1337 IS
1338 SELECT description
1339 FROM mtl_categories_vl
1340 WHERE structure_id IN
1341 (
1342 SELECT fifs.id_flex_num
1343 FROM fnd_id_flex_structures_vl fifs
1344 WHERE fifs.application_id = 401
1345 AND fifs.id_flex_code = 'MCAT'
1346 AND fifs.id_flex_structure_code = 'GL_PRODUCT_LINE'
1347 AND enabled_flag = 'Y'
1348 )
1349 AND category_id = p_Gl_product_line_cat_id;
1350
1351 BEGIN
1352
1353 OPEN cur_Gl_product_line_cat(p_Gl_product_line_cat_id);
1354 FETCH cur_Gl_product_line_cat INTO l_Gl_product_line_cat;
1355
1356 IF cur_Gl_product_line_cat%NOTFOUND THEN
1357 CLOSE cur_Gl_product_line_cat;
1358 RAISE NO_DATA_FOUND;
1359 END IF;
1360
1361 CLOSE cur_Gl_product_line_cat;
1362
1363 RETURN(l_Gl_product_line_cat);
1364
1365 EXCEPTION
1366 WHEN OTHERS THEN
1367
1368 /********************************
1369 * Migration Started Log Message *
1370 ********************************/
1371
1372 GMA_COMMON_LOGGING.gma_migration_central_log
1373 (
1374 p_run_id => G_migration_run_id,
1375 p_log_level => FND_LOG.LEVEL_ERROR,
1376 p_message_token => 'GMA_MIG_GL_PROD_LINE_ERROR',
1377 p_table_name => G_Table_name,
1378 p_context => G_context,
1379 p_token1 => 'GL_PRODUCT_LINE_CAT_ID',
1380 p_param1 => p_Gl_product_line_cat_id,
1381 p_db_error => NULL,
1382 p_app_short_name => 'GMA'
1383 );
1384
1385 RETURN NULL;
1386
1387 END Get_Gl_product_line_cat;
1388
1389 /**********************************************************************
1390 * FUNCTION: *
1391 * Get_UOM_code *
1392 * *
1393 * DESCRIPTION: *
1394 * This is an internal function used to retrieve the UOM Code *
1395 * for the OPM UM passed *
1396 * *
1397 * PARAMETERS: *
1398 * p_UM_code - Unit Of Measure Code *
1399 * *
1400 * SYNOPSIS: *
1401 * Get_UOM_code (p_UM_Code => 'Hours'); *
1402 * *
1403 * HISTORY *
1404 * 27-Apr-2005 Created Anand Thiyagarajan *
1405 **********************************************************************/
1406 FUNCTION Get_Uom_Code
1407 (
1408 p_um_code IN VARCHAR2
1409 )
1410 RETURN VARCHAR2
1411 IS
1412
1413 /************************
1414 * Local Variables *
1415 ************************/
1416
1417 L_uom_code sy_uoms_mst.uom_code%TYPE;
1418
1419 /****************
1420 * Cursors *
1421 ****************/
1422
1423 CURSOR cur_uom_code
1424 (
1425 p_um_code IN VARCHAR2
1426 )
1427 IS
1428 SELECT uom_code
1429 FROM sy_uoms_mst
1430 WHERE um_code = p_um_code;
1431
1432 BEGIN
1433
1434 OPEN cur_uom_code(p_um_code);
1435 FETCH cur_uom_code INTO L_uom_code;
1436
1437 IF cur_uom_code%NOTFOUND THEN
1438 CLOSE cur_uom_code;
1439 RAISE NO_DATA_FOUND;
1440 END IF;
1441
1442 CLOSE cur_uom_code;
1443
1444 RETURN(L_uom_code);
1445
1446 EXCEPTION
1447 WHEN OTHERS THEN
1448
1449 /********************************
1450 * Migration Started Log Message *
1451 ********************************/
1452
1453 GMA_COMMON_LOGGING.gma_migration_central_log
1454 (
1455 p_run_id => G_migration_run_id,
1456 p_log_level => FND_LOG.LEVEL_ERROR,
1457 p_message_token => 'GMA_MIG_UOM_ERROR',
1458 p_table_name => G_Table_name,
1459 p_context => G_context,
1460 p_token1 => 'UM_CODE',
1461 p_param1 => p_um_code,
1462 p_db_error => NULL,
1463 p_app_short_name => 'GMA'
1464 );
1465
1466 RETURN NULL;
1467
1468 END Get_uom_Code;
1469
1470 /**********************************************************************
1471 * FUNCTION: *
1472 * Get_Account_Id *
1473 * *
1474 * DESCRIPTION: *
1475 * This is an internal function used to retrieve the Account Id *
1476 * value from the Financials setup for the Account Code and *
1477 * Company Code passed *
1478 * *
1479 * PARAMETERS: *
1480 * p_Account_code - Account Code *
1481 * p_co_code - Company Code *
1482 * *
1483 * SYNOPSIS: *
1484 * Get_Account_Id (p_Account_Code => '100-0000-0000-0000-0000', *
1485 * p_co_code => 'PRU'); *
1486 * *
1487 * HISTORY *
1488 * 27-Apr-2005 Created Anand Thiyagarajan *
1489 * 05-Jul-2006 rseshadr bug 5374823 - date has to be formatted *
1490 * appropriate in the call to fnd_flex_ext. *
1491 **********************************************************************/
1492 FUNCTION Get_Account_Id
1493 (
1494 p_account_code IN VARCHAR2,
1495 p_co_code IN VARCHAR2
1496 )
1497 RETURN VARCHAR2
1498 IS
1499
1500 /*****************************
1501 * PL/SQL Table Definition *
1502 *****************************/
1503
1504 TYPE segment_values_tbl IS TABLE OF VARCHAR2(240) INDEX BY BINARY_INTEGER;
1505
1506 /******************
1507 * Local Variables *
1508 ******************/
1509
1510 L_segment segment_values_tbl;
1511 L_segment_index NUMBER(10) DEFAULT 0;
1512 L_value NUMBER(10);
1513 L_index NUMBER(10);
1514 L_position NUMBER(10) DEFAULT 1;
1515 L_length NUMBER(10);
1516 L_result VARCHAR2(2000);
1517 L_segment_values gmf_get_mappings.my_opm_seg_values;
1518 L_segment_delimiter VARCHAR2(10);
1519 L_chart_of_accounts_id NUMBER;
1520 L_Account_Id NUMBER;
1521
1522 /**********
1523 * Cursors *
1524 **********/
1525
1526 CURSOR cur_plcy_seg
1527 IS
1528 SELECT p.type,
1529 p.length,
1530 p.segment_no segment_ref,
1531 pm.segment_delimiter
1532 FROM gl_plcy_seg p,
1533 gl_plcy_mst pm,
1534 fnd_id_flex_segments f,
1535 gl_sets_of_books s
1536 WHERE p.co_code = p_co_code
1537 AND p.delete_mark = 0
1538 AND p.co_code = pm.co_code
1539 AND pm.sob_id = s.set_of_books_id
1540 AND s.chart_of_accounts_id = f.id_flex_num
1541 AND f.application_id = 101
1542 AND f.id_flex_code = 'GL#'
1543 AND LOWER(f.segment_name) = LOWER(p.short_name)
1544 AND f.enabled_flag = 'Y'
1545 ORDER BY f.segment_num;
1546
1547 CURSOR cur_segment_delimiter
1548 IS
1549 SELECT concatenated_segment_delimiter,
1550 glsob.chart_of_accounts_id
1551 FROM gl_sets_of_books glsob,
1552 fnd_id_flex_structures fifstr,
1553 fnd_application fa,
1554 gl_plcy_mst gpm
1555 WHERE glsob.chart_of_accounts_id = fifstr.id_flex_num
1556 AND fifstr.id_flex_code = 'GL#'
1557 AND fifstr.application_id = fa.application_id
1558 AND fa.application_short_name = 'SQLGL'
1559 AND gpm.sob_id = glsob.set_of_books_id
1560 AND gpm.co_code = p_co_code;
1561
1562 BEGIN
1563
1564 OPEN cur_segment_delimiter;
1565 FETCH cur_segment_delimiter INTO L_segment_delimiter, L_Chart_of_accounts_id;
1566
1567 IF cur_segment_delimiter%NOTFOUND THEN
1568 CLOSE cur_segment_delimiter;
1569 RAISE NO_DATA_FOUND;
1570 END IF;
1571
1572 CLOSE cur_segment_delimiter;
1573
1574 L_segment_values := gmf_get_mappings.get_opm_segment_values(p_account_code,p_co_code,2);
1575
1576 FOR i IN 1..30 LOOP
1577 L_segment(i) := NULL;
1578 END LOOP;
1579
1580 FOR cur_plcy_seg_tmp IN cur_plcy_seg LOOP
1581
1582 L_segment_index := L_segment_index + 1;
1583
1584 IF (cur_plcy_seg_tmp.segment_ref = 0) THEN
1585 L_value := L_segment_index;
1586 ELSE
1587 L_value := cur_plcy_seg_tmp.segment_ref;
1588 END IF;
1589
1590 L_index := L_value;
1591 L_length := cur_plcy_seg_tmp.length;
1592 L_segment(L_index) := L_segment_values(L_position);
1593 L_position := L_position + 1;
1594
1595 END LOOP;
1596
1597 FOR i IN 1..30 LOOP
1598 IF (i < 30) THEN
1599 L_result := L_result||L_segment(i)||L_segment_delimiter;
1600 ELSE
1601 L_result := L_result||L_segment(i);
1602 END IF;
1603 END LOOP;
1604
1605 /**
1606 * rseshadr bug 5374823 - format date in call to fnd_flex_ext otherwise
1607 * raises an error
1608 **/
1609 L_Account_id := fnd_flex_ext.get_ccid(
1610 application_short_name => 'SQLGL',
1611 key_flex_code => 'GL#',
1612 structure_number => L_Chart_of_Accounts_id,
1613 validation_date => TO_CHAR(SYSDATE, FND_FLEX_EXT.DATE_FORMAT),
1614 concatenated_segments => L_Result);
1615
1616 IF L_Account_id IS NULL OR L_Account_id <= 0 THEN
1617 RAISE NO_DATA_FOUND;
1618 END IF;
1619
1620 RETURN (L_Account_id);
1621
1622 EXCEPTION
1623 WHEN OTHERS THEN
1624
1625 /********************************
1626 * Migration Started Log Message *
1627 ********************************/
1628
1629 GMA_COMMON_LOGGING.gma_migration_central_log
1630 (
1631 p_run_id => G_migration_run_id,
1632 p_log_level => FND_LOG.LEVEL_ERROR,
1633 p_message_token => 'GMA_MIG_ACCOUNT_ERROR',
1634 p_table_name => G_Table_name,
1635 p_context => G_context,
1636 p_token1 => 'ACCOUNT_CODE',
1637 p_token2 => 'CO_CODE',
1638 p_param1 => p_account_code,
1639 p_param2 => p_co_code,
1640 p_db_error => NULL,
1641 p_app_short_name => 'GMA'
1642 );
1643
1644 RETURN NULL;
1645
1646 END get_account_id;
1647
1648 /****************************************************************************
1649 * FUNCTION: *
1650 * Get_co_code *
1651 * *
1652 * DESCRIPTION: *
1653 * This is an internal function used to retrieve the Company Code *
1654 * value for the Warehouse Code passed *
1655 * *
1656 * PARAMETERS: *
1657 * p_whse_code - Warehouse Code to retrieve the value. *
1658 * *
1659 * SYNOPSIS: *
1660 * Get_Co_Code (p_whse_code => 'PR1'); *
1661 * *
1662 * HISTORY *
1663 * 27-Apr-2005 Created Anand Thiyagarajan *
1664 * *
1665 ****************************************************************************/
1666 FUNCTION Get_Co_Code
1667 (
1668 p_whse_code IN VARCHAR2
1669 )
1670 RETURN VARCHAR2
1671 IS
1672
1673 /************************
1674 * Local Variables *
1675 ************************/
1676
1677 L_co_code sy_orgn_mst.co_code%TYPE;
1678
1679 /****************
1680 * Cursors *
1681 ****************/
1682
1683 CURSOR cur_co_code
1684 (
1685 p_whse_code IN VARCHAR2
1686 )
1687 IS
1688 select a.co_code
1689 from sy_orgn_mst a,
1690 ic_whse_mst b
1691 where a.orgn_code = b.orgn_code
1692 and b.whse_code = p_whse_code;
1693
1694 BEGIN
1695
1696 OPEN Cur_co_code(p_whse_code);
1697 FETCH Cur_co_code INTO L_co_code;
1698
1699 IF Cur_co_code%NOTFOUND THEN
1700 CLOSE Cur_co_code;
1701 RAISE NO_DATA_FOUND;
1702 END IF;
1703
1704 CLOSE Cur_co_code;
1705
1706 RETURN(L_co_code);
1707
1708 EXCEPTION
1709 WHEN OTHERS THEN
1710
1711 /********************************
1712 * Migration Started Log Message *
1713 ********************************/
1714
1715 GMA_COMMON_LOGGING.gma_migration_central_log
1716 (
1717 p_run_id => G_migration_run_id,
1718 p_log_level => FND_LOG.LEVEL_ERROR,
1719 p_message_token => 'GMA_MIG_CO_WHSE_ERROR',
1720 p_table_name => G_Table_name,
1721 p_context => G_context,
1722 p_token1 => 'WHSE_CODE',
1723 p_param1 => p_whse_code,
1724 p_db_error => NULL,
1725 p_app_short_name => 'GMA'
1726 );
1727
1728 RETURN NULL;
1729
1730 END get_co_code;
1731
1732 /**********************************************************************
1733 * PROCEDURE: *
1734 * Migrate_Fiscal_policies_LE *
1735 * *
1736 * DESCRIPTION: *
1737 * This PL/SQL procedure is used to migrate the Fiscal Policies from *
1738 * GL_PLCY_MST to GMF_FISCAL_POLICIES table. *
1739 * *
1740 * PARAMETERS: *
1741 * P_migration_run_id - id to use to right to migration log *
1742 * x_exception_count - Number of exceptions occurred. *
1743 * *
1744 * SYNOPSIS: *
1745 * Migrate_Fiscal_policies_LE(p_migartion_id => l_migration_id, *
1746 * p_commit => 'T', *
1747 * x_exception_count => l_exception_count ); *
1748 * *
1749 * HISTORY *
1750 * 27-Apr-2005 Created Anand Thiyagarajan *
1751 * 24-May-2006 rseshadr bug 5246510 - Use the new cost mthd if *
1752 * set by the user otherwise default from the old cost mthd *
1753 * Also, ordered the main cursor by le_id because if a null *
1754 * LE row comes first but the Company points to already mapped *
1755 * LE, then we may end up with an incorrect gl cost mthd for *
1756 * the already mapped LEs. Removed the L_new_legal_entity_id *
1757 * variable reference in update *
1758 * 23-Jun-2006 rseshadr bug 5354837 - do not rely on the view *
1759 * gmf_legal_entities. The underlying tables are not populated *
1760 * until after a much later phase (upg+74). Use the same logic *
1761 * as an auto upgrade without the pre-mig ui *
1762 * *
1763 **********************************************************************/
1764 PROCEDURE Migrate_Fiscal_Policies_LE
1765 (
1766 P_migration_run_id IN NUMBER,
1767 P_commit IN VARCHAR2,
1768 X_failure_count OUT NOCOPY NUMBER
1769 )
1770 IS
1771
1772 /***************************
1773 * PL/SQL Table Definitions *
1774 ***************************/
1775
1776 /************************
1777 * Local Variables *
1778 ************************/
1779
1780 L_legal_entity_id NUMBER(15);
1781 L_ledger_id NUMBER(15);
1782 /* L_new_legal_entity_id NUMBER(15); */
1783 l_le_count NUMBER;
1784
1785 /****************
1786 * Cursors *
1787 ****************/
1788
1789 CURSOR cur_get_fiscal_policies IS
1790 SELECT *
1791 FROM gl_plcy_mst
1792 WHERE NVL(migrated_ind,'~') <> '1'
1793 ORDER BY legal_entity_id NULLS LAST;
1794
1795 BEGIN
1796
1797 G_Migration_run_id := P_migration_run_id;
1798 G_Table_name := 'GMF_FISCAL_POLICIES';
1799 G_Context := 'Fiscal Policies LE Migration';
1800 X_failure_count := 0;
1801
1802 /********************************
1803 * Migration Started Log Message *
1804 ********************************/
1805
1806 GMA_COMMON_LOGGING.gma_migration_central_log
1807 (
1808 p_run_id => G_migration_run_id,
1809 p_log_level => FND_LOG.LEVEL_STATEMENT,
1810 p_message_token => 'GMA_MIGRATION_TABLE_STARTED',
1811 p_table_name => G_Table_name,
1812 p_context => G_Context,
1813 p_db_error => NULL,
1814 p_app_short_name => 'GMA'
1815 );
1816
1817
1818 /****************************************
1819 * Insert a row into gmf_fiscal_policies *
1820 ****************************************/
1821
1822 FOR i IN Cur_get_fiscal_policies
1823 LOOP
1824 IF i.legal_entity_id IS NULL THEN
1825 BEGIN
1826 SELECT to_number(org_information2),
1827 to_number(org_information3)
1828 INTO l_legal_entity_id,
1829 l_ledger_id
1830 FROM hr_organization_information
1831 WHERE org_information_context = 'Operating Unit Information'
1832 AND organization_id = i.org_id;
1833 EXCEPTION
1834 WHEN OTHERS THEN
1835 L_legal_entity_id := NULL;
1836 L_ledger_id := NULL;
1837 END;
1838 ELSE
1839 L_legal_entity_id := i.legal_entity_id;
1840 BEGIN
1841 SELECT to_number(org_information3)
1842 INTO l_ledger_id
1843 FROM hr_organization_information
1844 WHERE org_information_context = 'Operating Unit Information'
1845 AND organization_id = i.org_id;
1846 EXCEPTION
1847 WHEN OTHERS THEN
1848 L_ledger_id := NULL;
1849 END;
1850 END IF;
1851
1852 BEGIN
1853 SELECT count(1)
1854 INTO l_le_count
1855 FROM gmf_fiscal_policies
1856 WHERE legal_entity_id = L_legal_entity_id;
1857 EXCEPTION
1858 WHEN no_data_found THEN
1859 l_le_count := 0;
1860 WHEN too_many_rows THEN
1861 l_le_count := 99;
1862 WHEN OTHERS THEN
1863 l_le_count := 0;
1864 END;
1865
1866 IF L_legal_entity_id IS NOT NULL AND nvl(l_le_count,0) = 0 THEN
1867
1868 BEGIN
1869 INSERT INTO gmf_fiscal_policies
1870 (
1871 LEGAL_ENTITY_ID,
1872 BASE_CURRENCY_CODE,
1873 LEDGER_ID,
1874 MTL_CMPNTCLS_ID,
1875 MTL_ANALYSIS_CODE,
1876 GL_COST_MTHD,
1877 COST_BASIS,
1878 TEXT_CODE,
1879 DELETE_MARK,
1880 CREATED_BY,
1881 CREATION_DATE,
1882 LAST_UPDATE_LOGIN,
1883 LAST_UPDATE_DATE,
1884 LAST_UPDATED_BY,
1885 ATTRIBUTE1,
1886 ATTRIBUTE2,
1887 ATTRIBUTE3,
1888 ATTRIBUTE4,
1889 ATTRIBUTE5,
1890 ATTRIBUTE6,
1891 ATTRIBUTE7,
1892 ATTRIBUTE8,
1893 ATTRIBUTE9,
1894 ATTRIBUTE10,
1895 ATTRIBUTE11,
1896 ATTRIBUTE12,
1897 ATTRIBUTE13,
1898 ATTRIBUTE14,
1899 ATTRIBUTE15,
1900 ATTRIBUTE16,
1901 ATTRIBUTE17,
1902 ATTRIBUTE18,
1903 ATTRIBUTE19,
1904 ATTRIBUTE20,
1905 ATTRIBUTE21,
1906 ATTRIBUTE22,
1907 ATTRIBUTE23,
1908 ATTRIBUTE24,
1909 ATTRIBUTE25,
1910 ATTRIBUTE26,
1911 ATTRIBUTE27,
1912 ATTRIBUTE28,
1913 ATTRIBUTE29,
1914 ATTRIBUTE30,
1915 ATTRIBUTE_CATEGORY
1916 )
1917 VALUES
1918 (
1919 L_legal_entity_id,
1920 i.base_currency_code,
1921 L_ledger_id,
1922 i.mtl_cmpntcls_id,
1923 i.mtl_analysis_code,
1924 NVL(i.new_le_cost_mthd_code,i.gl_cost_mthd),
1925 i.cost_basis,
1926 i.text_code,
1927 i.delete_mark,
1928 i.created_by,
1929 i.creation_date,
1930 i.last_update_login,
1931 i.last_update_date,
1932 i.last_updated_by,
1933 i.attribute1,
1934 i.attribute2,
1935 i.attribute3,
1936 i.attribute4,
1937 i.attribute5,
1938 i.attribute6,
1939 i.attribute7,
1940 i.attribute8,
1941 i.attribute9,
1942 i.attribute10,
1943 i.attribute11,
1944 i.attribute12,
1945 i.attribute13,
1946 i.attribute14,
1947 i.attribute15,
1948 i.attribute16,
1949 i.attribute17,
1950 i.attribute18,
1951 i.attribute19,
1952 i.attribute20,
1953 i.attribute21,
1954 i.attribute22,
1955 i.attribute23,
1956 i.attribute24,
1957 i.attribute25,
1958 i.attribute26,
1959 i.attribute27,
1960 i.attribute28,
1961 i.attribute29,
1962 i.attribute30,
1963 i.attribute_category
1964 );
1965
1966 UPDATE gl_plcy_mst
1967 SET migrated_ind = '1',
1968 legal_entity_id = decode(legal_entity_id, NULL, L_legal_entity_id, legal_entity_id),
1969 last_update_date = SYSDATE
1970 WHERE co_code = i.co_code;
1971
1972 EXCEPTION
1973 WHEN OTHERS THEN
1974
1975 /************************************************
1976 * Increment Failure Count for Failed Migrations *
1977 ************************************************/
1978 x_failure_count := x_failure_count + 1;
1979
1980 GMA_COMMON_LOGGING.gma_migration_central_log
1981 (
1982 p_run_id => G_migration_run_id,
1983 p_log_level => FND_LOG.LEVEL_ERROR,
1984 p_message_token => 'GMA_MIGRATION_DB_ERROR',
1985 p_table_name => G_Table_name,
1986 p_context => G_Context,
1987 p_db_error => SQLERRM,
1988 p_app_short_name => 'GMA'
1989 );
1990
1991 GMA_COMMON_LOGGING.gma_migration_central_log
1992 (
1993 p_run_id => G_migration_run_id,
1994 p_log_level => FND_LOG.LEVEL_ERROR,
1995 p_message_token => 'GMA_TABLE_MIGRATION_TABLE_FAIL',
1996 p_table_name => G_Table_name,
1997 p_context => G_Context,
1998 p_db_error => NULL,
1999 p_app_short_name => 'GMA'
2000 );
2001 END;
2002
2003 ELSIF L_legal_entity_id IS NOT NULL AND nvl(l_le_count,0) > 0 THEN
2004
2005 UPDATE gl_plcy_mst
2006 SET migrated_ind = '1',
2007 legal_entity_id = decode(legal_entity_id, NULL, L_legal_entity_id, legal_entity_id),
2008 last_update_date = SYSDATE
2009 WHERE co_code = i.co_code;
2010
2011 ELSE
2012
2013 x_failure_count := x_failure_count + 1;
2014 L_legal_entity_id := NULL;
2015
2016 GMA_COMMON_LOGGING.gma_migration_central_log
2017 (
2018 p_run_id => G_migration_run_id,
2019 p_log_level => FND_LOG.LEVEL_ERROR,
2020 p_message_token => 'GMA_MIG_FISCAL_DUP_LE_ERROR',
2021 p_table_name => G_Table_name,
2022 p_context => G_Context,
2023 p_token1 => 'CO_CODE',
2024 p_param1 => i.co_code,
2025 p_db_error => NULL,
2026 p_app_short_name => 'GMA'
2027 );
2028
2029 END IF;
2030
2031 END LOOP;
2032
2033 /**********************************************
2034 * Handle all the rows which were not migrated *
2035 **********************************************/
2036
2037 SELECT count(*)
2038 INTO x_failure_count
2039 FROM gl_plcy_mst
2040 WHERE (legal_entity_id IS NULL AND co_code IS NOT NULL);
2041
2042 IF nvl(x_failure_count,0) > 0 THEN
2043
2044 /**************************************
2045 * Migration Failure Log Message *
2046 **************************************/
2047
2048 GMA_COMMON_LOGGING.gma_migration_central_log
2049 (
2050 p_run_id => gmf_migration.G_migration_run_id,
2051 p_log_level => FND_LOG.LEVEL_PROCEDURE,
2052 p_message_token => 'GMA_TABLE_MIGRATION_TABLE_FAIL',
2053 p_table_name => gmf_migration.G_Table_name,
2054 p_context => gmf_migration.G_context,
2055 p_db_error => NULL,
2056 p_app_short_name => 'GMA'
2057 );
2058
2059 ELSE
2060
2061 /**************************************
2062 * Migration Success Log Message *
2063 **************************************/
2064
2065 GMA_COMMON_LOGGING.gma_migration_central_log
2066 (
2067 p_run_id => G_migration_run_id,
2068 p_log_level => FND_LOG.LEVEL_STATEMENT,
2069 p_message_token => 'GMA_MIGRATION_TABLE_SUCCESS',
2070 p_table_name => G_Table_name,
2071 p_context => G_Context,
2072 p_param1 => 1,
2073 p_param2 => 0,
2074 p_db_error => NULL,
2075 p_app_short_name => 'GMA'
2076 );
2077
2078 END IF;
2079
2080 /****************************************************************
2081 * Lets save the changes now based on the commit parameter *
2082 ****************************************************************/
2083
2084 IF NVL(p_commit,'~') = FND_API.G_TRUE THEN
2085 COMMIT;
2086 END IF;
2087
2088 EXCEPTION
2089 WHEN OTHERS THEN
2090
2091 /************************************************
2092 * Increment Failure Count for Failed Migrations *
2093 ************************************************/
2094 x_failure_count := x_failure_count + 1;
2095
2096 /**************************************
2097 * Migration DB Error Log Message *
2098 **************************************/
2099
2100 GMA_COMMON_LOGGING.gma_migration_central_log
2101 (
2102 p_run_id => G_migration_run_id,
2103 p_log_level => FND_LOG.LEVEL_ERROR,
2104 p_message_token => 'GMA_MIGRATION_DB_ERROR',
2105 p_table_name => G_Table_name,
2106 p_context => G_Context,
2107 p_db_error => SQLERRM,
2108 p_app_short_name => 'GMA'
2109 );
2110
2111 /**************************************
2112 * Migration Failure Log Message *
2113 **************************************/
2114
2115 GMA_COMMON_LOGGING.gma_migration_central_log
2116 (
2117 p_run_id => G_migration_run_id,
2118 p_log_level => FND_LOG.LEVEL_ERROR,
2119 p_message_token => 'GMA_TABLE_MIGRATION_TABLE_FAIL',
2120 p_table_name => G_Table_name,
2121 p_context => G_Context,
2122 p_db_error => NULL,
2123 p_app_short_name => 'GMA'
2124 );
2125
2126 END Migrate_Fiscal_policies_LE;
2127
2128 /**********************************************************************
2129 * PROCEDURE: *
2130 * Migrate_Fiscal_Policies_Others *
2131 * *
2132 * DESCRIPTION: *
2133 * This PL/SQL procedure is used to migrate the Cost Method *
2134 * and Periods *
2135 * *
2136 * PARAMETERS: *
2137 * P_migration_run_id - id to use to right to migration log *
2138 * x_exception_count - Number of exceptions occurred. *
2139 * *
2140 * SYNOPSIS: *
2141 * Migrate_Fiscal_Policies_Others(p_migartion_id => l_migration_id, *
2142 * p_commit => 'T', *
2143 * x_exception_count => l_exception_count ); *
2144 * *
2145 * HISTORY *
2146 * 27-Apr-2005 Created Anand Thiyagarajan *
2147 * 22-aug-2006 bug 5473365, pmarada, inserting records in *
2148 * gmf_ledger_valuation_methods table *
2149 * *
2150 **********************************************************************/
2151 PROCEDURE Migrate_Fiscal_Policies_Others
2152 (
2153 P_migration_run_id IN NUMBER,
2154 P_commit IN VARCHAR2,
2155 X_failure_count OUT NOCOPY NUMBER
2156 )
2157 IS
2158
2159 /**************************
2160 * PL/SQL Table Definition *
2161 **************************/
2162
2163 /******************
2164 * Local Variables *
2165 ******************/
2166
2167 BEGIN
2168
2169 G_Migration_run_id := P_migration_run_id;
2170 G_Table_name := 'GMF_FISCAL_POLICIES';
2171 G_Context := 'Fiscal Policies Migration - Others';
2172 X_failure_count := 0;
2173
2174 /********************************
2175 * Migration Started Log Message *
2176 ********************************/
2177
2178 GMA_COMMON_LOGGING.gma_migration_central_log
2179 (
2180 p_run_id => G_migration_run_id,
2181 p_log_level => FND_LOG.LEVEL_STATEMENT,
2182 p_message_token => 'GMA_MIGRATION_TABLE_STARTED',
2183 p_table_name => G_Table_name,
2184 p_context => G_Context,
2185 p_db_error => NULL,
2186 p_app_short_name => 'GMA'
2187 );
2188
2189 /********************************************************
2190 * Update a row in GMF_FISCAL_POLICIES for GL cost Types *
2191 ********************************************************/
2192
2193 BEGIN
2194 UPDATE gmf_fiscal_policies a
2195 SET a.cost_type_id = (
2196 SELECT x.cost_type_id
2197 FROM cm_mthd_mst x
2198 WHERE x.cost_mthd_code = a.gl_cost_mthd
2199 )
2200 WHERE a.cost_type_id IS NULL AND a.gl_cost_mthd IS NOT NULL;
2201
2202 /*************************************************************************
2203 * Insert rows in GMF_ledger_valuation_methods table for the legal entity *
2204 **************************************************************************/
2205
2206 INSERT INTO gmf_ledger_valuation_methods
2207 (
2208 legal_entity_id,
2209 ledger_id,
2210 cost_type_id,
2211 creation_date,
2212 created_by,
2213 last_update_date,
2214 last_updated_by,
2215 last_update_login,
2216 text_code,
2217 delete_mark
2218 )
2219 SELECT gfp.legal_entity_id,
2220 gfp.ledger_id,
2221 gfp.cost_type_id,
2222 gfp.creation_date,
2223 gfp.created_by,
2224 gfp.last_update_date,
2225 gfp.last_updated_by,
2226 gfp.last_update_login,
2227 gfp.text_code,
2228 0
2229 FROM gmf_fiscal_policies gfp
2230 WHERE NOT EXISTS (
2231 SELECT '1'
2232 FROM gmf_ledger_valuation_methods glvm
2233 WHERE glvm.legal_entity_id = gfp.legal_entity_id
2234 AND glvm.ledger_id = gfp.ledger_id
2235 );
2236
2237 EXCEPTION
2238 WHEN OTHERS THEN
2239
2240 /************************************************
2241 * Increment Failure Count for Failed Migrations *
2242 ************************************************/
2243
2244 x_failure_count := x_failure_count + 1;
2245
2246 /**************************************
2247 * Migration DB Error Log Message *
2248 **************************************/
2249
2250 GMA_COMMON_LOGGING.gma_migration_central_log
2251 (
2252 p_run_id => G_migration_run_id,
2253 p_log_level => FND_LOG.LEVEL_ERROR,
2254 p_message_token => 'GMA_MIGRATION_DB_ERROR',
2255 p_table_name => G_Table_name,
2256 p_context => G_Context,
2257 p_db_error => SQLERRM,
2258 p_app_short_name => 'GMA'
2259 );
2260
2261 /**************************************
2262 * Migration Failure Log Message *
2263 **************************************/
2264
2265 GMA_COMMON_LOGGING.gma_migration_central_log
2266 (
2267 p_run_id => G_migration_run_id,
2268 p_log_level => FND_LOG.LEVEL_ERROR,
2269 p_message_token => 'GMA_TABLE_MIGRATION_TABLE_FAIL',
2270 p_table_name => G_Table_name,
2271 p_context => G_Context,
2272 p_db_error => NULL,
2273 p_app_short_name => 'GMA'
2274 );
2275
2276 END;
2277
2278 /**********************************************
2279 * Handle all the rows which were not migrated *
2280 **********************************************/
2281
2282 SELECT count(*)
2283 INTO x_failure_count
2284 FROM gmf_fiscal_policies
2285 WHERE (cost_type_id IS NULL AND gl_cost_mthd IS NOT NULL);
2286
2287 IF nvl(x_failure_count,0) > 0 THEN
2288
2289 /**************************************
2290 * Migration Failure Log Message *
2291 **************************************/
2292
2293 GMA_COMMON_LOGGING.gma_migration_central_log
2294 (
2295 p_run_id => gmf_migration.G_migration_run_id,
2296 p_log_level => FND_LOG.LEVEL_PROCEDURE,
2297 p_message_token => 'GMA_TABLE_MIGRATION_TABLE_FAIL',
2298 p_table_name => gmf_migration.G_Table_name,
2299 p_context => gmf_migration.G_context,
2300 p_db_error => NULL,
2301 p_app_short_name => 'GMA'
2302 );
2303
2304 ELSE
2305
2306 /**************************************
2307 * Migration Success Log Message *
2308 **************************************/
2309
2310 GMA_COMMON_LOGGING.gma_migration_central_log
2311 (
2312 p_run_id => G_migration_run_id,
2313 p_log_level => FND_LOG.LEVEL_STATEMENT,
2314 p_message_token => 'GMA_MIGRATION_TABLE_SUCCESS',
2315 p_table_name => G_Table_name,
2316 p_context => G_Context,
2317 p_param1 => 1,
2318 p_param2 => 0,
2319 p_db_error => NULL,
2320 p_app_short_name => 'GMA'
2321 );
2322
2323 END IF;
2324
2325 /****************************************************************
2326 * Lets save the changes now based on the commit parameter *
2327 ****************************************************************/
2328
2329 IF NVL(p_commit,'~') = FND_API.G_TRUE THEN
2330 COMMIT;
2331 END IF;
2332
2333 EXCEPTION
2334 WHEN OTHERS THEN
2335
2336 /************************************************
2337 * Increment Failure Count for Failed Migrations *
2338 ************************************************/
2339
2340 x_failure_count := x_failure_count + 1;
2341
2342 /**************************************
2343 * Migration DB Error Log Message *
2344 **************************************/
2345
2346 GMA_COMMON_LOGGING.gma_migration_central_log
2347 (
2348 p_run_id => G_migration_run_id,
2349 p_log_level => FND_LOG.LEVEL_ERROR,
2350 p_message_token => 'GMA_MIGRATION_DB_ERROR',
2351 p_table_name => G_Table_name,
2352 p_context => G_Context,
2353 p_db_error => SQLERRM,
2354 p_app_short_name => 'GMA'
2355 );
2356
2357 /**************************************
2358 * Migration Failure Log Message *
2359 **************************************/
2360
2361 GMA_COMMON_LOGGING.gma_migration_central_log
2362 (
2363 p_run_id => G_migration_run_id,
2364 p_log_level => FND_LOG.LEVEL_ERROR,
2365 p_message_token => 'GMA_TABLE_MIGRATION_TABLE_FAIL',
2366 p_table_name => G_Table_name,
2367 p_context => G_Context,
2368 p_db_error => NULL,
2369 p_app_short_name => 'GMA'
2370 );
2371
2372 END Migrate_Fiscal_Policies_Others;
2373
2374 /**********************************************************************
2375 * PROCEDURE: *
2376 * Migrate_Cost_Methods *
2377 * *
2378 * DESCRIPTION: *
2379 * This PL/SQL procedure is used to transform the Cost Methods *
2380 * data in CM_MTHD_MST *
2381 * *
2382 * PARAMETERS: *
2383 * P_migration_run_id - id to use to right to migration log *
2384 * x_exception_count - Number of exceptions occurred. *
2385 * *
2386 * SYNOPSIS: *
2387 * Migrate_cost_methods(p_migartion_id => l_migration_id, *
2388 * p_commit => 'T', *
2389 * x_exception_count => l_exception_count ); *
2390 * *
2391 * HISTORY *
2392 * 27-Apr-2005 Created Anand Thiyagarajan *
2393 * *
2394 **********************************************************************/
2395 PROCEDURE Migrate_Cost_Methods
2396 (
2397 P_migration_run_id IN NUMBER,
2398 P_commit IN VARCHAR2,
2399 X_failure_count OUT NOCOPY NUMBER
2400 )
2401 IS
2402
2403 /****************
2404 * PL/SQL Tables *
2405 ****************/
2406
2407 /******************
2408 * Local Variables *
2409 ******************/
2410
2411 BEGIN
2412
2413 G_Migration_run_id := P_migration_run_id;
2414 G_Table_name := 'CM_MTHD_MST';
2415 G_Context := 'Cost Types Migration';
2416 X_failure_count := 0;
2417
2418 /********************************
2419 * Migration Started Log Message *
2420 ********************************/
2421
2422 GMA_COMMON_LOGGING.gma_migration_central_log
2423 (
2424 p_run_id => G_migration_run_id,
2425 p_log_level => FND_LOG.LEVEL_STATEMENT,
2426 p_message_token => 'GMA_MIGRATION_TABLE_STARTED',
2427 p_table_name => G_table_name,
2428 p_context => G_context,
2429 p_db_error => NULL,
2430 p_app_short_name => 'GMA'
2431 );
2432
2433 /*****************************************
2434 * Update rows For Cost Type Identifier *
2435 *****************************************/
2436
2437 UPDATE cm_mthd_mst
2438 SET cost_type_id = gmf_cost_type_id_s.NEXTVAL
2439 WHERE (cost_type_id IS NULL AND cost_mthd_code IS NOT NULL);
2440
2441 /**********************************************
2442 * Handle all the rows which were not migrated *
2443 **********************************************/
2444
2445 SELECT count(*)
2446 INTO x_failure_count
2447 FROM cm_mthd_mst
2448 WHERE (cost_type_id IS NULL AND cost_mthd_code IS NOT NULL);
2449
2450 IF nvl(x_failure_count,0) > 0 THEN
2451
2452 /**************************************
2453 * Migration Failure Log Message *
2454 **************************************/
2455
2456 GMA_COMMON_LOGGING.gma_migration_central_log
2457 (
2458 p_run_id => gmf_migration.G_migration_run_id,
2459 p_log_level => FND_LOG.LEVEL_PROCEDURE,
2460 p_message_token => 'GMA_TABLE_MIGRATION_TABLE_FAIL',
2461 p_table_name => gmf_migration.G_Table_name,
2462 p_context => gmf_migration.G_context,
2463 p_db_error => NULL,
2464 p_app_short_name => 'GMA'
2465 );
2466
2467 ELSE
2468
2469 /**************************************
2470 * Migration Success Log Message *
2471 **************************************/
2472
2473 GMA_COMMON_LOGGING.gma_migration_central_log
2474 (
2475 p_run_id => G_migration_run_id,
2476 p_log_level => FND_LOG.LEVEL_STATEMENT,
2477 p_message_token => 'GMA_MIGRATION_TABLE_SUCCESS',
2478 p_table_name => G_Table_name,
2479 p_context => G_Context,
2480 p_param1 => 1,
2481 p_param2 => 0,
2482 p_db_error => NULL,
2483 p_app_short_name => 'GMA'
2484 );
2485
2486 END IF;
2487
2488 /****************************************************************
2489 *Lets save the changes now based on the commit parameter *
2490 ****************************************************************/
2491
2492 IF NVL(p_commit,'~') = FND_API.G_TRUE THEN
2493 COMMIT;
2494 END IF;
2495
2496 EXCEPTION
2497 WHEN OTHERS THEN
2498
2499 /************************************************
2500 * Increment Failure Count for Failed Migrations *
2501 ************************************************/
2502 x_failure_count := x_failure_count + 1;
2503
2504 /**************************************
2505 * Migration DB Error Log Message *
2506 **************************************/
2507
2508 GMA_COMMON_LOGGING.gma_migration_central_log
2509 (
2510 p_run_id => G_migration_run_id,
2511 p_log_level => FND_LOG.LEVEL_ERROR,
2512 p_message_token => 'GMA_MIGRATION_DB_ERROR',
2513 p_table_name => G_table_name,
2514 p_context => G_context,
2515 p_db_error => SQLERRM,
2516 p_app_short_name => 'GMA'
2517 );
2518
2519 /**************************************
2520 * Migration Failure Log Message *
2521 **************************************/
2522
2523 GMA_COMMON_LOGGING.gma_migration_central_log
2524 (
2525 p_run_id => G_migration_run_id,
2526 p_log_level => FND_LOG.LEVEL_ERROR,
2527 p_message_token => 'GMA_TABLE_MIGRATION_TABLE_FAIL',
2528 p_table_name => G_table_name,
2529 p_context => G_context,
2530 p_db_error => NULL,
2531 p_app_short_name => 'GMA'
2532 );
2533
2534 END Migrate_Cost_Methods;
2535
2536 /**********************************************************************
2537 * PROCEDURE: *
2538 * Migrate_Lot_Cost_Methods *
2539 * *
2540 * DESCRIPTION: *
2541 * This PL/SQL procedure is used to transform the Lot Cost Methods *
2542 * data in CM_MTHD_MST *
2543 * *
2544 * PARAMETERS: *
2545 * P_migration_run_id - id to use to right to migration log *
2546 * x_exception_count - Number of exceptions occurred. *
2547 * *
2548 * SYNOPSIS: *
2549 * Migrate_lot_cost_methods(p_migartion_id => l_migration_id, *
2550 * p_commit => 'T', *
2551 * x_exception_count => l_exception_count ); *
2552 * *
2553 * HISTORY *
2554 * 27-Apr-2005 Created Anand Thiyagarajan *
2555 * *
2556 **********************************************************************/
2557 PROCEDURE Migrate_Lot_Cost_Methods
2558 (
2559 P_migration_run_id IN NUMBER,
2560 P_commit IN VARCHAR2,
2561 X_failure_count OUT NOCOPY NUMBER
2562 )
2563 IS
2564
2565 /**************************
2566 * PL/SQL Table Definition *
2567 **************************/
2568
2569 /******************
2570 * Local Variables *
2571 ******************/
2572
2573 /**********
2574 * Cursors *
2575 **********/
2576
2577 BEGIN
2578
2579 G_Migration_run_id := P_migration_run_id;
2580 G_Table_name := 'CM_MTHD_MST';
2581 G_Context := 'Lot Cost Types Migration';
2582 X_failure_count := 0;
2583
2584 /********************************
2585 * Migration Started Log Message *
2586 ********************************/
2587
2588 GMA_COMMON_LOGGING.gma_migration_central_log
2589 (
2590 p_run_id => G_migration_run_id,
2591 p_log_level => FND_LOG.LEVEL_STATEMENT,
2592 p_message_token => 'GMA_MIGRATION_TABLE_STARTED',
2593 p_table_name => G_table_name,
2594 p_context => G_context,
2595 p_db_error => NULL,
2596 p_app_short_name => 'GMA'
2597 );
2598
2599 /*********************************************
2600 * Update a row in cm_mthd_mst for Lot Costs *
2601 *********************************************/
2602 BEGIN
2603
2604 UPDATE cm_mthd_mst a
2605 SET a.default_lot_cost_type_id = (
2606 SELECT x.cost_type_id
2607 FROM cm_mthd_mst x
2608 WHERE x.cost_mthd_code = a.default_lot_cost_mthd
2609 ),
2610 a.cost_type = 6,
2611 a.lot_actual_cost = NULL
2612 WHERE cost_type_id IS NOT NULL
2613 AND a.cost_type = 1
2614 AND nvl(a.lot_actual_cost,-1) = 1;
2615
2616 EXCEPTION
2617 WHEN OTHERS THEN
2618
2619 /************************************************
2620 * Increment Failure Count for Failed Migrations *
2621 ************************************************/
2622
2623 x_failure_count := x_failure_count + 1;
2624
2625 /**************************************
2626 * Migration DB Error Log Message *
2627 **************************************/
2628
2629 GMA_COMMON_LOGGING.gma_migration_central_log
2630 (
2631 p_run_id => G_migration_run_id,
2632 p_log_level => FND_LOG.LEVEL_ERROR,
2633 p_message_token => 'GMA_MIGRATION_DB_ERROR',
2634 p_table_name => G_table_name,
2635 p_context => G_context,
2636 p_db_error => SQLERRM,
2637 p_app_short_name => 'GMA'
2638 );
2639
2640 /**************************************
2641 * Migration Failure Log Message *
2642 **************************************/
2643
2644 GMA_COMMON_LOGGING.gma_migration_central_log
2645 (
2646 p_run_id => G_migration_run_id,
2647 p_log_level => FND_LOG.LEVEL_ERROR,
2648 p_message_token => 'GMA_TABLE_MIGRATION_TABLE_FAIL',
2649 p_table_name => G_table_name,
2650 p_context => G_context,
2651 p_db_error => NULL,
2652 p_app_short_name => 'GMA'
2653 );
2654
2655 END;
2656
2657 /**********************************************
2658 * Handle all the rows which were not migrated *
2659 **********************************************/
2660
2661 SELECT count(*)
2662 INTO x_failure_count
2663 FROM cm_mthd_mst
2664 WHERE (
2665 (default_lot_cost_type_id IS NULL AND default_lot_cost_mthd IS NOT NULL)
2666 OR (cost_type = 1 AND nvl(lot_actual_cost,-1) = 1)
2667 );
2668
2669 IF nvl(x_failure_count,0) > 0 THEN
2670
2671 /**************************************
2672 * Migration Failure Log Message *
2673 **************************************/
2674
2675 GMA_COMMON_LOGGING.gma_migration_central_log
2676 (
2677 p_run_id => gmf_migration.G_migration_run_id,
2678 p_log_level => FND_LOG.LEVEL_PROCEDURE,
2679 p_message_token => 'GMA_TABLE_MIGRATION_TABLE_FAIL',
2680 p_table_name => gmf_migration.G_Table_name,
2681 p_context => gmf_migration.G_context,
2682 p_db_error => NULL,
2683 p_app_short_name => 'GMA'
2684 );
2685
2686 ELSE
2687
2688 /**************************************
2689 * Migration Success Log Message *
2690 **************************************/
2691
2692 GMA_COMMON_LOGGING.gma_migration_central_log
2693 (
2694 p_run_id => G_migration_run_id,
2695 p_log_level => FND_LOG.LEVEL_STATEMENT,
2696 p_message_token => 'GMA_MIGRATION_TABLE_SUCCESS',
2697 p_table_name => G_Table_name,
2698 p_context => G_Context,
2699 p_param1 => 1,
2700 p_param2 => 0,
2701 p_db_error => NULL,
2702 p_app_short_name => 'GMA'
2703 );
2704
2705 END IF;
2706
2707 /****************************************************************
2708 *Lets save the changes now based on the commit parameter *
2709 ****************************************************************/
2710
2711 IF NVL(p_commit,'~') = FND_API.G_TRUE THEN
2712 COMMIT;
2713 END IF;
2714
2715 EXCEPTION
2716 WHEN OTHERS THEN
2717
2718 /************************************************
2719 * Increment Failure Count for Failed Migrations *
2720 ************************************************/
2721
2722 x_failure_count := x_failure_count + 1;
2723
2724 /**************************************
2725 * Migration DB Error Log Message *
2726 **************************************/
2727
2728 GMA_COMMON_LOGGING.gma_migration_central_log
2729 (
2730 p_run_id => G_migration_run_id,
2731 p_log_level => FND_LOG.LEVEL_ERROR,
2732 p_message_token => 'GMA_MIGRATION_DB_ERROR',
2733 p_table_name => G_table_name,
2734 p_context => G_context,
2735 p_db_error => SQLERRM,
2736 p_app_short_name => 'GMA'
2737 );
2738
2739 /**************************************
2740 * Migration Failure Log Message *
2741 **************************************/
2742
2743 GMA_COMMON_LOGGING.gma_migration_central_log
2744 (
2745 p_run_id => G_migration_run_id,
2746 p_log_level => FND_LOG.LEVEL_ERROR,
2747 p_message_token => 'GMA_TABLE_MIGRATION_TABLE_FAIL',
2748 p_table_name => G_table_name,
2749 p_context => G_context,
2750 p_db_error => NULL,
2751 p_app_short_name => 'GMA'
2752 );
2753
2754 END Migrate_Lot_Cost_Methods;
2755
2756 /**********************************************************************
2757 * PROCEDURE: *
2758 * Migrate_Cost_Calendars *
2759 * *
2760 * DESCRIPTION: *
2761 * This PL/SQL procedure is used to transform the Cost Calendars *
2762 * data in CM_CLDR_HDR_B AND CM_CLDR_DTL to GMF_CALENDAR_ASSIGNMENTS *
2763 * and GMF_PERIOD_STATUSES *
2764 * *
2765 * PARAMETERS: *
2766 * P_migration_run_id - id to use to right to migration log *
2767 * x_exception_count - Number of exceptions occurred. *
2768 * *
2769 * SYNOPSIS: *
2770 * Migrate_cost_calendars(p_migartion_id => l_migration_id, *
2771 * p_commit => 'T', *
2772 * x_exception_count => l_exception_count ); *
2773 * *
2774 * HISTORY *
2775 * 27-Apr-2005 Created Anand Thiyagarajan *
2776 * 16-Dec-2006 Bug#5716122 Anand Thiyagarajan *
2777 * Modified Code to remve call to gmf_legal_entity_tz API *
2778 * since dates in t he DB are always stored in SRV TZ and not *
2779 * in LE TZ *
2780 * *
2781 **********************************************************************/
2782 PROCEDURE Migrate_Cost_Calendars
2783 (
2784 P_migration_run_id IN NUMBER,
2785 P_commit IN VARCHAR2,
2786 X_failure_count OUT NOCOPY NUMBER
2787 )
2788 IS
2789
2790 /*****************
2791 * PL/SQL Cursors *
2792 *****************/
2793
2794 CURSOR cur_overlap_Calendar
2795 IS
2796 SELECT a.legal_entity_id,
2797 a.cost_Type_id,
2798 a.calendar_code
2799 FROM gmf_calendar_assignments a
2800 ORDER BY a.legal_entity_id,
2801 a.cost_Type_id,
2802 a.calendar_code;
2803
2804 /******************
2805 * Local Variables *
2806 ******************/
2807
2808 l_exception_count NUMBER := 0;
2809
2810 BEGIN
2811
2812 G_Migration_run_id := P_migration_run_id;
2813 G_Table_name := 'GMF_CALENDAR_ASSIGNMENTS';
2814 G_Context := 'Cost Calendar Assignments Migration';
2815 X_failure_count := 0;
2816
2817 /********************************
2818 * Migration Started Log Message *
2819 ********************************/
2820
2821 GMA_COMMON_LOGGING.gma_migration_central_log
2822 (
2823 p_run_id => G_migration_run_id,
2824 p_log_level => FND_LOG.LEVEL_STATEMENT,
2825 p_message_token => 'GMA_MIGRATION_TABLE_STARTED',
2826 p_table_name => G_table_name,
2827 p_context => G_context,
2828 p_db_error => NULL,
2829 p_app_short_name => 'GMA'
2830 );
2831
2832 /****************************************************************************
2833 * Insert a row in gmf_calendar_assignments for Direct Calendar Assignments *
2834 *****************************************************************************/
2835 BEGIN
2836
2837 INSERT INTO gmf_calendar_assignments
2838 (
2839 ASSIGNMENT_ID,
2840 CALENDAR_CODE,
2841 LEGAL_ENTITY_ID,
2842 COST_TYPE_ID,
2843 CREATION_DATE,
2844 CREATED_BY,
2845 LAST_UPDATE_DATE,
2846 LAST_UPDATED_BY,
2847 LAST_UPDATE_LOGIN,
2848 TEXT_CODE,
2849 DELETE_MARK
2850 )
2851 SELECT gmf_calendar_assignments_s.NEXTVAL,
2852 a.calendar_code,
2853 b.legal_entity_id,
2854 c.cost_type_id,
2855 a.creation_date,
2856 a.created_by,
2857 a.last_update_date,
2858 a.last_updated_by,
2859 a.last_update_login,
2860 a.text_code,
2861 a.delete_mark
2862 FROM cm_cldr_hdr_b a,
2863 gl_plcy_mst b,
2864 cm_mthd_mst c
2865 WHERE a.cost_mthd_code IS NOT NULL
2866 AND a.co_code IS NOT NULL
2867 AND b.legal_entity_id IS NOT NULL
2868 AND c.cost_type_id IS NOT NULL
2869 AND a.co_code = b.co_code
2870 AND c.cost_mthd_code = a.cost_mthd_code
2871 AND NOT EXISTS (
2872 SELECT 'X'
2873 FROM gmf_calendar_assignments x
2874 WHERE x.calendar_code = a.calendar_code
2875 AND x.cost_type_id = c.cost_type_id
2876 AND x.legal_entity_id = b.legal_entity_id
2877 );
2878
2879 EXCEPTION
2880 WHEN OTHERS THEN
2881
2882 /************************************************
2883 * Increment Failure Count for Failed Migrations *
2884 ************************************************/
2885
2886 x_failure_count := x_failure_count + 1;
2887
2888 /**************************************
2889 * Migration DB Error Log Message *
2890 **************************************/
2891
2892 GMA_COMMON_LOGGING.gma_migration_central_log
2893 (
2894 p_run_id => G_migration_run_id,
2895 p_log_level => FND_LOG.LEVEL_ERROR,
2896 p_message_token => 'GMA_MIGRATION_DB_ERROR',
2897 p_table_name => G_Table_name,
2898 p_context => G_context,
2899 p_db_error => SQLERRM,
2900 p_app_short_name => 'GMA'
2901 );
2902
2903 /**************************************
2904 * Migration Failure Log Message *
2905 **************************************/
2906
2907 GMA_COMMON_LOGGING.gma_migration_central_log
2908 (
2909 p_run_id => G_migration_run_id,
2910 p_log_level => FND_LOG.LEVEL_ERROR,
2911 p_message_token => 'GMA_TABLE_MIGRATION_TABLE_FAIL',
2912 p_table_name => G_Table_name,
2913 p_context => G_context,
2914 p_db_error => NULL,
2915 p_app_short_name => 'GMA'
2916 );
2917 END;
2918
2919 /**********************************************************************
2920 * Insert a row in gmf_calendar_assignments for transaction table data *
2921 **********************************************************************/
2922 BEGIN
2923
2924 INSERT INTO gmf_calendar_assignments
2925 (
2926 ASSIGNMENT_ID,
2927 CALENDAR_CODE,
2928 LEGAL_ENTITY_ID,
2929 COST_TYPE_ID,
2930 CREATION_DATE,
2931 CREATED_BY,
2932 LAST_UPDATE_DATE,
2933 LAST_UPDATED_BY,
2934 LAST_UPDATE_LOGIN,
2935 TEXT_CODE,
2936 DELETE_MARK
2937 )
2938 (
2939 SELECT gmf_calendar_assignments_s.NEXTVAL,
2940 g.calendar_code,
2941 i.legal_entity_id,
2942 h.cost_type_id,
2943 g.creation_date,
2944 g.created_by,
2945 g.last_update_date,
2946 g.last_updated_by,
2947 g.last_update_login,
2948 g.text_code,
2949 1
2950 FROM cm_cldr_hdr_b g,
2951 cm_mthd_mst h,
2952 gl_plcy_mst i
2953 WHERE g.co_code IS NOT NULL
2954 AND i.legal_entity_id IS NOT NULL
2955 AND g.cost_mthd_code <> h.cost_mthd_code
2956 AND i.co_code = g.co_code
2957 AND EXISTS (
2958 SELECT 'CM_RSRC_DTL'
2959 FROM cm_rsrc_dtl a
2960 WHERE a.calendar_code is not null
2961 AND a.cost_mthd_Code is not null
2962 AND a.calendar_code = g.calendar_code
2963 AND a.cost_mthd_code = h.cost_mthd_code
2964 UNION
2965 SELECT 'CM_CMPT_DTL'
2966 FROM cm_cmpt_dtl a
2967 WHERE a.calendar_code is not null
2968 AND a.cost_mthd_Code is not null
2969 AND a.calendar_code = g.calendar_code
2970 AND a.cost_mthd_code = h.cost_mthd_code
2971 UNION
2972 SELECT 'CM_BRDN_DTL'
2973 FROM cm_brdn_dtl a
2974 WHERE a.calendar_code is not null
2975 AND a.cost_mthd_Code is not null
2976 AND a.calendar_code = g.calendar_code
2977 AND a.cost_mthd_code = h.cost_mthd_code
2978 UNION
2979 SELECT 'CM_ADJS_DTL'
2980 FROM cm_adjs_dtl a
2981 WHERE a.calendar_code is not null
2982 AND a.cost_mthd_Code is not null
2983 AND a.calendar_code = g.calendar_code
2984 AND a.cost_mthd_code = h.cost_mthd_code
2985 UNION
2986 SELECT 'CM_RLUP_CTL'
2987 FROM cm_rlup_ctl a
2988 WHERE a.calendar_code is not null
2989 AND a.cost_mthd_Code is not null
2990 AND a.calendar_code = g.calendar_code
2991 AND a.cost_mthd_code = h.cost_mthd_code
2992 UNION
2993 SELECT 'CM_ACPR_CTL'
2994 FROM cm_acpr_ctl a
2995 WHERE a.calendar_code is not null
2996 AND a.cost_mthd_Code is not null
2997 AND a.calendar_code = g.calendar_code
2998 AND a.cost_mthd_code = h.cost_mthd_code
2999 UNION
3000 SELECT 'CM_CUPD_CTL'
3001 FROM cm_cupd_ctl a
3002 WHERE a.calendar_code is not null
3003 AND a.cost_mthd_Code is not null
3004 AND a.calendar_code = g.calendar_code
3005 AND a.cost_mthd_code = h.cost_mthd_code
3006 )
3007 AND NOT EXISTS (
3008 SELECT 'X'
3009 FROM gmf_calendar_assignments x
3010 WHERE x.calendar_code = g.calendar_code
3011 AND x.cost_type_id = h.cost_type_id
3012 AND x.legal_entity_id = i.legal_entity_id
3013 )
3014 );
3015
3016 EXCEPTION
3017 WHEN OTHERS THEN
3018
3019 /************************************************
3020 * Increment Failure Count for Failed Migrations *
3021 ************************************************/
3022
3023 x_failure_count := x_failure_count + 1;
3024
3025 /**************************************
3026 * Migration DB Error Log Message *
3027 **************************************/
3028
3029 GMA_COMMON_LOGGING.gma_migration_central_log
3030 (
3031 p_run_id => G_migration_run_id,
3032 p_log_level => FND_LOG.LEVEL_ERROR,
3033 p_message_token => 'GMA_MIGRATION_DB_ERROR',
3034 p_table_name => G_Table_name,
3035 p_context => G_context,
3036 p_db_error => SQLERRM,
3037 p_app_short_name => 'GMA'
3038 );
3039
3040 /**************************************
3041 * Migration Failure Log Message *
3042 **************************************/
3043
3044 GMA_COMMON_LOGGING.gma_migration_central_log
3045 (
3046 p_run_id => G_migration_run_id,
3047 p_log_level => FND_LOG.LEVEL_ERROR,
3048 p_message_token => 'GMA_TABLE_MIGRATION_TABLE_FAIL',
3049 p_table_name => G_Table_name,
3050 p_context => G_context,
3051 p_db_error => NULL,
3052 p_app_short_name => 'GMA'
3053 );
3054 END;
3055
3056 /**********************************************************************
3057 * Insert a row in gmf_calendar_assignments for CM_RSRC_DTL table data *
3058 **********************************************************************/
3059 BEGIN
3060
3061 INSERT INTO gmf_calendar_assignments
3062 (
3063 ASSIGNMENT_ID,
3064 CALENDAR_CODE,
3065 LEGAL_ENTITY_ID,
3066 COST_TYPE_ID,
3067 CREATION_DATE,
3068 CREATED_BY,
3069 LAST_UPDATE_DATE,
3070 LAST_UPDATED_BY,
3071 LAST_UPDATE_LOGIN,
3072 TEXT_CODE,
3073 DELETE_MARK
3074 )
3075 (
3076 SELECT gmf_calendar_assignments_s.NEXTVAL,
3077 x.*
3078 FROM (
3079 SELECT DISTINCT
3080 g.calendar_code,
3081 i.legal_entity_id,
3082 h.cost_type_id,
3083 g.creation_date,
3084 g.created_by,
3085 g.last_update_date,
3086 g.last_updated_by,
3087 g.last_update_login,
3088 g.text_code,
3089 1
3090 FROM cm_cldr_hdr_b g,
3091 cm_mthd_mst h,
3092 gl_plcy_mst i,
3093 sy_orgn_mst j,
3094 cm_rsrc_dtl k
3095 WHERE g.co_code IS NOT NULL
3096 AND j.orgn_code = k.orgn_code
3097 AND i.co_code = j.co_code
3098 AND i.legal_entity_id IS NOT NULL
3099 AND j.co_code <> g.co_code
3100 AND h.cost_mthd_code = k.cost_mthd_code
3101 AND g.calendar_code = k.calendar_code
3102 AND NOT EXISTS (
3103 SELECT 'X'
3104 FROM gmf_calendar_assignments x
3105 WHERE x.calendar_code = g.calendar_code
3106 AND x.cost_type_id = h.cost_Type_id
3107 AND x.legal_entity_id = i.legal_Entity_id
3108 )
3109 ) x
3110 );
3111
3112 EXCEPTION
3113 WHEN OTHERS THEN
3114
3115 /************************************************
3116 * Increment Failure Count for Failed Migrations *
3117 ************************************************/
3118
3119 x_failure_count := x_failure_count + 1;
3120
3121 /**************************************
3122 * Migration DB Error Log Message *
3123 **************************************/
3124
3125 GMA_COMMON_LOGGING.gma_migration_central_log
3126 (
3127 p_run_id => G_migration_run_id,
3128 p_log_level => FND_LOG.LEVEL_ERROR,
3129 p_message_token => 'GMA_MIGRATION_DB_ERROR',
3130 p_table_name => G_Table_name,
3131 p_context => G_context,
3132 p_db_error => SQLERRM,
3133 p_app_short_name => 'GMA'
3134 );
3135
3136 /**************************************
3137 * Migration Failure Log Message *
3138 **************************************/
3139
3140 GMA_COMMON_LOGGING.gma_migration_central_log
3141 (
3142 p_run_id => G_migration_run_id,
3143 p_log_level => FND_LOG.LEVEL_ERROR,
3144 p_message_token => 'GMA_TABLE_MIGRATION_TABLE_FAIL',
3145 p_table_name => G_Table_name,
3146 p_context => G_context,
3147 p_db_error => NULL,
3148 p_app_short_name => 'GMA'
3149 );
3150 END;
3151
3152 /**********************************************************************
3153 * Insert a row in gmf_calendar_assignments for CM_BRDN_DTL table data *
3154 **********************************************************************/
3155 BEGIN
3156
3157 INSERT INTO gmf_calendar_assignments
3158 (
3159 ASSIGNMENT_ID,
3160 CALENDAR_CODE,
3161 LEGAL_ENTITY_ID,
3162 COST_TYPE_ID,
3163 CREATION_DATE,
3164 CREATED_BY,
3165 LAST_UPDATE_DATE,
3166 LAST_UPDATED_BY,
3167 LAST_UPDATE_LOGIN,
3168 TEXT_CODE,
3169 DELETE_MARK
3170 )
3171 (
3172 SELECT gmf_calendar_assignments_s.NEXTVAL,
3173 x.*
3174 FROM (
3175 SELECT DISTINCT
3176 g.calendar_code,
3177 i.legal_entity_id,
3178 h.cost_type_id,
3179 g.creation_date,
3180 g.created_by,
3181 g.last_update_date,
3182 g.last_updated_by,
3183 g.last_update_login,
3184 g.text_code,
3185 1
3186 FROM cm_cldr_hdr_b g,
3187 cm_mthd_mst h,
3188 gl_plcy_mst i,
3189 sy_orgn_mst j,
3190 cm_brdn_dtl k
3191 WHERE g.co_code IS NOT NULL
3192 AND j.orgn_code = k.orgn_code
3193 AND i.co_code = j.co_code
3194 AND i.legal_entity_id IS NOT NULL
3195 AND j.co_code <> g.co_code
3196 AND h.cost_mthd_code = k.cost_mthd_code
3197 AND g.calendar_code = k.calendar_code
3198 AND NOT EXISTS (
3199 SELECT 'X'
3200 FROM gmf_calendar_assignments x
3201 WHERE x.calendar_code = g.calendar_code
3202 AND x.cost_type_id = h.cost_Type_id
3203 AND x.legal_entity_id = i.legal_Entity_id
3204 )
3205 ) x
3206 );
3207
3208 EXCEPTION
3209 WHEN OTHERS THEN
3210
3211 /************************************************
3212 * Increment Failure Count for Failed Migrations *
3213 ************************************************/
3214
3215 x_failure_count := x_failure_count + 1;
3216
3217 /**************************************
3218 * Migration DB Error Log Message *
3219 **************************************/
3220
3221 GMA_COMMON_LOGGING.gma_migration_central_log
3222 (
3223 p_run_id => G_migration_run_id,
3224 p_log_level => FND_LOG.LEVEL_ERROR,
3225 p_message_token => 'GMA_MIGRATION_DB_ERROR',
3226 p_table_name => G_Table_name,
3227 p_context => G_context,
3228 p_db_error => SQLERRM,
3229 p_app_short_name => 'GMA'
3230 );
3231
3232 /**************************************
3233 * Migration Failure Log Message *
3234 **************************************/
3235
3236 GMA_COMMON_LOGGING.gma_migration_central_log
3237 (
3238 p_run_id => G_migration_run_id,
3239 p_log_level => FND_LOG.LEVEL_ERROR,
3240 p_message_token => 'GMA_TABLE_MIGRATION_TABLE_FAIL',
3241 p_table_name => G_Table_name,
3242 p_context => G_context,
3243 p_db_error => NULL,
3244 p_app_short_name => 'GMA'
3245 );
3246 END;
3247
3248 /**********************************************************************
3249 * Insert a row in gmf_calendar_assignments for CM_CMPT_DTL table data *
3250 **********************************************************************/
3251 BEGIN
3252
3253 INSERT INTO gmf_calendar_assignments
3254 (
3255 ASSIGNMENT_ID,
3256 CALENDAR_CODE,
3257 LEGAL_ENTITY_ID,
3258 COST_TYPE_ID,
3259 CREATION_DATE,
3260 CREATED_BY,
3261 LAST_UPDATE_DATE,
3262 LAST_UPDATED_BY,
3263 LAST_UPDATE_LOGIN,
3264 TEXT_CODE,
3265 DELETE_MARK
3266 )
3267 (
3268 SELECT gmf_calendar_assignments_s.NEXTVAL,
3269 x.*
3270 FROM (
3271 SELECT DISTINCT
3272 g.calendar_code,
3273 i.legal_entity_id,
3274 h.cost_type_id,
3275 g.creation_date,
3276 g.created_by,
3277 g.last_update_date,
3278 g.last_updated_by,
3279 g.last_update_login,
3280 g.text_code,
3281 1
3282 FROM cm_cldr_hdr_b g,
3283 cm_mthd_mst h,
3284 gl_plcy_mst i,
3285 sy_orgn_mst j,
3286 cm_cmpt_dtl k,
3287 ic_whse_mst l
3288 WHERE g.co_code IS NOT NULL
3289 AND l.whse_code = k.whse_code
3290 AND j.orgn_code = l.orgn_code
3291 AND i.co_code = j.co_code
3292 AND i.legal_entity_id IS NOT NULL
3293 AND j.co_code <> g.co_code
3294 AND h.cost_mthd_code = k.cost_mthd_code
3295 AND g.calendar_code = k.calendar_code
3296 AND NOT EXISTS (
3297 SELECT 'X'
3298 FROM gmf_calendar_assignments x
3299 WHERE x.calendar_code = g.calendar_code
3300 AND x.cost_type_id = h.cost_Type_id
3301 AND x.legal_entity_id = i.legal_Entity_id
3302 )
3303 ) x
3304 );
3305
3306 EXCEPTION
3307 WHEN OTHERS THEN
3308
3309 /************************************************
3310 * Increment Failure Count for Failed Migrations *
3311 ************************************************/
3312
3313 x_failure_count := x_failure_count + 1;
3314
3315 /**************************************
3316 * Migration DB Error Log Message *
3317 **************************************/
3318
3319 GMA_COMMON_LOGGING.gma_migration_central_log
3320 (
3321 p_run_id => G_migration_run_id,
3322 p_log_level => FND_LOG.LEVEL_ERROR,
3323 p_message_token => 'GMA_MIGRATION_DB_ERROR',
3324 p_table_name => G_Table_name,
3325 p_context => G_context,
3326 p_db_error => SQLERRM,
3327 p_app_short_name => 'GMA'
3328 );
3329
3330 /**************************************
3331 * Migration Failure Log Message *
3332 **************************************/
3333
3334 GMA_COMMON_LOGGING.gma_migration_central_log
3335 (
3336 p_run_id => G_migration_run_id,
3337 p_log_level => FND_LOG.LEVEL_ERROR,
3338 p_message_token => 'GMA_TABLE_MIGRATION_TABLE_FAIL',
3339 p_table_name => G_Table_name,
3340 p_context => G_context,
3341 p_db_error => NULL,
3342 p_app_short_name => 'GMA'
3343 );
3344 END;
3345
3346 /**********************************************************************
3347 * Insert a row in gmf_calendar_assignments for CM_ADJS_DTL table data *
3348 **********************************************************************/
3349 BEGIN
3350
3351 INSERT INTO gmf_calendar_assignments
3352 (
3353 ASSIGNMENT_ID,
3354 CALENDAR_CODE,
3355 LEGAL_ENTITY_ID,
3356 COST_TYPE_ID,
3357 CREATION_DATE,
3358 CREATED_BY,
3359 LAST_UPDATE_DATE,
3360 LAST_UPDATED_BY,
3361 LAST_UPDATE_LOGIN,
3362 TEXT_CODE,
3363 DELETE_MARK
3364 )
3365 (
3366 SELECT gmf_calendar_assignments_s.NEXTVAL,
3367 x.*
3368 FROM (
3369 SELECT DISTINCT
3370 g.calendar_code,
3371 i.legal_entity_id,
3372 h.cost_type_id,
3373 g.creation_date,
3374 g.created_by,
3375 g.last_update_date,
3376 g.last_updated_by,
3377 g.last_update_login,
3378 g.text_code,
3379 1
3380 FROM cm_cldr_hdr_b g,
3381 cm_mthd_mst h,
3382 gl_plcy_mst i,
3383 sy_orgn_mst j,
3384 cm_adjs_dtl k,
3385 ic_whse_mst l
3386 WHERE g.co_code IS NOT NULL
3387 AND l.whse_code = k.whse_code
3388 AND j.orgn_code = l.orgn_code
3389 AND i.co_code = j.co_code
3390 AND i.legal_entity_id IS NOT NULL
3391 AND j.co_code <> g.co_code
3392 AND h.cost_mthd_code = k.cost_mthd_code
3393 AND g.calendar_code = k.calendar_code
3394 AND NOT EXISTS (
3395 SELECT 'X'
3396 FROM gmf_calendar_assignments x
3397 WHERE x.calendar_code = g.calendar_code
3398 AND x.cost_type_id = h.cost_Type_id
3399 AND x.legal_entity_id = i.legal_Entity_id
3400 )
3401 ) x
3402 );
3403
3404 EXCEPTION
3405 WHEN OTHERS THEN
3406
3407 /************************************************
3408 * Increment Failure Count for Failed Migrations *
3409 ************************************************/
3410
3411 x_failure_count := x_failure_count + 1;
3412
3413 /**************************************
3414 * Migration DB Error Log Message *
3415 **************************************/
3416
3417 GMA_COMMON_LOGGING.gma_migration_central_log
3418 (
3419 p_run_id => G_migration_run_id,
3420 p_log_level => FND_LOG.LEVEL_ERROR,
3421 p_message_token => 'GMA_MIGRATION_DB_ERROR',
3422 p_table_name => G_Table_name,
3423 p_context => G_context,
3424 p_db_error => SQLERRM,
3425 p_app_short_name => 'GMA'
3426 );
3427
3428 /**************************************
3429 * Migration Failure Log Message *
3430 **************************************/
3431
3432 GMA_COMMON_LOGGING.gma_migration_central_log
3433 (
3434 p_run_id => G_migration_run_id,
3435 p_log_level => FND_LOG.LEVEL_ERROR,
3436 p_message_token => 'GMA_TABLE_MIGRATION_TABLE_FAIL',
3437 p_table_name => G_Table_name,
3438 p_context => G_context,
3439 p_db_error => NULL,
3440 p_app_short_name => 'GMA'
3441 );
3442 END;
3443
3444 FOR i IN cur_overlap_calendar loop
3445 UPDATE GMF_CALENDAR_ASSIGNMENTS g
3446 SET g.delete_mark = 1
3447 WHERE g.delete_mark <> 1
3448 AND EXISTS (
3449 SELECT 'X'
3450 FROM gmf_calendar_assignments a,
3451 cm_cldr_dtl b
3452 WHERE a.calendar_code = b.calendar_code
3453 AND a.calendar_code = g.calendar_code
3454 AND a.legal_entity_id = g.legal_entity_id
3455 AND a.cost_Type_id = g.cost_type_id
3456 AND EXISTS (
3457 SELECT 'X' FROM (
3458 SELECT m.legal_entity_id,
3459 m.cost_type_id,
3460 m.calendar_code,
3461 min(n.start_date) mindate,
3462 max(n.end_date) maxdate
3463 FROM gmf_calendar_assignments m,
3464 cm_cldr_dtl n
3465 WHERE m.calendar_code = n.calendar_code
3466 AND m.calendar_code = i.calendar_code
3467 AND m.legal_entity_id = i.legal_entity_id
3468 AND m.cost_type_id = i.cost_type_id
3469 AND m.delete_mark <> 1
3470 GROUP by m.legal_entity_id,
3471 m.calendar_code,
3472 m.cost_type_id
3473 ) x
3474 WHERE x.legal_entity_id = a.legal_entity_id
3475 AND x.cost_type_id = a.cost_Type_id
3476 AND x.calendar_code <> a.calendar_Code
3477 AND (
3478 b.start_date BETWEEN x.mindate AND x.maxdate
3479 OR
3480 b.end_date BETWEEN x.mindate AND x.maxdate
3481 )
3482 )
3483 );
3484 END LOOP;
3485
3486 /**************************************
3487 * Migration Success Log Message *
3488 **************************************/
3489
3490 GMA_COMMON_LOGGING.gma_migration_central_log
3491 (
3492 p_run_id => G_migration_run_id,
3493 p_log_level => FND_LOG.LEVEL_STATEMENT,
3494 p_message_token => 'GMA_MIGRATION_TABLE_SUCCESS',
3495 p_table_name => G_Table_name,
3496 p_context => G_context,
3497 p_param1 => 1,
3498 p_param2 => 0,
3499 p_db_error => NULL,
3500 p_app_short_name => 'GMA'
3501 );
3502
3503 G_Migration_run_id := P_migration_run_id;
3504 G_Table_name := 'GMF_PERIOD_STATUSES';
3505 G_Context := 'Cost Calendar Period Statuses Migration';
3506
3507 /********************************
3508 * Migration Started Log Message *
3509 ********************************/
3510
3511 GMA_COMMON_LOGGING.gma_migration_central_log
3512 (
3513 p_run_id => G_migration_run_id,
3514 p_log_level => FND_LOG.LEVEL_STATEMENT,
3515 p_message_token => 'GMA_MIGRATION_TABLE_STARTED',
3516 p_table_name => G_Table_name,
3517 p_context => G_context,
3518 p_db_error => NULL,
3519 p_app_short_name => 'GMA'
3520 );
3521
3522 /*****************************************
3523 * Insert a row into gmf_period_statuses *
3524 *****************************************/
3525
3526 BEGIN
3527
3528 INSERT INTO gmf_period_statuses
3529 (
3530 PERIOD_ID,
3531 LEGAL_ENTITY_ID,
3532 COST_TYPE_ID,
3533 CALENDAR_CODE,
3534 PERIOD_CODE,
3535 START_DATE,
3536 END_DATE,
3537 PERIOD_STATUS,
3538 CREATION_DATE,
3539 CREATED_BY,
3540 LAST_UPDATE_DATE,
3541 LAST_UPDATED_BY,
3542 LAST_UPDATE_LOGIN,
3543 TEXT_CODE,
3544 DELETE_MARK
3545 )
3546 SELECT gmf_period_id_s.NEXTVAL,
3547 a.legal_entity_id,
3548 a.cost_type_id,
3549 a.calendar_code,
3550 b.period_code,
3551 b.start_date, /* Bug#5716122 ANTHIYAG 16-Dec-2006 */
3552 b.end_date, /* Bug#5716122 ANTHIYAG 16-Dec-2006 */
3553 decode(b.period_status, 0, 'O', 1, 'F', 2, 'C', 'O') period_status,
3554 b.creation_date,
3555 b.created_by,
3556 b.last_update_date,
3557 b.last_updated_by,
3558 b.last_update_login,
3559 b.text_code,
3560 decode(a.delete_mark + b.delete_mark, 0, 0, 1)
3561 FROM gmf_calendar_assignments a,
3562 cm_cldr_dtl b,
3563 cm_cldr_hdr_b h
3564 WHERE a.calendar_code = b.calendar_code
3565 AND b.calendar_code = h.calendar_code
3566 AND h.co_code IS NOT NULL
3567 AND h.cost_mthd_code IS NOT NULL
3568 AND NOT EXISTS (
3569 SELECT 'X'
3570 FROM gmf_period_statuses p
3571 WHERE p.legal_entity_id = a.legal_entity_id
3572 AND p.cost_type_id = a.cost_type_id
3573 AND p.calendar_code = b.calendar_code
3574 AND p.period_code = b.period_code
3575 );
3576
3577 UPDATE gmf_period_statuses a
3578 SET a.delete_mark = 1
3579 WHERE EXISTS (
3580 SELECT 'X'
3581 FROM gmf_calendar_assignments x
3582 WHERE x.legal_entity_id = a.legal_entity_id
3583 AND x.calendar_code = a.calendar_code
3584 AND x.cost_type_id = a.cost_type_id
3585 AND x.delete_mark = 1
3586 );
3587
3588 EXCEPTION
3589 WHEN OTHERS THEN
3590
3591 /************************************************
3592 * Increment Failure Count for Failed Migrations *
3593 ************************************************/
3594
3595 x_failure_count := x_failure_count + 1;
3596
3597 /**************************************
3598 * Migration DB Error Log Message *
3599 **************************************/
3600
3601 GMA_COMMON_LOGGING.gma_migration_central_log
3602 (
3603 p_run_id => G_migration_run_id,
3604 p_log_level => FND_LOG.LEVEL_ERROR,
3605 p_message_token => 'GMA_MIGRATION_DB_ERROR',
3606 p_table_name => G_Table_name,
3607 p_context => G_context,
3608 p_db_error => SQLERRM,
3609 p_app_short_name => 'GMA'
3610 );
3611
3612 /**************************************
3613 * Migration Failure Log Message *
3614 **************************************/
3615
3616 GMA_COMMON_LOGGING.gma_migration_central_log
3617 (
3618 p_run_id => G_migration_run_id,
3619 p_log_level => FND_LOG.LEVEL_ERROR,
3620 p_message_token => 'GMA_TABLE_MIGRATION_TABLE_FAIL',
3621 p_table_name => G_Table_name,
3622 p_context => G_context,
3623 p_db_error => NULL,
3624 p_app_short_name => 'GMA'
3625 );
3626
3627 END;
3628
3629 /**************************************
3630 * Migration Success Log Message *
3631 **************************************/
3632
3633 GMA_COMMON_LOGGING.gma_migration_central_log
3634 (
3635 p_run_id => G_migration_run_id,
3636 p_log_level => FND_LOG.LEVEL_STATEMENT,
3637 p_message_token => 'GMA_MIGRATION_TABLE_SUCCESS',
3638 p_table_name => G_Table_name,
3639 p_context => G_context,
3640 p_param1 => 1,
3641 p_param2 => 0,
3642 p_db_error => NULL,
3643 p_app_short_name => 'GMA'
3644 );
3645
3646 /****************************************************************
3647 * Lets save the changes now based on the commit parameter *
3648 ****************************************************************/
3649
3650 IF NVL(p_commit,'~') = FND_API.G_TRUE THEN
3651 COMMIT;
3652 END IF;
3653
3654 EXCEPTION
3655 WHEN OTHERS THEN
3656
3657 /************************************************
3658 * Increment Failure Count for Failed Migrations *
3659 ************************************************/
3660
3661 x_failure_count := x_failure_count + 1;
3662
3663 /**************************************
3664 * Migration DB Error Log Message *
3665 **************************************/
3666
3667 GMA_COMMON_LOGGING.gma_migration_central_log
3668 (
3669 p_run_id => G_migration_run_id,
3670 p_log_level => FND_LOG.LEVEL_ERROR,
3671 p_message_token => 'GMA_MIGRATION_DB_ERROR',
3672 p_table_name => G_Table_name,
3673 p_context => G_context,
3674 p_db_error => SQLERRM,
3675 p_app_short_name => 'GMA'
3676 );
3677
3678 /**************************************
3679 * Migration Failure Log Message *
3680 **************************************/
3681
3682 GMA_COMMON_LOGGING.gma_migration_central_log
3683 (
3684 p_run_id => G_migration_run_id,
3685 p_log_level => FND_LOG.LEVEL_ERROR,
3686 p_message_token => 'GMA_TABLE_MIGRATION_TABLE_FAIL',
3687 p_table_name => G_Table_name,
3688 p_context => G_context,
3689 p_db_error => NULL,
3690 p_app_short_name => 'GMA'
3691 );
3692
3693 END Migrate_Cost_Calendars;
3694
3695 /**********************************************************************
3696 * PROCEDURE: *
3697 * Migrate_Burden_Percentages *
3698 * *
3699 * DESCRIPTION: *
3700 * This PL/SQL procedure is used to migrate the Burden Percentages *
3701 * *
3702 * PARAMETERS: *
3703 * P_migration_run_id - id to use to right to migration log *
3704 * x_exception_count - Number of exceptions occurred. *
3705 * *
3706 * SYNOPSIS: *
3707 * Migrate_Burden_Percentages(p_migartion_id => l_migration_id, *
3708 * p_commit => 'T', *
3709 * x_exception_count => l_exception_count ); *
3710 * *
3711 * HISTORY *
3712 * 27-Apr-2005 Created Anand Thiyagarajan *
3713 * 05-Jul-2006 rseshadr bug 5374823 - call item mig inline for *
3714 * the current table *
3715 * 04-May-2010 Pramod B.H. Bug 9674561 *
3716 * Modified procedure to Update organization_id seperately for *
3717 * the Burden percentage records. *
3718 * *
3719 **********************************************************************/
3720 PROCEDURE Migrate_Burden_Percentages
3721 (
3722 P_migration_run_id IN NUMBER,
3723 P_commit IN VARCHAR2,
3724 X_failure_count OUT NOCOPY NUMBER
3725 )
3726 IS
3727
3728 /****************
3729 * PL/SQL Tables *
3730 ****************/
3731
3732 /******************
3733 * Local Variables *
3734 ******************/
3735
3736 l_inventory_item_id NUMBER;
3737 l_itm_failure_count NUMBER;
3738 l_itm_failure_count_all NUMBER;
3739
3740 /****************
3741 * Cursors *
3742 ****************/
3743
3744 CURSOR cur_get_gmf_items IS
3745 SELECT DISTINCT item_id,
3746 organization_id
3747 FROM (
3748 SELECT a.item_id,
3749 nvl(DECODE(NVL(c.subinventory_ind_flag,'N'), 'Y', c.organization_id, c.mtl_organization_id), DECODE(NVL(b.subinventory_ind_flag,'N'), 'Y', b.organization_id, b.mtl_organization_id)) organization_id
3750 FROM gmf_burden_percentages a,
3751 ic_whse_mst b,
3752 ic_whse_mst c
3753 WHERE a.item_id IS NOT NULL
3754 AND b.orgn_code = a.orgn_code
3755 AND c.whse_code(+) = a.whse_code
3756 );
3757
3758 BEGIN
3759
3760 G_Migration_run_id := P_migration_run_id;
3761 G_Table_name := 'GMF_BURDEN_PERCENTAGES';
3762 G_Context := 'Burden Percentages Migration';
3763 X_failure_count := 0;
3764
3765 /********************************
3766 * Migration Started Log Message *
3767 ********************************/
3768
3769 GMA_COMMON_LOGGING.gma_migration_central_log
3770 (
3771 p_run_id => G_migration_run_id,
3772 p_log_level => FND_LOG.LEVEL_STATEMENT,
3773 p_message_token => 'GMA_MIGRATION_TABLE_STARTED',
3774 p_table_name => G_Table_name,
3775 p_context => G_context,
3776 p_db_error => NULL,
3777 p_app_short_name => 'GMA'
3778 );
3779
3780 /********************************************
3781 * rseshadr bug 5374823 *
3782 * Call Item Migration API in a loop *
3783 * To Migrate necessary items for this table *
3784 *********************************************/
3785
3786 FOR i IN cur_get_gmf_items
3787 LOOP
3788 IF i.item_id IS NOT NULL AND i.organization_id IS NOT NULL THEN
3789 inv_opm_item_migration.get_odm_item
3790 (
3791 p_migration_run_id => p_migration_run_id,
3792 p_item_id => i.item_id,
3793 p_organization_id => i.organization_id,
3794 p_mode => NULL,
3795 p_commit => FND_API.G_TRUE,
3796 x_inventory_item_id => l_inventory_item_id,
3797 x_failure_count => l_itm_failure_count
3798 );
3799 END IF;
3800 l_itm_failure_count_all := nvl(l_itm_failure_count_all,0) + nvl(l_itm_failure_count,0);
3801 END LOOP;
3802
3803 /********************************************************
3804 * Update a row in GMF_BURDEN_PERCENTAGES *
3805 ********************************************************/
3806
3807 BEGIN
3808
3809 INSERT
3810 INTO gmf_burden_percentages
3811 (
3812 burden_percentage_id,
3813 calendar_code,
3814 period_code,
3815 cost_mthd_code,
3816 burden_id,
3817 orgn_code,
3818 whse_code,
3819 item_id,
3820 percentage,
3821 created_by,
3822 creation_date,
3823 last_updated_by,
3824 last_update_date,
3825 last_update_login,
3826 delete_mark,
3827 gl_business_category_id,
3828 gl_category_id,
3829 cost_category_id,
3830 gl_prod_line_category_id
3831 )
3832 (
3833 SELECT gmf_burden_percentage_id_s.NEXTVAL,
3834 a.calendar_code,
3835 a.period_code,
3836 a.cost_mthd_code,
3837 a.burden_id,
3838 a.orgn_code,
3839 e.whse_code,
3840 a.item_id,
3841 a.percentage,
3842 a.created_by,
3843 sysdate,
3844 a.last_updated_by,
3845 sysdate,
3846 a.last_update_login,
3847 a.delete_mark,
3848 a.gl_business_category_id,
3849 a.gl_category_id,
3850 a.cost_category_id,
3851 a.gl_prod_line_category_id
3852 FROM gmf_burden_percentages a,
3853 ic_whse_mst e
3854 WHERE a.orgn_code IS NOT NULL
3855 AND a.whse_code IS NULL
3856 AND a.orgn_code = e.orgn_code
3857 AND e.mtl_organization_id IS NOT NULL
3858 AND nvl(e.subinventory_ind_flag,'N') <> 'Y'
3859 AND NOT EXISTS (
3860 SELECT 'X'
3861 FROM gmf_burden_percentages x
3862 WHERE x.calendar_code = a.calendar_code
3863 AND x.period_code = a.period_code
3864 AND x.cost_mthd_code = a.cost_mthd_code
3865 AND x.burden_id = a.burden_id
3866 AND x.orgn_code = a.orgn_code
3867 AND x.whse_code = e.whse_code
3868 AND nvl(x.item_id, -1) = nvl(a.item_id, -1)
3869 AND nvl(x.gl_category_id, -1) = nvl(a.gl_category_id, -1)
3870 AND nvl(x.cost_category_id, -1) = nvl(a.cost_category_id, -1)
3871 AND nvl(x.gl_business_category_id, -1) = nvl(a.gl_business_category_id, -1)
3872 AND nvl(x.gl_prod_line_category_id, -1) = nvl(a.gl_prod_line_category_id, -1)
3873 )
3874 );
3875
3876 UPDATE gmf_burden_percentages a
3877 SET (
3878 a.cost_type_id,
3879 a.period_id,
3880 a.legal_entity_id
3881 )
3882 = (
3883 SELECT x.cost_type_id,
3884 x.period_id,
3885 x.legal_entity_id
3886 FROM gmf_period_statuses x,
3887 cm_mthd_mst y,
3888 cm_cldr_hdr_b z,
3889 gl_plcy_mst w
3890 WHERE y.cost_mthd_code = a.cost_mthd_code
3891 AND x.cost_type_id = y.cost_type_id
3892 AND x.calendar_code = a.calendar_code
3893 AND x.period_code = a.period_code
3894 AND z.calendar_code = x.calendar_code
3895 AND z.co_code = w.co_code
3896 AND x.legal_entity_id= w.legal_entity_id
3897 )
3898 /* Bug 9674561 - Commented (will achieve this as a seperate update)
3899 ,
3900 (
3901 a.organization_id,
3902 a.delete_mark
3903 )
3904 = (
3905 SELECT DECODE(a.whse_code, null, DECODE(NVL(Y.INVENTORY_ORG_IND,'N'), 'Y', y.organization_id, NULL), DECODE(NVL(x.subinventory_ind_flag,'N'), 'Y', x.organization_id, x.mtl_organization_id)),
3906 DECODE(a.delete_mark, 1, a.delete_mark, DECODE(a.whse_code, null, DECODE(NVL(Y.INVENTORY_ORG_IND,'N'), 'Y', 0, 1), DECODE(NVL(x.subinventory_ind_flag,'N'), 'Y', 1, 0)))
3907 FROM ic_whse_mst x, sy_orgn_mst y
3908 WHERE x.whse_code = nvl(a.whse_code, x.whse_code)
3909 and y.orgn_code = DECODE(a.whse_code, NULL, a.orgn_code, x.orgn_code)
3910 AND ROWNUM = 1
3911 )*/
3912 WHERE (
3913 (a.cost_type_id IS NULL AND a.cost_mthd_code IS NOT NULL)
3914 OR (a.calendar_code IS NOT NULL AND a.period_code IS NOT NULL AND a.period_id IS NULL)
3915 OR (a.calendar_code IS NOT NULL AND a.legal_entity_id IS NULL)
3916 OR (a.organization_id IS NULL AND (a.whse_code IS NOT NULL OR a.orgn_code IS NOT NULL))
3917 );
3918
3919 /* Bug 9674561 - Updating organization_id for the Burden percentage records (START) */
3920 UPDATE gmf_burden_percentages a
3921 SET (
3922 a.organization_id,
3923 a.delete_mark
3924 )
3925 = (
3926 SELECT DECODE(a.whse_code, null, DECODE(NVL(Y.INVENTORY_ORG_IND,'N'), 'Y', y.organization_id, NULL), DECODE(NVL(x.subinventory_ind_flag,'N'), 'Y', x.organization_id, x.mtl_organization_id)),
3927 DECODE(a.delete_mark, 1, a.delete_mark, DECODE(a.whse_code, null, DECODE(NVL(Y.INVENTORY_ORG_IND,'N'), 'Y', 0, 1), DECODE(NVL(x.subinventory_ind_flag,'N'), 'Y', 1, 0)))
3928 FROM ic_whse_mst x, sy_orgn_mst y
3929 WHERE x.whse_code = nvl(a.whse_code, x.whse_code)
3930 and y.orgn_code = DECODE(a.whse_code, NULL, a.orgn_code, x.orgn_code)
3931 AND ROWNUM = 1
3932 )
3933 WHERE (a.organization_id IS NULL AND (a.whse_code IS NOT NULL OR a.orgn_code IS NOT NULL));
3934
3935 /* Bug 9674561 - Updating organization_id for the Burden percentage records (END) */
3936
3937 EXCEPTION
3938 WHEN OTHERS THEN
3939
3940 /************************************************
3941 * Increment Failure Count for Failed Migrations *
3942 ************************************************/
3943
3944 x_failure_count := x_failure_count + 1;
3945
3946 /**************************************
3947 * Migration DB Error Log Message *
3948 **************************************/
3949
3950 GMA_COMMON_LOGGING.gma_migration_central_log
3951 (
3952 p_run_id => G_migration_run_id,
3953 p_log_level => FND_LOG.LEVEL_ERROR,
3954 p_message_token => 'GMA_MIGRATION_DB_ERROR',
3955 p_table_name => G_Table_name,
3956 p_context => G_context,
3957 p_db_error => SQLERRM,
3958 p_app_short_name => 'GMA'
3959 );
3960
3961 /**************************************
3962 * Migration Failure Log Message *
3963 **************************************/
3964
3965 GMA_COMMON_LOGGING.gma_migration_central_log
3966 (
3967 p_run_id => G_migration_run_id,
3968 p_log_level => FND_LOG.LEVEL_ERROR,
3969 p_message_token => 'GMA_TABLE_MIGRATION_TABLE_FAIL',
3970 p_table_name => G_Table_name,
3971 p_context => G_context,
3972 p_db_error => NULL,
3973 p_app_short_name => 'GMA'
3974 );
3975
3976 END;
3977
3978 BEGIN
3979 UPDATE gmf_burden_percentages a
3980 SET (
3981 a.master_organization_id,
3982 a.inventory_item_id
3983 )
3984 = (
3985 SELECT z.master_organization_id,
3986 y.inventory_item_id
3987 FROM ic_item_mst_b_mig y,
3988 mtl_parameters z,
3989 hr_organization_information hoi
3990 WHERE y.item_id = a.item_id
3991 AND y.organization_id = z.organization_id
3992 AND hoi.organization_id = z.organization_id
3993 AND hoi.org_information_context = 'Accounting Information'
3994 AND hoi.org_information2 = a.legal_entity_id
3995 AND ROWNUM = 1
3996 )
3997 WHERE (a.inventory_item_id IS NULL AND a.item_id IS NOT NULL)
3998 OR (a.master_organization_id IS NULL AND a.item_id IS NOT NULL);
3999
4000 UPDATE gmf_burden_percentages a
4001 SET a.delete_mark = 1
4002 WHERE ROWID NOT IN (
4003 SELECT MIN(x.ROWID)
4004 FROM gmf_burden_percentages x
4005 WHERE x.legal_entity_id = a.legal_entity_id
4006 AND x.period_id = a.period_id
4007 AND x.cost_type_id = a.cost_type_id
4008 AND x.burden_id = a.burden_id
4009 AND nvl(x.inventory_item_id, -1) = nvl(a.inventory_item_id, -1)
4010 AND nvl(x.organization_id, -1) = nvl(a.organization_id, -1)
4011 AND nvl(x.gl_category_id, -1) = nvl(a.gl_category_id, -1)
4012 AND nvl(x.cost_category_id, -1) = nvl(a.cost_category_id, -1)
4013 AND nvl(x.gl_business_category_id, -1) = nvl(a.gl_business_category_id, -1)
4014 AND nvl(x.gl_prod_line_category_id, -1) = nvl(a.gl_prod_line_category_id, -1)
4015 AND x.delete_mark <> 1
4016 );
4017
4018 EXCEPTION
4019 WHEN OTHERS THEN
4020
4021 /************************************************
4022 * Increment Failure Count for Failed Migrations *
4023 ************************************************/
4024
4025 x_failure_count := x_failure_count + 1;
4026
4027 /**************************************
4028 * Migration DB Error Log Message *
4029 **************************************/
4030
4031 GMA_COMMON_LOGGING.gma_migration_central_log
4032 (
4033 p_run_id => G_migration_run_id,
4034 p_log_level => FND_LOG.LEVEL_ERROR,
4035 p_message_token => 'GMA_MIGRATION_DB_ERROR',
4036 p_table_name => G_Table_name,
4037 p_context => G_context,
4038 p_db_error => SQLERRM,
4039 p_app_short_name => 'GMA'
4040 );
4041
4042 /**************************************
4043 * Migration Failure Log Message *
4044 **************************************/
4045
4046 GMA_COMMON_LOGGING.gma_migration_central_log
4047 (
4048 p_run_id => G_migration_run_id,
4049 p_log_level => FND_LOG.LEVEL_ERROR,
4050 p_message_token => 'GMA_TABLE_MIGRATION_TABLE_FAIL',
4051 p_table_name => G_Table_name,
4052 p_context => G_context,
4053 p_db_error => NULL,
4054 p_app_short_name => 'GMA'
4055 );
4056
4057 END;
4058
4059 /**********************************************
4060 * Handle all the rows which were not migrated *
4061 **********************************************/
4062
4063 SELECT count(*)
4064 INTO x_failure_count
4065 FROM gmf_burden_percentages
4066 WHERE (
4067 (cost_type_id IS NULL AND cost_mthd_code IS NOT NULL)
4068 OR (calendar_code IS NOT NULL AND period_code IS NOT NULL AND period_id IS NULL)
4069 OR (calendar_code IS NOT NULL AND legal_entity_id IS NULL)
4070 OR (organization_id IS NULL AND delete_mark = 0 AND (whse_code IS NOT NULL OR orgn_code IS NOT NULL))
4071 OR (inventory_item_id IS NULL AND item_id IS NOT NULL)
4072 OR (master_organization_id IS NULL AND item_id IS NOT NULL)
4073 );
4074
4075 IF nvl(x_failure_count,0) > 0 THEN
4076
4077 /**************************************
4078 * Migration Failure Log Message *
4079 **************************************/
4080
4081 GMA_COMMON_LOGGING.gma_migration_central_log
4082 (
4083 p_run_id => gmf_migration.G_migration_run_id,
4084 p_log_level => FND_LOG.LEVEL_PROCEDURE,
4085 p_message_token => 'GMA_TABLE_MIGRATION_TABLE_FAIL',
4086 p_table_name => gmf_migration.G_Table_name,
4087 p_context => gmf_migration.G_context,
4088 p_db_error => NULL,
4089 p_app_short_name => 'GMA'
4090 );
4091
4092 ELSE
4093
4094 /**************************************
4095 * Migration Success Log Message *
4096 **************************************/
4097
4098 GMA_COMMON_LOGGING.gma_migration_central_log
4099 (
4100 p_run_id => G_migration_run_id,
4101 p_log_level => FND_LOG.LEVEL_STATEMENT,
4102 p_message_token => 'GMA_MIGRATION_TABLE_SUCCESS',
4103 p_table_name => G_Table_name,
4104 p_context => G_Context,
4105 p_param1 => 1,
4106 p_param2 => 0,
4107 p_db_error => NULL,
4108 p_app_short_name => 'GMA'
4109 );
4110
4111 END IF;
4112
4113 /****************************************************************
4114 * Lets save the changes now based on the commit parameter *
4115 ****************************************************************/
4116
4117 IF NVL(p_commit,'~') = FND_API.G_TRUE THEN
4118 COMMIT;
4119 END IF;
4120
4121 EXCEPTION
4122 WHEN OTHERS THEN
4123
4124 /************************************************
4125 * Increment Failure Count for Failed Migrations *
4126 ************************************************/
4127
4128 x_failure_count := x_failure_count + 1;
4129
4130 /**************************************
4131 * Migration DB Error Log Message *
4132 **************************************/
4133
4134 GMA_COMMON_LOGGING.gma_migration_central_log
4135 (
4136 p_run_id => G_migration_run_id,
4137 p_log_level => FND_LOG.LEVEL_ERROR,
4138 p_message_token => 'GMA_MIGRATION_DB_ERROR',
4139 p_table_name => G_Table_name,
4140 p_context => G_context,
4141 p_db_error => SQLERRM,
4142 p_app_short_name => 'GMA'
4143 );
4144
4145 /**************************************
4146 * Migration Failure Log Message *
4147 **************************************/
4148
4149 GMA_COMMON_LOGGING.gma_migration_central_log
4150 (
4151 p_run_id => G_migration_run_id,
4152 p_log_level => FND_LOG.LEVEL_ERROR,
4153 p_message_token => 'GMA_TABLE_MIGRATION_TABLE_FAIL',
4154 p_table_name => G_Table_name,
4155 p_context => G_context,
4156 p_db_error => NULL,
4157 p_app_short_name => 'GMA'
4158 );
4159
4160 END Migrate_Burden_Percentages;
4161
4162 /**********************************************************************
4163 * PROCEDURE: *
4164 * Migrate_Lot_Costs *
4165 * *
4166 * DESCRIPTION: *
4167 * This PL/SQL procedure is used to migrate the Lot Costs *
4168 * *
4169 * PARAMETERS: *
4170 * P_migration_run_id - id to use to right to migration log *
4171 * x_exception_count - Number of exceptions occurred. *
4172 * *
4173 * SYNOPSIS: *
4174 * Migrate_Lot_Costs(p_migartion_id => l_migration_id, *
4175 * p_commit => 'T', *
4176 * x_exception_count => l_exception_count ); *
4177 * *
4178 * HISTORY *
4179 * 27-Apr-2005 Created Anand Thiyagarajan *
4180 * 31-Oct-2006 Modified Anand Thiyagarajan *
4181 * Modified Code to add insertion of Lot cost records for new *
4182 * lots created by the Lot migration process for lot id's *
4183 * *
4184 **********************************************************************/
4185 PROCEDURE Migrate_Lot_Costs
4186 (
4187 P_migration_run_id IN NUMBER,
4188 P_commit IN VARCHAR2,
4189 X_failure_count OUT NOCOPY NUMBER
4190 )
4191 IS
4192
4193 /**************************
4194 * PL/SQL Table Definition *
4195 **************************/
4196
4197 /******************
4198 * Local Variables *
4199 ******************/
4200
4201 BEGIN
4202
4203 G_Migration_run_id := P_migration_run_id;
4204 G_Table_name := 'GMF_LOT_COSTS';
4205 G_Context := 'Lot Costs Migration';
4206 X_failure_count := 0;
4207
4208 /********************************
4209 * Migration Started Log Message *
4210 ********************************/
4211
4212 GMA_COMMON_LOGGING.gma_migration_central_log
4213 (
4214 p_run_id => G_migration_run_id,
4215 p_log_level => FND_LOG.LEVEL_STATEMENT,
4216 p_message_token => 'GMA_MIGRATION_TABLE_STARTED',
4217 p_table_name => G_Table_name,
4218 p_context => G_context,
4219 p_db_error => NULL,
4220 p_app_short_name => 'GMA'
4221 );
4222
4223 BEGIN
4224
4225 /******************************
4226 * Update a row for cost Types *
4227 ******************************/
4228
4229 UPDATE gmf_lot_costs a
4230 SET a.cost_type_id
4231 = (
4232 SELECT x.cost_Type_id
4233 FROM cm_mthd_mst x
4234 WHERE x.cost_mthd_code = a.cost_mthd_code
4235 ),
4236 (
4237 a.organization_id,
4238 a.inventory_item_id
4239 )
4240 = (
4241 SELECT decode(x.cost_organization_id, -1, -1, y.organization_id),
4242 y.inventory_item_id
4243 FROM ic_whse_mst x,
4244 ic_item_mst_b_mig y
4245 WHERE x.whse_code = a.whse_code
4246 AND y.item_id = a.item_id
4247 AND y.organization_id = NVL(DECODE(x.cost_organization_id, -1, x.mtl_organization_id, x.cost_organization_id), x.mtl_organization_id)
4248 )
4249 WHERE (
4250 (a.cost_type_id IS NULL AND a.cost_mthd_code IS NOT NULL)
4251 OR (a.organization_id IS NULL AND a.whse_code IS NOT NULL)
4252 OR (a.inventory_item_id IS NULL AND a.item_id IS NOT NULL)
4253 );
4254
4255 EXCEPTION
4256 WHEN OTHERS THEN
4257
4258 /************************************************
4259 * Increment Failure Count for Failed Migrations *
4260 ************************************************/
4261
4262 x_failure_count := x_failure_count + 1;
4263
4264 /**************************************
4265 * Migration DB Error Log Message *
4266 **************************************/
4267
4268 GMA_COMMON_LOGGING.gma_migration_central_log
4269 (
4270 p_run_id => G_migration_run_id,
4271 p_log_level => FND_LOG.LEVEL_ERROR,
4272 p_message_token => 'GMA_MIGRATION_DB_ERROR',
4273 p_table_name => G_Table_name,
4274 p_context => G_context,
4275 p_db_error => SQLERRM,
4276 p_app_short_name => 'GMA'
4277 );
4278
4279 /**************************************
4280 * Migration Failure Log Message *
4281 **************************************/
4282
4283 GMA_COMMON_LOGGING.gma_migration_central_log
4284 (
4285 p_run_id => G_migration_run_id,
4286 p_log_level => FND_LOG.LEVEL_ERROR,
4287 p_message_token => 'GMA_TABLE_MIGRATION_TABLE_FAIL',
4288 p_table_name => G_Table_name,
4289 p_context => G_context,
4290 p_db_error => NULL,
4291 p_app_short_name => 'GMA'
4292 );
4293
4294 END;
4295
4296 BEGIN
4297 /****************************************************************************
4298 * Insert rows for Additional Lots Created as part of Lot Balances Migration *
4299 ****************************************************************************/
4300 INSERT INTO gmf_lot_costs
4301 (
4302 header_id,
4303 unit_cost,
4304 cost_date,
4305 onhand_qty,
4306 frozen_ind,
4307 attribute1,
4308 attribute2,
4309 attribute3,
4310 attribute4,
4311 attribute5,
4312 attribute6,
4313 attribute7,
4314 attribute8,
4315 attribute9,
4316 attribute10,
4317 attribute11,
4318 attribute12,
4319 attribute13,
4320 attribute14,
4321 attribute15,
4322 attribute16,
4323 attribute17,
4324 attribute18,
4325 attribute19,
4326 attribute20,
4327 attribute21,
4328 attribute22,
4329 attribute23,
4330 attribute24,
4331 attribute25,
4332 attribute26,
4333 attribute27,
4334 attribute28,
4335 attribute29,
4336 attribute30,
4337 attribute_category,
4338 creation_date,
4339 created_by,
4340 last_update_date,
4341 last_updated_by,
4342 last_update_login,
4343 text_code,
4344 delete_mark,
4345 final_cost_flag,
4346 cost_type_id,
4347 inventory_item_id,
4348 lot_number,
4349 organization_id
4350 )
4351 (
4352 SELECT gmf_cost_header_id_s.NEXTVAL,
4353 a.unit_cost,
4354 a.cost_date,
4355 a.onhand_qty,
4356 a.frozen_ind,
4357 a.attribute1,
4358 a.attribute2,
4359 a.attribute3,
4360 a.attribute4,
4361 a.attribute5,
4362 a.attribute6,
4363 a.attribute7,
4364 a.attribute8,
4365 a.attribute9,
4366 a.attribute10,
4367 a.attribute11,
4368 a.attribute12,
4369 a.attribute13,
4370 a.attribute14,
4371 a.attribute15,
4372 a.attribute16,
4373 a.attribute17,
4374 a.attribute18,
4375 a.attribute19,
4376 a.attribute20,
4377 a.attribute21,
4378 a.attribute22,
4379 a.attribute23,
4380 a.attribute24,
4381 a.attribute25,
4382 a.attribute26,
4383 a.attribute27,
4384 a.attribute28,
4385 a.attribute29,
4386 a.attribute30,
4387 a.attribute_category,
4388 sysdate,
4389 a.created_by,
4390 sysdate,
4391 a.last_updated_by,
4392 a.last_update_login,
4393 a.header_id,
4394 a.delete_mark,
4395 a.final_cost_flag,
4396 a.cost_type_id,
4397 a.inventory_item_id,
4398 b.lot_number,
4399 a.organization_id
4400 FROM gmf_lot_costs a,
4401 ic_lots_mst_mig b
4402 WHERE a.lot_id = b.lot_id
4403 AND nvl(b.additional_status_lot,0) = 1
4404 AND (
4405 (a.cost_type_id IS NOT NULL AND a.cost_mthd_code IS NOT NULL)
4406 OR (a.organization_id IS NOT NULL AND a.whse_code IS NOT NULL)
4407 OR (a.inventory_item_id IS NOT NULL AND a.item_id IS NOT NULL)
4408 OR (a.lot_number IS NOT NULL AND a.lot_id IS NOT NULL)
4409 )
4410 AND NOT EXISTS (
4411 SELECT 'RECORD_ALREADY_EXISTS'
4412 FROM gmf_lot_costs x
4413 WHERE x.organization_id = a.organization_id
4414 AND x.inventory_item_id = a.inventory_item_id
4415 AND x.cost_type_id = a.cost_type_id
4416 AND x.lot_number = b.lot_number
4417 AND x.cost_date = a.cost_date
4418 )
4419 );
4420 EXCEPTION
4421 WHEN OTHERS THEN
4422 /************************************************
4423 * Increment Failure Count for Failed Migrations *
4424 ************************************************/
4425 x_failure_count := x_failure_count + 1;
4426 /**************************************
4427 * Migration DB Error Log Message *
4428 **************************************/
4429 GMA_COMMON_LOGGING.gma_migration_central_log
4430 (
4431 p_run_id => G_migration_run_id,
4432 p_log_level => FND_LOG.LEVEL_ERROR,
4433 p_message_token => 'GMA_MIGRATION_DB_ERROR',
4434 p_table_name => G_Table_name,
4435 p_context => G_context,
4436 p_db_error => SQLERRM,
4437 p_app_short_name => 'GMA'
4438 );
4439 /**************************************
4440 * Migration Failure Log Message *
4441 **************************************/
4442 GMA_COMMON_LOGGING.gma_migration_central_log
4443 (
4444 p_run_id => G_migration_run_id,
4445 p_log_level => FND_LOG.LEVEL_ERROR,
4446 p_message_token => 'GMA_TABLE_MIGRATION_TABLE_FAIL',
4447 p_table_name => G_Table_name,
4448 p_context => G_context,
4449 p_db_error => NULL,
4450 p_app_short_name => 'GMA'
4451 );
4452 END;
4453
4454 BEGIN
4455 /****************************************************************************
4456 * Insert rows for Additional Lots Created as part of Lot Balances Migration *
4457 ****************************************************************************/
4458 INSERT INTO gmf_lot_cost_details
4459 (
4460 header_id,
4461 detail_id,
4462 cost_cmpntcls_id,
4463 cost_analysis_code,
4464 cost_level,
4465 component_cost,
4466 burden_ind,
4467 cost_origin,
4468 frozen_ind,
4469 attribute1,
4470 attribute2,
4471 attribute3,
4472 attribute4,
4473 attribute5,
4474 attribute6,
4475 attribute7,
4476 attribute8,
4477 attribute9,
4478 attribute10,
4479 attribute11,
4480 attribute12,
4481 attribute13,
4482 attribute14,
4483 attribute15,
4484 attribute16,
4485 attribute17,
4486 attribute18,
4487 attribute19,
4488 attribute20,
4489 attribute21,
4490 attribute22,
4491 attribute23,
4492 attribute24,
4493 attribute25,
4494 attribute26,
4495 attribute27,
4496 attribute28,
4497 attribute29,
4498 attribute30,
4499 attribute_category,
4500 creation_date,
4501 created_by,
4502 last_update_date,
4503 last_updated_by,
4504 last_update_login,
4505 text_code,
4506 delete_mark,
4507 final_cost_flag
4508 )
4509 (
4510 SELECT b.header_id,
4511 gmf_cost_detail_id_s.NEXTVAL,
4512 a.cost_cmpntcls_id,
4513 a.cost_analysis_code,
4514 a.cost_level,
4515 a.component_cost,
4516 a.burden_ind,
4517 a.cost_origin,
4518 a.frozen_ind,
4519 a.attribute1,
4520 a.attribute2,
4521 a.attribute3,
4522 a.attribute4,
4523 a.attribute5,
4524 a.attribute6,
4525 a.attribute7,
4526 a.attribute8,
4527 a.attribute9,
4528 a.attribute10,
4529 a.attribute11,
4530 a.attribute12,
4531 a.attribute13,
4532 a.attribute14,
4533 a.attribute15,
4534 a.attribute16,
4535 a.attribute17,
4536 a.attribute18,
4537 a.attribute19,
4538 a.attribute20,
4539 a.attribute21,
4540 a.attribute22,
4541 a.attribute23,
4542 a.attribute24,
4543 a.attribute25,
4544 a.attribute26,
4545 a.attribute27,
4546 a.attribute28,
4547 a.attribute29,
4548 a.attribute30,
4549 a.attribute_category,
4550 SYSDATE,
4551 a.created_by,
4552 SYSDATE,
4553 a.last_updated_by,
4554 a.last_update_login,
4555 a.detail_id,
4556 a.delete_mark,
4557 a.final_cost_flag
4558 FROM gmf_lot_cost_details a,
4559 gmf_lot_costs b
4560 WHERE a.header_id = b.text_code
4561 AND b.text_code IS NOT NULL
4562 AND (
4563 (b.cost_type_id IS NOT NULL AND b.cost_mthd_code IS NULL)
4564 OR (b.organization_id IS NOT NULL AND b.whse_code IS NULL)
4565 OR (b.inventory_item_id IS NOT NULL AND b.item_id IS NULL)
4566 OR (b.lot_number IS NOT NULL AND b.lot_id IS NULL)
4567 )
4568 AND NOT EXISTS (
4569 SELECT 'RECORD_ALREADY_EXISTS'
4570 FROM gmf_lot_cost_details x
4571 WHERE b.header_id = x.header_id
4572 )
4573 );
4574 EXCEPTION
4575 WHEN OTHERS THEN
4576 /************************************************
4577 * Increment Failure Count for Failed Migrations *
4578 ************************************************/
4579 x_failure_count := x_failure_count + 1;
4580 /**************************************
4581 * Migration DB Error Log Message *
4582 **************************************/
4583 GMA_COMMON_LOGGING.gma_migration_central_log
4584 (
4585 p_run_id => G_migration_run_id,
4586 p_log_level => FND_LOG.LEVEL_ERROR,
4587 p_message_token => 'GMA_MIGRATION_DB_ERROR',
4588 p_table_name => G_Table_name,
4589 p_context => G_context,
4590 p_db_error => SQLERRM,
4591 p_app_short_name => 'GMA'
4592 );
4593 /**************************************
4594 * Migration Failure Log Message *
4595 **************************************/
4596 GMA_COMMON_LOGGING.gma_migration_central_log
4597 (
4598 p_run_id => G_migration_run_id,
4599 p_log_level => FND_LOG.LEVEL_ERROR,
4600 p_message_token => 'GMA_TABLE_MIGRATION_TABLE_FAIL',
4601 p_table_name => G_Table_name,
4602 p_context => G_context,
4603 p_db_error => NULL,
4604 p_app_short_name => 'GMA'
4605 );
4606 END;
4607
4608 /**********************************************
4609 * Handle all the rows which were not migrated *
4610 **********************************************/
4611 gmf_migration.Log_Errors (
4612 p_log_level => 1,
4613 p_from_rowid => NULL,
4614 p_to_rowid => NULL
4615 );
4616
4617 /****************************************************************
4618 * Lets save the changes now based on the commit parameter *
4619 ****************************************************************/
4620
4621 IF NVL(p_commit,'~') = FND_API.G_TRUE THEN
4622 COMMIT;
4623 END IF;
4624
4625 EXCEPTION
4626 WHEN OTHERS THEN
4627
4628 /************************************************
4629 * Increment Failure Count for Failed Migrations *
4630 ************************************************/
4631
4632 x_failure_count := x_failure_count + 1;
4633
4634 /**************************************
4635 * Migration DB Error Log Message *
4636 **************************************/
4637
4638 GMA_COMMON_LOGGING.gma_migration_central_log
4639 (
4640 p_run_id => G_migration_run_id,
4641 p_log_level => FND_LOG.LEVEL_ERROR,
4642 p_message_token => 'GMA_MIGRATION_DB_ERROR',
4643 p_table_name => G_Table_name,
4644 p_context => G_context,
4645 p_db_error => SQLERRM,
4646 p_app_short_name => 'GMA'
4647 );
4648
4649 /**************************************
4650 * Migration Failure Log Message *
4651 **************************************/
4652
4653 GMA_COMMON_LOGGING.gma_migration_central_log
4654 (
4655 p_run_id => G_migration_run_id,
4656 p_log_level => FND_LOG.LEVEL_ERROR,
4657 p_message_token => 'GMA_TABLE_MIGRATION_TABLE_FAIL',
4658 p_table_name => G_Table_name,
4659 p_context => G_context,
4660 p_db_error => NULL,
4661 p_app_short_name => 'GMA'
4662 );
4663
4664 END Migrate_Lot_Costs;
4665
4666 /**********************************************************************
4667 * PROCEDURE: *
4668 * Migrate_Lot_Costed_Items *
4669 * *
4670 * DESCRIPTION: *
4671 * This PL/SQL procedure is used to migrate the Lot Costed Items *
4672 * *
4673 * PARAMETERS: *
4674 * P_migration_run_id - id to use to right to migration log *
4675 * x_exception_count - Number of exceptions occurred. *
4676 * *
4677 * SYNOPSIS: *
4678 * Migrate_Lot_Costed_Items(p_migartion_id => l_migration_id, *
4679 * p_commit => 'T', *
4680 * x_exception_count => l_exception_count ); *
4681 * *
4682 * HISTORY *
4683 * 27-Apr-2005 Created Anand Thiyagarajan *
4684 * *
4685 **********************************************************************/
4686 PROCEDURE Migrate_Lot_Costed_Items
4687 (
4688 P_migration_run_id IN NUMBER,
4689 P_commit IN VARCHAR2,
4690 X_failure_count OUT NOCOPY NUMBER
4691 )
4692 IS
4693
4694 /**************************
4695 * PL/SQL Table Definition *
4696 **************************/
4697
4698 /******************
4699 * Local Variables *
4700 ******************/
4701
4702 BEGIN
4703
4704 G_Migration_run_id := P_migration_run_id;
4705 G_Table_name := 'GMF_LOT_COSTED_ITEMS';
4706 G_Context := 'Lot Costed Items Migration';
4707 X_failure_count := 0;
4708
4709 /********************************
4710 * Migration Started Log Message *
4711 ********************************/
4712
4713 GMA_COMMON_LOGGING.gma_migration_central_log
4714 (
4715 p_run_id => G_migration_run_id,
4716 p_log_level => FND_LOG.LEVEL_STATEMENT,
4717 p_message_token => 'GMA_MIGRATION_TABLE_STARTED',
4718 p_table_name => G_Table_name,
4719 p_context => G_context,
4720 p_db_error => NULL,
4721 p_app_short_name => 'GMA'
4722 );
4723
4724 BEGIN
4725
4726 /***************************************************************
4727 * Update a row for cost Types, LE, Organization Id and Item Id *
4728 ***************************************************************/
4729
4730 UPDATE gmf_lot_costed_items a
4731 SET a.cost_type_id
4732 = (
4733 SELECT x.cost_Type_id
4734 FROM cm_mthd_mst x
4735 WHERE x.cost_mthd_code = a.cost_mthd_code
4736 ),
4737 a.legal_entity_id
4738 = (
4739 SELECT x.legal_entity_id
4740 FROM gl_plcy_mst x
4741 WHERE x.co_code = a.co_code
4742 )
4743 WHERE (a.cost_type_id IS NULL AND a.cost_mthd_code IS NOT NULL)
4744 OR (a.legal_entity_id IS NULL AND a.co_code IS NOT NULL);
4745
4746 EXCEPTION
4747 WHEN OTHERS THEN
4748
4749 /************************************************
4750 * Increment Failure Count for Failed Migrations *
4751 ************************************************/
4752
4753 x_failure_count := x_failure_count + 1;
4754
4755 /**************************************
4756 * Migration DB Error Log Message *
4757 **************************************/
4758
4759 GMA_COMMON_LOGGING.gma_migration_central_log
4760 (
4761 p_run_id => G_migration_run_id,
4762 p_log_level => FND_LOG.LEVEL_ERROR,
4763 p_message_token => 'GMA_MIGRATION_DB_ERROR',
4764 p_table_name => G_Table_name,
4765 p_context => G_context,
4766 p_db_error => SQLERRM,
4767 p_app_short_name => 'GMA'
4768 );
4769
4770 /**************************************
4771 * Migration Failure Log Message *
4772 **************************************/
4773
4774 GMA_COMMON_LOGGING.gma_migration_central_log
4775 (
4776 p_run_id => G_migration_run_id,
4777 p_log_level => FND_LOG.LEVEL_ERROR,
4778 p_message_token => 'GMA_TABLE_MIGRATION_TABLE_FAIL',
4779 p_table_name => G_Table_name,
4780 p_context => G_context,
4781 p_db_error => NULL,
4782 p_app_short_name => 'GMA'
4783 );
4784
4785 END;
4786
4787 BEGIN
4788
4789 /***************************************************************
4790 * Update a row for Master_Organization Id and Item Id *
4791 ***************************************************************/
4792
4793 UPDATE gmf_lot_costed_items a
4794 SET (
4795 a.master_organization_id,
4796 a.inventory_item_id
4797 )
4798 =
4799 (
4800 SELECT z.master_organization_id,
4801 y.inventory_item_id
4802 FROM ic_item_mst_b_mig y,
4803 mtl_parameters z,
4804 hr_organization_information hoi
4805 WHERE y.item_id = a.item_id
4806 AND y.organization_id = z.organization_id
4807 AND hoi.organization_id = z.organization_id
4808 AND hoi.org_information_context = 'Accounting Information'
4809 AND hoi.org_information2 = a.legal_entity_id
4810 AND ROWNUM = 1
4811 )
4812 WHERE (a.inventory_item_id IS NULL AND a.item_id IS NOT NULL)
4813 OR (a.master_organization_id IS NULL AND a.item_id IS NOT NULL);
4814
4815 EXCEPTION
4816 WHEN OTHERS THEN
4817
4818 /************************************************
4819 * Increment Failure Count for Failed Migrations *
4820 ************************************************/
4821
4822 x_failure_count := x_failure_count + 1;
4823
4824 /**************************************
4825 * Migration DB Error Log Message *
4826 **************************************/
4827
4828 GMA_COMMON_LOGGING.gma_migration_central_log
4829 (
4830 p_run_id => G_migration_run_id,
4831 p_log_level => FND_LOG.LEVEL_ERROR,
4832 p_message_token => 'GMA_MIGRATION_DB_ERROR',
4833 p_table_name => G_Table_name,
4834 p_context => G_context,
4835 p_db_error => SQLERRM,
4836 p_app_short_name => 'GMA'
4837 );
4838
4839 /**************************************
4840 * Migration Failure Log Message *
4841 **************************************/
4842
4843 GMA_COMMON_LOGGING.gma_migration_central_log
4844 (
4845 p_run_id => G_migration_run_id,
4846 p_log_level => FND_LOG.LEVEL_ERROR,
4847 p_message_token => 'GMA_TABLE_MIGRATION_TABLE_FAIL',
4848 p_table_name => G_Table_name,
4849 p_context => G_context,
4850 p_db_error => NULL,
4851 p_app_short_name => 'GMA'
4852 );
4853
4854 END;
4855
4856 /**********************************************
4857 * Handle all the rows which were not migrated *
4858 **********************************************/
4859 gmf_migration.Log_Errors (
4860 p_log_level => 1,
4861 p_from_rowid => NULL,
4862 p_to_rowid => NULL
4863 );
4864
4865 /****************************************************************
4866 * Lets save the changes now based on the commit parameter *
4867 ****************************************************************/
4868
4869 IF NVL(p_commit,'~') = FND_API.G_TRUE THEN
4870 COMMIT;
4871 END IF;
4872
4873 EXCEPTION
4874 WHEN OTHERS THEN
4875
4876 /************************************************
4877 * Increment Failure Count for Failed Migrations *
4878 ************************************************/
4879
4880 x_failure_count := x_failure_count + 1;
4881
4882 /**************************************
4883 * Migration DB Error Log Message *
4884 **************************************/
4885
4886 GMA_COMMON_LOGGING.gma_migration_central_log
4887 (
4888 p_run_id => G_migration_run_id,
4889 p_log_level => FND_LOG.LEVEL_ERROR,
4890 p_message_token => 'GMA_MIGRATION_DB_ERROR',
4891 p_table_name => G_Table_name,
4892 p_context => G_context,
4893 p_db_error => SQLERRM,
4894 p_app_short_name => 'GMA'
4895 );
4896
4897 /**************************************
4898 * Migration Failure Log Message *
4899 **************************************/
4900
4901 GMA_COMMON_LOGGING.gma_migration_central_log
4902 (
4903 p_run_id => G_migration_run_id,
4904 p_log_level => FND_LOG.LEVEL_ERROR,
4905 p_message_token => 'GMA_TABLE_MIGRATION_TABLE_FAIL',
4906 p_table_name => G_Table_name,
4907 p_context => G_context,
4908 p_db_error => NULL,
4909 p_app_short_name => 'GMA'
4910 );
4911
4912 END Migrate_Lot_Costed_Items;
4913
4914 /**********************************************************************
4915 * PROCEDURE: *
4916 * Migrate_Lot_Cost_Adjustments *
4917 * *
4918 * DESCRIPTION: *
4919 * This PL/SQL procedure is used to migrate the Lot Cost Adjustments *
4920 * *
4921 * PARAMETERS: *
4922 * P_migration_run_id - id to use to right to migration log *
4923 * x_exception_count - Number of exceptions occurred. *
4924 * *
4925 * SYNOPSIS: *
4926 * Migrate_Lot_Cost_adjustments(p_migartion_id => l_migration_id, *
4927 * p_commit => 'T', *
4928 * x_exception_count => l_exception_count ); *
4929 * *
4930 * HISTORY *
4931 * 27-Apr-2005 Created Anand Thiyagarajan *
4932 * *
4933 **********************************************************************/
4934 PROCEDURE Migrate_Lot_Cost_Adjustments
4935 (
4936 P_migration_run_id IN NUMBER,
4937 P_commit IN VARCHAR2,
4938 X_failure_count OUT NOCOPY NUMBER
4939 )
4940 IS
4941
4942 /**************************
4943 * PL/SQL Table Definition *
4944 **************************/
4945
4946 /******************
4947 * Local Variables *
4948 ******************/
4949
4950 BEGIN
4951
4952 G_Migration_run_id := P_migration_run_id;
4953 G_Table_name := 'GMF_LOT_COST_ADJUSTMENTS';
4954 G_Context := 'Lot Cost Adjustments Migration';
4955 X_failure_count := 0;
4956
4957 /********************************
4958 * Migration Started Log Message *
4959 ********************************/
4960
4961 GMA_COMMON_LOGGING.gma_migration_central_log
4962 (
4963 p_run_id => G_migration_run_id,
4964 p_log_level => FND_LOG.LEVEL_STATEMENT,
4965 p_message_token => 'GMA_MIGRATION_TABLE_STARTED',
4966 p_table_name => G_Table_name,
4967 p_context => G_context,
4968 p_db_error => NULL,
4969 p_app_short_name => 'GMA'
4970 );
4971
4972 BEGIN
4973
4974 /**********************************************************
4975 * Update a row in GMF_LOT_COST_ADJUSTMENTS for cost Types *
4976 **********************************************************/
4977
4978 UPDATE gmf_lot_cost_adjustments a
4979 SET a.cost_type_id
4980 = (
4981 SELECT x.cost_Type_id
4982 FROM cm_mthd_mst x
4983 WHERE x.cost_mthd_code = a.cost_mthd_code
4984 ),
4985 a.legal_entity_id
4986 = (
4987 SELECT x.legal_entity_id
4988 FROM gl_plcy_mst x
4989 WHERE x.co_code = a.co_code
4990 ),
4991 (
4992 a.organization_id,
4993 a.inventory_item_id
4994 )
4995 = (
4996 SELECT decode(x.cost_organization_id, -1, -1, y.organization_id),
4997 y.inventory_item_id
4998 FROM ic_whse_mst x,
4999 ic_item_mst_b_mig y
5000 WHERE x.whse_code = a.whse_code
5001 AND y.item_id = a.item_id
5002 AND y.organization_id = NVL(DECODE(x.cost_organization_id, -1, x.mtl_organization_id, x.cost_organization_id), x.mtl_organization_id)
5003 )
5004 WHERE (
5005 (a.cost_type_id IS NULL AND a.cost_mthd_code IS NOT NULL)
5006 OR (a.organization_id IS NULL AND a.whse_code IS NOT NULL)
5007 OR (a.inventory_item_id IS NULL AND a.item_id IS NOT NULL)
5008 OR (a.legal_entity_id IS NULL AND a.co_code IS NOT NULL)
5009 );
5010
5011 EXCEPTION
5012 WHEN OTHERS THEN
5013
5014 /************************************************
5015 * Increment Failure Count for Failed Migrations *
5016 ************************************************/
5017
5018 x_failure_count := x_failure_count + 1;
5019
5020 /**************************************
5021 * Migration DB Error Log Message *
5022 **************************************/
5023
5024 GMA_COMMON_LOGGING.gma_migration_central_log
5025 (
5026 p_run_id => G_migration_run_id,
5027 p_log_level => FND_LOG.LEVEL_ERROR,
5028 p_message_token => 'GMA_MIGRATION_DB_ERROR',
5029 p_table_name => G_Table_name,
5030 p_context => G_context,
5031 p_db_error => SQLERRM,
5032 p_app_short_name => 'GMA'
5033 );
5034
5035 /**************************************
5036 * Migration Failure Log Message *
5037 **************************************/
5038
5039 GMA_COMMON_LOGGING.gma_migration_central_log
5040 (
5041 p_run_id => G_migration_run_id,
5042 p_log_level => FND_LOG.LEVEL_ERROR,
5043 p_message_token => 'GMA_TABLE_MIGRATION_TABLE_FAIL',
5044 p_table_name => G_Table_name,
5045 p_context => G_context,
5046 p_db_error => NULL,
5047 p_app_short_name => 'GMA'
5048 );
5049
5050 END;
5051
5052 BEGIN
5053 /****************************************************************************
5054 * Insert rows for Additional Lots Created as part of Lot Balances Migration *
5055 ****************************************************************************/
5056 INSERT INTO gmf_lot_cost_adjustments
5057 (
5058 adjustment_id,
5059 adjustment_date,
5060 reason_code,
5061 applied_ind,
5062 gl_posted_ind,
5063 delete_mark,
5064 text_code,
5065 created_by,
5066 creation_date,
5067 last_updated_by,
5068 last_update_login,
5069 last_update_date,
5070 attribute1,
5071 attribute2,
5072 attribute3,
5073 attribute4,
5074 attribute5,
5075 attribute6,
5076 attribute7,
5077 attribute8,
5078 attribute9,
5079 attribute10,
5080 attribute11,
5081 attribute12,
5082 attribute13,
5083 attribute14,
5084 attribute15,
5085 attribute16,
5086 attribute17,
5087 attribute18,
5088 attribute19,
5089 attribute20,
5090 attribute21,
5091 attribute22,
5092 attribute23,
5093 attribute24,
5094 attribute25,
5095 attribute26,
5096 attribute27,
5097 attribute28,
5098 attribute29,
5099 attribute30,
5100 attribute_category,
5101 onhand_qty,
5102 cost_type_id,
5103 inventory_item_id,
5104 legal_entity_id,
5105 lot_number,
5106 organization_id
5107 )
5108 (
5109 SELECT gmf_lot_cost_adjs_id_s.NEXTVAL,
5110 a.adjustment_date,
5111 a.reason_code,
5112 a.applied_ind,
5113 a.gl_posted_ind,
5114 a.delete_mark,
5115 a.adjustment_id,
5116 a.created_by,
5117 SYSDATE,
5118 a.last_updated_by,
5119 a.last_update_login,
5120 SYSDATE,
5121 a.attribute1,
5122 a.attribute2,
5123 a.attribute3,
5124 a.attribute4,
5125 a.attribute5,
5126 a.attribute6,
5127 a.attribute7,
5128 a.attribute8,
5129 a.attribute9,
5130 a.attribute10,
5131 a.attribute11,
5132 a.attribute12,
5133 a.attribute13,
5134 a.attribute14,
5135 a.attribute15,
5136 a.attribute16,
5137 a.attribute17,
5138 a.attribute18,
5139 a.attribute19,
5140 a.attribute20,
5141 a.attribute21,
5142 a.attribute22,
5143 a.attribute23,
5144 a.attribute24,
5145 a.attribute25,
5146 a.attribute26,
5147 a.attribute27,
5148 a.attribute28,
5149 a.attribute29,
5150 a.attribute30,
5151 a.attribute_category,
5152 a.onhand_qty,
5153 a.cost_type_id,
5154 a.inventory_item_id,
5155 a.legal_entity_id,
5156 b.lot_number,
5157 a.organization_id
5158 FROM gmf_lot_cost_adjustments a,
5159 ic_lots_mst_mig b
5160 WHERE a.lot_id = b.lot_id
5161 AND nvl(b.additional_status_lot,0) = 1
5162 AND (
5163 (a.cost_type_id IS NOT NULL AND a.cost_mthd_code IS NOT NULL)
5164 OR (a.organization_id IS NOT NULL AND a.whse_code IS NOT NULL)
5165 OR (a.inventory_item_id IS NOT NULL AND a.item_id IS NOT NULL)
5166 OR (a.legal_entity_id IS NOT NULL AND a.co_code IS NOT NULL)
5167 )
5168 AND NOT EXISTS (
5169 SELECT 'RECORD_ALREADY_EXISTS'
5170 FROM gmf_lot_cost_adjustments x
5171 WHERE x.legal_entity_id = a.legal_entity_id
5172 AND x.organization_id = a.organization_id
5173 AND x.inventory_item_id = a.inventory_item_id
5174 AND x.cost_type_id = a.cost_type_id
5175 AND x.lot_number = b.lot_number
5176 AND x.adjustment_date = a.adjustment_date
5177 )
5178 );
5179 EXCEPTION
5180 WHEN OTHERS THEN
5181 /************************************************
5182 * Increment Failure Count for Failed Migrations *
5183 ************************************************/
5184 x_failure_count := x_failure_count + 1;
5185 /**************************************
5186 * Migration DB Error Log Message *
5187 **************************************/
5188 GMA_COMMON_LOGGING.gma_migration_central_log
5189 (
5190 p_run_id => G_migration_run_id,
5191 p_log_level => FND_LOG.LEVEL_ERROR,
5192 p_message_token => 'GMA_MIGRATION_DB_ERROR',
5193 p_table_name => G_Table_name,
5194 p_context => G_context,
5195 p_db_error => SQLERRM,
5196 p_app_short_name => 'GMA'
5197 );
5198 /**************************************
5199 * Migration Failure Log Message *
5200 **************************************/
5201 GMA_COMMON_LOGGING.gma_migration_central_log
5202 (
5203 p_run_id => G_migration_run_id,
5204 p_log_level => FND_LOG.LEVEL_ERROR,
5205 p_message_token => 'GMA_TABLE_MIGRATION_TABLE_FAIL',
5206 p_table_name => G_Table_name,
5207 p_context => G_context,
5208 p_db_error => NULL,
5209 p_app_short_name => 'GMA'
5210 );
5211 END;
5212
5213 BEGIN
5214 /****************************************************************************
5215 * Insert rows for Additional Lots Created as part of Lot Balances Migration *
5216 ****************************************************************************/
5217 INSERT INTO gmf_lot_cost_adjustment_dtls
5218 (
5219 adjustment_dtl_id,
5220 adjustment_id,
5221 cost_cmpntcls_id,
5222 cost_analysis_code,
5223 adjustment_cost,
5224 delete_mark,
5225 text_code,
5226 created_by,
5227 creation_date,
5228 last_updated_by,
5229 last_update_login,
5230 last_update_date
5231 )
5232 (
5233 SELECT gmf_lot_cost_adjs_dtl_id_s.NEXTVAL,
5234 b.adjustment_id,
5235 a.cost_cmpntcls_id,
5236 a.cost_analysis_code,
5237 a.adjustment_cost,
5238 a.delete_mark,
5239 a.adjustment_dtl_id,
5240 a.created_by,
5241 SYSDATE,
5242 a.last_updated_by,
5243 a.last_update_login,
5244 SYSDATE
5245 FROM gmf_lot_cost_adjustment_dtls a,
5246 gmf_lot_cost_adjustments b
5247 WHERE a.adjustment_id = b.text_code
5248 AND b.text_code IS NOT NULL
5249 AND (
5250 (b.cost_type_id IS NOT NULL AND b.cost_mthd_code IS NULL)
5251 OR (b.organization_id IS NOT NULL AND b.whse_code IS NULL)
5252 OR (b.inventory_item_id IS NOT NULL AND b.item_id IS NULL)
5253 OR (b.legal_entity_id IS NOT NULL AND b.co_code IS NULL)
5254 )
5255 AND NOT EXISTS (
5256 SELECT 'RECORD_ALREADY_EXISTS'
5257 FROM gmf_lot_cost_adjustment_dtls x
5258 WHERE b.adjustment_id = x.adjustment_id
5259 )
5260 );
5261 EXCEPTION
5262 WHEN OTHERS THEN
5263 /************************************************
5264 * Increment Failure Count for Failed Migrations *
5265 ************************************************/
5266 x_failure_count := x_failure_count + 1;
5267 /**************************************
5268 * Migration DB Error Log Message *
5269 **************************************/
5270 GMA_COMMON_LOGGING.gma_migration_central_log
5271 (
5272 p_run_id => G_migration_run_id,
5273 p_log_level => FND_LOG.LEVEL_ERROR,
5274 p_message_token => 'GMA_MIGRATION_DB_ERROR',
5275 p_table_name => G_Table_name,
5276 p_context => G_context,
5277 p_db_error => SQLERRM,
5278 p_app_short_name => 'GMA'
5279 );
5280 /**************************************
5281 * Migration Failure Log Message *
5282 **************************************/
5283 GMA_COMMON_LOGGING.gma_migration_central_log
5284 (
5285 p_run_id => G_migration_run_id,
5286 p_log_level => FND_LOG.LEVEL_ERROR,
5287 p_message_token => 'GMA_TABLE_MIGRATION_TABLE_FAIL',
5288 p_table_name => G_Table_name,
5289 p_context => G_context,
5290 p_db_error => NULL,
5291 p_app_short_name => 'GMA'
5292 );
5293 END;
5294
5295 /**********************************************
5296 * Handle all the rows which were not migrated *
5297 **********************************************/
5298 gmf_migration.Log_Errors (
5299 p_log_level => 1,
5300 p_from_rowid => NULL,
5301 p_to_rowid => NULL
5302 );
5303
5304 /****************************************************************
5305 * Lets save the changes now based on the commit parameter *
5306 ****************************************************************/
5307
5308 IF NVL(p_commit,'~') = FND_API.G_TRUE THEN
5309 COMMIT;
5310 END IF;
5311
5312 EXCEPTION
5313 WHEN OTHERS THEN
5314
5315 /************************************************
5316 * Increment Failure Count for Failed Migrations *
5317 ************************************************/
5318
5319 x_failure_count := x_failure_count + 1;
5320
5321 /**************************************
5322 * Migration DB Error Log Message *
5323 **************************************/
5324
5325 GMA_COMMON_LOGGING.gma_migration_central_log
5326 (
5327 p_run_id => G_migration_run_id,
5328 p_log_level => FND_LOG.LEVEL_ERROR,
5329 p_message_token => 'GMA_MIGRATION_DB_ERROR',
5330 p_table_name => G_Table_name,
5331 p_context => G_context,
5332 p_db_error => SQLERRM,
5333 p_app_short_name => 'GMA'
5334 );
5335
5336 /**************************************
5337 * Migration Failure Log Message *
5338 **************************************/
5339
5340 GMA_COMMON_LOGGING.gma_migration_central_log
5341 (
5342 p_run_id => G_migration_run_id,
5343 p_log_level => FND_LOG.LEVEL_ERROR,
5344 p_message_token => 'GMA_TABLE_MIGRATION_TABLE_FAIL',
5345 p_table_name => G_Table_name,
5346 p_context => G_context,
5347 p_db_error => NULL,
5348 p_app_short_name => 'GMA'
5349 );
5350
5351 END Migrate_Lot_Cost_Adjustments;
5352
5353 /**********************************************************************
5354 * PROCEDURE: *
5355 * Migrate_Material_Lot_Cost_Txns *
5356 * *
5357 * DESCRIPTION: *
5358 * This PL/SQL procedure is used to migrate the Lot Cost Adjustments *
5359 * *
5360 * PARAMETERS: *
5361 * P_migration_run_id - id to use to right to migration log *
5362 * x_exception_count - Number of exceptions occurred. *
5363 * *
5364 * SYNOPSIS: *
5365 * Migrate_Material_Lot_Cost_Txns(p_migartion_id => l_migration_id, *
5366 * p_commit => 'T', *
5367 * x_exception_count => l_exception_count ); *
5368 * *
5369 * HISTORY *
5370 * 27-Apr-2005 Created Anand Thiyagarajan *
5371 * *
5372 **********************************************************************/
5373 PROCEDURE Migrate_Material_Lot_Cost_Txns
5374 (
5375 P_migration_run_id IN NUMBER,
5376 P_commit IN VARCHAR2,
5377 X_failure_count OUT NOCOPY NUMBER
5378 )
5379 IS
5380
5381 /**************************
5382 * PL/SQL Table Definition *
5383 **************************/
5384
5385 /******************
5386 * Local Variables *
5387 ******************/
5388
5389 BEGIN
5390
5391 G_Migration_run_id := P_migration_run_id;
5392 G_Table_name := 'GMF_MATERIAL_LOT_COST_TXNS';
5393 G_Context := 'Material Lot Cost Transactions Migration';
5394 X_failure_count := 0;
5395
5396 /********************************
5397 * Migration Started Log Message *
5398 ********************************/
5399
5400 GMA_COMMON_LOGGING.gma_migration_central_log
5401 (
5402 p_run_id => G_migration_run_id,
5403 p_log_level => FND_LOG.LEVEL_STATEMENT,
5404 p_message_token => 'GMA_MIGRATION_TABLE_STARTED',
5405 p_table_name => G_Table_name,
5406 p_context => G_context,
5407 p_db_error => NULL,
5408 p_app_short_name => 'GMA'
5409 );
5410
5411 BEGIN
5412
5413 /**********************************************************
5414 * Update a row in GMF_MATERIAL_LOT_COST_TXNS for cost Types *
5415 **********************************************************/
5416
5417 UPDATE gmf_material_lot_cost_txns a
5418 SET a.cost_type_id = (
5419 SELECT x.cost_Type_id
5420 FROM cm_mthd_mst x
5421 WHERE x.cost_mthd_code = a.cost_type_code
5422 ),
5423 a.cost_trans_um = (
5424 SELECT x.uom_Code
5425 FROM sy_uoms_mst x
5426 WHERE x.um_code = a.cost_trans_uom
5427 )
5428 WHERE (
5429 (a.cost_type_id IS NULL AND a.cost_type_code IS NOT NULL)
5430 OR (a.cost_trans_um IS NULL AND a.cost_trans_uom IS NOT NULL)
5431 );
5432
5433 EXCEPTION
5434 WHEN OTHERS THEN
5435
5436 /************************************************
5437 * Increment Failure Count for Failed Migrations *
5438 ************************************************/
5439
5440 x_failure_count := x_failure_count + 1;
5441
5442 /**************************************
5443 * Migration DB Error Log Message *
5444 **************************************/
5445
5446 GMA_COMMON_LOGGING.gma_migration_central_log
5447 (
5448 p_run_id => G_migration_run_id,
5449 p_log_level => FND_LOG.LEVEL_ERROR,
5450 p_message_token => 'GMA_MIGRATION_DB_ERROR',
5451 p_table_name => G_Table_name,
5452 p_context => G_context,
5453 p_db_error => SQLERRM,
5454 p_app_short_name => 'GMA'
5455 );
5456
5457 /**************************************
5458 * Migration Failure Log Message *
5459 **************************************/
5460
5461 GMA_COMMON_LOGGING.gma_migration_central_log
5462 (
5463 p_run_id => G_migration_run_id,
5464 p_log_level => FND_LOG.LEVEL_ERROR,
5465 p_message_token => 'GMA_TABLE_MIGRATION_TABLE_FAIL',
5466 p_table_name => G_Table_name,
5467 p_context => G_context,
5468 p_db_error => NULL,
5469 p_app_short_name => 'GMA'
5470 );
5471
5472 END;
5473
5474 /**********************************************
5475 * Handle all the rows which were not migrated *
5476 **********************************************/
5477 gmf_migration.Log_Errors (
5478 p_log_level => 1,
5479 p_from_rowid => NULL,
5480 p_to_rowid => NULL
5481 );
5482
5483 /****************************************************************
5484 * Lets save the changes now based on the commit parameter *
5485 ****************************************************************/
5486
5487 IF NVL(p_commit,'~') = FND_API.G_TRUE THEN
5488 COMMIT;
5489 END IF;
5490
5491 EXCEPTION
5492 WHEN OTHERS THEN
5493
5494 /************************************************
5495 * Increment Failure Count for Failed Migrations *
5496 ************************************************/
5497
5498 x_failure_count := x_failure_count + 1;
5499
5500 /**************************************
5501 * Migration DB Error Log Message *
5502 **************************************/
5503
5504 GMA_COMMON_LOGGING.gma_migration_central_log
5505 (
5506 p_run_id => G_migration_run_id,
5507 p_log_level => FND_LOG.LEVEL_ERROR,
5508 p_message_token => 'GMA_MIGRATION_DB_ERROR',
5509 p_table_name => G_Table_name,
5510 p_context => G_context,
5511 p_db_error => SQLERRM,
5512 p_app_short_name => 'GMA'
5513 );
5514
5515 /**************************************
5516 * Migration Failure Log Message *
5517 **************************************/
5518
5519 GMA_COMMON_LOGGING.gma_migration_central_log
5520 (
5521 p_run_id => G_migration_run_id,
5522 p_log_level => FND_LOG.LEVEL_ERROR,
5523 p_message_token => 'GMA_TABLE_MIGRATION_TABLE_FAIL',
5524 p_table_name => G_Table_name,
5525 p_context => G_context,
5526 p_db_error => NULL,
5527 p_app_short_name => 'GMA'
5528 );
5529
5530 END Migrate_Material_Lot_Cost_txns;
5531
5532 /**********************************************************************
5533 * PROCEDURE: *
5534 * Migrate_Lot_Cost_Burdens *
5535 * *
5536 * DESCRIPTION: *
5537 * This PL/SQL procedure is used to migrate the Lot Cost Burdens *
5538 * *
5539 * PARAMETERS: *
5540 * P_migration_run_id - id to use to right to migration log *
5541 * x_exception_count - Number of exceptions occurred. *
5542 * *
5543 * SYNOPSIS: *
5544 * Migrate_Lot_Cost_Burdens(p_migartion_id => l_migration_id, *
5545 * p_commit => 'T', *
5546 * x_exception_count => l_exception_count ); *
5547 * *
5548 * HISTORY *
5549 * 27-Apr-2005 Created Anand Thiyagarajan *
5550 * *
5551 **********************************************************************/
5552 PROCEDURE Migrate_Lot_Cost_Burdens
5553 (
5554 P_migration_run_id IN NUMBER,
5555 P_commit IN VARCHAR2,
5556 X_failure_count OUT NOCOPY NUMBER
5557 )
5558 IS
5559
5560 /**************************
5561 * PL/SQL Table Definition *
5562 **************************/
5563
5564 /******************
5565 * Local Variables *
5566 ******************/
5567
5568 /**********
5569 * Cursors *
5570 **********/
5571
5572 BEGIN
5573
5574 G_Migration_run_id := P_migration_run_id;
5575 G_Table_name := 'GMF_LOT_COST_BURDENS';
5576 G_Context := 'Lot Cost Burdens Migration';
5577 X_failure_count := 0;
5578
5579 /********************************
5580 * Migration Started Log Message *
5581 ********************************/
5582
5583 GMA_COMMON_LOGGING.gma_migration_central_log
5584 (
5585 p_run_id => G_migration_run_id,
5586 p_log_level => FND_LOG.LEVEL_STATEMENT,
5587 p_message_token => 'GMA_MIGRATION_TABLE_STARTED',
5588 p_table_name => G_Table_name,
5589 p_context => G_context,
5590 p_db_error => NULL,
5591 p_app_short_name => 'GMA'
5592 );
5593
5594 BEGIN
5595
5596 /******************************************************
5597 * Update a row in GMF_LOT_COST_BURDENS for cost Types *
5598 ******************************************************/
5599
5600 UPDATE gmf_lot_cost_burdens a
5601 SET a.cost_type_id
5602 = (
5603 SELECT x.cost_Type_id
5604 FROM cm_mthd_mst x
5605 WHERE x.cost_mthd_code = a.cost_mthd_code
5606 ),
5607 a.item_uom
5608 = (
5609 SELECT x.uom_code
5610 FROM sy_uoms_mst x
5611 WHERE x.um_code = a.item_um
5612 ),
5613 a.resource_uom
5614 = (
5615 SELECT y.uom_code
5616 FROM sy_uoms_mst y
5617 WHERE y.um_code = a.resource_um
5618 ),
5619 (
5620 a.organization_id,
5621 a.inventory_item_id
5622 )
5623 = (
5624 SELECT decode(x.cost_organization_id, -1, -1, y.organization_id),
5625 y.inventory_item_id
5626 FROM ic_whse_mst x,
5627 ic_item_mst_b_mig y
5628 WHERE x.whse_code = a.whse_code
5629 AND y.item_id = a.item_id
5630 AND y.organization_id = NVL(DECODE(x.cost_organization_id, -1, x.mtl_organization_id, x.cost_organization_id), x.mtl_organization_id)
5631 )
5632 WHERE (
5633 (a.cost_type_id IS NULL AND a.cost_mthd_code IS NOT NULL)
5634 OR (a.item_uom IS NULL AND a.item_um IS NOT NULL)
5635 OR (a.resource_uom IS NULL AND a.resource_um IS NOT NULL)
5636 OR (a.organization_id IS NULL AND a.whse_code IS NOT NULL)
5637 OR (a.inventory_item_id IS NULL AND a.item_id IS NOT NULL)
5638 );
5639
5640 EXCEPTION
5641 WHEN OTHERS THEN
5642
5643 /************************************************
5644 * Increment Failure Count for Failed Migrations *
5645 ************************************************/
5646
5647 x_failure_count := x_failure_count + 1;
5648
5649 /**************************************
5650 * Migration DB Error Log Message *
5651 **************************************/
5652
5653 GMA_COMMON_LOGGING.gma_migration_central_log
5654 (
5655 p_run_id => G_migration_run_id,
5656 p_log_level => FND_LOG.LEVEL_ERROR,
5657 p_message_token => 'GMA_MIGRATION_DB_ERROR',
5658 p_table_name => G_Table_name,
5659 p_context => G_context,
5660 p_db_error => SQLERRM,
5661 p_app_short_name => 'GMA'
5662 );
5663
5664 /**************************************
5665 * Migration Failure Log Message *
5666 **************************************/
5667
5668 GMA_COMMON_LOGGING.gma_migration_central_log
5669 (
5670 p_run_id => G_migration_run_id,
5671 p_log_level => FND_LOG.LEVEL_ERROR,
5672 p_message_token => 'GMA_TABLE_MIGRATION_TABLE_FAIL',
5673 p_table_name => G_Table_name,
5674 p_context => G_context,
5675 p_db_error => NULL,
5676 p_app_short_name => 'GMA'
5677 );
5678
5679 END;
5680 BEGIN
5681 /****************************************************************************
5682 * Insert rows for Additional Lots Created as part of Lot Balances Migration *
5683 ****************************************************************************/
5684 INSERT INTO gmf_lot_cost_burdens
5685 (
5686 lot_burden_line_id,
5687 resources,
5688 cost_cmpntcls_id,
5689 cost_analysis_code,
5690 start_date,
5691 end_date,
5692 resource_usage,
5693 resource_count,
5694 item_qty,
5695 burden_factor,
5696 applied_ind,
5697 delete_mark,
5698 text_code,
5699 created_by,
5700 creation_date,
5701 last_updated_by,
5702 last_update_date,
5703 last_update_login,
5704 attribute1,
5705 attribute2,
5706 attribute3,
5707 attribute4,
5708 attribute5,
5709 attribute6,
5710 attribute7,
5711 attribute8,
5712 attribute9,
5713 attribute10,
5714 attribute11,
5715 attribute12,
5716 attribute13,
5717 attribute14,
5718 attribute15,
5719 attribute16,
5720 attribute17,
5721 attribute18,
5722 attribute19,
5723 attribute20,
5724 attribute21,
5725 attribute22,
5726 attribute23,
5727 attribute24,
5728 attribute25,
5729 attribute26,
5730 attribute27,
5731 attribute28,
5732 attribute29,
5733 attribute30,
5734 attribute_category,
5735 cost_type_id,
5736 inventory_item_id,
5737 item_uom,
5738 lot_number,
5739 organization_id,
5740 resource_uom
5741 )
5742 (
5743 SELECT GMF_LOT_BURDEN_LINE_ID_S.NEXTVAL,
5744 a.resources,
5745 a.cost_cmpntcls_id,
5746 a.cost_analysis_code,
5747 a.start_date,
5748 a.end_date,
5749 a.resource_usage,
5750 a.resource_count,
5751 a.item_qty,
5752 a.burden_factor,
5753 a.applied_ind,
5754 a.delete_mark,
5755 a.lot_burden_line_id,
5756 a.created_by,
5757 SYSDATE,
5758 a.last_updated_by,
5759 SYSDATE,
5760 a.last_update_login,
5761 a.attribute1,
5762 a.attribute2,
5763 a.attribute3,
5764 a.attribute4,
5765 a.attribute5,
5766 a.attribute6,
5767 a.attribute7,
5768 a.attribute8,
5769 a.attribute9,
5770 a.attribute10,
5771 a.attribute11,
5772 a.attribute12,
5773 a.attribute13,
5774 a.attribute14,
5775 a.attribute15,
5776 a.attribute16,
5777 a.attribute17,
5778 a.attribute18,
5779 a.attribute19,
5780 a.attribute20,
5781 a.attribute21,
5782 a.attribute22,
5783 a.attribute23,
5784 a.attribute24,
5785 a.attribute25,
5786 a.attribute26,
5787 a.attribute27,
5788 a.attribute28,
5789 a.attribute29,
5790 a.attribute30,
5791 a.attribute_category,
5792 a.cost_type_id,
5793 a.inventory_item_id,
5794 a.item_uom,
5795 b.lot_number,
5796 a.organization_id,
5797 a.resource_uom
5798 FROM gmf_lot_cost_burdens a,
5799 ic_lots_mst_mig b
5800 WHERE a.lot_id = b.lot_id
5801 AND nvl(b.additional_status_lot,0) = 1
5802 AND (
5803 (a.cost_type_id IS NOT NULL AND a.cost_mthd_code IS NOT NULL)
5804 OR (a.item_uom IS NOT NULL AND a.item_um IS NOT NULL)
5805 OR (a.resource_uom IS NOT NULL AND a.resource_um IS NOT NULL)
5806 OR (a.organization_id IS NOT NULL AND a.whse_code IS NOT NULL)
5807 OR (a.inventory_item_id IS NOT NULL AND a.item_id IS NOT NULL)
5808 )
5809 AND NOT EXISTS (
5810 SELECT 'RECORD_ALREADY_EXISTS'
5811 FROM gmf_lot_cost_burdens x
5812 WHERE x.organization_id = a.organization_id
5813 AND x.inventory_item_id = a.inventory_item_id
5814 AND x.cost_type_id = a.cost_type_id
5815 AND x.lot_number = b.lot_number
5816 AND x.resources = a.resources
5817 AND x.cost_cmpntcls_id = a.cost_cmpntcls_id
5818 AND x.cost_analysis_code = a.cost_analysis_code
5819 )
5820 );
5821 EXCEPTION
5822 WHEN OTHERS THEN
5823 /************************************************
5824 * Increment Failure Count for Failed Migrations *
5825 ************************************************/
5826 x_failure_count := x_failure_count + 1;
5827 /**************************************
5828 * Migration DB Error Log Message *
5829 **************************************/
5830 GMA_COMMON_LOGGING.gma_migration_central_log
5831 (
5832 p_run_id => G_migration_run_id,
5833 p_log_level => FND_LOG.LEVEL_ERROR,
5834 p_message_token => 'GMA_MIGRATION_DB_ERROR',
5835 p_table_name => G_Table_name,
5836 p_context => G_context,
5837 p_db_error => SQLERRM,
5838 p_app_short_name => 'GMA'
5839 );
5840 /**************************************
5841 * Migration Failure Log Message *
5842 **************************************/
5843 GMA_COMMON_LOGGING.gma_migration_central_log
5844 (
5845 p_run_id => G_migration_run_id,
5846 p_log_level => FND_LOG.LEVEL_ERROR,
5847 p_message_token => 'GMA_TABLE_MIGRATION_TABLE_FAIL',
5848 p_table_name => G_Table_name,
5849 p_context => G_context,
5850 p_db_error => NULL,
5851 p_app_short_name => 'GMA'
5852 );
5853 END;
5854
5855 /**********************************************
5856 * Handle all the rows which were not migrated *
5857 **********************************************/
5858 gmf_migration.Log_Errors (
5859 p_log_level => 1,
5860 p_from_rowid => NULL,
5861 p_to_rowid => NULL
5862 );
5863
5864 /****************************************************************
5865 * Lets save the changes now based on the commit parameter *
5866 ****************************************************************/
5867
5868 IF NVL(p_commit,'~') = FND_API.G_TRUE THEN
5869 COMMIT;
5870 END IF;
5871
5872 EXCEPTION
5873 WHEN OTHERS THEN
5874
5875 /************************************************
5876 * Increment Failure Count for Failed Migrations *
5877 ************************************************/
5878
5879 x_failure_count := x_failure_count + 1;
5880
5881 /**************************************
5882 * Migration DB Error Log Message *
5883 **************************************/
5884
5885 GMA_COMMON_LOGGING.gma_migration_central_log
5886 (
5887 p_run_id => G_migration_run_id,
5888 p_log_level => FND_LOG.LEVEL_ERROR,
5889 p_message_token => 'GMA_MIGRATION_DB_ERROR',
5890 p_table_name => G_Table_name,
5891 p_context => G_context,
5892 p_db_error => SQLERRM,
5893 p_app_short_name => 'GMA'
5894 );
5895
5896 /**************************************
5897 * Migration Failure Log Message *
5898 **************************************/
5899
5900 GMA_COMMON_LOGGING.gma_migration_central_log
5901 (
5902 p_run_id => G_migration_run_id,
5903 p_log_level => FND_LOG.LEVEL_ERROR,
5904 p_message_token => 'GMA_TABLE_MIGRATION_TABLE_FAIL',
5905 p_table_name => G_Table_name,
5906 p_context => G_context,
5907 p_db_error => NULL,
5908 p_app_short_name => 'GMA'
5909 );
5910
5911 END Migrate_Lot_Cost_Burdens;
5912
5913 /**********************************************************************
5914 * PROCEDURE: *
5915 * Migrate_Allocation_Basis *
5916 * *
5917 * DESCRIPTION: *
5918 * This PL/SQL procedure is used to migrate the Expense Allocation *
5919 * Basis Records *
5920 * *
5921 * PARAMETERS: *
5922 * P_migration_run_id - id to use to right to migration log *
5923 * x_exception_count - Number of exceptions occurred. *
5924 * *
5925 * SYNOPSIS: *
5926 * Migrate_Allocation_Basis(p_migartion_id => l_migration_id, *
5927 * p_commit => 'T', *
5928 * x_exception_count => l_exception_count ); *
5929 * *
5930 * HISTORY *
5931 * 27-Apr-2005 Created Anand Thiyagarajan *
5932 * *
5933 **********************************************************************/
5934 PROCEDURE Migrate_Allocation_Basis
5935 (
5936 P_migration_run_id IN NUMBER,
5937 P_commit IN VARCHAR2,
5938 X_failure_count OUT NOCOPY NUMBER
5939 )
5940 IS
5941
5942 /**************************
5943 * PL/SQL Table Definition *
5944 **************************/
5945
5946 /******************
5947 * Local Variables *
5948 ******************/
5949
5950 l_inventory_item_id NUMBER;
5951 l_itm_failure_count NUMBER;
5952 l_itm_failure_count_all NUMBER;
5953
5954 /**********
5955 * Cursors *
5956 **********/
5957
5958 CURSOR cur_get_gmf_items
5959 IS
5960 SELECT DISTINCT
5961 item_id,
5962 organization_id
5963 FROM (
5964 SELECT a.item_id,
5965 DECODE(NVL(b.subinventory_ind_flag,'N'), 'Y', b.organization_id, b.mtl_organization_id) organization_id
5966 FROM gl_aloc_bas a,
5967 ic_whse_mst b
5968 WHERE a.item_id IS NOT NULL
5969 AND b.whse_code = a.whse_code
5970 );
5971
5972 BEGIN
5973
5974 G_Migration_run_id := P_migration_run_id;
5975 G_Table_name := 'GL_ALOC_BAS';
5976 G_Context := 'Expense Allocation Basis Migration';
5977 X_failure_count := 0;
5978
5979 /********************************
5980 * Migration Started Log Message *
5981 ********************************/
5982
5983 GMA_COMMON_LOGGING.gma_migration_central_log
5984 (
5985 p_run_id => G_migration_run_id,
5986 p_log_level => FND_LOG.LEVEL_STATEMENT,
5987 p_message_token => 'GMA_MIGRATION_TABLE_STARTED',
5988 p_table_name => G_Table_name,
5989 p_context => G_context,
5990 p_db_error => NULL,
5991 p_app_short_name => 'GMA'
5992 );
5993
5994 /****************************************************************
5995 * Migrating Items IN GL_ALOC_BAS table to Converged Item Master *
5996 ****************************************************************/
5997
5998 FOR i IN cur_get_gmf_items
5999 LOOP
6000 IF i.item_id IS NOT NULL
6001 AND i.organization_id IS NOT NULL
6002 THEN
6003 inv_opm_item_migration.get_odm_item
6004 (
6005 p_migration_run_id => p_migration_run_id,
6006 p_item_id => i.item_id,
6007 p_organization_id => i.organization_id,
6008 p_mode => NULL,
6009 p_commit => FND_API.G_TRUE,
6010 x_inventory_item_id => l_inventory_item_id,
6011 x_failure_count => l_itm_failure_count
6012 );
6013 END IF;
6014 l_itm_failure_count_all := nvl(l_itm_failure_count_all,0) + nvl(l_itm_failure_count,0);
6015 END LOOP;
6016
6017 /**********************************************************
6018 * Update a row in GL_ALOC_BAS for Account Codes *
6019 **********************************************************/
6020
6021 BEGIN
6022 /* B8266256 -- Splitting update into 2 parts Starts */
6023 -- UPDATE gl_aloc_bas a
6024 -- SET a.basis_account_id
6025 -- = (
6026 -- SELECT gmf_migration.get_account_id(a.basis_Account_key, x.co_code)
6027 -- FROM gl_aloc_mst x
6028 -- WHERE x.alloc_id = a.alloc_id
6029 -- ),
6030 -- a.basis_type = decode(a.alloc_method, 0, a.basis_type, 1),
6031 -- (
6032 -- a.organization_id,
6033 -- a.inventory_item_id
6034 -- )
6035 -- = (
6036 -- SELECT y.organization_id,
6037 -- y.inventory_item_id
6038 -- FROM ic_whse_mst x,
6039 -- ic_item_mst_b_mig y
6040 -- WHERE x.whse_code = a.whse_code
6041 -- AND y.item_id = a.item_id
6042 -- AND y.organization_id = DECODE(NVL(x.subinventory_ind_flag, 'N'), 'Y', x.organization_id, x.mtl_organization_id)
6043 -- )
6044 -- WHERE (
6045 -- (a.basis_account_key IS NOT NULL AND a.basis_account_id IS NULL)
6046 -- OR (a.inventory_item_id IS NULL AND a.item_id IS NOT NULL)
6047 -- OR (a.organization_id IS NULL AND a.whse_code IS NOT NULL)
6048 -- );
6049
6050 /* For fixed percentage allocations */
6051 UPDATE gl_aloc_bas a
6052 SET a.basis_type = decode(a.alloc_method, 0, a.basis_type, 1),
6053 (
6054 a.organization_id,
6055 a.inventory_item_id
6056 )
6057 = (
6058 SELECT y.organization_id,
6059 y.inventory_item_id
6060 FROM ic_whse_mst x,
6061 ic_item_mst_b_mig y
6062 WHERE x.whse_code = a.whse_code
6063 AND y.item_id = a.item_id
6064 AND y.organization_id = DECODE(NVL(x.subinventory_ind_flag, 'N'), 'Y', x.organization_id, x.mtl_organization_id)
6065 )
6066 WHERE (
6067 (a.basis_account_key IS NOT NULL AND a.basis_account_id IS NULL)
6068 OR (a.inventory_item_id IS NULL AND a.item_id IS NOT NULL)
6069 OR (a.organization_id IS NULL AND a.whse_code IS NOT NULL)
6070 )
6071 AND a.alloc_method <> 0 ;
6072
6073 /* For GL Balance percentage allocations */
6074 UPDATE gl_aloc_bas a
6075 SET a.basis_account_id
6076 = (
6077 SELECT decode(a.alloc_method,0, gmf_migration.get_account_id(a.basis_Account_key, x.co_code), NULL)
6078 FROM gl_aloc_mst x
6079 WHERE x.alloc_id = a.alloc_id
6080 ),
6081 a.basis_type = decode(a.alloc_method, 0, a.basis_type, 1),
6082 (
6083 a.organization_id,
6084 a.inventory_item_id
6085 )
6086 = (
6087 SELECT y.organization_id,
6088 y.inventory_item_id
6089 FROM ic_whse_mst x,
6090 ic_item_mst_b_mig y
6091 WHERE x.whse_code = a.whse_code
6092 AND y.item_id = a.item_id
6093 AND y.organization_id = DECODE(NVL(x.subinventory_ind_flag, 'N'), 'Y', x.organization_id, x.mtl_organization_id)
6094 )
6095 WHERE (
6096 (a.basis_account_key IS NOT NULL AND a.basis_account_id IS NULL)
6097 OR (a.inventory_item_id IS NULL AND a.item_id IS NOT NULL)
6098 OR (a.organization_id IS NULL AND a.whse_code IS NOT NULL)
6099 )
6100 AND a.alloc_method = 0 ;
6101 /* B8266256 -- Ends */
6102
6103
6104 EXCEPTION
6105 WHEN OTHERS THEN
6106
6107 /************************************************
6108 * Increment Failure Count for Failed Migrations *
6109 ************************************************/
6110
6111 x_failure_count := x_failure_count + 1;
6112
6113 /**************************************
6114 * Migration DB Error Log Message *
6115 **************************************/
6116
6117 GMA_COMMON_LOGGING.gma_migration_central_log
6118 (
6119 p_run_id => G_migration_run_id,
6120 p_log_level => FND_LOG.LEVEL_ERROR,
6121 p_message_token => 'GMA_MIGRATION_DB_ERROR',
6122 p_table_name => G_Table_name,
6123 p_context => G_context,
6124 p_db_error => SQLERRM,
6125 p_app_short_name => 'GMA'
6126 );
6127
6128 /**************************************
6129 * Migration Failure Log Message *
6130 **************************************/
6131
6132 GMA_COMMON_LOGGING.gma_migration_central_log
6133 (
6134 p_run_id => G_migration_run_id,
6135 p_log_level => FND_LOG.LEVEL_ERROR,
6136 p_message_token => 'GMA_TABLE_MIGRATION_TABLE_FAIL',
6137 p_table_name => G_Table_name,
6138 p_context => G_context,
6139 p_db_error => NULL,
6140 p_app_short_name => 'GMA'
6141 );
6142
6143 END;
6144
6145 /**********************************************
6146 * Handle all the rows which were not migrated *
6147 **********************************************/
6148
6149 SELECT count(*)
6150 INTO x_failure_count
6151 FROM gl_aloc_bas
6152 WHERE (
6153 (basis_account_key IS NOT NULL AND basis_account_id IS NULL)
6154 OR (inventory_item_id IS NULL AND item_id IS NOT NULL)
6155 OR (organization_id IS NULL AND whse_code IS NOT NULL)
6156 );
6157
6158 IF nvl(x_failure_count,0) > 0 THEN
6159
6160 /**************************************
6161 * Migration Failure Log Message *
6162 **************************************/
6163
6164 GMA_COMMON_LOGGING.gma_migration_central_log
6165 (
6166 p_run_id => gmf_migration.G_migration_run_id,
6167 p_log_level => FND_LOG.LEVEL_PROCEDURE,
6168 p_message_token => 'GMA_TABLE_MIGRATION_TABLE_FAIL',
6169 p_table_name => gmf_migration.G_Table_name,
6170 p_context => gmf_migration.G_context,
6171 p_db_error => NULL,
6172 p_app_short_name => 'GMA'
6173 );
6174
6175 ELSE
6176
6177 /**************************************
6178 * Migration Success Log Message *
6179 **************************************/
6180
6181 GMA_COMMON_LOGGING.gma_migration_central_log
6182 (
6183 p_run_id => G_migration_run_id,
6184 p_log_level => FND_LOG.LEVEL_STATEMENT,
6185 p_message_token => 'GMA_MIGRATION_TABLE_SUCCESS',
6186 p_table_name => G_Table_name,
6187 p_context => G_Context,
6188 p_param1 => 1,
6189 p_param2 => 0,
6190 p_db_error => NULL,
6191 p_app_short_name => 'GMA'
6192 );
6193
6194 END IF;
6195
6196 /****************************************************************
6197 * Lets save the changes now based on the commit parameter *
6198 ****************************************************************/
6199
6200 IF NVL(p_commit,'~') = FND_API.G_TRUE THEN
6201 COMMIT;
6202 END IF;
6203
6204 EXCEPTION
6205 WHEN OTHERS THEN
6206
6207 /************************************************
6208 * Increment Failure Count for Failed Migrations *
6209 ************************************************/
6210
6211 x_failure_count := x_failure_count + 1;
6212
6213 /**************************************
6214 * Migration DB Error Log Message *
6215 **************************************/
6216
6217 GMA_COMMON_LOGGING.gma_migration_central_log
6218 (
6219 p_run_id => G_migration_run_id,
6220 p_log_level => FND_LOG.LEVEL_ERROR,
6221 p_message_token => 'GMA_MIGRATION_DB_ERROR',
6222 p_table_name => G_Table_name,
6223 p_context => G_context,
6224 p_db_error => SQLERRM,
6225 p_app_short_name => 'GMA'
6226 );
6227
6228 /**************************************
6229 * Migration Failure Log Message *
6230 **************************************/
6231
6232 GMA_COMMON_LOGGING.gma_migration_central_log
6233 (
6234 p_run_id => G_migration_run_id,
6235 p_log_level => FND_LOG.LEVEL_ERROR,
6236 p_message_token => 'GMA_TABLE_MIGRATION_TABLE_FAIL',
6237 p_table_name => G_Table_name,
6238 p_context => G_context,
6239 p_db_error => NULL,
6240 p_app_short_name => 'GMA'
6241 );
6242
6243 END Migrate_Allocation_Basis;
6244
6245 /**********************************************************************
6246 * PROCEDURE: *
6247 * Migrate_Allocation_Expenses *
6248 * *
6249 * DESCRIPTION: *
6250 * This PL/SQL procedure is used to migrate the Expense Allocation *
6251 * Expenses Records *
6252 * *
6253 * PARAMETERS: *
6254 * P_migration_run_id - id to use to right to migration log *
6255 * x_exception_count - Number of exceptions occurred. *
6256 * *
6257 * SYNOPSIS: *
6258 * Migrate_Allocation_Expenses(p_migartion_id => l_migration_id, *
6259 * p_commit => 'T', *
6260 * x_exception_count => l_exception_count ); *
6261 * *
6262 * HISTORY *
6263 * 27-Apr-2005 Created Anand Thiyagarajan *
6264 * *
6265 **********************************************************************/
6266 PROCEDURE Migrate_Allocation_Expenses
6267 (
6268 P_migration_run_id IN NUMBER,
6269 P_commit IN VARCHAR2,
6270 X_failure_count OUT NOCOPY NUMBER
6271 )
6272 IS
6273
6274 /***************************
6275 * PL/SQL Table Definitions *
6276 ***************************/
6277
6278 /******************
6279 * Local Variables *
6280 ******************/
6281
6282 BEGIN
6283
6284 G_Migration_run_id := P_migration_run_id;
6285 G_Table_name := 'GL_ALOC_EXP';
6286 G_Context := 'Expense Allocation Expenses Migration';
6287 X_failure_count := 0;
6288
6289 /********************************
6290 * Migration Started Log Message *
6291 ********************************/
6292
6293 GMA_COMMON_LOGGING.gma_migration_central_log
6294 (
6295 p_run_id => G_migration_run_id,
6296 p_log_level => FND_LOG.LEVEL_STATEMENT,
6297 p_message_token => 'GMA_MIGRATION_TABLE_STARTED',
6298 p_table_name => G_Table_name,
6299 p_context => G_context,
6300 p_db_error => NULL,
6301 p_app_short_name => 'GMA'
6302 );
6303
6304
6305 /**********************************************************
6306 * Update a row in GL_ALOC_EXP for Account Codes *
6307 **********************************************************/
6308
6309 BEGIN
6310 UPDATE gl_aloc_exp a
6311 SET (
6312 a.from_account_id,
6313 a.to_account_id
6314 )
6315 = (
6316 SELECT gmf_migration.get_account_id(a.from_account, x.co_code),
6317 gmf_migration.get_account_id(a.to_account, x.co_code)
6318 FROM gl_aloc_mst x
6319 WHERE x.alloc_id = a.alloc_id
6320 )
6321 WHERE (
6322 (from_account_id IS NULL AND from_account IS NOT NULL)
6323 OR (to_account_id IS NULL AND to_account IS NOT NULL)
6324 );
6325
6326 EXCEPTION
6327 WHEN OTHERS THEN
6328
6329 /************************************************
6330 * Increment Failure Count for Failed Migrations *
6331 ************************************************/
6332
6333 x_failure_count := x_failure_count + 1;
6334
6335 /**************************************
6336 * Migration DB Error Log Message *
6337 **************************************/
6338
6339 GMA_COMMON_LOGGING.gma_migration_central_log
6340 (
6341 p_run_id => G_migration_run_id,
6342 p_log_level => FND_LOG.LEVEL_ERROR,
6343 p_message_token => 'GMA_MIGRATION_DB_ERROR',
6344 p_table_name => G_Table_name,
6345 p_context => G_context,
6346 p_db_error => SQLERRM,
6347 p_app_short_name => 'GMA'
6348 );
6349
6350 /**************************************
6351 * Migration Failure Log Message *
6352 **************************************/
6353
6354 GMA_COMMON_LOGGING.gma_migration_central_log
6355 (
6356 p_run_id => G_migration_run_id,
6357 p_log_level => FND_LOG.LEVEL_ERROR,
6358 p_message_token => 'GMA_TABLE_MIGRATION_TABLE_FAIL',
6359 p_table_name => G_Table_name,
6360 p_context => G_context,
6361 p_db_error => NULL,
6362 p_app_short_name => 'GMA'
6363 );
6364
6365 END;
6366
6367 /**********************************************
6368 * Handle all the rows which were not migrated *
6369 **********************************************/
6370
6371 SELECT count(*)
6372 INTO x_failure_count
6373 FROM gl_aloc_exp
6374 WHERE (
6375 (from_account_id IS NULL AND from_account IS NOT NULL)
6376 OR (to_account_id IS NULL AND to_account IS NOT NULL)
6377 );
6378
6379 IF nvl(x_failure_count,0) > 0 THEN
6380
6381 /**************************************
6382 * Migration Failure Log Message *
6383 **************************************/
6384
6385 GMA_COMMON_LOGGING.gma_migration_central_log
6386 (
6387 p_run_id => gmf_migration.G_migration_run_id,
6388 p_log_level => FND_LOG.LEVEL_PROCEDURE,
6389 p_message_token => 'GMA_TABLE_MIGRATION_TABLE_FAIL',
6390 p_table_name => gmf_migration.G_Table_name,
6391 p_context => gmf_migration.G_context,
6392 p_db_error => NULL,
6393 p_app_short_name => 'GMA'
6394 );
6395
6396 ELSE
6397
6398 /**************************************
6399 * Migration Success Log Message *
6400 **************************************/
6401
6402 GMA_COMMON_LOGGING.gma_migration_central_log
6403 (
6404 p_run_id => G_migration_run_id,
6405 p_log_level => FND_LOG.LEVEL_STATEMENT,
6406 p_message_token => 'GMA_MIGRATION_TABLE_SUCCESS',
6407 p_table_name => G_Table_name,
6408 p_context => G_Context,
6409 p_param1 => 1,
6410 p_param2 => 0,
6411 p_db_error => NULL,
6412 p_app_short_name => 'GMA'
6413 );
6414
6415 END IF;
6416
6417 /****************************************************************
6418 * Lets save the changes now based on the commit parameter *
6419 ****************************************************************/
6420
6421 IF NVL(p_commit,'~') = FND_API.G_TRUE THEN
6422 COMMIT;
6423 END IF;
6424
6425 EXCEPTION
6426
6427 WHEN OTHERS THEN
6428
6429 /************************************************
6430 * Increment Failure Count for Failed Migrations *
6431 ************************************************/
6432
6433 x_failure_count := x_failure_count + 1;
6434
6435 /**************************************
6436 * Migration DB Error Log Message *
6437 **************************************/
6438
6439 GMA_COMMON_LOGGING.gma_migration_central_log
6440 (
6441 p_run_id => G_migration_run_id,
6442 p_log_level => FND_LOG.LEVEL_ERROR,
6443 p_message_token => 'GMA_MIGRATION_DB_ERROR',
6444 p_table_name => G_Table_name,
6445 p_context => G_context,
6446 p_param1 => NULL,
6447 p_param2 => NULL,
6448 p_db_error => SQLERRM,
6449 p_app_short_name => 'GMA'
6450 );
6451
6452 /**************************************
6453 * Migration Failure Log Message *
6454 **************************************/
6455
6456 GMA_COMMON_LOGGING.gma_migration_central_log
6457 (
6458 p_run_id => G_migration_run_id,
6459 p_log_level => FND_LOG.LEVEL_ERROR,
6460 p_message_token => 'GMA_TABLE_MIGRATION_TABLE_FAIL',
6461 p_table_name => G_Table_name,
6462 p_context => G_context,
6463 p_db_error => NULL,
6464 p_app_short_name => 'GMA'
6465 );
6466
6467 END Migrate_Allocation_Expenses;
6468
6469 /**********************************************************************
6470 * PROCEDURE: *
6471 * Migrate_Account_Mappings *
6472 * *
6473 * DESCRIPTION: *
6474 * This PL/SQL procedure is used to migrate the Account Mappings from*
6475 * OPM Data model to SLA ADR Model *
6476 * *
6477 * PARAMETERS: *
6478 * P_migration_run_id - id to use to right to migration log *
6479 * x_exception_count - Number of exceptions occurred. *
6480 * *
6481 * SYNOPSIS: *
6482 * Migrate_Account_Mappings(p_migartion_id => l_migration_id, *
6483 * p_commit => 'T', *
6484 * x_exception_count => l_exception_count ); *
6485 * *
6486 * HISTORY *
6487 * 27-Apr-2005 Created Anand Thiyagarajan *
6488 * 30-Apr-2010 Pramod B.H Bug 9660507 *
6489 * Modified procedure Migrate_Account_Mappings. When only one *
6490 * Acctng Unit segment is available, using the value directly. *
6491 * *
6492 **********************************************************************/
6493 PROCEDURE Migrate_Account_Mappings
6494 (
6495 P_migration_run_id IN NUMBER,
6496 P_commit IN VARCHAR2,
6497 X_failure_count OUT NOCOPY NUMBER
6498 )
6499 IS
6500
6501 /**************************
6502 * PL/SQL Table Definition *
6503 **************************/
6504
6505 TYPE my_order_tbl IS TABLE OF NUMBER(2) INDEX BY BINARY_INTEGER;
6506 TYPE t_event_class_code IS TABLE OF VARCHAR2(30) INDEX BY VARCHAR2(4);
6507 TYPE t_event_type_code IS TABLE OF VARCHAR2(30) INDEX BY VARCHAR2(4);
6508
6509 TYPE t_co_code IS TABLE OF GL_ACCT_MAP.CO_CODE%TYPE INDEX BY BINARY_INTEGER;
6510 TYPE t_orgn_code IS TABLE OF GL_ACCT_MAP.ORGN_CODE%TYPE INDEX BY BINARY_INTEGER;
6511 TYPE t_whse_code IS TABLE OF GL_ACCT_MAP.WHSE_CODE%TYPE INDEX BY BINARY_INTEGER;
6512 TYPE t_item_id IS TABLE OF GL_ACCT_MAP.ITEM_ID%TYPE INDEX BY BINARY_INTEGER;
6513 TYPE t_vendor_id IS TABLE OF GL_ACCT_MAP.VENDOR_ID%TYPE INDEX BY BINARY_INTEGER;
6514 TYPE t_cust_id IS TABLE OF GL_ACCT_MAP.CUST_ID%TYPE INDEX BY BINARY_INTEGER;
6515 TYPE t_reason_code IS TABLE OF GL_ACCT_MAP.REASON_CODE%TYPE INDEX BY BINARY_INTEGER;
6516 TYPE t_gl_category_id IS TABLE OF GL_ACCT_MAP.GL_CATEGORY_ID%TYPE INDEX BY BINARY_INTEGER;
6517 TYPE t_vendgl_class IS TABLE OF GL_ACCT_MAP.VENDGL_CLASS%TYPE INDEX BY BINARY_INTEGER;
6518 TYPE t_custgl_class IS TABLE OF GL_ACCT_MAP.CUSTGL_CLASS%TYPE INDEX BY BINARY_INTEGER;
6519 TYPE t_currency_code IS TABLE OF GL_ACCT_MAP.CURRENCY_CODE%TYPE INDEX BY BINARY_INTEGER;
6520 TYPE t_routing_id IS TABLE OF GL_ACCT_MAP.ROUTING_ID%TYPE INDEX BY BINARY_INTEGER;
6521 TYPE t_charge_id IS TABLE OF GL_ACCT_MAP.CHARGE_ID%TYPE INDEX BY BINARY_INTEGER;
6522 TYPE t_taxauth_id IS TABLE OF GL_ACCT_MAP.TAXAUTH_ID%TYPE INDEX BY BINARY_INTEGER;
6523 TYPE t_acct_id IS TABLE OF GL_ACCT_MAP.ACCT_ID%TYPE INDEX BY BINARY_INTEGER;
6524 TYPE t_aqui_cost_id IS TABLE OF GL_ACCT_MAP.AQUI_COST_ID%TYPE INDEX BY BINARY_INTEGER;
6525 TYPE t_resources IS TABLE OF GL_ACCT_MAP.RESOURCES%TYPE INDEX BY BINARY_INTEGER;
6526 TYPE t_cost_cmpntcls_id IS TABLE OF GL_ACCT_MAP.COST_CMPNTCLS_ID%TYPE INDEX BY BINARY_INTEGER;
6527 TYPE t_cost_analysis_code IS TABLE OF GL_ACCT_MAP.COST_ANALYSIS_CODE%TYPE INDEX BY BINARY_INTEGER;
6528 TYPE t_order_type IS TABLE OF GL_ACCT_MAP.ORDER_TYPE%TYPE INDEX BY BINARY_INTEGER;
6529 TYPE t_gl_business_class_cat_id IS TABLE OF GL_ACCT_MAP.GL_BUSINESS_CLASS_CAT_ID%TYPE INDEX BY BINARY_INTEGER;
6530 TYPE t_gl_product_line_cat_id IS TABLE OF GL_ACCT_MAP.GL_PRODUCT_LINE_CAT_ID%TYPE INDEX BY BINARY_INTEGER;
6531 TYPE t_line_type IS TABLE OF GL_ACCT_MAP.LINE_TYPE%TYPE INDEX BY BINARY_INTEGER;
6532 TYPE t_ar_trx_type_id IS TABLE OF GL_ACCT_MAP.AR_TRX_TYPE_ID%TYPE INDEX BY BINARY_INTEGER;
6533 TYPE t_rowid IS TABLE OF ROWID INDEX BY BINARY_INTEGER;
6534 TYPE t_inventory_org_ind IS TABLE OF SY_ORGN_MST.INVENTORY_ORG_IND%TYPE INDEX BY BINARY_INTEGER;
6535 TYPE t_organization_id IS TABLE OF SY_ORGN_MST.ORGANIZATION_ID%TYPE INDEX BY BINARY_INTEGER;
6536 TYPE t_mtl_organization_id IS TABLE OF IC_WHSE_MST.MTL_ORGANIZATION_ID%TYPE INDEX BY BINARY_INTEGER;
6537 TYPE t_subinventory_ind_flag IS TABLE OF IC_WHSE_MST.SUBINVENTORY_IND_FLAG%TYPE INDEX BY BINARY_INTEGER;
6538 TYPE t_acct_no IS TABLE OF GL_ACCT_MST.ACCT_NO%TYPE INDEX BY BINARY_INTEGER;
6539 TYPE t_source_type IS TABLE OF GL_ACCT_MAP.SOURCE_TYPE%TYPE INDEX BY BINARY_INTEGER;
6540
6541 /******************
6542 * Local Variables *
6543 ******************/
6544
6545 l_legal_entity_id GMF_FISCAL_POLICIES.LEGAL_ENTITY_ID%TYPE;
6546 l_adr_priority NUMBER := 10;
6547 l_adr_condition_priority NUMBER := 10;
6548 l_old_adr_condition_priority NUMBER := 10;
6549 l_adr_rule_code VARCHAR2(30);
6550 l_adr_rule_name VARCHAR2(80);
6551 l_acctg_unit_count NUMBER;
6552 l_segment_value VARCHAR2(240);
6553
6554 X_sqlstmt VARCHAR2(32000);
6555 X_sqlwhere VARCHAR2(32000);
6556 X_my_order_by VARCHAR2(200);
6557 X_sqlcolumns VARCHAR2(32000);
6558 X_sqlordby VARCHAR2(32000);
6559 X_tmp1 NUMBER(10);
6560 X_cursor_handle INTEGER;
6561 X_var_col VARCHAR2(32000);
6562 X_rows_processed NUMBER(15);
6563
6564 x_order_tbl my_order_tbl;
6565
6566 l_inventory_item_id MTL_SYSTEM_ITEMS_B.inventory_item_id%TYPE;
6567 l_item MTL_ITEM_FLEXFIELDS.item_number%TYPE;
6568 l_customer_no OP_CUST_MST.cust_no%TYPE;
6569 l_vendor_site_id PO_VEND_MST.of_vendor_site_id%TYPE;
6570 l_taxauth_code TX_TAXA_MST.taxauth_code%TYPE;
6571 l_Charge_code OP_CHRG_MST.Charge_code%TYPE;
6572 l_routing_no GMD_ROUTINGS_B.routing_no%TYPE;
6573 l_routing_vers GMD_ROUTINGS_B.routing_vers%TYPE;
6574 l_price_element_type_id PO_COST_MST.price_element_type_id%TYPE;
6575 l_cost_cmpntcls_code CM_CMPT_MST.cost_cmpntcls_code%TYPE;
6576 l_Order_type_code OP_ORDR_TYP.Order_type_code%TYPE;
6577 l_Line_type_code GEM_LOOKUPS.meaning%TYPE;
6578 l_ar_trx_type_code RA_CUST_TRX_TYPES_ALL.name%TYPE;
6579
6580 l_co_code t_co_code;
6581 l_orgn_code t_orgn_code;
6582 l_whse_code t_whse_code;
6583 l_item_id t_item_id;
6584 l_vendor_id t_vendor_id;
6585 l_cust_id t_cust_id;
6586 l_reason_code t_reason_code;
6587 l_gl_category_id t_gl_category_id;
6588 l_vendgl_class t_vendgl_class;
6589 l_custgl_class t_custgl_class;
6590 l_currency_code t_currency_code;
6591 l_routing_id t_routing_id;
6592 l_charge_id t_charge_id;
6593 l_taxauth_id t_taxauth_id;
6594 l_acct_id t_acct_id;
6595 l_aqui_cost_id t_aqui_cost_id;
6596 l_resources t_resources;
6597 l_cost_cmpntcls_id t_cost_cmpntcls_id;
6598 l_cost_analysis_code t_cost_analysis_code;
6599 l_order_type t_order_type;
6600 l_gl_business_class_cat_id t_gl_business_class_cat_id;
6601 l_gl_product_line_cat_id t_gl_product_line_cat_id;
6602 l_line_type t_line_type;
6603 l_ar_trx_type_id t_ar_trx_type_id;
6604 l_rowid t_rowid;
6605 l_acct_no t_acct_no;
6606 l_inventory_org_ind t_inventory_org_ind;
6607 l_subinventory_ind_flag t_subinventory_ind_flag;
6608 l_source_type t_source_type;
6609 l_organization_id t_organization_id;
6610 l_mtl_organization_id t_mtl_organization_id;
6611
6612 l_orgn_code_pri GL_ACCT_HRC.ORGN_CODE_PRI%TYPE := 0;
6613 l_whse_code_pri GL_ACCT_HRC.WHSE_CODE_PRI%TYPE := 0;
6614 l_item_pri GL_ACCT_HRC.ITEM_PRI%TYPE := 0;
6615 l_vendor_pri GL_ACCT_HRC.VENDOR_PRI%TYPE := 0;
6616 l_customer_pri GL_ACCT_HRC.CUSTOMER_PRI%TYPE := 0;
6617 l_reason_code_pri GL_ACCT_HRC.REASON_CODE_PRI%TYPE := 0;
6618 l_icgl_class_pri GL_ACCT_HRC.ICGL_CLASS_PRI%TYPE := 0;
6619 l_vendgl_class_pri GL_ACCT_HRC.VENDGL_CLASS_PRI%TYPE := 0;
6620 l_custgl_class_pri GL_ACCT_HRC.CUSTGL_CLASS_PRI%TYPE := 0;
6621 l_currency_code_pri GL_ACCT_HRC.CURRENCY_CODE_PRI%TYPE := 0;
6622 l_routing_pri GL_ACCT_HRC.ROUTING_PRI%TYPE := 0;
6623 l_charge_pri GL_ACCT_HRC.CHARGE_PRI%TYPE := 0;
6624 l_tax_auth_pri GL_ACCT_HRC.TAX_AUTH_PRI%TYPE := 0;
6625 l_aqui_cost_code_pri GL_ACCT_HRC.AQUI_COST_CODE_PRI%TYPE := 0;
6626 l_resource_pri GL_ACCT_HRC.RESOURCE_PRI%TYPE := 0;
6627 l_cost_cmpntcls_pri GL_ACCT_HRC.COST_CMPNTCLS_PRI%TYPE := 0;
6628 l_cost_analysis_pri GL_ACCT_HRC.COST_ANALYSIS_PRI%TYPE := 0;
6629 l_order_type_pri GL_ACCT_HRC.ORDER_TYPE_PRI%TYPE := 0;
6630 l_gl_business_class_pri GL_ACCT_HRC.GL_BUSINESS_CLASS_PRI%TYPE := 0;
6631 l_gl_product_line_pri GL_ACCT_HRC.GL_PRODUCT_LINE_PRI%TYPE := 0;
6632 l_line_type_pri GL_ACCT_HRC.LINE_TYPE_PRI%TYPE := 0;
6633 l_ar_trx_type_pri GL_ACCT_HRC.AR_TRX_TYPE_PRI%TYPE := 0;
6634 l_co_code1 GL_ACCT_HRC.CO_CODE%TYPE;
6635
6636 l_reason_id MTL_TRANSACTION_REASONS.REASON_ID%TYPE;
6637 l_row_id ROWID;
6638
6639 xct PLS_INTEGER := 1;
6640 xrt PLS_INTEGER := 1;
6641 xlat PLS_INTEGER := 1;
6642 xrdt PLS_INTEGER := 1;
6643 mcnt PLS_INTEGER := 1;
6644 l_event_class_code t_event_class_code;
6645 l_event_type_code t_event_type_code;
6646 l_segment_rule_detail_id NUMBER(38);
6647 l_old_segment_rule_detail_id NUMBER(38);
6648 l_amb_context VARCHAR2(30);
6649
6650 /**********
6651 * Cursors *
6652 **********/
6653
6654 CURSOR cur_legal_entities
6655 IS
6656 SELECT a.legal_entity_id,
6657 d.organization_code,
6658 c.legal_entity_name organization_name,
6659 b.segment_delimiter,
6660 b.co_code,
6661 e.chart_of_accounts_id,
6662 e.short_name,
6663 e.name,
6664 e.ledger_id
6665 FROM gmf_fiscal_policies a,
6666 gl_plcy_mst b,
6667 gmf_legal_entities c,
6668 mtl_parameters d,
6669 gl_ledgers e
6670 WHERE a.legal_entity_id = b.legal_entity_id
6671 AND c.legal_entity_id = a.legal_entity_id
6672 AND d.organization_id(+) = c.legal_entity_id
6673 AND e.ledger_id = a.ledger_id
6674 ORDER BY a.legal_entity_id;
6675
6676 CURSOR cur_account_title
6677 IS
6678 SELECT DISTINCT
6679 DECODE(acct_ttl_code, 'PCO', 'COGS', 'IPF', 'IOPR', 'XFC', 'XTC', acct_ttl_code) acct_ttl_code,
6680 DECODE(acct_ttl_code, 'PCO', 'Cost of Goods Sold' , 'IPF', 'Inter-Org Profit', 'XFC', 'Inter-org Transfer Credit', acct_ttl_desc) acct_ttl_desc,
6681 acct_ttl_type
6682 FROM gl_acct_ttl
6683 ORDER BY acct_ttl_code;
6684
6685 CURSOR cur_plcy_seg
6686 (
6687 p_co_code IN VARCHAR2,
6688 p_coa_id IN NUMBER
6689 )
6690 IS
6691 SELECT a.segment_no,
6692 a.type,
6693 b.segment_name short_name,
6694 b.application_column_name,
6695 c.id_flex_structure_code structure_code,
6696 c.id_flex_structure_name structure_name
6697 FROM gl_plcy_seg a,
6698 fnd_id_flex_segments b,
6699 fnd_id_flex_structures_vl c
6700 WHERE a.co_code = p_co_code
6701 AND b.segment_num = a.segment_ref
6702 AND b.id_flex_num = p_coa_id
6703 AND b.enabled_flag = 'Y'
6704 AND b.id_flex_code = 'GL#'
6705 AND b.application_id = 101
6706 AND c.application_id = b.application_id
6707 AND c.id_flex_code = b.id_flex_code
6708 AND c.id_flex_num = b.id_flex_num
6709 ORDER BY a.type,
6710 a.segment_no;
6711
6712 CURSOR cur_account_unit_map
6713 (
6714 p_co_code IN VARCHAR2
6715 )
6716 IS
6717 SELECT a.co_code,
6718 a.orgn_code,
6719 NVL(c.inventory_org_ind,'N') inventory_org_ind,
6720 c.organization_id,
6721 a.whse_code,
6722 NVL(d.subinventory_ind_flag,'N') subinventory_ind_flag,
6723 d.mtl_organization_id,
6724 b.acctg_unit_id,
6725 b.acctg_unit_no,
6726 a.accu_map_id
6727 FROM gl_accu_map a,
6728 gl_accu_mst b,
6729 sy_orgn_mst c,
6730 ic_whse_mst d
6731 WHERE a.co_code = p_co_code
6732 AND b.acctg_unit_id = a.acctg_unit_id
6733 AND c.orgn_code(+) = a.orgn_code
6734 AND d.whse_code(+) = a.whse_code
6735 AND nvl(a.migrated_ind,0) <> 1
6736 ORDER BY a.co_code,
6737 a.orgn_code NULLS LAST,
6738 a.whse_code NULLS LAST;
6739
6740 CURSOR cur_whse_accu
6741 (
6742 p_orgn_code IN VARCHAR2,
6743 p_co_code IN VARCHAR2,
6744 p_acctg_unit_id IN VARCHAR2
6745 )
6746 IS
6747 SELECT a.whse_code,
6748 a.whse_name,
6749 NVL(a.subinventory_ind_flag,'N') subinventory_ind_flag,
6750 a.mtl_organization_id
6751 FROM ic_whse_mst a
6752 WHERE a.orgn_code = p_orgn_code
6753 AND NOT EXISTS
6754 (
6755 SELECT 'X'
6756 FROM gl_accu_map x
6757 WHERE x.whse_code = a.whse_code
6758 AND x.co_code = p_co_code
6759 AND x.orgn_code = a.orgn_code
6760 AND x.acctg_unit_id = p_acctg_unit_id
6761 )
6762 ORDER BY a.whse_code;
6763
6764 CURSOR cur_whse_acct
6765 (
6766 p_orgn_code IN VARCHAR2,
6767 p_co_code IN VARCHAR2,
6768 p_acct_id IN VARCHAR2
6769 )
6770 IS
6771 SELECT a.whse_code,
6772 a.whse_name,
6773 NVL(a.subinventory_ind_flag,'N') subinventory_ind_flag,
6774 a.mtl_organization_id
6775 FROM ic_whse_mst a
6776 WHERE a.orgn_code = p_orgn_code
6777 AND NOT EXISTS
6778 (
6779 SELECT 'X'
6780 FROM gl_acct_map x
6781 WHERE x.whse_code = a.whse_code
6782 AND x.co_code = p_co_code
6783 AND x.orgn_code = a.orgn_code
6784 AND x.acct_id = p_acct_id
6785 AND x.delete_mark = 0 /* Bug 9765910 */
6786 )
6787 ORDER BY a.whse_code;
6788
6789 CURSOR cur_sub_event_code
6790 (
6791 p_acct_ttl_type IN gl_acct_ttl.acct_ttl_type%TYPE
6792 )
6793 IS
6794 SELECT DISTINCT c.sub_event_code,
6795 d.event_class_code,
6796 d.event_Type_code
6797 FROM gl_sevt_ttl a,
6798 gl_sevt_mst c,
6799 gmf_xla_event_model d
6800 WHERE a.acct_ttl_type = p_acct_ttl_type
6801 AND c.sub_event_type = a.sub_event_type
6802 AND c.sub_event_type = d.sub_event_type
6803 AND 1 = 2; /* Stubbed to avoid migration for Line Assignments */
6804
6805 /*********************
6806 * Local Sub-Programs *
6807 *********************/
6808
6809 PROCEDURE insert_conditions
6810 (
6811 p_condition_tag IN VARCHAR2,
6812 p_sequence IN OUT NOCOPY NUMBER,
6813 p_source IN VARCHAR2,
6814 p_comparision_operator IN VARCHAR2,
6815 p_value_type IN VARCHAR2,
6816 p_value IN VARCHAR2,
6817 p_logical_operator IN VARCHAR2,
6818 p_segment_rule_detail_id IN NUMBER
6819 )
6820 IS
6821 l_logical_operator_code VARCHAR2(1);
6822 BEGIN
6823 IF p_condition_tag IN ('FIRST', 'ONLY') THEN
6824 p_sequence := 10;
6825 IF p_condition_tag = 'ONLY' THEN
6826 l_logical_operator_code := NULL;
6827 ELSE
6828 l_logical_operator_code := p_logical_operator;
6829 END IF;
6830 ELSE
6831 p_sequence := nvl(p_sequence,0) + 10;
6832 IF p_condition_tag <> 'LAST' THEN
6833 l_logical_operator_code := p_logical_operator;
6834 END IF;
6835 END IF;
6836 /***************************************
6837 * Loading XLA_CONDITIONS_T Structure *
6838 ***************************************/
6839 INSERT INTO xla_conditions_t
6840 (
6841 CONDITION_ID,
6842 APPLICATION_ID,
6843 AMB_CONTEXT_CODE,
6844 SEGMENT_RULE_DETAIL_ID,
6845 USER_SEQUENCE,
6846 BRACKET_LEFT_CODE,
6847 BRACKET_RIGHT_CODE,
6848 VALUE_TYPE_CODE,
6849 SOURCE_APPLICATION_ID,
6850 SOURCE_TYPE_CODE,
6851 SOURCE_CODE,
6852 FLEXFIELD_SEGMENT_CODE,
6853 VALUE_FLEXFIELD_SEGMENT_CODE,
6854 VALUE_SOURCE_APPLICATION_ID,
6855 VALUE_SOURCE_TYPE_CODE,
6856 VALUE_SOURCE_CODE,
6857 VALUE_CONSTANT,
6858 LINE_OPERATOR_CODE,
6859 LOGICAL_OPERATOR_CODE,
6860 INDEPENDENT_VALUE_CONSTANT,
6861 ERROR_VALUE
6862 )
6863 VALUES
6864 (
6865 xla_conditions_s.NEXTVAL,
6866 G_Application_id,
6867 l_amb_context,
6868 p_segment_rule_detail_id,
6869 p_sequence,
6870 NULL,
6871 NULL,
6872 p_value_type,
6873 G_Application_id,
6874 'S',
6875 p_source,
6876 NULL,
6877 NULL,
6878 NULL,
6879 NULL,
6880 NULL,
6881 p_value,
6882 p_comparision_operator,
6883 l_logical_operator_code,
6884 NULL,
6885 0
6886 );
6887 END insert_conditions;
6888 BEGIN
6889
6890 G_Migration_run_id := P_migration_run_id;
6891 G_Table_name := 'SLA_ADR_MIGRATION';
6892 G_Context := 'Account Mappings Migration';
6893 X_failure_count := 0;
6894
6895 /********************************
6896 * Migration Started Log Message *
6897 ********************************/
6898 GMA_COMMON_LOGGING.gma_migration_central_log
6899 (
6900 p_run_id => G_migration_run_id,
6901 p_log_level => FND_LOG.LEVEL_STATEMENT,
6902 p_message_token => 'GMA_MIGRATION_TABLE_STARTED',
6903 p_table_name => G_Table_name,
6904 p_context => G_Context,
6905 p_db_error => NULL,
6906 p_app_short_name => 'GMA'
6907 );
6908
6909 l_amb_context := 'DEFAULT';
6910
6911 <<ACCOUNT_TITLES>>
6912 FOR k IN cur_account_title LOOP
6913 <<LEGAL_ENTITIES>>
6914 FOR i IN cur_legal_entities LOOP
6915 /***************************************************************************************************
6916 * Looping through Company Codes to migrate the Accounting Unit and Accounting Number Mappings once *
6917 ***************************************************************************************************/
6918 BEGIN
6919 SELECT count(1)
6920 INTO l_acctg_unit_count
6921 FROM gl_plcy_seg a
6922 WHERE TYPE = 0
6923 AND a.co_code = i.co_code;
6924 EXCEPTION
6925 WHEN OTHERS THEN
6926 l_acctg_unit_count := 0;
6927 END;
6928 <<POLICY_SEGMENTS>>
6929 FOR j IN cur_plcy_seg(p_co_code => i.co_code, p_coa_id => i.chart_of_accounts_id) LOOP
6930 IF j.TYPE = 0 THEN /* Accounting Unit Mapping */
6931 l_adr_rule_code := REPLACE( UPPER (SUBSTRB(i.short_name, 1, 14) ||'_'||k.acct_ttl_code||'_'||SUBSTRB(j.short_name, 1, 10)), ' ', '_');
6932 l_adr_rule_name := SUBSTRB(i.name, 1, 20 )||': ('|| k.acct_ttl_code ||') '|| SUBSTRB(k.acct_ttl_desc, 1, 25) ||' For '||SUBSTRB(j.short_name, 1, 10)||' Segment';
6933 xrt := 0;
6934 /********************************
6935 * Loading XLA_RULES_T GTMP *
6936 ********************************/
6937 BEGIN
6938 SELECT count(*)
6939 INTO xrt
6940 FROM xla_rules_t
6941 WHERE application_id = G_Application_id
6942 AND segment_rule_code = l_adr_rule_code
6943 AND amb_context_code = l_amb_context;
6944 EXCEPTION
6945 WHEN no_data_found THEN
6946 xrt := 0;
6947 END;
6948 IF nvl(xrt,0) = 0 THEN
6949 INSERT INTO xla_rules_t
6950 (
6951 APPLICATION_ID,
6952 AMB_CONTEXT_CODE,
6953 SEGMENT_RULE_TYPE_CODE,
6954 SEGMENT_RULE_CODE,
6955 TRANSACTION_COA_ID,
6956 ACCOUNTING_COA_ID,
6957 FLEXFIELD_ASSIGN_MODE_CODE,
6958 FLEXFIELD_SEGMENT_CODE,
6959 ENABLED_FLAG,
6960 NAME,
6961 DESCRIPTION,
6962 ERROR_VALUE
6963 )
6964 VALUES
6965 (
6966 G_Application_id,
6967 l_amb_context,
6968 'C',
6969 l_adr_rule_code,
6970 i.chart_of_accounts_id,
6971 i.chart_of_accounts_id,
6972 'S',
6973 j.application_column_name,
6974 'Y',
6975 l_adr_rule_name,
6976 'ADR for Ledger: '|| i.name ||' - JLT: ('|| k.acct_ttl_code ||') '||SUBSTRB(k.acct_ttl_desc, 1, 25)||' - Segment: '||j.short_name,
6977 0
6978 );
6979 l_adr_priority := 10;
6980 ELSE
6981 BEGIN
6982 SELECT nvl(MAX(nvl(user_sequence,0)) + 10,10)
6983 INTO l_adr_priority
6984 FROM xla_rule_details_t
6985 WHERE application_id = G_Application_id
6986 AND segment_rule_code = l_adr_rule_code
6987 AND amb_context_code = l_amb_context;
6988 EXCEPTION
6989 WHEN no_data_found THEN
6990 l_adr_priority := 10;
6991 END;
6992 END IF;
6993 <<SUB_EVENT_CODE_1>>
6994 FOR m IN cur_sub_event_code (k.acct_ttl_type) LOOP
6995 /***************************************
6996 * Loading XLA_LINE_ASSGNS_T Structure *
6997 ***************************************/
6998 BEGIN
6999 SELECT count(*)
7000 INTO xlat
7001 FROM xla_line_assgns_t
7002 WHERE application_id = G_Application_id
7003 AND amb_context_code = l_amb_context
7004 AND event_class_code = m.event_class_code
7005 AND event_type_code = m.event_type_code
7006 AND line_definition_code = m.event_type_code
7007 AND accounting_line_code = k.acct_ttl_code
7008 AND segment_rule_code = l_adr_rule_code
7009 AND flexfield_segment_code = j.application_column_name;
7010 EXCEPTION
7011 WHEN no_data_found THEN
7012 xlat := 0;
7013 END;
7014 IF nvl(xlat,0) = 0 THEN
7015 INSERT INTO xla_line_assgns_t
7016 (
7017 APPLICATION_ID,
7018 AMB_CONTEXT_CODE,
7019 EVENT_CLASS_CODE,
7020 EVENT_TYPE_CODE,
7021 LINE_DEFINITION_OWNER_CODE,
7022 LINE_DEFINITION_CODE,
7023 ACCOUNTING_LINE_TYPE_CODE,
7024 ACCOUNTING_LINE_CODE,
7025 FLEXFIELD_SEGMENT_CODE,
7026 SEGMENT_RULE_TYPE_CODE,
7027 SEGMENT_RULE_CODE,
7028 ERROR_VALUE
7029 )
7030 VALUES
7031 (
7032 G_Application_id,
7033 l_amb_context,
7034 m.event_class_code,
7035 m.event_type_code,
7036 'C',
7037 m.event_type_code,
7038 'S',
7039 k.acct_ttl_code,
7040 j.application_column_name,
7041 'C',
7042 l_adr_rule_code,
7043 0
7044 );
7045 END IF;
7046 END LOOP SUB_EVENT_CODE_1;
7047 <<ACCOUNTING_UNITS>>
7048 FOR l IN cur_account_unit_map(p_co_code => i.co_code) LOOP
7049 IF l_acctg_unit_count > 1 THEN /*Bug 9660507 - Added the condition */
7050 SELECT substrb(a, decode(b-1, 0, 1, instr(a, c, 1, (b-1))+ 1), decode(instr(a, c, 1, b), 0, (length(a) - instr(a, c, 1, (b-1))+ 1), (instr(a, c, 1, b)) - decode(b-1, 0, 1, instr(a, c, 1, (b-1))+ 1)))
7051 INTO l_segment_value
7052 FROM (
7053 SELECT l.acctg_unit_no a,
7054 j.segment_no b,
7055 i.segment_delimiter c
7056 FROM dual
7057 );
7058 ELSE
7059 l_segment_value := l.acctg_unit_no ; /*Bug 9660507 - When only one AU segment is available, use the value directly*/
7060 END IF;
7061 /***************************************
7062 * Loading XLA_RULE_DETAILS_T Structure *
7063 ***************************************/
7064 BEGIN
7065 SELECT nvl(MAX(nvl(user_sequence,0)) + 10,10)
7066 INTO l_adr_priority
7067 FROM xla_rule_details_t
7068 WHERE application_id = G_Application_id
7069 AND segment_rule_code = l_adr_rule_code
7070 AND amb_context_code = l_amb_context;
7071 EXCEPTION
7072 WHEN no_data_found THEN
7073 l_adr_priority := 10;
7074 END;
7075 l_segment_rule_detail_id := NULL;
7076 INSERT INTO xla_rule_details_t
7077 (
7078 APPLICATION_ID,
7079 AMB_CONTEXT_CODE,
7080 SEGMENT_RULE_TYPE_CODE,
7081 SEGMENT_RULE_CODE,
7082 SEGMENT_RULE_DETAIL_ID,
7083 USER_SEQUENCE,
7084 VALUE_TYPE_CODE,
7085 VALUE_SOURCE_APPLICATION_ID,
7086 VALUE_SOURCE_TYPE_CODE,
7087 VALUE_SOURCE_CODE,
7088 VALUE_CONSTANT,
7089 VALUE_CODE_COMBINATION_ID,
7090 VALUE_MAPPING_SET_CODE,
7091 VALUE_FLEXFIELD_SEGMENT_CODE,
7092 INPUT_SOURCE_APPLICATION_ID,
7093 INPUT_SOURCE_TYPE_CODE,
7094 INPUT_SOURCE_CODE,
7095 VALUE_SEGMENT_RULE_APPL_ID,
7096 VALUE_SEGMENT_RULE_TYPE_CODE,
7097 VALUE_SEGMENT_RULE_CODE,
7098 VALUE_ADR_VERSION_NUM,
7099 ERROR_VALUE
7100 )
7101 VALUES
7102 (
7103 G_Application_id,
7104 l_amb_context,
7105 'C',
7106 l_adr_rule_code,
7107 xla_seg_rule_details_s.NEXTVAL,
7108 l_adr_priority,
7109 'C',
7110 NULL,
7111 NULL,
7112 NULL,
7113 l_segment_value,
7114 NULL,
7115 NULL,
7116 NULL,
7117 NULL,
7118 NULL,
7119 NULL,
7120 NULL,
7121 NULL,
7122 NULL,
7123 NULL,
7124 0
7125 ) returning segment_rule_detail_id INTO l_segment_rule_detail_id;
7126 IF l_segment_rule_detail_id IS NOT NULL THEN
7127 insert_conditions (
7128 p_condition_tag => 'FIRST',
7129 p_sequence => l_adr_condition_priority,
7130 p_source => G_Journal_Line_Type,
7131 p_comparision_operator => G_Equal,
7132 p_value_type => G_constant,
7133 p_value => k.acct_ttl_code,
7134 p_logical_operator => G_And,
7135 p_segment_rule_detail_id => l_segment_rule_detail_id
7136 );
7137 insert_conditions (
7138 p_condition_tag => 'MID',
7139 p_sequence => l_adr_condition_priority,
7140 p_source => G_ledger_id,
7141 p_comparision_operator => G_Equal,
7142 p_value_type => G_constant,
7143 p_value => i.ledger_id,
7144 p_logical_operator => G_And,
7145 p_segment_rule_detail_id => l_segment_rule_detail_id
7146 );
7147 insert_conditions (
7148 p_condition_tag => 'MID',
7149 p_sequence => l_adr_condition_priority,
7150 p_source => G_legal_entity,
7151 p_comparision_operator => G_Equal,
7152 p_value_type => G_constant,
7153 p_value => i.legal_entity_id,
7154 p_logical_operator => G_And,
7155 p_segment_rule_detail_id => l_segment_rule_detail_id
7156 );
7157 IF l.orgn_code IS NOT NULL THEN
7158 IF l.whse_code IS NOT NULL AND nvl(l.subinventory_ind_flag,'N') = 'Y' AND NVL(l.inventory_org_ind,'N') = 'Y' THEN
7159 /************************************************************
7160 * OPM Organizations is Migrated as inventory Organization *
7161 ************************************************************/
7162 insert_conditions (
7163 p_condition_tag => 'MID',
7164 p_sequence => l_adr_condition_priority,
7165 p_source => G_Organization,
7166 p_comparision_operator => G_Equal,
7167 p_value_type => G_constant,
7168 p_value => l.organization_id,
7169 p_logical_operator => G_and,
7170 p_segment_rule_detail_id => l_segment_rule_detail_id
7171 );
7172 /*******************************************************************
7173 * Warehouse Code Is specified and is migrated as subinventories *
7174 *******************************************************************/
7175 insert_conditions (
7176 p_condition_tag => 'LAST',
7177 p_sequence => l_adr_condition_priority,
7178 p_source => G_subinventory,
7179 p_comparision_operator => G_Equal,
7180 p_value_type => G_constant,
7181 p_value => l.whse_code,
7182 p_logical_operator => NULL,
7183 p_segment_rule_detail_id => l_segment_rule_detail_id
7184 );
7185 ELSIF l.whse_code IS NOT NULL AND nvl(l.subinventory_ind_flag,'N') <> 'Y' THEN
7186 /****************************************************************************
7187 * Warehouse Code Is specified and is migrated as Inventory Organizations *
7188 ****************************************************************************/
7189 insert_conditions (
7190 p_condition_tag => 'LAST',
7191 p_sequence => l_adr_condition_priority,
7192 p_source => G_Organization,
7193 p_comparision_operator => G_Equal,
7194 p_value_type => G_constant,
7195 p_value => l.mtl_organization_id,
7196 p_logical_operator => NULL,
7197 p_segment_rule_detail_id => l_segment_rule_detail_id
7198 );
7199 ELSE
7200 /*******************************************************************************************************
7201 * Warehouse Code Is not specified, so inserting a record for all warehouses under the OPM organization *
7202 *******************************************************************************************************/
7203 mcnt := 1;
7204 <<WAREHOUSE_ACCU>>
7205 FOR m IN cur_whse_accu (l.orgn_code, i.co_code, l.acctg_unit_id) LOOP
7206 IF m.mtl_organization_id <> nvl(l.organization_id, -1) THEN
7207 IF mcnt > 1 THEN
7208 BEGIN
7209 SELECT nvl(MAX(nvl(user_sequence,0)) + 10,10)
7210 INTO l_adr_priority
7211 FROM xla_rule_details_t
7212 WHERE application_id = G_Application_id
7213 AND segment_rule_code = l_adr_rule_code
7214 AND amb_context_code = l_amb_context;
7215 EXCEPTION
7216 WHEN no_data_found THEN
7217 l_adr_priority := 10;
7218 END;
7219 l_segment_rule_detail_id := NULL;
7220 INSERT INTO xla_rule_details_t
7221 (
7222 APPLICATION_ID,
7223 AMB_CONTEXT_CODE,
7224 SEGMENT_RULE_TYPE_CODE,
7225 SEGMENT_RULE_CODE,
7226 SEGMENT_RULE_DETAIL_ID,
7227 USER_SEQUENCE,
7228 VALUE_TYPE_CODE,
7229 VALUE_SOURCE_APPLICATION_ID,
7230 VALUE_SOURCE_TYPE_CODE,
7231 VALUE_SOURCE_CODE,
7232 VALUE_CONSTANT,
7233 VALUE_CODE_COMBINATION_ID,
7234 VALUE_MAPPING_SET_CODE,
7235 VALUE_FLEXFIELD_SEGMENT_CODE,
7236 INPUT_SOURCE_APPLICATION_ID,
7237 INPUT_SOURCE_TYPE_CODE,
7238 INPUT_SOURCE_CODE,
7239 VALUE_SEGMENT_RULE_APPL_ID,
7240 VALUE_SEGMENT_RULE_TYPE_CODE,
7241 VALUE_SEGMENT_RULE_CODE,
7242 VALUE_ADR_VERSION_NUM,
7243 ERROR_VALUE
7244 )
7245 VALUES
7246 (
7247 G_Application_id,
7248 l_amb_context,
7249 'C',
7250 l_adr_rule_code,
7251 xla_seg_rule_details_s.NEXTVAL,
7252 l_adr_priority,
7253 'C',
7254 NULL,
7255 NULL,
7256 NULL,
7257 l_segment_value,
7258 NULL,
7259 NULL,
7260 NULL,
7261 NULL,
7262 NULL,
7263 NULL,
7264 NULL,
7265 NULL,
7266 NULL,
7267 NULL,
7268 0
7269 ) returning segment_rule_detail_id INTO l_segment_rule_detail_id;
7270 insert_conditions (
7271 p_condition_tag => 'FIRST',
7272 p_sequence => l_adr_condition_priority,
7273 p_source => G_Journal_Line_Type,
7274 p_comparision_operator => G_Equal,
7275 p_value_type => G_constant,
7276 p_value => k.acct_ttl_code,
7277 p_logical_operator => G_And,
7278 p_segment_rule_detail_id => l_segment_rule_detail_id
7279 );
7280 insert_conditions (
7281 p_condition_tag => 'MID',
7282 p_sequence => l_adr_condition_priority,
7283 p_source => G_ledger_id,
7284 p_comparision_operator => G_Equal,
7285 p_value_type => G_constant,
7286 p_value => i.ledger_id,
7287 p_logical_operator => G_And,
7288 p_segment_rule_detail_id => l_segment_rule_detail_id
7289 );
7290 insert_conditions (
7291 p_condition_tag => 'MID',
7292 p_sequence => l_adr_condition_priority,
7293 p_source => G_legal_entity,
7294 p_comparision_operator => G_Equal,
7295 p_value_type => G_constant,
7296 p_value => i.legal_entity_id,
7297 p_logical_operator => G_And,
7298 p_segment_rule_detail_id => l_segment_rule_detail_id
7299 );
7300 END IF;
7301 IF nvl(m.subinventory_ind_flag,'N') = 'Y' THEN
7302 /************************************************************
7303 * OPM Organizations is Migrated as inventory Organization *
7304 ************************************************************/
7305 insert_conditions (
7306 p_condition_tag => 'MID',
7307 p_sequence => l_adr_condition_priority,
7308 p_source => G_Organization,
7309 p_comparision_operator => G_Equal,
7310 p_value_type => G_constant,
7311 p_value => l.organization_id,
7312 p_logical_operator => G_and,
7313 p_segment_rule_detail_id => l_segment_rule_detail_id
7314 );
7315 /*******************************************************************
7316 * Warehouse Code Is specified and is migrated as subinventories *
7317 *******************************************************************/
7318 insert_conditions (
7319 p_condition_tag => 'LAST',
7320 p_sequence => l_adr_condition_priority,
7321 p_source => G_subinventory,
7322 p_comparision_operator => G_Equal,
7323 p_value_type => G_constant,
7324 p_value => m.whse_code,
7325 p_logical_operator => NULL,
7326 p_segment_rule_detail_id => l_segment_rule_detail_id
7327 );
7328 ELSIF nvl(m.subinventory_ind_flag,'N') <> 'Y' THEN
7329 /****************************************************************************
7330 * Warehouse Code Is specified and is migrated as Inventory Organizations *
7331 ****************************************************************************/
7332 insert_conditions (
7333 p_condition_tag => 'LAST',
7334 p_sequence => l_adr_condition_priority,
7335 p_source => G_Organization,
7336 p_comparision_operator => G_Equal,
7337 p_value_type => G_constant,
7338 p_value => m.mtl_organization_id,
7339 p_logical_operator => NULL,
7340 p_segment_rule_detail_id => l_segment_rule_detail_id
7341 );
7342 END IF;
7343 mcnt := nvl(mcnt,1) + 1;
7344 END IF;
7345 END LOOP WAREHOUSE_ACCU;
7346 IF NVL(l.inventory_org_ind,'N') = 'Y' AND nvl(mcnt, 1) > 1 THEN
7347 BEGIN
7348 SELECT nvl(MAX(nvl(user_sequence,0)) + 10,10)
7349 INTO l_adr_priority
7350 FROM xla_rule_details_t
7351 WHERE application_id = G_Application_id
7352 AND segment_rule_code = l_adr_rule_code
7353 AND amb_context_code = l_amb_context;
7354 EXCEPTION
7355 WHEN no_data_found THEN
7356 l_adr_priority := 10;
7357 END;
7358 l_segment_rule_detail_id := NULL;
7359 INSERT INTO xla_rule_details_t
7360 (
7361 APPLICATION_ID,
7362 AMB_CONTEXT_CODE,
7363 SEGMENT_RULE_TYPE_CODE,
7364 SEGMENT_RULE_CODE,
7365 SEGMENT_RULE_DETAIL_ID,
7366 USER_SEQUENCE,
7367 VALUE_TYPE_CODE,
7368 VALUE_SOURCE_APPLICATION_ID,
7369 VALUE_SOURCE_TYPE_CODE,
7370 VALUE_SOURCE_CODE,
7371 VALUE_CONSTANT,
7372 VALUE_CODE_COMBINATION_ID,
7373 VALUE_MAPPING_SET_CODE,
7374 VALUE_FLEXFIELD_SEGMENT_CODE,
7375 INPUT_SOURCE_APPLICATION_ID,
7376 INPUT_SOURCE_TYPE_CODE,
7377 INPUT_SOURCE_CODE,
7378 VALUE_SEGMENT_RULE_APPL_ID,
7379 VALUE_SEGMENT_RULE_TYPE_CODE,
7380 VALUE_SEGMENT_RULE_CODE,
7381 VALUE_ADR_VERSION_NUM,
7382 ERROR_VALUE
7383 )
7384 VALUES
7385 (
7386 G_Application_id,
7387 l_amb_context,
7388 'C',
7389 l_adr_rule_code,
7390 xla_seg_rule_details_s.NEXTVAL,
7391 l_adr_priority,
7392 'C',
7393 NULL,
7394 NULL,
7395 NULL,
7396 l_segment_value,
7397 NULL,
7398 NULL,
7399 NULL,
7400 NULL,
7401 NULL,
7402 NULL,
7403 NULL,
7404 NULL,
7405 NULL,
7406 NULL,
7407 0
7408 ) returning segment_rule_detail_id INTO l_segment_rule_detail_id;
7409 IF l_segment_rule_detail_id IS NOT NULL THEN
7410 insert_conditions (
7411 p_condition_tag => 'FIRST',
7412 p_sequence => l_adr_condition_priority,
7413 p_source => G_Journal_Line_Type,
7414 p_comparision_operator => G_Equal,
7415 p_value_type => G_constant,
7416 p_value => k.acct_ttl_code,
7417 p_logical_operator => G_And,
7418 p_segment_rule_detail_id => l_segment_rule_detail_id
7419 );
7420 insert_conditions (
7421 p_condition_tag => 'MID',
7422 p_sequence => l_adr_condition_priority,
7423 p_source => G_ledger_id,
7424 p_comparision_operator => G_Equal,
7425 p_value_type => G_constant,
7426 p_value => i.ledger_id,
7427 p_logical_operator => G_And,
7428 p_segment_rule_detail_id => l_segment_rule_detail_id
7429 );
7430 insert_conditions (
7431 p_condition_tag => 'MID',
7432 p_sequence => l_adr_condition_priority,
7433 p_source => G_legal_entity,
7434 p_comparision_operator => G_Equal,
7435 p_value_type => G_constant,
7436 p_value => i.legal_entity_id,
7437 p_logical_operator => G_And,
7438 p_segment_rule_detail_id => l_segment_rule_detail_id
7439 );
7440 insert_conditions (
7441 p_condition_tag => 'LAST',
7442 p_sequence => l_adr_condition_priority,
7443 p_source => G_Organization,
7444 p_comparision_operator => G_Equal,
7445 p_value_type => G_constant,
7446 p_value => l.organization_id,
7447 p_logical_operator => NULL,
7448 p_segment_rule_detail_id => l_segment_rule_detail_id
7449 );
7450 END IF;
7451 ELSIF NVL(l.inventory_org_ind,'N') <> 'Y' THEN
7452 BEGIN
7453 UPDATE xla_conditions_t
7454 SET logical_operator_code = NULL
7455 WHERE user_sequence = l_adr_condition_priority
7456 AND segment_rule_detail_id = l_segment_rule_detail_id
7457 AND amb_context_code = l_amb_context;
7458 EXCEPTION
7459 WHEN OTHERS THEN
7460 NULL;
7461 END;
7462 ELSE
7463 insert_conditions (
7464 p_condition_tag => 'LAST',
7465 p_sequence => l_adr_condition_priority,
7466 p_source => G_Organization,
7467 p_comparision_operator => G_Equal,
7468 p_value_type => G_constant,
7469 p_value => l.organization_id,
7470 p_logical_operator => NULL,
7471 p_segment_rule_detail_id => l_segment_rule_detail_id
7472 );
7473 END IF;
7474 END IF;
7475 ELSE
7476 BEGIN
7477 UPDATE xla_conditions_t
7478 SET logical_operator_code = NULL
7479 WHERE user_sequence = l_adr_condition_priority
7480 AND segment_rule_detail_id = l_segment_rule_detail_id
7481 AND amb_context_code = l_amb_context;
7482 EXCEPTION
7483 WHEN OTHERS THEN
7484 NULL;
7485 END;
7486 END IF;
7487 END IF;
7488 END LOOP ACCOUNTING_UNITS;
7489 ELSE /* Account Mapping */
7490 /***************************************
7491 * Migration of Account Number Mappings *
7492 ***************************************/
7493 l_adr_rule_code := REPLACE (UPPER (SUBSTRB(i.short_name, 1, 14) ||'_'||k.acct_ttl_code||'_'||SUBSTRB(j.short_name, 1, 10)), ' ', '_');
7494 l_adr_rule_name := SUBSTRB(i.name, 1, 20 )||': ('|| k.acct_ttl_code ||') '|| SUBSTRB(k.acct_ttl_desc, 1, 25) ||' For '||SUBSTRB(j.short_name, 1, 10)||' Segment';
7495 xrt := 0;
7496 /********************************
7497 * Loading XLA_RULES_T GTMP *
7498 ********************************/
7499 BEGIN
7500 SELECT count(*)
7501 INTO xrt
7502 FROM xla_rules_t
7503 WHERE application_id = G_Application_id
7504 AND SEGMENT_RULE_CODE = l_adr_rule_code
7505 AND amb_context_code = l_amb_context;
7506 EXCEPTION
7507 WHEN no_data_found THEN
7508 xrt := 0;
7509 END;
7510 IF nvl(xrt,0) = 0 THEN
7511 INSERT INTO xla_rules_t
7512 (
7513 APPLICATION_ID,
7514 AMB_CONTEXT_CODE,
7515 SEGMENT_RULE_TYPE_CODE,
7516 SEGMENT_RULE_CODE,
7517 TRANSACTION_COA_ID,
7518 ACCOUNTING_COA_ID,
7519 FLEXFIELD_ASSIGN_MODE_CODE,
7520 FLEXFIELD_SEGMENT_CODE,
7521 ENABLED_FLAG,
7522 NAME,
7523 DESCRIPTION,
7524 ERROR_VALUE
7525 )
7526 VALUES
7527 (
7528 G_Application_id,
7529 l_amb_context,
7530 'C',
7531 l_adr_rule_code,
7532 i.chart_of_accounts_id,
7533 i.chart_of_accounts_id,
7534 'S',
7535 j.application_column_name,
7536 'Y',
7537 l_adr_rule_name,
7538 'ADR for Ledger: '|| i.name ||' - JLT: ('|| k.acct_ttl_code ||') '||SUBSTRB(k.acct_ttl_desc, 1, 25)||' - Segment: '||j.short_name,
7539 0
7540 );
7541 l_adr_priority := 10;
7542 ELSE
7543 BEGIN
7544 SELECT nvl(MAX(nvl(user_sequence,0)) + 10,10)
7545 INTO l_adr_priority
7546 FROM xla_rule_details_t
7547 WHERE application_id = G_Application_id
7548 AND segment_rule_code = l_adr_rule_code
7549 AND amb_context_code = l_amb_context;
7550 EXCEPTION
7551 WHEN no_data_found THEN
7552 l_adr_priority := 10;
7553 END;
7554 END IF;
7555 <<SUB_EVENT_CODE_2>>
7556 FOR m IN cur_sub_event_code (k.acct_ttl_type) LOOP
7557 /***************************************
7558 * Loading XLA_LINE_ASSGNS_T Structure *
7559 ***************************************/
7560 BEGIN
7561 SELECT count(*)
7562 INTO xlat
7563 FROM xla_line_assgns_t
7564 WHERE application_id = G_Application_id
7565 AND amb_context_code = l_amb_context
7566 AND event_class_code = m.event_class_code
7567 AND event_type_code = m.event_type_code
7568 AND line_definition_code = m.event_type_code
7569 AND accounting_line_code = k.acct_ttl_code
7570 AND segment_rule_code = l_adr_rule_code
7571 AND flexfield_segment_code = j.application_column_name;
7572 EXCEPTION
7573 WHEN no_data_found THEN
7574 xlat := 0;
7575 END;
7576 IF nvl(xlat,0) = 0 THEN
7577 INSERT INTO xla_line_assgns_t
7578 (
7579 APPLICATION_ID,
7580 AMB_CONTEXT_CODE,
7581 EVENT_CLASS_CODE,
7582 EVENT_TYPE_CODE,
7583 LINE_DEFINITION_OWNER_CODE,
7584 LINE_DEFINITION_CODE,
7585 ACCOUNTING_LINE_TYPE_CODE,
7586 ACCOUNTING_LINE_CODE,
7587 FLEXFIELD_SEGMENT_CODE,
7588 SEGMENT_RULE_TYPE_CODE,
7589 SEGMENT_RULE_CODE,
7590 ERROR_VALUE
7591 )
7592 VALUES
7593 (
7594 G_Application_id,
7595 l_amb_context,
7596 m.event_class_code,
7597 m.event_type_code,
7598 'C',
7599 m.event_type_code,
7600 'S',
7601 k.acct_ttl_code,
7602 j.application_column_name,
7603 'C',
7604 l_adr_rule_code,
7605 0
7606 );
7607 END IF;
7608 END LOOP SUB_EVENT_CODE_2;
7609 X_sqlstmt := 'SELECT a.co_code,
7610 a.orgn_code_pri,
7611 a.whse_code_pri,
7612 a.icgl_class_pri,
7613 a.custgl_class_pri,
7614 a.vendgl_class_pri ,
7615 a.item_pri,
7616 a.customer_pri,
7617 a.vendor_pri,
7618 a.tax_auth_pri,
7619 a.charge_pri,
7620 a.currency_code_pri,
7621 a.reason_code_pri,
7622 a.routing_pri,
7623 a.aqui_cost_code_pri,
7624 a.resource_pri,
7625 a.cost_cmpntcls_pri,
7626 a.cost_analysis_pri,
7627 a.order_type_pri,
7628 a.gl_business_class_pri,
7629 a.gl_product_line_pri,
7630 a.line_type_pri,
7631 a.ar_trx_type_pri
7632 FROM gl_acct_hrc a
7633 WHERE a.acct_ttl_type = :p_acct_ttl_type
7634 AND a.co_code = :p_co_code
7635 ORDER BY 1 desc';
7636 BEGIN
7637 EXECUTE IMMEDIATE X_sqlstmt
7638 INTO l_co_code1, l_orgn_code_pri, l_whse_code_pri,
7639 l_icgl_class_pri, l_custgl_class_pri, l_vendgl_class_pri,
7640 l_item_pri, l_customer_pri, l_vendor_pri,
7641 l_tax_auth_pri, l_charge_pri, l_currency_code_pri,
7642 l_reason_code_pri,l_routing_pri, l_aqui_cost_code_pri,
7643 l_resource_pri, l_cost_cmpntcls_pri, l_cost_analysis_pri,
7644 l_order_type_pri, l_gl_business_class_pri,l_gl_product_line_pri,
7645 l_line_type_pri, l_ar_trx_type_pri
7646 using k.acct_ttl_type, i.co_code;
7647 EXCEPTION
7648 WHEN no_data_found THEN
7649 NULL;
7650 END;
7651 FOR z IN 1..23 LOOP
7652 X_order_tbl(z) := 0;
7653 END LOOP;
7654 X_my_order_by := ' ORDER BY 1';
7655 IF sql%rowcount > 0 THEN
7656 IF l_orgn_code_pri > 0 THEN
7657 x_tmp1:= l_orgn_code_pri + 1;
7658 X_order_tbl(x_tmp1) := 2;
7659 END IF;
7660 IF l_whse_code_pri > 0 THEN
7661 x_tmp1:= l_whse_code_pri + 1;
7662 X_order_tbl(x_tmp1) := 3;
7663 END IF;
7664 IF l_icgl_class_pri > 0 THEN
7665 x_tmp1:= l_icgl_class_pri + 1;
7666 X_order_tbl(x_tmp1) := 4;
7667 END IF;
7668 IF l_custgl_class_pri > 0 THEN
7669 x_tmp1:= l_custgl_class_pri + 1;
7670 X_order_tbl(x_tmp1) := 5;
7671 END IF;
7672 IF l_vendgl_class_pri > 0 THEN
7673 x_tmp1:= l_vendgl_class_pri + 1;
7674 X_order_tbl(x_tmp1) := 6;
7675 END IF;
7676 IF l_item_pri > 0 THEN
7677 x_tmp1:= l_item_pri + 1;
7678 X_order_tbl(x_tmp1) := 7;
7679 END IF;
7680 IF l_customer_pri > 0 THEN
7681 x_tmp1:= l_customer_pri + 1;
7682 X_order_tbl(x_tmp1) := 8;
7683 END IF;
7684 IF l_vendor_pri > 0 THEN
7685 x_tmp1:= l_vendor_pri + 1;
7686 X_order_tbl(x_tmp1) := 9;
7687 END IF;
7688 IF l_tax_auth_pri > 0 THEN
7689 x_tmp1:= l_tax_auth_pri + 1;
7690 X_order_tbl(x_tmp1) := 10;
7691 END IF;
7692 IF l_charge_pri > 0 THEN
7693 x_tmp1:= l_charge_pri + 1;
7694 X_order_tbl(x_tmp1) := 11;
7695 END IF;
7696 IF l_currency_code_pri > 0 THEN
7697 x_tmp1:= l_currency_code_pri + 1;
7698 X_order_tbl(x_tmp1) := 12;
7699 END IF;
7700 IF l_reason_code_pri > 0 THEN
7701 x_tmp1:= l_reason_code_pri + 1;
7702 X_order_tbl(x_tmp1) := 13;
7703 END IF;
7704 IF l_routing_pri > 0 THEN
7705 x_tmp1:= l_routing_pri + 1;
7706 X_order_tbl(x_tmp1) := 14;
7707 END IF;
7708 IF l_aqui_cost_code_pri > 0 THEN
7709 x_tmp1:= l_aqui_cost_code_pri + 1;
7710 X_order_tbl(x_tmp1) := 15;
7711 END IF;
7712 IF l_resource_pri > 0 THEN
7713 x_tmp1:= l_resource_pri + 1;
7714 X_order_tbl(x_tmp1) := 16;
7715 END IF;
7716 IF l_cost_cmpntcls_pri > 0 THEN
7717 x_tmp1:= l_cost_cmpntcls_pri + 1;
7718 X_order_tbl(x_tmp1) := 17;
7719 END IF;
7720 IF l_cost_analysis_pri > 0 THEN
7721 x_tmp1:= l_cost_analysis_pri + 1;
7722 X_order_tbl(x_tmp1) := 18;
7723 END IF;
7724 IF l_order_type_pri > 0 THEN
7725 x_tmp1:= l_order_type_pri + 1;
7726 X_order_tbl(x_tmp1) := 19;
7727 END IF;
7728 IF l_gl_business_class_pri > 0 THEN
7729 x_tmp1:= l_gl_business_class_pri + 1;
7730 X_order_tbl(x_tmp1) := 20;
7731 END IF;
7732 IF l_gl_product_line_pri > 0 THEN
7733 x_tmp1:= l_gl_product_line_pri + 1;
7734 X_order_tbl(x_tmp1) := 21;
7735 END IF;
7736 IF l_line_type_pri > 0 THEN
7737 x_tmp1:= l_line_type_pri + 1;
7738 X_order_tbl(x_tmp1) := 22;
7739 END IF;
7740 IF l_ar_trx_type_pri > 0 THEN
7741 x_tmp1:= l_ar_trx_type_pri + 1;
7742 X_order_tbl(x_tmp1) := 23;
7743 END IF;
7744 END IF;
7745 FOR z IN 2..23 LOOP
7746 IF X_order_tbl(z) > 0 THEN
7747 X_my_order_by := X_my_order_by||', '||to_char(x_order_tbl(z))||' NULLS LAST ';
7748 END IF;
7749 END LOOP;
7750 X_sqlcolumns:= ' SELECT a.co_code,
7751 a.orgn_code,
7752 a.whse_code,
7753 a.gl_category_id,
7754 a.custgl_class,
7755 a.vendgl_class,
7756 a.item_id,
7757 a.cust_id,
7758 a.vendor_id,
7759 a.taxauth_id,
7760 a.charge_id,
7761 a.currency_code,
7762 a.reason_code,
7763 a.routing_id,
7764 a.aqui_cost_id,
7765 a.resources,
7766 a.cost_cmpntcls_id,
7767 a.cost_analysis_code,
7768 a.order_type,
7769 a.gl_business_class_cat_id,
7770 a.gl_product_line_cat_id,
7771 a.line_type,
7772 a.ar_trx_type_id,
7773 b.acct_id,
7774 b.acct_no,
7775 NVL(c.inventory_org_ind,''N'') inventory_org_ind,
7776 NVL(d.subinventory_ind_flag,''N'') subinventory_ind_flag,
7777 a.ROWID,
7778 a.source_type,
7779 c.organization_id,
7780 d.mtl_organization_id ';
7781 X_sqlwhere := ' WHERE a.acct_ttl_type = :p_acct_ttl_type
7782 AND a.co_code = :p_co_code
7783 AND a.co_code = b.co_code
7784 AND a.acct_id = b.acct_id
7785
7786 AND a.delete_mark = 0 /* Bug 9765910 */
7787 AND c.orgn_code(+) = a.orgn_code
7788 AND d.whse_code(+) = a.whse_code
7789 AND a.taxauth_id IS NULL
7790 AND a.charge_id IS NULL
7791 AND nvl(a.migrated_ind,0) <> 1 ';
7792 X_sqlordby:= X_my_order_by;
7793 BEGIN
7794 EXECUTE IMMEDIATE X_sqlcolumns ||
7795 ' FROM gl_acct_map a,
7796 gl_acct_mst b,
7797 sy_orgn_mst c,
7798 ic_whse_mst d '
7799 ||
7800 X_sqlwhere
7801 ||
7802 X_sqlordby
7803 BULK COLLECT INTO l_co_code,
7804 l_orgn_code,
7805 l_whse_code,
7806 l_gl_category_id,
7807 l_custgl_class,
7808 l_vendgl_class,
7809 l_item_id,
7810 l_cust_id,
7811 l_vendor_id,
7812 l_taxauth_id,
7813 l_charge_id,
7814 l_currency_code,
7815 l_reason_code,
7816 l_routing_id,
7817 l_aqui_cost_id,
7818 l_resources,
7819 l_cost_cmpntcls_id,
7820 l_cost_analysis_code,
7821 l_order_type,
7822 l_gl_business_class_cat_id,
7823 l_gl_product_line_cat_id,
7824 l_line_type,
7825 l_ar_trx_type_id,
7826 l_acct_id,
7827 l_acct_no,
7828 l_inventory_org_ind,
7829 l_subinventory_ind_flag,
7830 l_rowid,
7831 l_source_type,
7832 l_organization_id,
7833 l_mtl_organization_id
7834 USING k.acct_ttl_type,
7835 i.co_code;
7836 EXCEPTION
7837 WHEN no_data_found THEN
7838 NULL;
7839 END;
7840 IF nvl(l_rowid.count,0) > 0 THEN
7841 <<GL_ACCT_MAP>>
7842 FOR m in l_rowid.FIRST..l_rowid.LAST LOOP
7843 SELECT substrb(a, decode(b-1, 0, 1, instr(a, c, 1, (b-1))+ 1), decode(instr(a, c, 1, b), 0, (length(a) - instr(a, c, 1, (b-1))+ 1), (instr(a, c, 1, b)) - decode(b-1, 0, 1, instr(a, c, 1, (b-1))+ 1)))
7844 INTO l_segment_value
7845 FROM (
7846 SELECT l_acct_no(m) a,
7847 (j.segment_no - l_acctg_unit_count) b,
7848 i.segment_delimiter c
7849 FROM dual
7850 );
7851 /***************************************
7852 * Loading XLA_RULE_DETAILS_T Structure *
7853 ***************************************/
7854 BEGIN
7855 SELECT NVL(MAX(nvl(user_sequence,0)) + 10,10)
7856 INTO l_adr_priority
7857 FROM xla_rule_details_t
7858 WHERE application_id = G_Application_id
7859 AND segment_rule_code = l_adr_rule_code
7860 AND amb_context_code = l_amb_context;
7861 EXCEPTION
7862 WHEN no_data_found THEN
7863 l_adr_priority := 10;
7864 END;
7865 l_segment_rule_detail_id := NULL;
7866 INSERT INTO xla_rule_details_t
7867 (
7868 APPLICATION_ID,
7869 AMB_CONTEXT_CODE,
7870 SEGMENT_RULE_TYPE_CODE,
7871 SEGMENT_RULE_CODE,
7872 SEGMENT_RULE_DETAIL_ID,
7873 USER_SEQUENCE,
7874 VALUE_TYPE_CODE,
7875 VALUE_SOURCE_APPLICATION_ID,
7876 VALUE_SOURCE_TYPE_CODE,
7877 VALUE_SOURCE_CODE,
7878 VALUE_CONSTANT,
7879 VALUE_CODE_COMBINATION_ID,
7880 VALUE_MAPPING_SET_CODE,
7881 VALUE_FLEXFIELD_SEGMENT_CODE,
7882 INPUT_SOURCE_APPLICATION_ID,
7883 INPUT_SOURCE_TYPE_CODE,
7884 INPUT_SOURCE_CODE,
7885 VALUE_SEGMENT_RULE_APPL_ID,
7886 VALUE_SEGMENT_RULE_TYPE_CODE,
7887 VALUE_SEGMENT_RULE_CODE,
7888 VALUE_ADR_VERSION_NUM,
7889 ERROR_VALUE
7890 )
7891 VALUES
7892 (
7893 G_Application_id,
7894 l_amb_context,
7895 'C',
7896 l_adr_rule_code,
7897 xla_seg_rule_details_s.NEXTVAL,
7898 l_adr_priority,
7899 'C',
7900 NULL,
7901 NULL,
7902 NULL,
7903 l_segment_value,
7904 NULL,
7905 NULL,
7906 NULL,
7907 NULL,
7908 NULL,
7909 NULL,
7910 NULL,
7911 NULL,
7912 NULL,
7913 NULL,
7914 0
7915 ) returning segment_rule_detail_id INTO l_segment_rule_detail_id;
7916 IF l_segment_rule_detail_id IS NOT NULL THEN
7917 insert_conditions (
7918 p_condition_tag => 'FIRST',
7919 p_sequence => l_adr_condition_priority,
7920 p_source => G_Journal_Line_Type,
7921 p_comparision_operator => G_Equal,
7922 p_value_type => G_constant,
7923 p_value => k.acct_ttl_code,
7924 p_logical_operator => G_And,
7925 p_segment_rule_detail_id => l_segment_rule_detail_id
7926 );
7927 insert_conditions (
7928 p_condition_tag => 'MID',
7929 p_sequence => l_adr_condition_priority,
7930 p_source => G_ledger_id,
7931 p_comparision_operator => G_Equal,
7932 p_value_type => G_constant,
7933 p_value => i.ledger_id,
7934 p_logical_operator => G_And,
7935 p_segment_rule_detail_id => l_segment_rule_detail_id
7936 );
7937 insert_conditions (
7938 p_condition_tag => 'MID',
7939 p_sequence => l_adr_condition_priority,
7940 p_source => G_legal_entity,
7941 p_comparision_operator => G_Equal,
7942 p_value_type => G_constant,
7943 p_value => i.legal_entity_id,
7944 p_logical_operator => G_And,
7945 p_segment_rule_detail_id => l_segment_rule_detail_id
7946 );
7947 IF l_gl_category_id(m) IS NOT NULL THEN
7948 insert_conditions (
7949 p_condition_tag => 'MID',
7950 p_sequence => l_adr_condition_priority,
7951 p_source => G_gl_category_id,
7952 p_comparision_operator => G_Equal,
7953 p_value_type => G_constant,
7954 p_value => l_gl_category_id(m),
7955 p_logical_operator => G_And,
7956 p_segment_rule_detail_id => l_segment_rule_detail_id
7957 );
7958 END IF;
7959 IF l_custgl_class(m) IS NOT NULL THEN
7960 insert_conditions (
7961 p_condition_tag => 'MID',
7962 p_sequence => l_adr_condition_priority,
7963 p_source => G_custgl_class,
7964 p_comparision_operator => G_Equal,
7965 p_value_type => G_constant,
7966 p_value => l_custgl_class(m),
7967 p_logical_operator => G_And,
7968 p_segment_rule_detail_id => l_segment_rule_detail_id
7969 );
7970 END IF;
7971 IF l_vendgl_class(m) IS NOT NULL THEN
7972 insert_conditions (
7973 p_condition_tag => 'MID',
7974 p_sequence => l_adr_condition_priority,
7975 p_source => G_vendgl_class,
7976 p_comparision_operator => G_Equal,
7977 p_value_type => G_constant,
7978 p_value => l_vendgl_class(m),
7979 p_logical_operator => G_And,
7980 p_segment_rule_detail_id => l_segment_rule_detail_id
7981 );
7982 END IF;
7983 IF l_item_id(m) IS NOT NULL THEN
7984 l_inventory_item_id := gmf_migration.get_inventory_item_id(p_item_id => l_item_id(m));
7985 IF l_inventory_item_id IS NOT NULL THEN
7986 insert_conditions (
7987 p_condition_tag => 'MID',
7988 p_sequence => l_adr_condition_priority,
7989 p_source => G_Inventory_item_id,
7990 p_comparision_operator => G_Equal,
7991 p_value_type => G_constant,
7992 p_value => l_inventory_item_id,
7993 p_logical_operator => G_And,
7994 p_segment_rule_detail_id => l_segment_rule_detail_id
7995 );
7996 END IF;
7997 END IF;
7998 IF l_cust_id(m) IS NOT NULL THEN
7999 insert_conditions (
8000 p_condition_tag => 'MID',
8001 p_sequence => l_adr_condition_priority,
8002 p_source => G_customer,
8003 p_comparision_operator => G_Equal,
8004 p_value_type => G_constant,
8005 p_value => l_cust_id(m),
8006 p_logical_operator => G_And,
8007 p_segment_rule_detail_id => l_segment_rule_detail_id
8008 );
8009 END IF;
8010 IF l_vendor_id(m) IS NOT NULL THEN
8011 l_vendor_site_id := Get_Vendor_id (p_vendor_id => l_vendor_id(m));
8012 IF l_vendor_site_id IS NOT NULL THEN
8013 insert_conditions (
8014 p_condition_tag => 'MID',
8015 p_sequence => l_adr_condition_priority,
8016 p_source => G_vendor,
8017 p_comparision_operator => G_Equal,
8018 p_value_type => G_constant,
8019 p_value => l_vendor_site_id,
8020 p_logical_operator => G_And,
8021 p_segment_rule_detail_id => l_segment_rule_detail_id
8022 );
8023 END IF;
8024 END IF;
8025 IF l_currency_code(m) IS NOT NULL THEN
8026 insert_conditions (
8027 p_condition_tag => 'MID',
8028 p_sequence => l_adr_condition_priority,
8029 p_source => G_currency_code,
8030 p_comparision_operator => G_Equal,
8031 p_value_type => G_constant,
8032 p_value => l_currency_code(m),
8033 p_logical_operator => G_And,
8034 p_segment_rule_detail_id => l_segment_rule_detail_id
8035 );
8036 END IF;
8037 IF l_reason_code(m) IS NOT NULL THEN
8038 l_reason_id := gmf_migration.Get_reason_id(p_reason_code => l_reason_code(m));
8039 IF l_reason_id IS NOT NULL THEN
8040 insert_conditions (
8041 p_condition_tag => 'MID',
8042 p_sequence => l_adr_condition_priority,
8043 p_source => G_reason_id,
8044 p_comparision_operator => G_Equal,
8045 p_value_type => G_constant,
8046 p_value => l_reason_id,
8047 p_logical_operator => G_And,
8048 p_segment_rule_detail_id => l_segment_rule_detail_id
8049 );
8050 END IF;
8051 END IF;
8052 IF l_routing_id(m) IS NOT NULL THEN
8053 insert_conditions (
8054 p_condition_tag => 'MID',
8055 p_sequence => l_adr_condition_priority,
8056 p_source => G_routing_id,
8057 p_comparision_operator => G_Equal,
8058 p_value_type => G_constant,
8059 p_value => l_routing_id(m),
8060 p_logical_operator => G_And,
8061 p_segment_rule_detail_id => l_segment_rule_detail_id
8062 );
8063 END IF;
8064 IF l_aqui_cost_id(m) IS NOT NULL THEN
8065 l_price_element_type_id := gmf_migration.Get_price_element_type_id(p_aqui_cost_id => l_aqui_cost_id(m));
8066 IF l_price_element_type_id IS NOT NULL THEN
8067 insert_conditions (
8068 p_condition_tag => 'MID',
8069 p_sequence => l_adr_condition_priority,
8070 p_source => G_price_element_type_id,
8071 p_comparision_operator => G_Equal,
8072 p_value_type => G_constant,
8073 p_value => l_price_element_type_id,
8074 p_logical_operator => G_And,
8075 p_segment_rule_detail_id => l_segment_rule_detail_id
8076 );
8077 END IF;
8078 END IF;
8079 IF l_resources(m) IS NOT NULL THEN
8080 insert_conditions (
8081 p_condition_tag => 'MID',
8082 p_sequence => l_adr_condition_priority,
8083 p_source => G_resources,
8084 p_comparision_operator => G_Equal,
8085 p_value_type => G_constant,
8086 p_value => l_resources(m),
8087 p_logical_operator => G_And,
8088 p_segment_rule_detail_id => l_segment_rule_detail_id
8089 );
8090 END IF;
8091 IF l_cost_cmpntcls_id(m) IS NOT NULL THEN
8092 insert_conditions (
8093 p_condition_tag => 'MID',
8094 p_sequence => l_adr_condition_priority,
8095 p_source => G_cost_cmpntcls_id,
8096 p_comparision_operator => G_Equal,
8097 p_value_type => G_constant,
8098 p_value => l_cost_cmpntcls_id(m),
8099 p_logical_operator => G_And,
8100 p_segment_rule_detail_id => l_segment_rule_detail_id
8101 );
8102 END IF;
8103 IF l_cost_analysis_code(m) IS NOT NULL THEN
8104 insert_conditions (
8105 p_condition_tag => 'MID',
8106 p_sequence => l_adr_condition_priority,
8107 p_source => G_cost_analysis_code,
8108 p_comparision_operator => G_Equal,
8109 p_value_type => G_constant,
8110 p_value => l_cost_analysis_code(m),
8111 p_logical_operator => G_And,
8112 p_segment_rule_detail_id => l_segment_rule_detail_id
8113 );
8114 END IF;
8115 IF l_order_type(m) IS NOT NULL THEN
8116 insert_conditions (
8117 p_condition_tag => 'MID',
8118 p_sequence => l_adr_condition_priority,
8119 p_source => G_order_type,
8120 p_comparision_operator => G_Equal,
8121 p_value_type => G_constant,
8122 p_value => l_order_type(m),
8123 p_logical_operator => G_And,
8124 p_segment_rule_detail_id => l_segment_rule_detail_id
8125 );
8126 END IF;
8127 IF l_gl_business_class_cat_id(m) IS NOT NULL THEN
8128 insert_conditions (
8129 p_condition_tag => 'MID',
8130 p_sequence => l_adr_condition_priority,
8131 p_source => G_gl_business_class_cat_id,
8132 p_comparision_operator => G_Equal,
8133 p_value_type => G_constant,
8134 p_value => l_gl_business_class_cat_id(m),
8135 p_logical_operator => G_And,
8136 p_segment_rule_detail_id => l_segment_rule_detail_id
8137 );
8138 END IF;
8139 IF l_gl_product_line_cat_id(m) IS NOT NULL THEN
8140 insert_conditions (
8141 p_condition_tag => 'MID',
8142 p_sequence => l_adr_condition_priority,
8143 p_source => G_gl_product_line_cat_id,
8144 p_comparision_operator => G_Equal,
8145 p_value_type => G_constant,
8146 p_value => l_gl_product_line_cat_id(m),
8147 p_logical_operator => G_And,
8148 p_segment_rule_detail_id => l_segment_rule_detail_id
8149 );
8150 END IF;
8151 IF l_line_type(m) IS NOT NULL THEN
8152 insert_conditions (
8153 p_condition_tag => 'MID',
8154 p_sequence => l_adr_condition_priority,
8155 p_source => G_line_type,
8156 p_comparision_operator => G_Equal,
8157 p_value_type => G_constant,
8158 p_value => l_line_type(m),
8159 p_logical_operator => G_And,
8160 p_segment_rule_detail_id => l_segment_rule_detail_id
8161 );
8162 END IF;
8163 IF l_ar_trx_type_id(m) IS NOT NULL THEN
8164 insert_conditions (
8165 p_condition_tag => 'MID',
8166 p_sequence => l_adr_condition_priority,
8167 p_source => G_ar_trx_type,
8168 p_comparision_operator => G_Equal,
8169 p_value_type => G_constant,
8170 p_value => l_ar_trx_type_id(m),
8171 p_logical_operator => G_And,
8172 p_segment_rule_detail_id => l_segment_rule_detail_id
8173 );
8174 END IF;
8175 IF l_orgn_code(m) IS NOT NULL THEN
8176 IF l_whse_code(m) IS NOT NULL AND nvl(l_subinventory_ind_flag(m),'N') = 'Y' AND NVL(l_inventory_org_ind(m),'N') = 'Y' THEN
8177 /************************************************************
8178 * OPM Organizations is Migrated as inventory Organization *
8179 ************************************************************/
8180 insert_conditions (
8181 p_condition_tag => 'MID',
8182 p_sequence => l_adr_condition_priority,
8183 p_source => G_Organization,
8184 p_comparision_operator => G_Equal,
8185 p_value_type => G_constant,
8186 p_value => l_organization_id(m),
8187 p_logical_operator => G_and,
8188 p_segment_rule_detail_id => l_segment_rule_detail_id
8189 );
8190 /*******************************************************************
8191 * Warehouse Code Is specified and is migrated as subinventories *
8192 *******************************************************************/
8193 insert_conditions (
8194 p_condition_tag => 'LAST',
8195 p_sequence => l_adr_condition_priority,
8196 p_source => G_subinventory,
8197 p_comparision_operator => G_Equal,
8198 p_value_type => G_constant,
8199 p_value => l_whse_code(m),
8200 p_logical_operator => NULL,
8201 p_segment_rule_detail_id => l_segment_rule_detail_id
8202 );
8203 ELSIF l_whse_code(m) IS NOT NULL AND nvl(l_subinventory_ind_flag(m),'N') <> 'Y' THEN
8204 insert_conditions (
8205 p_condition_tag => 'LAST',
8206 p_sequence => l_adr_condition_priority,
8207 p_source => G_Organization,
8208 p_comparision_operator => G_Equal,
8209 p_value_type => G_constant,
8210 p_value => l_mtl_organization_id(m),
8211 p_logical_operator => G_and,
8212 p_segment_rule_detail_id => l_segment_rule_detail_id
8213 );
8214 ELSE
8215 l_old_segment_rule_detail_id := l_segment_rule_detail_id;
8216 l_old_adr_condition_priority := l_adr_condition_priority;
8217 mcnt := 1;
8218 <<WAREHOUSE_ACCOUNT>>
8219 FOR n IN cur_whse_acct(l_orgn_code(m), i.co_code, l_acct_id(m)) LOOP
8220 IF n.mtl_organization_id <> nvl(l_organization_id(m), -1) THEN
8221 IF mcnt > 1 THEN
8222 BEGIN
8223 SELECT NVL(MAX(nvl(user_sequence,0)) + 10,10)
8224 INTO l_adr_priority
8225 FROM xla_rule_details_t
8226 WHERE application_id = G_Application_id
8227 AND segment_rule_code = l_adr_rule_code
8228 AND amb_context_code = l_amb_context;
8229 EXCEPTION
8230 WHEN no_data_found THEN
8231 l_adr_priority := 10;
8232 END;
8233 INSERT INTO xla_rule_details_t
8234 (
8235 APPLICATION_ID,
8236 AMB_CONTEXT_CODE,
8237 SEGMENT_RULE_TYPE_CODE,
8238 SEGMENT_RULE_CODE,
8239 SEGMENT_RULE_DETAIL_ID,
8240 USER_SEQUENCE,
8241 VALUE_TYPE_CODE,
8242 VALUE_SOURCE_APPLICATION_ID,
8243 VALUE_SOURCE_TYPE_CODE,
8244 VALUE_SOURCE_CODE,
8245 VALUE_CONSTANT,
8246 VALUE_CODE_COMBINATION_ID,
8247 VALUE_MAPPING_SET_CODE,
8248 VALUE_FLEXFIELD_SEGMENT_CODE,
8249 INPUT_SOURCE_APPLICATION_ID,
8250 INPUT_SOURCE_TYPE_CODE,
8251 INPUT_SOURCE_CODE,
8252 VALUE_SEGMENT_RULE_APPL_ID,
8253 VALUE_SEGMENT_RULE_TYPE_CODE,
8254 VALUE_SEGMENT_RULE_CODE,
8255 VALUE_ADR_VERSION_NUM,
8256 ERROR_VALUE
8257 )
8258 VALUES
8259 (
8260 G_Application_id,
8261 l_amb_context,
8262 'C',
8263 l_adr_rule_code,
8264 xla_seg_rule_details_s.NEXTVAL,
8265 l_adr_priority,
8266 'C',
8267 NULL,
8268 NULL,
8269 NULL,
8270 l_segment_value,
8271 NULL,
8272 NULL,
8273 NULL,
8274 NULL,
8275 NULL,
8276 NULL,
8277 NULL,
8278 NULL,
8279 NULL,
8280 NULL,
8281 0
8282 ) returning segment_rule_detail_id INTO l_segment_rule_detail_id;
8283 INSERT INTO xla_conditions_t
8284 (
8285 CONDITION_ID,
8286 APPLICATION_ID,
8287 AMB_CONTEXT_CODE,
8288 SEGMENT_RULE_DETAIL_ID,
8289 USER_SEQUENCE,
8290 BRACKET_LEFT_CODE,
8291 BRACKET_RIGHT_CODE,
8292 VALUE_TYPE_CODE,
8293 SOURCE_APPLICATION_ID,
8294 SOURCE_TYPE_CODE,
8295 SOURCE_CODE,
8296 FLEXFIELD_SEGMENT_CODE,
8297 VALUE_FLEXFIELD_SEGMENT_CODE,
8298 VALUE_SOURCE_APPLICATION_ID,
8299 VALUE_SOURCE_TYPE_CODE,
8300 VALUE_SOURCE_CODE,
8301 VALUE_CONSTANT,
8302 LINE_OPERATOR_CODE,
8303 LOGICAL_OPERATOR_CODE,
8304 INDEPENDENT_VALUE_CONSTANT,
8305 ERROR_VALUE
8306 )
8307 (
8308 SELECT xla_conditions_s.NEXTVAL,
8309 APPLICATION_ID,
8310 AMB_CONTEXT_CODE,
8311 l_segment_rule_detail_id,
8312 USER_SEQUENCE,
8313 BRACKET_LEFT_CODE,
8314 BRACKET_RIGHT_CODE,
8315 VALUE_TYPE_CODE,
8316 SOURCE_APPLICATION_ID,
8317 SOURCE_TYPE_CODE,
8318 SOURCE_CODE,
8319 FLEXFIELD_SEGMENT_CODE,
8320 VALUE_FLEXFIELD_SEGMENT_CODE,
8321 VALUE_SOURCE_APPLICATION_ID,
8322 VALUE_SOURCE_TYPE_CODE,
8323 VALUE_SOURCE_CODE,
8324 VALUE_CONSTANT,
8325 LINE_OPERATOR_CODE,
8326 LOGICAL_OPERATOR_CODE,
8327 INDEPENDENT_VALUE_CONSTANT,
8328 ERROR_VALUE
8329 FROM xla_conditions_t
8330 WHERE segment_rule_detail_id = l_old_segment_rule_detail_id
8331 AND amb_context_code = l_amb_context
8332 AND user_sequence <= l_old_adr_condition_priority
8333 );
8334 l_adr_condition_priority := l_old_adr_condition_priority;
8335 END IF;
8336 IF nvl(n.subinventory_ind_flag,'N') = 'Y' THEN
8337 /************************************************************
8338 * OPM Organizations is Migrated as inventory Organization *
8339 ************************************************************/
8340 insert_conditions (
8341 p_condition_tag => 'MID',
8342 p_sequence => l_adr_condition_priority,
8343 p_source => G_Organization,
8344 p_comparision_operator => G_Equal,
8345 p_value_type => G_constant,
8346 p_value => l_organization_id(m),
8347 p_logical_operator => G_and,
8348 p_segment_rule_detail_id => l_segment_rule_detail_id
8349 );
8350 /*******************************************************************
8351 * Warehouse Code Is specified and is migrated as subinventories *
8352 *******************************************************************/
8353 insert_conditions (
8354 p_condition_tag => 'LAST',
8355 p_sequence => l_adr_condition_priority,
8356 p_source => G_subinventory,
8357 p_comparision_operator => G_Equal,
8358 p_value_type => G_constant,
8359 p_value => n.whse_code,
8360 p_logical_operator => NULL,
8361 p_segment_rule_detail_id => l_segment_rule_detail_id
8362 );
8363 ELSIF nvl(n.subinventory_ind_flag,'N') <> 'Y' THEN
8364 insert_conditions (
8365 p_condition_tag => 'LAST',
8366 p_sequence => l_adr_condition_priority,
8367 p_source => G_Organization,
8368 p_comparision_operator => G_Equal,
8369 p_value_type => G_constant,
8370 p_value => n.mtl_organization_id,
8371 p_logical_operator => G_and,
8372 p_segment_rule_detail_id => l_segment_rule_detail_id
8373 );
8374 END IF;
8375 mcnt := nvl(mcnt,1) + 1;
8376 END IF;
8377 END LOOP WAREHOUSE_ACCOUNT;
8378 IF NVL(l_inventory_org_ind(m),'N') = 'Y' AND nvl(mcnt, 1) > 1 THEN
8379 BEGIN
8380 SELECT NVL(MAX(nvl(user_sequence,0)) + 10,10)
8381 INTO l_adr_priority
8382 FROM xla_rule_details_t
8383 WHERE application_id = G_Application_id
8384 AND segment_rule_code = l_adr_rule_code
8385 AND amb_context_code = l_amb_context;
8386 EXCEPTION
8387 WHEN no_data_found THEN
8388 l_adr_priority := 10;
8389 END;
8390 l_segment_rule_detail_id := NULL;
8391 INSERT INTO xla_rule_details_t
8392 (
8393 APPLICATION_ID,
8394 AMB_CONTEXT_CODE,
8395 SEGMENT_RULE_TYPE_CODE,
8396 SEGMENT_RULE_CODE,
8397 SEGMENT_RULE_DETAIL_ID,
8398 USER_SEQUENCE,
8399 VALUE_TYPE_CODE,
8400 VALUE_SOURCE_APPLICATION_ID,
8401 VALUE_SOURCE_TYPE_CODE,
8402 VALUE_SOURCE_CODE,
8403 VALUE_CONSTANT,
8404 VALUE_CODE_COMBINATION_ID,
8405 VALUE_MAPPING_SET_CODE,
8406 VALUE_FLEXFIELD_SEGMENT_CODE,
8407 INPUT_SOURCE_APPLICATION_ID,
8408 INPUT_SOURCE_TYPE_CODE,
8409 INPUT_SOURCE_CODE,
8410 VALUE_SEGMENT_RULE_APPL_ID,
8411 VALUE_SEGMENT_RULE_TYPE_CODE,
8412 VALUE_SEGMENT_RULE_CODE,
8413 VALUE_ADR_VERSION_NUM,
8414 ERROR_VALUE
8415 )
8416 VALUES
8417 (
8418 G_Application_id,
8419 l_amb_context,
8420 'C',
8421 l_adr_rule_code,
8422 xla_seg_rule_details_s.NEXTVAL,
8423 l_adr_priority,
8424 'C',
8425 NULL,
8426 NULL,
8427 NULL,
8428 l_segment_value,
8429 NULL,
8430 NULL,
8431 NULL,
8432 NULL,
8433 NULL,
8434 NULL,
8435 NULL,
8436 NULL,
8437 NULL,
8438 NULL,
8439 0
8440 ) returning segment_rule_detail_id INTO l_segment_rule_detail_id;
8441 INSERT INTO xla_conditions_t
8442 (
8443 CONDITION_ID,
8444 APPLICATION_ID,
8445 AMB_CONTEXT_CODE,
8446 SEGMENT_RULE_DETAIL_ID,
8447 USER_SEQUENCE,
8448 BRACKET_LEFT_CODE,
8449 BRACKET_RIGHT_CODE,
8450 VALUE_TYPE_CODE,
8451 SOURCE_APPLICATION_ID,
8452 SOURCE_TYPE_CODE,
8453 SOURCE_CODE,
8454 FLEXFIELD_SEGMENT_CODE,
8455 VALUE_FLEXFIELD_SEGMENT_CODE,
8456 VALUE_SOURCE_APPLICATION_ID,
8457 VALUE_SOURCE_TYPE_CODE,
8458 VALUE_SOURCE_CODE,
8459 VALUE_CONSTANT,
8460 LINE_OPERATOR_CODE,
8461 LOGICAL_OPERATOR_CODE,
8462 INDEPENDENT_VALUE_CONSTANT,
8463 ERROR_VALUE
8464 )
8465 (
8466 SELECT xla_conditions_s.NEXTVAL,
8467 APPLICATION_ID,
8468 AMB_CONTEXT_CODE,
8469 l_segment_rule_detail_id,
8470 USER_SEQUENCE,
8471 BRACKET_LEFT_CODE,
8472 BRACKET_RIGHT_CODE,
8473 VALUE_TYPE_CODE,
8474 SOURCE_APPLICATION_ID,
8475 SOURCE_TYPE_CODE,
8476 SOURCE_CODE,
8477 FLEXFIELD_SEGMENT_CODE,
8478 VALUE_FLEXFIELD_SEGMENT_CODE,
8479 VALUE_SOURCE_APPLICATION_ID,
8480 VALUE_SOURCE_TYPE_CODE,
8481 VALUE_SOURCE_CODE,
8482 VALUE_CONSTANT,
8483 LINE_OPERATOR_CODE,
8484 LOGICAL_OPERATOR_CODE,
8485 INDEPENDENT_VALUE_CONSTANT,
8486 ERROR_VALUE
8487 FROM xla_conditions_t
8488 WHERE segment_rule_detail_id = l_old_segment_rule_detail_id
8489 AND amb_context_code = l_amb_context
8490 AND user_sequence <= l_old_adr_condition_priority
8491 );
8492 l_adr_condition_priority := l_old_adr_condition_priority;
8493 insert_conditions (
8494 p_condition_tag => 'LAST',
8495 p_sequence => l_adr_condition_priority,
8496 p_source => G_Organization,
8497 p_comparision_operator => G_Equal,
8498 p_value_type => G_constant,
8499 p_value => l_organization_id(m),
8500 p_logical_operator => G_and,
8501 p_segment_rule_detail_id => l_segment_rule_detail_id
8502 );
8503 ELSIF NVL(l_inventory_org_ind(m),'N') <> 'Y' THEN
8504 BEGIN
8505 UPDATE xla_conditions_t
8506 SET logical_operator_code = NULL
8507 WHERE user_sequence = l_adr_condition_priority
8508 AND segment_rule_detail_id = l_segment_rule_detail_id
8509 AND amb_context_code = l_amb_context;
8510 EXCEPTION
8511 WHEN OTHERS THEN
8512 NULL;
8513 END;
8514 ELSE
8515 insert_conditions (
8516 p_condition_tag => 'LAST',
8517 p_sequence => l_adr_condition_priority,
8518 p_source => G_Organization,
8519 p_comparision_operator => G_Equal,
8520 p_value_type => G_constant,
8521 p_value => l_organization_id(m),
8522 p_logical_operator => G_and,
8523 p_segment_rule_detail_id => l_segment_rule_detail_id
8524 );
8525 END IF;
8526 END IF;
8527 ELSE
8528 BEGIN
8529 UPDATE xla_conditions_t
8530 SET logical_operator_code = NULL
8531 WHERE user_sequence = l_adr_condition_priority
8532 AND segment_rule_detail_id = l_segment_rule_detail_id
8533 AND amb_context_code = l_amb_context;
8534 EXCEPTION
8535 WHEN OTHERS THEN
8536 NULL;
8537 END;
8538 END IF;
8539 END IF;
8540 END LOOP GL_ACCT_MAP;
8541 END IF;
8542 END IF;
8543 END LOOP POLICY_SEGMENTS;
8544 BEGIN
8545 UPDATE gl_acct_map
8546 SET migrated_ind = 1
8547 WHERE co_code = i.co_code
8548 AND delete_mark = 0 /* Bug 9765910 */
8549 AND acct_ttl_type = k.acct_ttl_type;
8550 EXCEPTION
8551 WHEN OTHERS THEN
8552 RAISE;
8553 END;
8554 END LOOP LEGAL_ENTITIES;
8555 END LOOP ACCOUNT_TITLE;
8556 BEGIN
8557 UPDATE GL_ACCU_MAP
8558 SET MIGRATED_IND = 1;
8559 EXCEPTION
8560 WHEN OTHERS THEN
8561 RAISE;
8562 END;
8563 /******************************************************
8564 * Upload Data IN XLA interface tables into XLA tables *
8565 ******************************************************/
8566 xla_adr_interface_pkg.upload_rules;
8567 /****************************************************************
8568 * Lets save the changes now based on the commit parameter *
8569 ****************************************************************/
8570 IF NVL(p_commit,'~') = FND_API.G_TRUE THEN
8571 COMMIT;
8572 END IF;
8573 /************************************
8574 * ADR Rules Migration Error Logging *
8575 ************************************/
8576 gmf_migration.G_Table_name := 'XLA_RULES_T';
8577 gmf_migration.G_context := 'GMF Error Logging';
8578 gmf_migration.Log_Errors (
8579 p_log_level => 1,
8580 p_from_rowid => NULL,
8581 p_to_rowid => NULL
8582 );
8583 /*******************************************
8584 * ADR Rule Details Migration Error Logging *
8585 *******************************************/
8586 gmf_migration.G_Table_name := 'XLA_RULE_DETAILS_T';
8587 gmf_migration.G_context := 'GMF Error Logging';
8588 gmf_migration.Log_Errors (
8589 p_log_level => 1,
8590 p_from_rowid => NULL,
8591 p_to_rowid => NULL
8592 );
8593 /*****************************************
8594 * ADR Conditions Migration Error Logging *
8595 *****************************************/
8596 gmf_migration.G_Table_name := 'XLA_CONDITIONS_T';
8597 gmf_migration.G_context := 'GMF Error Logging';
8598 gmf_migration.Log_Errors (
8599 p_log_level => 1,
8600 p_from_rowid => NULL,
8601 p_to_rowid => NULL
8602 );
8603 /***********************************************
8604 * ADR Line Assignments Migration Error Logging *
8605 ***********************************************/
8606 gmf_migration.G_Table_name := 'XLA_LINE_ASSGNS_T';
8607 gmf_migration.G_context := 'GMF Error Logging';
8608 gmf_migration.Log_Errors (
8609 p_log_level => 1,
8610 p_from_rowid => NULL,
8611 p_to_rowid => NULL
8612 );
8613 EXCEPTION
8614 WHEN OTHERS THEN
8615 /************************************************
8616 * Increment Failure Count for Failed Migrations *
8617 ************************************************/
8618 x_failure_count := x_failure_count + 1;
8619 /**************************************
8620 * Migration DB Error Log Message *
8621 **************************************/
8622 GMA_COMMON_LOGGING.gma_migration_central_log
8623 (
8624 p_run_id => G_migration_run_id,
8625 p_log_level => FND_LOG.LEVEL_ERROR,
8626 p_message_token => 'GMA_MIGRATION_DB_ERROR',
8627 p_table_name => G_Table_name,
8628 p_context => G_Context,
8629 p_db_error => SQLERRM,
8630 p_app_short_name => 'GMA'
8631 );
8632 /**************************************
8633 * Migration Failure Log Message *
8634 **************************************/
8635 GMA_COMMON_LOGGING.gma_migration_central_log
8636 (
8637 p_run_id => G_migration_run_id,
8638 p_log_level => FND_LOG.LEVEL_ERROR,
8639 p_message_token => 'GMA_TABLE_MIGRATION_TABLE_FAIL',
8640 p_table_name => G_Table_name,
8641 p_context => G_Context,
8642 p_db_error => NULL,
8643 p_app_short_name => 'GMA'
8644 );
8645 END Migrate_Account_Mappings;
8646
8647 /**********************************************************************
8648 * PROCEDURE: *
8649 * Migrate_Acquisition_codes *
8650 * *
8651 * DESCRIPTION: *
8652 * This PL/SQL procedure is used to migrate the Acquisition Codes *
8653 * *
8654 * PARAMETERS: *
8655 * P_migration_run_id - id to use to right to migration log *
8656 * x_exception_count - Number of exceptions occurred. *
8657 * *
8658 * SYNOPSIS: *
8659 * Migrate_Acquisition_Codes(p_migartion_id => l_migration_id, *
8660 * p_commit => 'T', *
8661 * x_exception_count => l_exception_count ); *
8662 * *
8663 * HISTORY *
8664 * 27-Apr-2005 Created Anand Thiyagarajan *
8665 * *
8666 **********************************************************************/
8667 PROCEDURE Migrate_Acquisition_Codes
8668 (
8669 P_migration_run_id IN NUMBER,
8670 P_commit IN VARCHAR2,
8671 X_failure_count OUT NOCOPY NUMBER
8672 )
8673 IS
8674
8675 /**************************
8676 * PL/SQL Table Definition *
8677 **************************/
8678
8679 TYPE t_rowid IS TABLE OF ROWID INDEX BY BINARY_INTEGER;
8680 TYPE t_price_element_type_id IS TABLE OF PO_COST_MST.PRICE_ELEMENT_TYPE_ID%TYPE INDEX BY BINARY_INTEGER;
8681 TYPE t_aqui_cost_code IS TABLE OF PO_COST_MST.AQUI_COST_CODE%TYPE INDEX BY BINARY_INTEGER;
8682 TYPE t_aqui_cost_desc IS TABLE OF PO_COST_MST.AQUI_COST_DESC%TYPE INDEX BY BINARY_INTEGER;
8683 TYPE t_cmpntcls_id IS TABLE OF PO_COST_MST.CMPNTCLS_ID%TYPE INDEX BY BINARY_INTEGER;
8684 TYPE t_analysis_code IS TABLE OF PO_COST_MST.ANALYSIS_CODE%TYPE INDEX BY BINARY_INTEGER;
8685 TYPE t_incl_ind IS TABLE OF PO_COST_MST.INCL_IND%TYPE INDEX BY BINARY_INTEGER;
8686
8687 /******************
8688 * Local Variables *
8689 ******************/
8690
8691 l_rowid t_rowid;
8692 l_aqui_cost_code t_aqui_cost_code;
8693 l_aqui_cost_desc t_aqui_cost_desc;
8694 l_cmpntcls_id t_cmpntcls_id;
8695 l_analysis_code t_analysis_code;
8696 l_incl_ind t_incl_ind;
8697 l_price_element_type_id t_price_element_type_id;
8698
8699 l_exception_count NUMBER := 0;
8700 l_pricing_basis VARCHAR2(10);
8701 l_cost_acquisition_code VARCHAR2(1);
8702 l_return_status VARCHAR2(1);
8703 l_msg_data VARCHAR2(2000);
8704 l_msg_count NUMBER;
8705 l_insert_update_flag VARCHAR2(10);
8706
8707 BEGIN
8708
8709 G_Migration_run_id := P_migration_run_id;
8710 G_Table_name := 'PO_COST_MST';
8711 G_Context := 'Acquisiton Codes Migration';
8712 X_failure_count := 0;
8713
8714 /********************************
8715 * Migration Started Log Message *
8716 ********************************/
8717
8718 GMA_COMMON_LOGGING.gma_migration_central_log
8719 (
8720 p_run_id => G_migration_run_id,
8721 p_log_level => FND_LOG.LEVEL_STATEMENT,
8722 p_message_token => 'GMA_MIGRATION_TABLE_STARTED',
8723 p_table_name => G_Table_name,
8724 p_context => G_context,
8725 p_db_error => NULL,
8726 p_app_short_name => 'GMA'
8727 );
8728
8729 SELECT ROWID,
8730 aqui_cost_code,
8731 aqui_cost_desc,
8732 cmpntcls_id,
8733 analysis_code,
8734 incl_ind
8735 BULK COLLECT INTO l_rowid,
8736 l_aqui_cost_code,
8737 l_aqui_cost_desc,
8738 l_cmpntcls_id,
8739 l_analysis_code,
8740 l_incl_ind
8741 FROM po_cost_mst
8742 WHERE price_element_type_id IS NULL;
8743
8744 l_pricing_basis := 'PER_UNIT';
8745
8746 IF SQL%FOUND THEN
8747
8748 FOR i IN l_rowid.FIRST..l_rowid.LAST LOOP
8749
8750 CASE l_incl_ind(i)
8751 WHEN 1 THEN
8752 l_cost_acquisition_code := 'I';
8753 WHEN 0 THEN
8754 l_cost_acquisition_code := 'E';
8755 ELSE
8756 l_cost_acquisition_code := 'I';
8757 END CASE;
8758
8759 PON_CF_TYPE_GRP.opm_create_update_cost_factor
8760 (
8761 p_api_version => 1.0
8762 , p_price_element_code => l_aqui_cost_code(i)
8763 , p_pricing_basis => 'PER_UNIT'
8764 , p_cost_component_class_id => l_cmpntcls_id(i)
8765 , p_cost_analysis_code => l_analysis_code(i)
8766 , p_cost_acquisition_code => l_cost_acquisition_code
8767 , p_name => l_aqui_cost_code(i)
8768 , p_description => l_aqui_cost_desc(i)
8769 , x_insert_update_action => l_insert_update_flag
8770 , x_price_element_type_id => l_price_element_type_id(i)
8771 , x_pricing_basis => l_pricing_basis
8772 , x_return_status => l_return_status
8773 , x_msg_data => l_msg_data
8774 , x_msg_count => l_msg_count
8775 );
8776
8777 END LOOP;
8778
8779 FORALL j IN indices OF l_rowid SAVE EXCEPTIONS
8780 UPDATE po_cost_mst
8781 SET migrated_ind = 1,
8782 price_element_type_id = l_price_element_type_id(j)
8783 WHERE ROWID = l_rowid(j)
8784 AND price_element_type_id IS NULL;
8785
8786 l_exception_count := nvl(l_exception_count,0) + SQL%BULK_EXCEPTIONS.COUNT;
8787
8788 FOR i IN 1..SQL%BULK_EXCEPTIONS.COUNT LOOP
8789
8790 /************************************************
8791 * Increment Failure Count for Failed Migrations *
8792 ************************************************/
8793
8794 x_failure_count := x_failure_count + 1;
8795
8796 /**************************************
8797 * Migration DB Error Log Message *
8798 **************************************/
8799
8800 GMA_COMMON_LOGGING.gma_migration_central_log
8801 (
8802 p_run_id => G_migration_run_id,
8803 p_log_level => FND_LOG.LEVEL_ERROR,
8804 p_message_token => 'GMA_MIGRATION_DB_ERROR',
8805 p_table_name => G_Table_name,
8806 p_context => G_context,
8807 p_db_error => SQLERRM(SQL%BULK_EXCEPTIONS(i).ERROR_CODE),
8808 p_app_short_name => 'GMA'
8809 );
8810
8811 /**************************************
8812 * Migration Failure Log Message *
8813 **************************************/
8814
8815 GMA_COMMON_LOGGING.gma_migration_central_log
8816 (
8817 p_run_id => G_migration_run_id,
8818 p_log_level => FND_LOG.LEVEL_ERROR,
8819 p_message_token => 'GMA_TABLE_MIGRATION_TABLE_FAIL',
8820 p_table_name => G_Table_name,
8821 p_context => G_context,
8822 p_app_short_name => 'GMA'
8823 );
8824
8825 END LOOP;
8826
8827 /**********************************************
8828 * Handle all the rows which were not migrated *
8829 **********************************************/
8830
8831 SELECT count(*)
8832 INTO x_failure_count
8833 FROM po_cost_mst
8834 WHERE price_element_type_id IS NULL;
8835
8836 IF nvl(x_failure_count,0) > 0 THEN
8837
8838 /**************************************
8839 * Migration Failure Log Message *
8840 **************************************/
8841
8842 GMA_COMMON_LOGGING.gma_migration_central_log
8843 (
8844 p_run_id => gmf_migration.G_migration_run_id,
8845 p_log_level => FND_LOG.LEVEL_PROCEDURE,
8846 p_message_token => 'GMA_TABLE_MIGRATION_TABLE_FAIL',
8847 p_table_name => gmf_migration.G_Table_name,
8848 p_context => gmf_migration.G_context,
8849 p_db_error => NULL,
8850 p_app_short_name => 'GMA'
8851 );
8852
8853 ELSE
8854
8855 /**************************************
8856 * Migration Success Log Message *
8857 **************************************/
8858
8859 GMA_COMMON_LOGGING.gma_migration_central_log
8860 (
8861 p_run_id => G_migration_run_id,
8862 p_log_level => FND_LOG.LEVEL_STATEMENT,
8863 p_message_token => 'GMA_MIGRATION_TABLE_SUCCESS',
8864 p_table_name => G_Table_name,
8865 p_context => G_Context,
8866 p_param1 => 1,
8867 p_param2 => 0,
8868 p_db_error => NULL,
8869 p_app_short_name => 'GMA'
8870 );
8871
8872 END IF;
8873
8874 /****************************************************************
8875 * Lets save the changes now based on the commit parameter *
8876 ****************************************************************/
8877
8878 IF NVL(p_commit,'~') = FND_API.G_TRUE THEN
8879 COMMIT;
8880 END IF;
8881
8882 END IF;
8883
8884 EXCEPTION
8885 WHEN OTHERS THEN
8886
8887 /************************************************
8888 * Increment Failure Count for Failed Migrations *
8889 ************************************************/
8890
8891 x_failure_count := x_failure_count + 1;
8892
8893 /**************************************
8894 * Migration DB Error Log Message *
8895 **************************************/
8896
8897 GMA_COMMON_LOGGING.gma_migration_central_log
8898 (
8899 p_run_id => G_migration_run_id,
8900 p_log_level => FND_LOG.LEVEL_ERROR,
8901 p_message_token => 'GMA_MIGRATION_DB_ERROR',
8902 p_table_name => G_Table_name,
8903 p_context => G_context,
8904 p_db_error => SQLERRM,
8905 p_app_short_name => 'GMA'
8906 );
8907
8908 /**************************************
8909 * Migration Failure Log Message *
8910 **************************************/
8911
8912 GMA_COMMON_LOGGING.gma_migration_central_log
8913 (
8914 p_run_id => G_migration_run_id,
8915 p_log_level => FND_LOG.LEVEL_ERROR,
8916 p_message_token => 'GMA_TABLE_MIGRATION_TABLE_FAIL',
8917 p_table_name => G_Table_name,
8918 p_context => G_context,
8919 p_db_error => NULL,
8920 p_app_short_name => 'GMA'
8921 );
8922
8923 END Migrate_Acquisition_Codes;
8924
8925 /**********************************************************************
8926 * PROCEDURE: *
8927 * Migrate_Period_Balances *
8928 * *
8929 * DESCRIPTION: *
8930 * This PL/SQL procedure is used to migrate the Period Balances *
8931 * *
8932 * PARAMETERS: *
8933 * P_migration_run_id - id to use to right to migration log *
8934 * x_exception_count - Number of exceptions occurred. *
8935 * *
8936 * SYNOPSIS: *
8937 * Migrate_Period_Balances(p_migartion_id => l_migration_id, *
8938 * p_commit => 'T', *
8939 * x_exception_count => l_exception_count ); *
8940 * *
8941 * HISTORY *
8942 * 27-Apr-2005 Created Anand Thiyagarajan *
8943 * *
8944 * 08-Mar-2011 Pramod B.H. Bug 10339562 *
8945 * It is observed that cursor "cur_orgn_periods" is fetching *
8946 * only warehouses under Orgn_codes which are same as co_code *
8947 * and is missing remaining warehouses under other orgn_codes *
8948 * witin the company. In 11i, as OPM inventory calendar periods *
8949 * (i.e ic_cldr_dtl) are maintained at Company level (and not *
8950 * at warehouse/orgn level), ic_cldr_dtl.orgn_code points to *
8951 * co_code. Hence Modified CURSOR cur_orgn_periods to join *
8952 * ic_cldr_dtl.orgn_code to sy_orgn_mst.co_code, so that it *
8953 * identifies all the organizations under the company and thus *
8954 * fetches all the warehouses under that company. *
8955 * *
8956 * 11-Apr-2012 Uday Phadtare Bug 13942118. *
8957 * Code modified so that data in gmf_period_balances gets *
8958 * populated correctly when ic_perd_bal has balances for the same *
8959 * lot in multiple locations. *
8960 **********************************************************************/
8961 PROCEDURE Migrate_Period_Balances
8962 (
8963 P_migration_run_id IN NUMBER,
8964 P_commit IN VARCHAR2,
8965 X_failure_count OUT NOCOPY NUMBER
8966 )
8967 IS
8968
8969 /**************************
8970 * PL/SQL Table Definition *
8971 **************************/
8972
8973 /******************
8974 * Local Variables *
8975 ******************/
8976
8977 l_perd_bal_count NUMBER := 0;
8978
8979 l_lot_number VARCHAR2(80); /* Bug 13045530 */
8980 l_parent_lot_number VARCHAR2(80); /* Bug 13045530 */
8981 l_failure_count NUMBER; /* Bug 13045530 */
8982
8983 /**********
8984 * Cursors *
8985 **********/
8986
8987 CURSOR cur_orgn_periods
8988 IS
8989 SELECT DISTINCT a.orgn_code,
8990 e.whse_code,
8991 NVL(e.subinventory_ind_flag,'N') subinventory_ind_flag,
8992 DECODE(NVL(e.subinventory_ind_flag,'N'), 'Y', e.organization_id, e.mtl_organization_id) organization_id,
8993 d.acct_period_id,
8994 d.period_start_date,
8995 d.schedule_close_date,
8996 b.period_id curr_period_id,
8997 b.period_end_date curr_period_end_date,
8998 c.period_id prior_period_id,
8999 c.period_end_date prior_period_end_date,
9000 c.closed_period_ind prior_period_closed_ind,
9001 c.fiscal_year prior_fiscal_year, /* Bug 13045530 */
9002 c.period prior_period /* Bug 13045530 */
9003 FROM sy_orgn_mst a,
9004 ic_cldr_dtl b,
9005 ic_cldr_dtl c,
9006 org_acct_periods d,
9007 hr_organization_information hoi,
9008 ic_whse_mst e,
9009 gl_ledgers f
9010 WHERE a.co_code = b.orgn_code /* Bug 10339562 - Changed a.orgn_code to a.co_code */
9011 AND c.orgn_code = a.co_code /* Bug 10339562 - Changed a.orgn_code to a.co_code */
9012 AND e.orgn_code = a.orgn_code
9013 AND d.organization_id = e.cost_organization_id
9014 AND hoi.organization_id = d.organization_id
9015 AND hoi.org_information_context = 'Accounting Information'
9016 AND hoi.org_information1 = f.ledger_id
9017 AND f.period_set_name = d.period_Set_name
9018 AND c.period_end_date = d.schedule_close_date
9019 AND nvl(c.closed_period_ind, 1) = 3
9020 AND b.period_end_date = (
9021 SELECT MIN(x.period_end_date)
9022 FROM ic_cldr_dtl x
9023 --WHERE a.orgn_code = x.orgn_code
9024 WHERE a.co_code = x.orgn_code -- Modified where condition as pr bug # 12372491
9025 AND SYSDATE < x.period_end_date
9026 )
9027 AND c.period_end_date = (
9028 SELECT MAX(y.period_end_date)
9029 FROM ic_cldr_dtl y
9030 --WHERE a.orgn_code = y.orgn_code
9031 WHERE a.co_code = y.orgn_code -- Modified where condition as pr bug # 12372491
9032 AND SYSDATE > y.period_end_Date
9033 );
9034
9035 /* Bug 13045530 - select lots that are NOT migrated */
9036 CURSOR cur_lots
9037 ( p_fiscal_year IN VARCHAR2,
9038 p_period IN NUMBER,
9039 p_whse_code IN VARCHAR2
9040 )
9041 IS
9042 SELECT fiscal_year,
9043 period,
9044 whse_code,
9045 item_id,
9046 lot_id,
9047 location
9048 FROM ic_perd_bal b
9049 WHERE b.fiscal_year = p_fiscal_year
9050 AND b.period = p_period
9051 AND b.whse_code = p_whse_code
9052 AND NOT EXISTS (
9053 SELECT 'X'
9054 FROM ic_lots_mst_mig c
9055 WHERE c.item_id = b.item_id
9056 AND c.lot_id = b.lot_id
9057 AND c.whse_code = b.whse_code
9058 /* AND c.location = b.location Bug 13942118 */
9059 )
9060 ;
9061
9062
9063 BEGIN
9064
9065 G_Migration_run_id := P_migration_run_id;
9066 G_Table_name := 'GMF_PERIOD_BALANCES';
9067 G_Context := 'Period Balances Migration';
9068 X_failure_count := 0;
9069
9070 /********************************
9071 * Migration Started Log Message *
9072 ********************************/
9073
9074 GMA_COMMON_LOGGING.gma_migration_central_log
9075 (
9076 p_run_id => G_migration_run_id,
9077 p_log_level => FND_LOG.LEVEL_STATEMENT,
9078 p_message_token => 'GMA_MIGRATION_TABLE_STARTED',
9079 p_table_name => G_Table_name,
9080 p_context => G_context,
9081 p_db_error => NULL,
9082 p_app_short_name => 'GMA'
9083 );
9084
9085 <<WAREHOUSES>>
9086 FOR i IN cur_orgn_periods LOOP
9087
9088 /* Bug 13045530 Migrate Lots */
9089
9090 <<LOTS>>
9091 FOR bal IN cur_lots(i.prior_fiscal_year, i.prior_period, i.whse_code) LOOP
9092
9093 /* call lot migration and get discrete lot number */
9094
9095 l_lot_number := NULL;
9096 l_parent_lot_number := NULL;
9097 l_failure_count := 0;
9098
9099 IF (bal.lot_id > 0) THEN -- Lot controlled item
9100 INV_OPM_Lot_Migration.get_ODM_lot (
9101 p_migration_run_id => gmf_migration.G_migration_run_id,
9102 p_item_id => bal.item_id,
9103 p_lot_id => bal.lot_id,
9104 p_whse_code => bal.whse_code,
9105 p_orgn_code => NULL,
9106 /* p_location => bal.location, Bug 13942118 */
9107 p_location => NULL, /* Bug 13942118 */
9108 p_commit => FND_API.G_TRUE,
9109 x_lot_number => l_lot_number,
9110 x_parent_lot_number => l_parent_lot_number,
9111 x_failure_count => l_failure_count);
9112
9113 IF (l_failure_count > 0) THEN
9114 -- Log Error
9115 -- dbms_output.put_line ('Failed to migrate lot = '||to_char(bal.lot_id)||', '||bal.whse_code||', '||bal.location);
9116 GMA_COMMON_LOGGING.gma_migration_central_log (
9117 p_run_id => gmf_migration.G_migration_run_id,
9118 p_log_level => FND_LOG.LEVEL_ERROR,
9119 p_message_token => 'GMI_MIG_LOT_MIG_FAILED',
9120 p_table_name => gmf_migration.G_Table_name,
9121 p_context => gmf_migration.G_context,
9122 p_param1 => INV_GMI_Migration.item(bal.item_id),
9123 p_param2 => INV_GMI_Migration.lot(bal.lot_id),
9124 p_param3 => bal.whse_code,
9125 /* p_param4 => bal.location, Bug 13942118 */
9126 p_param4 => NULL, /* Bug 13942118 */
9127 p_param5 => NULL,
9128 p_db_error => NULL,
9129 p_app_short_name => 'GMA');
9130 END IF;
9131 END IF;
9132
9133 END LOOP LOTS;
9134
9135
9136 /* Bug 13045530 Migrate Lots - End */
9137
9138 SELECT count(1)
9139 INTO l_perd_bal_count
9140 FROM ic_perd_bal
9141 WHERE whse_code = i.whse_code
9142 AND period_id = i.prior_period_id;
9143
9144 INSERT INTO gmf_period_balances
9145 (
9146 period_balance_id,
9147 acct_period_id,
9148 organization_id,
9149 cost_group_id,
9150 subinventory_code,
9151 inventory_item_id,
9152 lot_number,
9153 locator_id,
9154 primary_quantity,
9155 secondary_quantity,
9156 intransit_primary_quantity,
9157 intransit_secondary_quantity,
9158 accounted_value,
9159 intransit_accounted_value,
9160 costed_flag,
9161 creation_date,
9162 created_by,
9163 last_update_date,
9164 last_updated_by,
9165 last_update_login,
9166 request_id,
9167 program_application_id,
9168 program_id,
9169 program_update_date
9170 )
9171 (
9172 SELECT gmf_period_balances_s.NEXTVAL,
9173 acct_period_id,
9174 organization_id,
9175 cost_group_id,
9176 subinventory_code,
9177 inventory_item_id,
9178 lot_number,
9179 locator_id,
9180 primary_quantity,
9181 secondary_quantity,
9182 intransit_primary_quantity,
9183 intransit_secondary_quantity,
9184 accounted_value,
9185 intransit_accounted_value,
9186 costed_flag,
9187 creation_date,
9188 created_by,
9189 last_update_date,
9190 last_updated_by,
9191 last_update_login,
9192 request_id,
9193 program_application_id,
9194 program_id,
9195 program_update_date
9196 FROM
9197 (
9198 SELECT
9199 i.acct_period_id acct_period_id,
9200 i.organization_id organization_id,
9201 decode(i.subinventory_ind_flag, 'N', NULL, e.default_cost_group_id) cost_group_id,
9202 decode(i.subinventory_ind_flag, 'N', NULL, e.secondary_inventory_name) subinventory_code,
9203 b.inventory_item_id,
9204 c.lot_number,
9205 d.inventory_location_id locator_id,
9206 a.loct_onhand primary_quantity,
9207 a.loct_onhand2 secondary_quantity,
9208 0 intransit_primary_quantity,
9209 0 intransit_secondary_quantity,
9210 a.loct_value accounted_value,
9211 0 intransit_accounted_value,
9212 NULL costed_flag,
9213 SYSDATE creation_date,
9214 1 created_by,
9215 SYSDATE last_update_date,
9216 1 last_updated_by,
9217 1 last_update_login,
9218 NULL request_id,
9219 NULL program_application_id,
9220 NULL program_id,
9221 NULL program_update_date
9222 FROM ic_perd_bal a,
9223 ic_item_mst_b_mig b,
9224 /* ic_lots_mst_mig c, Bug 13942118 */
9225 (SELECT DISTINCT item_id, lot_id, whse_code, lot_number FROM ic_lots_mst_mig) c, /* Bug 13942118 */
9226 ic_loct_mst d,
9227 mtl_secondary_inventories e
9228 WHERE a.whse_code = i.whse_code
9229 AND a.period_id = i.prior_period_id
9230 AND b.organization_id = i.organization_id
9231 AND e.secondary_inventory_name(+) = i.whse_code
9232 AND e.organization_id(+) = i.organization_id
9233 AND b.item_id = a.item_id
9234 AND c.item_id = a.item_id
9235 AND c.lot_id = a.lot_id
9236 AND c.whse_code = a.whse_code
9237 /* AND c.location = a.location Bug 13942118 */
9238 AND d.whse_code = a.whse_code
9239 AND d.location = a.location
9240 AND a.lot_id <> 0 /* Bug 13045530 */
9241 AND NOT EXISTS (
9242 SELECT 'X'
9243 FROM gmf_period_balances x
9244 WHERE x.acct_period_id = i.acct_period_id
9245 AND x.organization_id = i.organization_id
9246 AND x.inventory_item_id = b.inventory_item_id
9247 AND nvl(x.subinventory_code, '~') = nvl(decode(i.subinventory_ind_flag, 'N', NULL, e.secondary_inventory_name), '~')
9248 AND nvl(x.lot_number,'~') = nvl(c.lot_number, '~')
9249 AND nvl(x.locator_id, -1) = nvl(d.inventory_location_id, -1)
9250 )
9251 UNION ALL /* Bug 13045530 - for non-lot controlled items */
9252 SELECT
9253 i.acct_period_id,
9254 i.organization_id,
9255 decode(i.subinventory_ind_flag, 'N', NULL, e.default_cost_group_id) cost_group_id,
9256 decode(i.subinventory_ind_flag, 'N', NULL, e.secondary_inventory_name) subinventory_code,
9257 b.inventory_item_id,
9258 NULL lot_number,
9259 d.inventory_location_id locator_id,
9260 a.loct_onhand primary_quantity,
9261 a.loct_onhand2 secondary_quantity,
9262 0 intransit_primary_quantity,
9263 0 intransit_secondary_quantity,
9264 a.loct_value accounted_value,
9265 0 intransit_accounted_value,
9266 NULL costed_flag,
9267 SYSDATE creation_date,
9268 1 created_by,
9269 SYSDATE last_update_date,
9270 1 last_updated_by,
9271 1 last_update_login,
9272 NULL request_id,
9273 NULL program_application_id,
9274 NULL program_id,
9275 NULL program_update_date
9276 FROM ic_perd_bal a,
9277 ic_item_mst_b_mig b,
9278 ic_loct_mst d,
9279 mtl_secondary_inventories e
9280 WHERE a.whse_code = i.whse_code
9281 AND a.period_id = i.prior_period_id
9282 AND b.organization_id = i.organization_id
9283 AND e.secondary_inventory_name(+) = i.whse_code
9284 AND e.organization_id(+) = i.organization_id
9285 AND b.item_id = a.item_id
9286 AND d.whse_code = a.whse_code
9287 AND d.location = a.location
9288 AND a.lot_id = 0 /* Bug 13045530 */
9289 AND NOT EXISTS (
9290 SELECT 'X'
9291 FROM gmf_period_balances x
9292 WHERE x.acct_period_id = i.acct_period_id
9293 AND x.organization_id = i.organization_id
9294 AND x.inventory_item_id = b.inventory_item_id
9295 AND nvl(x.subinventory_code, '~') = nvl(decode(i.subinventory_ind_flag, 'N', NULL, e.secondary_inventory_name), '~')
9296 AND nvl(x.locator_id, -1) = nvl(d.inventory_location_id, -1)
9297 )
9298 )
9299 );
9300
9301
9302 IF l_perd_bal_count = SQL%ROWCOUNT THEN
9303
9304 /**********************************************************************
9305 * Handle the periods for which the period balances have been migrated *
9306 **********************************************************************/
9307
9308 UPDATE org_acct_periods
9309 SET period_close_date = SYSDATE,
9310 open_flag = 'N',
9311 summarized_flag = 'Y'
9312 WHERE acct_period_id = i.prior_period_id
9313 AND organization_id = i.organization_id;
9314
9315 ELSE
9316
9317 /**********************************************
9318 * Handle all the rows which were not migrated *
9319 **********************************************/
9320
9321 SELECT count(*)
9322 INTO x_failure_count
9323 FROM ic_perd_bal
9324 WHERE whse_code = i.whse_code
9325 AND period_id = i.prior_period_id;
9326
9327 IF nvl(x_failure_count,0) > 0 THEN
9328
9329 /**************************************
9330 * Migration Failure Log Message *
9331 **************************************/
9332
9333 GMA_COMMON_LOGGING.gma_migration_central_log
9334 (
9335 p_run_id => gmf_migration.G_migration_run_id,
9336 p_log_level => FND_LOG.LEVEL_PROCEDURE,
9337 p_message_token => 'GMA_TABLE_MIGRATION_TABLE_FAIL',
9338 p_table_name => gmf_migration.G_Table_name,
9339 p_context => gmf_migration.G_context,
9340 p_db_error => NULL,
9341 p_app_short_name => 'GMA'
9342 );
9343
9344 ELSE
9345
9346 /**************************************
9347 * Migration Success Log Message *
9348 **************************************/
9349
9350 GMA_COMMON_LOGGING.gma_migration_central_log
9351 (
9352 p_run_id => G_migration_run_id,
9353 p_log_level => FND_LOG.LEVEL_STATEMENT,
9354 p_message_token => 'GMA_MIGRATION_TABLE_SUCCESS',
9355 p_table_name => G_Table_name,
9356 p_context => G_Context,
9357 p_param1 => 1,
9358 p_param2 => 0,
9359 p_db_error => NULL,
9360 p_app_short_name => 'GMA'
9361 );
9362
9363 END IF;
9364
9365 END IF;
9366
9367 END LOOP WAREHOUSES;
9368
9369 /**************************************
9370 * Migration Success Log Message *
9371 **************************************/
9372
9373 GMA_COMMON_LOGGING.gma_migration_central_log
9374 (
9375 p_run_id => G_migration_run_id,
9376 p_log_level => FND_LOG.LEVEL_STATEMENT,
9377 p_message_token => 'GMA_MIGRATION_TABLE_SUCCESS',
9378 p_table_name => G_Table_name,
9379 p_context => G_context,
9380 p_param1 => 1,
9381 p_param2 => 0,
9382 p_db_error => NULL,
9383 p_app_short_name => 'GMA'
9384 );
9385
9386 /****************************************************************
9387 * Lets save the changes now based on the commit parameter *
9388 ****************************************************************/
9389
9390 IF NVL(p_commit,'~') = FND_API.G_TRUE THEN
9391 COMMIT;
9392 END IF;
9393
9394 EXCEPTION
9395 WHEN OTHERS THEN
9396
9397 /************************************************
9398 * Increment Failure Count for Failed Migrations *
9399 ************************************************/
9400
9401 x_failure_count := x_failure_count + 1;
9402
9403 /**************************************
9404 * Migration DB Error Log Message *
9405 **************************************/
9406
9407 GMA_COMMON_LOGGING.gma_migration_central_log
9408 (
9409 p_run_id => G_migration_run_id,
9410 p_log_level => FND_LOG.LEVEL_ERROR,
9411 p_message_token => 'GMA_MIGRATION_DB_ERROR',
9412 p_table_name => G_Table_name,
9413 p_context => G_context,
9414 p_db_error => SQLERRM,
9415 p_app_short_name => 'GMA'
9416 );
9417
9418 /**************************************
9419 * Migration Failure Log Message *
9420 **************************************/
9421
9422 GMA_COMMON_LOGGING.gma_migration_central_log
9423 (
9424 p_run_id => G_migration_run_id,
9425 p_log_level => FND_LOG.LEVEL_ERROR,
9426 p_message_token => 'GMA_TABLE_MIGRATION_TABLE_FAIL',
9427 p_table_name => G_Table_name,
9428 p_context => G_context,
9429 p_db_error => NULL,
9430 p_app_short_name => 'GMA'
9431 );
9432
9433 END Migrate_Period_Balances;
9434
9435 /**********************************************************************
9436 * PROCEDURE: *
9437 * Migrate_Allocation_Inputs *
9438 * *
9439 * DESCRIPTION: *
9440 * This PL/SQL procedure is used to migrate the Expense Allocation *
9441 * Input Records used for Account Balance maintenance *
9442 * *
9443 * PARAMETERS: *
9444 * P_migration_run_id - id to use to right to migration log *
9445 * x_exception_count - Number of exceptions occurred. *
9446 * *
9447 * SYNOPSIS: *
9448 * Migrate_Allocation_Inputs(p_migartion_id => l_migration_id, *
9449 * p_commit => 'T', *
9450 * x_exception_count => l_exception_count ); *
9451 * *
9452 * HISTORY *
9453 * 27-Apr-2005 Created Anand Thiyagarajan *
9454 * *
9455 **********************************************************************/
9456 PROCEDURE Migrate_Allocation_Inputs
9457 (
9458 P_migration_run_id IN NUMBER,
9459 P_commit IN VARCHAR2,
9460 X_failure_count OUT NOCOPY NUMBER
9461 )
9462 IS
9463
9464 /***************************
9465 * PL/SQL Table Definitions *
9466 ***************************/
9467
9468 /* USKUMARI Bug 14614554 */
9469 /**********
9470 * Cursors *
9471 **********/
9472 CURSOR c_gl_aloc_inp
9473 IS
9474 SELECT y.alloc_id,
9475 y.mina,
9476 count(x.alloc_id) cnt
9477 FROM gl_aloc_inp x, (
9478 SELECT a.alloc_id,
9479 (
9480 SELECT MIN(h.alloc_id)
9481 FROM gl_aloc_mst h
9482 WHERE (h.legal_entity_id, h.alloc_code) IN (
9483 SELECT i.legal_entity_id, i.alloc_code
9484 FROM gl_aloc_mst i
9485 WHERE i.alloc_id = a.alloc_id
9486 )
9487 ) mina
9488 FROM gl_aloc_inp a
9489 GROUP BY a.alloc_id
9490 ) y
9491 WHERE x.alloc_id(+) = y.mina
9492 GROUP BY y.alloc_id,
9493 x.alloc_id,
9494 y.mina
9495 HAVING y.alloc_id <> y.mina;
9496
9497 /******************
9498 * Local Variables *
9499 ******************/
9500
9501 BEGIN
9502 /**************************************************************************************************************
9503 * Migrating records can have duplicate value of Allocation codes since, codes from different companies *
9504 * are merged together to form the legal entities allocation records. so we delete the duplicate records *
9505 * from the allocation tables. Since there are some references too the allocation codes in Allocation basis *
9506 * we have to delete the records from those tables as well. *
9507 **************************************************************************************************************/
9508
9509 /******************************************************************
9510 * Deleting referenced records and updating records in GL_ALOC_INP *
9511 ******************************************************************/
9512
9513 FOR i IN c_gl_aloc_inp LOOP
9514 IF i.cnt > 0 THEN
9515 UPDATE gl_aloc_inp a
9516 SET a.delete_mark = 1
9517 WHERE a.alloc_id = i.alloc_id
9518 AND a.delete_mark <> 1;
9519 ELSE
9520 UPDATE gl_aloc_inp a
9521 SET a.alloc_id = i.mina
9522 WHERE a.alloc_id = i.alloc_id
9523 AND a.delete_mark <> 1;
9524 END IF;
9525 END LOOP;
9526
9527 G_Migration_run_id := P_migration_run_id;
9528 G_Table_name := 'GL_ALOC_INP';
9529 G_Context := 'Expense Allocation Inputs Migration';
9530 X_failure_count := 0;
9531
9532 /********************************
9533 * Migration Started Log Message *
9534 ********************************/
9535
9536 GMA_COMMON_LOGGING.gma_migration_central_log
9537 (
9538 p_run_id => G_migration_run_id,
9539 p_log_level => FND_LOG.LEVEL_STATEMENT,
9540 p_message_token => 'GMA_MIGRATION_TABLE_STARTED',
9541 p_table_name => G_Table_name,
9542 p_context => G_context,
9543 p_db_error => NULL,
9544 p_app_short_name => 'GMA'
9545 );
9546
9547 /**********************************************************
9548 * Update a row in GL_ALOC_INP for Account Codes *
9549 **********************************************************/
9550
9551 BEGIN
9552
9553 UPDATE gl_aloc_inp a
9554 SET a.account_id = (
9555 SELECT gmf_migration.get_account_id(a.account_key, x.co_code)
9556 FROM gl_aloc_mst x
9557 WHERE x.alloc_id = a.alloc_id
9558 )
9559 WHERE (account_id IS NULL AND a.account_key IS NOT NULL);
9560
9561 EXCEPTION
9562
9563 WHEN OTHERS THEN
9564
9565 /************************************************
9566 * Increment Failure Count for Failed Migrations *
9567 ************************************************/
9568
9569 x_failure_count := x_failure_count + 1;
9570
9571 /**************************************
9572 * Migration DB Error Log Message *
9573 **************************************/
9574
9575 GMA_COMMON_LOGGING.gma_migration_central_log
9576 (
9577 p_run_id => G_migration_run_id,
9578 p_log_level => FND_LOG.LEVEL_ERROR,
9579 p_message_token => 'GMA_MIGRATION_DB_ERROR',
9580 p_table_name => G_Table_name,
9581 p_context => G_context,
9582 p_param1 => NULL,
9583 p_param2 => NULL,
9584 p_db_error => SQLERRM,
9585 p_app_short_name => 'GMA'
9586 );
9587
9588 /**************************************
9589 * Migration Failure Log Message *
9590 **************************************/
9591
9592 GMA_COMMON_LOGGING.gma_migration_central_log
9593 (
9594 p_run_id => G_migration_run_id,
9595 p_log_level => FND_LOG.LEVEL_ERROR,
9596 p_message_token => 'GMA_TABLE_MIGRATION_TABLE_FAIL',
9597 p_table_name => G_Table_name,
9598 p_context => G_context,
9599 p_db_error => NULL,
9600 p_app_short_name => 'GMA'
9601 );
9602
9603 END;
9604
9605 /**********************************************
9606 * Handle all the rows which were not migrated *
9607 **********************************************/
9608
9609 SELECT count(*)
9610 INTO x_failure_count
9611 FROM gl_aloc_inp
9612 WHERE (account_id IS NULL AND account_key IS NOT NULL);
9613
9614 IF nvl(x_failure_count,0) > 0 THEN
9615
9616 /**************************************
9617 * Migration Failure Log Message *
9618 **************************************/
9619
9620 GMA_COMMON_LOGGING.gma_migration_central_log
9621 (
9622 p_run_id => gmf_migration.G_migration_run_id,
9623 p_log_level => FND_LOG.LEVEL_PROCEDURE,
9624 p_message_token => 'GMA_TABLE_MIGRATION_TABLE_FAIL',
9625 p_table_name => gmf_migration.G_Table_name,
9626 p_context => gmf_migration.G_context,
9627 p_db_error => NULL,
9628 p_app_short_name => 'GMA'
9629 );
9630
9631 ELSE
9632
9633 /**************************************
9634 * Migration Success Log Message *
9635 **************************************/
9636
9637 GMA_COMMON_LOGGING.gma_migration_central_log
9638 (
9639 p_run_id => G_migration_run_id,
9640 p_log_level => FND_LOG.LEVEL_STATEMENT,
9641 p_message_token => 'GMA_MIGRATION_TABLE_SUCCESS',
9642 p_table_name => G_Table_name,
9643 p_context => G_Context,
9644 p_param1 => 1,
9645 p_param2 => 0,
9646 p_db_error => NULL,
9647 p_app_short_name => 'GMA'
9648 );
9649
9650 END IF;
9651
9652 /****************************************************************
9653 * Lets save the changes now based on the commit parameter *
9654 ****************************************************************/
9655
9656 IF NVL(p_commit,'~') = FND_API.G_TRUE THEN
9657 COMMIT;
9658 END IF;
9659
9660 EXCEPTION
9661
9662 WHEN OTHERS THEN
9663
9664 /************************************************
9665 * Increment Failure Count for Failed Migrations *
9666 ************************************************/
9667
9668 x_failure_count := x_failure_count + 1;
9669
9670 /**************************************
9671 * Migration DB Error Log Message *
9672 **************************************/
9673
9674 GMA_COMMON_LOGGING.gma_migration_central_log
9675 (
9676 p_run_id => G_migration_run_id,
9677 p_log_level => FND_LOG.LEVEL_ERROR,
9678 p_message_token => 'GMA_MIGRATION_DB_ERROR',
9679 p_table_name => G_Table_name,
9680 p_context => G_context,
9681 p_param1 => NULL,
9682 p_param2 => NULL,
9683 p_db_error => SQLERRM,
9684 p_app_short_name => 'GMA'
9685 );
9686
9687 /**************************************
9688 * Migration Failure Log Message *
9689 **************************************/
9690
9691 GMA_COMMON_LOGGING.gma_migration_central_log
9692 (
9693 p_run_id => G_migration_run_id,
9694 p_log_level => FND_LOG.LEVEL_ERROR,
9695 p_message_token => 'GMA_TABLE_MIGRATION_TABLE_FAIL',
9696 p_table_name => G_Table_name,
9697 p_context => G_context,
9698 p_db_error => NULL,
9699 p_app_short_name => 'GMA'
9700 );
9701
9702 END Migrate_Allocation_Inputs;
9703
9704 /**********************************************************************
9705 * PROCEDURE: *
9706 * Migrate_Burden_Priorities *
9707 * *
9708 * DESCRIPTION: *
9709 * This PL/SQL procedure is used to migrate the Burden Priorities *
9710 * *
9711 * PARAMETERS: *
9712 * P_migration_run_id - id to use to right to migration log *
9713 * x_exception_count - Number of exceptions occurred. *
9714 * *
9715 * SYNOPSIS: *
9716 * Migrate_Burden_Priorities(p_migartion_id => l_migration_id, *
9717 * p_commit => 'T', *
9718 * x_exception_count => l_exception_count ); *
9719 * *
9720 * HISTORY *
9721 * 27-Apr-2005 Created Anand Thiyagarajan *
9722 * *
9723 **********************************************************************/
9724 PROCEDURE Migrate_Burden_Priorities
9725 (
9726 P_migration_run_id IN NUMBER,
9727 P_commit IN VARCHAR2,
9728 X_failure_count OUT NOCOPY NUMBER
9729 )
9730 IS
9731 /***************************
9732 * PL/SQL Table Definitions *
9733 ***************************/
9734
9735 /*******************
9736 * Local Variables *
9737 *******************/
9738
9739 BEGIN
9740
9741 G_Migration_run_id := P_migration_run_id;
9742 G_Table_name := 'GMF_BURDEN_PRIORITIES';
9743 G_Context := 'Burden Priorities Migration';
9744 X_failure_count := 0;
9745
9746 /********************************
9747 * Migration Started Log Message *
9748 ********************************/
9749
9750 GMA_COMMON_LOGGING.gma_migration_central_log
9751 (
9752 p_run_id => G_migration_run_id,
9753 p_log_level => FND_LOG.LEVEL_STATEMENT,
9754 p_message_token => 'GMA_MIGRATION_TABLE_STARTED',
9755 p_table_name => G_table_name,
9756 p_context => G_context,
9757 p_db_error => NULL,
9758 p_app_short_name => 'GMA'
9759 );
9760
9761 /*****************************************
9762 * Update rows For Organization Priority *
9763 *****************************************/
9764
9765 UPDATE gmf_burden_priorities a
9766 SET a.organization_pri = nvl(a.whse_code_pri, a.orgn_code_pri),
9767 a.legal_entity_id
9768 = (
9769 SELECT x.legal_entity_id
9770 FROM gl_plcy_mst x
9771 WHERE x.co_code = a.co_code
9772 )
9773 WHERE ((a.whse_code_pri IS NOT NULL OR a.orgn_code_pri IS NOT null) AND a.organization_pri IS NULL)
9774 OR (a.co_code IS NOT NULL AND a.legal_entity_id IS NULL);
9775
9776 UPDATE gmf_burden_priorities a
9777 SET a.delete_mark = 1
9778 WHERE a.ROWID NOT IN (
9779 SELECT MIN(x.ROWID)
9780 FROM gmf_burden_priorities x
9781 WHERE x.burden_id = a.burden_id
9782 AND x.legal_entity_id = a.legal_Entity_id
9783 AND x.delete_mark <> 1
9784 );
9785
9786 UPDATE gmf_burden_priorities
9787 SET organization_pri = decode(trunc(nvl(organization_pri,0) / orgn_code_pri), 0, organization_pri, organization_pri - 1),
9788 item_id_pri = decode(trunc(nvl(item_id_pri,0) / orgn_code_pri), 0, item_id_pri, item_id_pri - 1),
9789 icgl_class_pri = decode(trunc(nvl(icgl_class_pri,0) / orgn_code_pri), 0, icgl_class_pri, icgl_class_pri - 1),
9790 itemcost_class_pri = decode(trunc(nvl(itemcost_class_pri,0) / orgn_code_pri), 0, itemcost_class_pri, itemcost_class_pri - 1),
9791 gl_prod_line_pri = decode(trunc(nvl(gl_prod_line_pri,0) / orgn_code_pri), 0, gl_prod_line_pri, gl_prod_line_pri - 1),
9792 gl_business_class_pri = decode(trunc(nvl(gl_business_class_pri,0) / orgn_code_pri), 0, gl_business_class_pri, gl_business_class_pri - 1),
9793 orgn_code_pri = NULL
9794 WHERE orgn_code_pri IS NOT NULL
9795 AND orgn_code_pri < 7
9796 AND whse_code_pri IS NOT NULL;
9797
9798 /**********************************************
9799 * Handle all the rows which were not migrated *
9800 **********************************************/
9801
9802 SELECT count(*)
9803 INTO x_failure_count
9804 FROM gmf_burden_priorities a
9805 WHERE ((a.whse_code_pri IS NOT NULL OR a.orgn_code_pri IS NOT null) AND a.organization_pri IS NULL)
9806 OR (a.co_code IS NOT NULL AND a.legal_entity_id IS NULL);
9807
9808 IF nvl(x_failure_count,0) > 0 THEN
9809
9810 /**************************************
9811 * Migration Failure Log Message *
9812 **************************************/
9813
9814 GMA_COMMON_LOGGING.gma_migration_central_log
9815 (
9816 p_run_id => gmf_migration.G_migration_run_id,
9817 p_log_level => FND_LOG.LEVEL_PROCEDURE,
9818 p_message_token => 'GMA_TABLE_MIGRATION_TABLE_FAIL',
9819 p_table_name => gmf_migration.G_Table_name,
9820 p_context => gmf_migration.G_context,
9821 p_db_error => NULL,
9822 p_app_short_name => 'GMA'
9823 );
9824
9825 ELSE
9826
9827 /**************************************
9828 * Migration Success Log Message *
9829 **************************************/
9830
9831 GMA_COMMON_LOGGING.gma_migration_central_log
9832 (
9833 p_run_id => G_migration_run_id,
9834 p_log_level => FND_LOG.LEVEL_STATEMENT,
9835 p_message_token => 'GMA_MIGRATION_TABLE_SUCCESS',
9836 p_table_name => G_Table_name,
9837 p_context => G_Context,
9838 p_param1 => 1,
9839 p_param2 => 0,
9840 p_db_error => NULL,
9841 p_app_short_name => 'GMA'
9842 );
9843
9844 END IF;
9845
9846 /****************************************************************
9847 * Lets save the changes now based on the commit parameter *
9848 ****************************************************************/
9849
9850 IF NVL(p_commit,'~') = FND_API.G_TRUE THEN
9851 COMMIT;
9852 END IF;
9853
9854 EXCEPTION
9855 WHEN OTHERS THEN
9856
9857 /************************************************
9858 * Increment Failure Count for Failed Migrations *
9859 ************************************************/
9860 x_failure_count := x_failure_count + 1;
9861
9862 /**************************************
9863 * Migration DB Error Log Message *
9864 **************************************/
9865
9866 GMA_COMMON_LOGGING.gma_migration_central_log
9867 (
9868 p_run_id => G_migration_run_id,
9869 p_log_level => FND_LOG.LEVEL_ERROR,
9870 p_message_token => 'GMA_MIGRATION_DB_ERROR',
9871 p_table_name => G_table_name,
9872 p_context => G_context,
9873 p_db_error => SQLERRM,
9874 p_app_short_name => 'GMA'
9875 );
9876
9877 /**************************************
9878 * Migration Failure Log Message *
9879 **************************************/
9880
9881 GMA_COMMON_LOGGING.gma_migration_central_log
9882 (
9883 p_run_id => G_migration_run_id,
9884 p_log_level => FND_LOG.LEVEL_ERROR,
9885 p_message_token => 'GMA_TABLE_MIGRATION_TABLE_FAIL',
9886 p_table_name => G_table_name,
9887 p_context => G_context,
9888 p_db_error => NULL,
9889 p_app_short_name => 'GMA'
9890 );
9891
9892 END Migrate_Burden_Priorities;
9893
9894 /**********************************************************************
9895 * PROCEDURE: *
9896 * Migrate_Component_Materials *
9897 * *
9898 * DESCRIPTION: *
9899 * This PL/SQL procedure is used to migrate the Material Components *
9900 * *
9901 * PARAMETERS: *
9902 * P_migration_run_id - id to use to right to migration log *
9903 * x_exception_count - Number of exceptions occurred. *
9904 * *
9905 * SYNOPSIS: *
9906 * Migrate_component_Materials(p_migartion_id => l_migration_id, *
9907 * p_commit => 'T', *
9908 * x_exception_count => l_exception_count ); *
9909 * *
9910 * HISTORY *
9911 * 27-Apr-2005 Created Anand Thiyagarajan *
9912 * 05-Jul-2006 rseshadr bug 5374823 - call item mig inline for *
9913 * the current table *
9914 * 06-Mar-2012 phiriyan Bug 13612793- As the script is updating *
9915 * only master_organization_id in table cm_cmpt_mtl along with *
9916 * inventory_item_id, Modified cur_get_gmf_items to restrict *
9917 * data to master_organization_id. So as to reduce the calls *
9918 * to item migration API. *
9919 **********************************************************************/
9920 PROCEDURE Migrate_Component_Materials
9921 (
9922 P_migration_run_id IN NUMBER,
9923 P_commit IN VARCHAR2,
9924 X_failure_count OUT NOCOPY NUMBER
9925 )
9926 IS
9927 /***************************
9928 * PL/SQL Table Definitions *
9929 ***************************/
9930
9931 /*******************
9932 * Local Variables *
9933 *******************/
9934
9935 l_inventory_item_id NUMBER;
9936 l_itm_failure_count NUMBER;
9937 l_itm_failure_count_all NUMBER;
9938
9939
9940 /****************
9941 * Cursors *
9942 ****************/
9943
9944 CURSOR cur_get_gmf_items IS
9945 SELECT DISTINCT
9946 x.item_id,
9947 z.master_organization_id as organization_id/*B13612793 */
9948 FROM (
9949 SELECT a.item_id,
9950 decode(NVL(c.subinventory_ind_flag,'N'), 'Y', c.organization_id, c.mtl_organization_id) organization_id
9951 FROM cm_cmpt_mtl a,
9952 sy_orgn_mst b,
9953 ic_whse_mst c
9954 WHERE a.item_id IS NOT NULL
9955 AND a.co_code = b.co_code
9956 AND b.orgn_code = c.orgn_code
9957 AND nvl(c.subinventory_ind_flag, 'N') <> 'Y'
9958 )x
9959 ,mtl_parameters z /*B13612793*/
9960 WHERE x.organization_id = z.organization_id /*B13612793*/
9961 ;
9962
9963 BEGIN
9964
9965 G_Migration_run_id := P_migration_run_id;
9966 G_Table_name := 'CM_CMPT_MTL';
9967 G_Context := 'Material Cost Components Migration';
9968 X_failure_count := 0;
9969
9970 /********************************
9971 * Migration Started Log Message *
9972 ********************************/
9973
9974 GMA_COMMON_LOGGING.gma_migration_central_log
9975 (
9976 p_run_id => G_migration_run_id,
9977 p_log_level => FND_LOG.LEVEL_STATEMENT,
9978 p_message_token => 'GMA_MIGRATION_TABLE_STARTED',
9979 p_table_name => G_table_name,
9980 p_context => G_context,
9981 p_db_error => NULL,
9982 p_app_short_name => 'GMA'
9983 );
9984
9985 /********************************************
9986 * rseshadr bug 5374823 *
9987 * Call Item Migration API in a loop *
9988 * To Migrate necessary items for this table *
9989 *********************************************/
9990
9991 FOR i IN cur_get_gmf_items
9992 LOOP
9993 IF i.item_id IS NOT NULL AND i.organization_id IS NOT NULL THEN
9994 inv_opm_item_migration.get_odm_item
9995 (
9996 p_migration_run_id => p_migration_run_id,
9997 p_item_id => i.item_id,
9998 p_organization_id => i.organization_id,
9999 p_mode => NULL,
10000 p_commit => FND_API.G_TRUE,
10001 x_inventory_item_id => l_inventory_item_id,
10002 x_failure_count => l_itm_failure_count
10003 );
10004 END IF;
10005 l_itm_failure_count_all := nvl(l_itm_failure_count_all,0) + nvl(l_itm_failure_count,0);
10006 END LOOP;
10007
10008 /*****************************************
10009 * Update rows For Legal Entity and Item *
10010 *****************************************/
10011
10012 UPDATE cm_cmpt_mtl a
10013 SET a.legal_entity_id
10014 = (
10015 SELECT x.legal_entity_id
10016 FROM gl_plcy_mst x
10017 WHERE x.co_code = a.co_code
10018 )
10019 WHERE (a.legal_entity_id IS NULL AND a.co_code IS NOT NULL);
10020
10021 UPDATE cm_cmpt_mtl a
10022 SET (
10023 a.master_organization_id,
10024 a.inventory_item_id
10025 )
10026 = (
10027 SELECT z.master_organization_id,
10028 y.inventory_item_id
10029 FROM ic_item_mst_b_mig y,
10030 mtl_parameters z,
10031 hr_organization_information hoi
10032 WHERE y.item_id = a.item_id
10033 AND y.organization_id = z.organization_id
10034 AND hoi.organization_id = z.organization_id
10035 AND hoi.org_information_context = 'Accounting Information'
10036 AND hoi.org_information2 = a.legal_entity_id
10037 AND ROWNUM = 1
10038 )
10039 WHERE (a.inventory_item_id IS NULL AND a.item_id IS NOT NULL)
10040 OR (a.master_organization_id IS NULL AND a.item_id IS NOT NULL);
10041
10042 UPDATE cm_cmpt_mtl a
10043 SET a.delete_mark = 1
10044 WHERE a.ROWID NOT IN (
10045 SELECT MIN(x.ROWID)
10046 FROM cm_cmpt_mtl x
10047 WHERE x.legal_entity_id = a.legal_Entity_id
10048 AND nvl(x.inventory_item_id, -1) = nvl(a.inventory_item_id, -1)
10049 AND nvl(x.cost_category_id, -1) = nvl(a.cost_category_id, -1)
10050 AND x.delete_mark <> 1
10051 AND (
10052 a.eff_start_date BETWEEN x.eff_start_date and x.eff_end_date
10053 OR
10054 a.eff_end_date BETWEEN x.eff_start_date and x.eff_end_date
10055 )
10056 );
10057
10058 /**********************************************
10059 * Handle all the rows which were not migrated *
10060 **********************************************/
10061
10062 SELECT count(*)
10063 INTO x_failure_count
10064 FROM cm_cmpt_mtl
10065 WHERE (
10066 (inventory_item_id IS NULL AND item_id IS NOT NULL)
10067 OR (legal_entity_id IS NULL AND co_code IS NOT NULL)
10068 OR (master_organization_id IS NULL AND item_id IS NOT NULL)
10069 );
10070
10071 IF nvl(x_failure_count,0) > 0 THEN
10072
10073 /**************************************
10074 * Migration Failure Log Message *
10075 **************************************/
10076
10077 GMA_COMMON_LOGGING.gma_migration_central_log
10078 (
10079 p_run_id => gmf_migration.G_migration_run_id,
10080 p_log_level => FND_LOG.LEVEL_PROCEDURE,
10081 p_message_token => 'GMA_TABLE_MIGRATION_TABLE_FAIL',
10082 p_table_name => gmf_migration.G_Table_name,
10083 p_context => gmf_migration.G_context,
10084 p_db_error => NULL,
10085 p_app_short_name => 'GMA'
10086 );
10087
10088 ELSE
10089
10090 /**************************************
10091 * Migration Success Log Message *
10092 **************************************/
10093
10094 GMA_COMMON_LOGGING.gma_migration_central_log
10095 (
10096 p_run_id => G_migration_run_id,
10097 p_log_level => FND_LOG.LEVEL_STATEMENT,
10098 p_message_token => 'GMA_MIGRATION_TABLE_SUCCESS',
10099 p_table_name => G_Table_name,
10100 p_context => G_Context,
10101 p_param1 => 1,
10102 p_param2 => 0,
10103 p_db_error => NULL,
10104 p_app_short_name => 'GMA'
10105 );
10106
10107 END IF;
10108
10109 /****************************************************************
10110 * Lets save the changes now based on the commit parameter *
10111 ****************************************************************/
10112
10113 IF NVL(p_commit,'~') = FND_API.G_TRUE THEN
10114 COMMIT;
10115 END IF;
10116
10117 EXCEPTION
10118 WHEN OTHERS THEN
10119
10120 /************************************************
10121 * Increment Failure Count for Failed Migrations *
10122 ************************************************/
10123 x_failure_count := x_failure_count + 1;
10124
10125 /**************************************
10126 * Migration DB Error Log Message *
10127 **************************************/
10128
10129 GMA_COMMON_LOGGING.gma_migration_central_log
10130 (
10131 p_run_id => G_migration_run_id,
10132 p_log_level => FND_LOG.LEVEL_ERROR,
10133 p_message_token => 'GMA_MIGRATION_DB_ERROR',
10134 p_table_name => G_table_name,
10135 p_context => G_context,
10136 p_db_error => SQLERRM,
10137 p_app_short_name => 'GMA'
10138 );
10139
10140 /**************************************
10141 * Migration Failure Log Message *
10142 **************************************/
10143
10144 GMA_COMMON_LOGGING.gma_migration_central_log
10145 (
10146 p_run_id => G_migration_run_id,
10147 p_log_level => FND_LOG.LEVEL_ERROR,
10148 p_message_token => 'GMA_TABLE_MIGRATION_TABLE_FAIL',
10149 p_table_name => G_table_name,
10150 p_context => G_context,
10151 p_db_error => NULL,
10152 p_app_short_name => 'GMA'
10153 );
10154
10155 END Migrate_Component_Materials;
10156
10157 /**********************************************************************
10158 * PROCEDURE: *
10159 * Migrate_Allocation_Codes *
10160 * *
10161 * DESCRIPTION: *
10162 * This PL/SQL procedure is used to migrate the Expense Allocation *
10163 * Basis Records *
10164 * *
10165 * PARAMETERS: *
10166 * P_migration_run_id - id to use to right to migration log *
10167 * x_exception_count - Number of exceptions occurred. *
10168 * *
10169 * SYNOPSIS: *
10170 * Migrate_Allocation_Codes(p_migartion_id => l_migration_id, *
10171 * p_commit => 'T', *
10172 * x_exception_count => l_exception_count ); *
10173 * *
10174 * HISTORY *
10175 * 27-Apr-2005 Created Anand Thiyagarajan *
10176 * *
10177 **********************************************************************/
10178 PROCEDURE Migrate_Allocation_Codes
10179 (
10180 P_migration_run_id IN NUMBER,
10181 P_commit IN VARCHAR2,
10182 X_failure_count OUT NOCOPY NUMBER
10183 )
10184 IS
10185 /***************************
10186 * PL/SQL Table Definitions *
10187 ***************************/
10188
10189 /**********
10190 * Cursors *
10191 **********/
10192
10193 CURSOR c_gl_aloc_bas
10194 IS
10195 SELECT y.alloc_id,
10196 y.mina,
10197 count(x.alloc_id) cnt
10198 FROM gl_aloc_bas x, (
10199 SELECT a.alloc_id,
10200 (
10201 SELECT MIN(h.alloc_id)
10202 FROM gl_aloc_mst h
10203 WHERE (h.legal_entity_id, h.alloc_code) IN (
10204 SELECT i.legal_entity_id, i.alloc_code
10205 FROM gl_aloc_mst i
10206 WHERE i.alloc_id = a.alloc_id
10207 )
10208 ) mina
10209 FROM gl_aloc_bas a
10210 GROUP BY a.alloc_id
10211 ) y
10212 WHERE x.alloc_id(+) = y.mina
10213 GROUP BY y.alloc_id,
10214 x.alloc_id,
10215 y.mina
10216 HAVING y.alloc_id <> y.mina;
10217
10218 CURSOR c_gl_aloc_exp
10219 IS
10220 SELECT y.alloc_id,
10221 y.mina,
10222 count(x.alloc_id) cnt
10223 FROM gl_aloc_exp x, (
10224 SELECT a.alloc_id,
10225 (
10226 SELECT MIN(h.alloc_id)
10227 FROM gl_aloc_mst h
10228 WHERE (h.legal_entity_id, h.alloc_code) IN (
10229 SELECT i.legal_entity_id, i.alloc_code
10230 FROM gl_aloc_mst i
10231 WHERE i.alloc_id = a.alloc_id
10232 )
10233 ) mina
10234 FROM gl_aloc_exp a
10235 GROUP BY a.alloc_id
10236 ) y
10237 WHERE x.alloc_id(+) = y.mina
10238 GROUP BY y.alloc_id,
10239 x.alloc_id,
10240 y.mina
10241 HAVING y.alloc_id <> y.mina;
10242 /* USKUMARI Bug 14614554 */
10243 /*
10244 CURSOR c_gl_aloc_inp
10245 IS
10246 SELECT y.alloc_id,
10247 y.mina,
10248 count(x.alloc_id) cnt
10249 FROM gl_aloc_inp x, (
10250 SELECT a.alloc_id,
10251 (
10252 SELECT MIN(h.alloc_id)
10253 FROM gl_aloc_mst h
10254 WHERE (h.legal_entity_id, h.alloc_code) IN (
10255 SELECT i.legal_entity_id, i.alloc_code
10256 FROM gl_aloc_mst i
10257 WHERE i.alloc_id = a.alloc_id
10258 )
10259 ) mina
10260 FROM gl_aloc_inp a
10261 GROUP BY a.alloc_id
10262 ) y
10263 WHERE x.alloc_id(+) = y.mina
10264 GROUP BY y.alloc_id,
10265 x.alloc_id,
10266 y.mina
10267 HAVING y.alloc_id <> y.mina;
10268 */
10269 /*******************
10270 * Local Variables *
10271 *******************/
10272
10273 BEGIN
10274
10275 G_Migration_run_id := P_migration_run_id;
10276 G_Table_name := 'GL_ALOC_MST';
10277 G_Context := 'Expense Allocation Codes Migration';
10278 X_failure_count := 0;
10279
10280 /********************************
10281 * Migration Started Log Message *
10282 ********************************/
10283
10284 GMA_COMMON_LOGGING.gma_migration_central_log
10285 (
10286 p_run_id => G_migration_run_id,
10287 p_log_level => FND_LOG.LEVEL_STATEMENT,
10288 p_message_token => 'GMA_MIGRATION_TABLE_STARTED',
10289 p_table_name => G_table_name,
10290 p_context => G_context,
10291 p_db_error => NULL,
10292 p_app_short_name => 'GMA'
10293 );
10294
10295 /*****************************************
10296 * Update rows For Legal Entity *
10297 *****************************************/
10298
10299 UPDATE gl_aloc_mst a
10300 SET a.legal_entity_id = (
10301 SELECT x.legal_entity_id
10302 FROM gl_plcy_mst x
10303 WHERE x.co_code = a.co_code
10304 )
10305 WHERE (a.legal_entity_id IS NULL AND a.co_code IS NOT NULL);
10306
10307 /**************************************************************************************************************
10308 * Migrating records can have duplicate value of Allocation codes since, codes from different companies *
10309 * are merged together to form the legal entities allocation records. so we delete the duplicate records *
10310 * from the allocation tables. Since there are some references too the allocation codes in Allocation basis *
10311 * we have to delete the records from those tables as well. *
10312 **************************************************************************************************************/
10313
10314 UPDATE gl_aloc_mst a
10315 SET a.delete_mark = 1
10316 WHERE a.ROWID NOT IN (
10317 SELECT MIN(x.ROWID)
10318 FROM gl_aloc_mst x
10319 WHERE x.alloc_code = a.alloc_code
10320 AND x.legal_entity_id = a.legal_Entity_id
10321 AND x.delete_mark <> 1
10322 );
10323
10324 /******************************************************************
10325 * Deleting referenced records and updating records in GL_ALOC_BAS *
10326 ******************************************************************/
10327
10328 FOR i IN c_gl_aloc_bas LOOP
10329 IF i.cnt > 0 THEN
10330 UPDATE gl_aloc_bas a
10331 SET a.delete_mark = 1
10332 WHERE a.alloc_id = i.alloc_id
10333 AND a.delete_mark <> 1;
10334 ELSE
10335 UPDATE gl_aloc_bas a
10336 SET a.alloc_id = i.mina
10337 WHERE a.alloc_id = i.alloc_id
10338 AND a.delete_mark <> 1;
10339 END IF;
10340 END LOOP;
10341
10342 /******************************************************************
10343 * Deleting referenced records and updating records in GL_ALOC_EXP *
10344 ******************************************************************/
10345
10346 FOR i IN c_gl_aloc_exp LOOP
10347 IF i.cnt > 0 THEN
10348 UPDATE gl_aloc_exp a
10349 SET a.delete_mark = 1
10350 WHERE a.alloc_id = i.alloc_id
10351 AND a.delete_mark <> 1;
10352 ELSE
10353 UPDATE gl_aloc_exp a
10354 SET a.alloc_id = i.mina
10355 WHERE a.alloc_id = i.alloc_id
10356 AND a.delete_mark <> 1;
10357 END IF;
10358 END LOOP;
10359
10360 /* USKUMARI Bug 14614554 */
10361 /******************************************************************
10362 * Deleting referenced records and updating records in GL_ALOC_INP *
10363 ******************************************************************/
10364 /*
10365 FOR i IN c_gl_aloc_inp LOOP
10366 IF i.cnt > 0 THEN
10367 UPDATE gl_aloc_inp a
10368 SET a.delete_mark = 1
10369 WHERE a.alloc_id = i.alloc_id
10370 AND a.delete_mark <> 1;
10371 ELSE
10372 UPDATE gl_aloc_inp a
10373 SET a.alloc_id = i.mina
10374 WHERE a.alloc_id = i.alloc_id
10375 AND a.delete_mark <> 1;
10376 END IF;
10377 END LOOP;
10378 */
10379 /**********************************************
10380 * Handle all the rows which were not migrated *
10381 **********************************************/
10382
10383 SELECT count(*)
10384 INTO x_failure_count
10385 FROM gl_aloc_mst
10386 WHERE (legal_entity_id IS NULL AND co_code IS NOT NULL);
10387
10388 IF nvl(x_failure_count,0) > 0 THEN
10389
10390 /**************************************
10391 * Migration Failure Log Message *
10392 **************************************/
10393
10394 GMA_COMMON_LOGGING.gma_migration_central_log
10395 (
10396 p_run_id => gmf_migration.G_migration_run_id,
10397 p_log_level => FND_LOG.LEVEL_PROCEDURE,
10398 p_message_token => 'GMA_TABLE_MIGRATION_TABLE_FAIL',
10399 p_table_name => gmf_migration.G_Table_name,
10400 p_context => gmf_migration.G_context,
10401 p_db_error => NULL,
10402 p_app_short_name => 'GMA'
10403 );
10404
10405 ELSE
10406
10407 /**************************************
10408 * Migration Success Log Message *
10409 **************************************/
10410
10411 GMA_COMMON_LOGGING.gma_migration_central_log
10412 (
10413 p_run_id => G_migration_run_id,
10414 p_log_level => FND_LOG.LEVEL_STATEMENT,
10415 p_message_token => 'GMA_MIGRATION_TABLE_SUCCESS',
10416 p_table_name => G_Table_name,
10417 p_context => G_Context,
10418 p_param1 => 1,
10419 p_param2 => 0,
10420 p_db_error => NULL,
10421 p_app_short_name => 'GMA'
10422 );
10423
10424 END IF;
10425
10426 /****************************************************************
10427 * Lets save the changes now based on the commit parameter *
10428 ****************************************************************/
10429
10430 IF NVL(p_commit,'~') = FND_API.G_TRUE THEN
10431 COMMIT;
10432 END IF;
10433
10434 EXCEPTION
10435 WHEN OTHERS THEN
10436
10437 /************************************************
10438 * Increment Failure Count for Failed Migrations *
10439 ************************************************/
10440 x_failure_count := x_failure_count + 1;
10441
10442 /**************************************
10443 * Migration DB Error Log Message *
10444 **************************************/
10445
10446 GMA_COMMON_LOGGING.gma_migration_central_log
10447 (
10448 p_run_id => G_migration_run_id,
10449 p_log_level => FND_LOG.LEVEL_ERROR,
10450 p_message_token => 'GMA_MIGRATION_DB_ERROR',
10451 p_table_name => G_table_name,
10452 p_context => G_context,
10453 p_db_error => SQLERRM,
10454 p_app_short_name => 'GMA'
10455 );
10456
10457 /**************************************
10458 * Migration Failure Log Message *
10459 **************************************/
10460
10461 GMA_COMMON_LOGGING.gma_migration_central_log
10462 (
10463 p_run_id => G_migration_run_id,
10464 p_log_level => FND_LOG.LEVEL_ERROR,
10465 p_message_token => 'GMA_TABLE_MIGRATION_TABLE_FAIL',
10466 p_table_name => G_table_name,
10467 p_context => G_context,
10468 p_db_error => NULL,
10469 p_app_short_name => 'GMA'
10470 );
10471
10472 END Migrate_Allocation_Codes;
10473
10474 /**********************************************************************
10475 * PROCEDURE: *
10476 * Migrate_Event Policies *
10477 * *
10478 * DESCRIPTION: *
10479 * This PL/SQL procedure is used to migrate the Event Fiscal Policies*
10480 * *
10481 * PARAMETERS: *
10482 * P_migration_run_id - id to use to right to migration log *
10483 * x_exception_count - Number of exceptions occurred. *
10484 * *
10485 * SYNOPSIS: *
10486 * Migrate_Evenr_Policies(p_migartion_id => l_migration_id, *
10487 * p_commit => 'T', *
10488 * x_exception_count => l_exception_count ); *
10489 * *
10490 * HISTORY *
10491 * 27-Apr-2005 Created Anand Thiyagarajan *
10492 * *
10493 **********************************************************************/
10494 PROCEDURE Migrate_Event_Policies
10495 (
10496 P_migration_run_id IN NUMBER,
10497 P_commit IN VARCHAR2,
10498 X_failure_count OUT NOCOPY NUMBER
10499 )
10500 IS
10501
10502 /***************************
10503 * PL/SQL Table Definitions *
10504 ***************************/
10505
10506 /*******************
10507 * Local Variables *
10508 *******************/
10509
10510 BEGIN
10511
10512 G_Migration_run_id := P_migration_run_id;
10513 G_Table_name := 'GL_EVNT_PLC';
10514 G_Context := 'Event Fiscal Policies Migration';
10515 X_failure_count := 0;
10516
10517 /********************************
10518 * Migration Started Log Message *
10519 ********************************/
10520
10521 GMA_COMMON_LOGGING.gma_migration_central_log
10522 (
10523 p_run_id => G_migration_run_id,
10524 p_log_level => FND_LOG.LEVEL_STATEMENT,
10525 p_message_token => 'GMA_MIGRATION_TABLE_STARTED',
10526 p_table_name => G_table_name,
10527 p_context => G_context,
10528 p_db_error => NULL,
10529 p_app_short_name => 'GMA'
10530 );
10531
10532 /*****************************************
10533 * Update rows For Legal Entity *
10534 *****************************************/
10535
10536 UPDATE gl_evnt_plc a
10537 SET a.legal_entity_id = (
10538 SELECT x.legal_entity_id
10539 FROM gl_plcy_mst x
10540 WHERE x.co_code = a.co_code
10541 ),
10542 a.entity_code = decode(a.trans_source_type, 12, 'PURCHASING', NULL),
10543 a.event_class_code = decode(a.event_type, 110, 'DELIVER', NULL)
10544 WHERE (a.legal_entity_id IS NULL AND a.co_code IS NOT NULL);
10545
10546 /**************************************************************************************************************
10547 * Migrating records can have duplicate value of Event Fiscal Policies since, codes from different companies *
10548 * are merged together to form the LE Event Fiscal Policy records.so we delete the duplicate records *
10549 * from the Event Fiscal Policy tables. *
10550 **************************************************************************************************************/
10551
10552 UPDATE gl_evnt_plc a
10553 SET a.delete_mark = 1
10554 WHERE a.ROWID NOT IN (
10555 SELECT MIN(x.ROWID)
10556 FROM gl_evnt_plc x
10557 WHERE x.legal_entity_id = a.legal_Entity_id
10558 AND nvl(x.trans_source_type, -1) = nvl(a.trans_source_type, -1)
10559 AND nvl(x.event_type, -1) = nvl(a.event_type, -1)
10560 AND x.delete_mark <> 1
10561 );
10562
10563 /**********************************************
10564 * Handle all the rows which were not migrated *
10565 **********************************************/
10566
10567 SELECT count(*)
10568 INTO x_failure_count
10569 FROM gl_evnt_plc
10570 WHERE (legal_entity_id IS NULL AND co_code IS NOT NULL);
10571
10572 IF nvl(x_failure_count,0) > 0 THEN
10573
10574 /**************************************
10575 * Migration Failure Log Message *
10576 **************************************/
10577
10578 GMA_COMMON_LOGGING.gma_migration_central_log
10579 (
10580 p_run_id => gmf_migration.G_migration_run_id,
10581 p_log_level => FND_LOG.LEVEL_PROCEDURE,
10582 p_message_token => 'GMA_TABLE_MIGRATION_TABLE_FAIL',
10583 p_table_name => gmf_migration.G_Table_name,
10584 p_context => gmf_migration.G_context,
10585 p_db_error => NULL,
10586 p_app_short_name => 'GMA'
10587 );
10588
10589 ELSE
10590
10591 /**************************************
10592 * Migration Success Log Message *
10593 **************************************/
10594
10595 GMA_COMMON_LOGGING.gma_migration_central_log
10596 (
10597 p_run_id => G_migration_run_id,
10598 p_log_level => FND_LOG.LEVEL_STATEMENT,
10599 p_message_token => 'GMA_MIGRATION_TABLE_SUCCESS',
10600 p_table_name => G_Table_name,
10601 p_context => G_Context,
10602 p_param1 => 1,
10603 p_param2 => 0,
10604 p_db_error => NULL,
10605 p_app_short_name => 'GMA'
10606 );
10607
10608 END IF;
10609
10610 /****************************************************************
10611 * Lets save the changes now based on the commit parameter *
10612 ****************************************************************/
10613
10614 IF NVL(p_commit,'~') = FND_API.G_TRUE THEN
10615 COMMIT;
10616 END IF;
10617
10618 EXCEPTION
10619 WHEN OTHERS THEN
10620
10621 /************************************************
10622 * Increment Failure Count for Failed Migrations *
10623 ************************************************/
10624 x_failure_count := x_failure_count + 1;
10625
10626 /**************************************
10627 * Migration DB Error Log Message *
10628 **************************************/
10629
10630 GMA_COMMON_LOGGING.gma_migration_central_log
10631 (
10632 p_run_id => G_migration_run_id,
10633 p_log_level => FND_LOG.LEVEL_ERROR,
10634 p_message_token => 'GMA_MIGRATION_DB_ERROR',
10635 p_table_name => G_table_name,
10636 p_context => G_context,
10637 p_db_error => SQLERRM,
10638 p_app_short_name => 'GMA'
10639 );
10640
10641 /**************************************
10642 * Migration Failure Log Message *
10643 **************************************/
10644
10645 GMA_COMMON_LOGGING.gma_migration_central_log
10646 (
10647 p_run_id => G_migration_run_id,
10648 p_log_level => FND_LOG.LEVEL_ERROR,
10649 p_message_token => 'GMA_TABLE_MIGRATION_TABLE_FAIL',
10650 p_table_name => G_table_name,
10651 p_context => G_context,
10652 p_db_error => NULL,
10653 p_app_short_name => 'GMA'
10654 );
10655
10656 END Migrate_Event_Policies;
10657
10658 /**********************************************************************
10659 * PROCEDURE: *
10660 * Migrate_source_Warehouses *
10661 * *
10662 * DESCRIPTION: *
10663 * This PL/SQL procedure is used to transform the Source Warehouses *
10664 * data in CM_WHSE_SRC *
10665 * *
10666 * PARAMETERS: *
10667 * P_migration_run_id - id to use to right to migration log *
10668 * x_exception_count - Number of exceptions occurred. *
10669 * *
10670 * SYNOPSIS: *
10671 * Migrate_Source_Warehouses(p_migartion_id => l_migration_id, *
10672 * p_commit => 'T', *
10673 * x_exception_count => l_exception_count ); *
10674 * *
10675 * HISTORY *
10676 * 04-Apr-2006 Created anthiyag *
10677 * *
10678 **********************************************************************/
10679 PROCEDURE Migrate_Source_Warehouses
10680 (
10681 P_migration_run_id IN NUMBER,
10682 P_commit IN VARCHAR2,
10683 X_failure_count OUT NOCOPY NUMBER
10684 )
10685 IS
10686
10687 /****************
10688 * PL/SQL Tables *
10689 ****************/
10690
10691 /******************
10692 * Local Variables *
10693 ******************/
10694
10695 BEGIN
10696
10697 G_Migration_run_id := P_migration_run_id;
10698 G_Table_name := 'CM_WHSE_SRC';
10699 G_Context := 'Source Warehouses Migration';
10700 X_failure_count := 0;
10701
10702 /********************************
10703 * Migration Started Log Message *
10704 ********************************/
10705
10706 GMA_COMMON_LOGGING.gma_migration_central_log
10707 (
10708 p_run_id => G_migration_run_id,
10709 p_log_level => FND_LOG.LEVEL_STATEMENT,
10710 p_message_token => 'GMA_MIGRATION_TABLE_STARTED',
10711 p_table_name => G_table_name,
10712 p_context => G_context,
10713 p_db_error => NULL,
10714 p_app_short_name => 'GMA'
10715 );
10716
10717 /***********************************************
10718 * Update rows For Source Warehouses *
10719 ***********************************************/
10720
10721 UPDATE cm_whse_src a
10722 SET (
10723 a.organization_id,
10724 a.legal_entity_id,
10725 a.delete_mark
10726 )
10727 = (
10728 SELECT w.organization_id, z.legal_entity_id, decode(a.delete_mark, 1, 1, decode(nvl(w.inventory_org_ind, 'N'), 'Y', 0, 1))
10729 FROM gl_plcy_mst z, sy_orgn_mst w
10730 WHERE w.orgn_code = a.orgn_code
10731 AND w.co_code = z.co_code
10732 ),
10733 a.source_organization_id = (
10734 SELECT DECODE(NVL(subinventory_ind_flag,'N'), 'Y', organization_id, mtl_organization_id)
10735 FROM ic_whse_mst w1
10736 WHERE w1.whse_code = a.whse_code
10737 )
10738 WHERE (a.legal_entity_id IS NULL AND a.orgn_code IS NOT NULL)
10739 OR (a.organization_id IS NULL AND a.orgn_code IS NOT NULL)
10740 OR (a.source_organization_id IS NULL AND a.whse_code IS NOT NULL);
10741
10742 UPDATE cm_whse_src a
10743 SET (
10744 a.master_organization_id,
10745 a.inventory_item_id
10746 )
10747 =
10748 (
10749 SELECT z.master_organization_id,
10750 y.inventory_item_id
10751 FROM ic_item_mst_b_mig y,
10752 mtl_parameters z,
10753 hr_organization_information hoi
10754 WHERE y.item_id = a.item_id
10755 AND y.organization_id = z.organization_id
10756 AND hoi.organization_id = z.organization_id
10757 AND hoi.org_information_context = 'Accounting Information'
10758 AND hoi.org_information2 = a.legal_entity_id
10759 AND y.organization_id = nvl(a.organization_id, y.organization_id)
10760 AND ROWNUM = 1
10761 )
10762 WHERE (a.inventory_item_id IS NULL AND a.item_id IS NOT NULL)
10763 OR (a.master_organization_id IS NULL AND a.item_id IS NOT NULL);
10764
10765 /********************************************************************************************************
10766 * Insert records for Warehouses falling under OPM Organizations not migrated as Inventory Organizations *
10767 ********************************************************************************************************/
10768
10769 INSERT
10770 INTO cm_whse_src
10771 (
10772 src_whse_id,
10773 calendar_code,
10774 period_code,
10775 sourcing_alloc_pct,
10776 creation_date,
10777 created_by,
10778 last_update_date,
10779 trans_cnt,
10780 text_code,
10781 delete_mark,
10782 last_updated_by,
10783 last_update_login,
10784 cost_category_id,
10785 inventory_item_id,
10786 organization_id,
10787 source_organization_id,
10788 master_organization_id,
10789 legal_entity_id
10790 )
10791 (
10792 SELECT /*+ ROWID(a) */
10793 GEM5_src_whse_id_s.NEXTVAL,
10794 a.calendar_code,
10795 a.period_code,
10796 a.sourcing_alloc_pct,
10797 a.creation_date,
10798 a.created_by,
10799 a.last_update_date,
10800 a.trans_cnt,
10801 a.text_code,
10802 0,
10803 a.last_updated_by,
10804 a.last_update_login,
10805 a.cost_category_id,
10806 a.inventory_item_id,
10807 e.mtl_organization_id,
10808 a.source_organization_id,
10809 a.master_organization_id,
10810 a.legal_entity_id
10811 FROM cm_whse_src a,
10812 ic_whse_mst e
10813 WHERE NOT EXISTS (
10814 SELECT 'X'
10815 FROM cm_whse_src x
10816 WHERE x.legal_entity_id = a.legal_entity_id
10817 AND nvl(x.organization_id, -1) = nvl(e.mtl_organization_id, -1)
10818 AND x.calendar_code = a.calendar_code
10819 AND x.period_code = a.period_code
10820 AND nvl(x.inventory_item_id, -1) = nvl(a.inventory_item_id, -1)
10821 AND nvl(x.cost_category_id, -1) = nvl(a.cost_category_id, -1)
10822 )
10823 AND e.orgn_code = a.orgn_code
10824 AND nvl(e.subinventory_ind_flag,'N') <> 'Y'
10825 AND e.mtl_organization_id IS NOT NULL
10826 AND a.source_organization_id IS NOT NULL
10827 AND a.inventory_item_id IS NOT NULL
10828 AND a.legal_entity_id IS NOT NULL
10829 );
10830
10831 /**********************************************
10832 * Handle all the rows which were not migrated *
10833 **********************************************/
10834 gmf_migration.Log_Errors (
10835 p_log_level => 1,
10836 p_from_rowid => NULL,
10837 p_to_rowid => NULL
10838 );
10839
10840 /****************************************************************
10841 *Lets save the changes now based on the commit parameter *
10842 ****************************************************************/
10843
10844 IF NVL(p_commit,'~') = FND_API.G_TRUE THEN
10845 COMMIT;
10846 END IF;
10847
10848 EXCEPTION
10849 WHEN OTHERS THEN
10850
10851 /************************************************
10852 * Increment Failure Count for Failed Migrations *
10853 ************************************************/
10854 x_failure_count := x_failure_count + 1;
10855
10856 /**************************************
10857 * Migration DB Error Log Message *
10858 **************************************/
10859
10860 GMA_COMMON_LOGGING.gma_migration_central_log
10861 (
10862 p_run_id => G_migration_run_id,
10863 p_log_level => FND_LOG.LEVEL_ERROR,
10864 p_message_token => 'GMA_MIGRATION_DB_ERROR',
10865 p_table_name => G_table_name,
10866 p_context => G_context,
10867 p_db_error => SQLERRM,
10868 p_app_short_name => 'GMA'
10869 );
10870
10871 /**************************************
10872 * Migration Failure Log Message *
10873 **************************************/
10874
10875 GMA_COMMON_LOGGING.gma_migration_central_log
10876 (
10877 p_run_id => G_migration_run_id,
10878 p_log_level => FND_LOG.LEVEL_ERROR,
10879 p_message_token => 'GMA_TABLE_MIGRATION_TABLE_FAIL',
10880 p_table_name => G_table_name,
10881 p_context => G_context,
10882 p_db_error => NULL,
10883 p_app_short_name => 'GMA'
10884 );
10885
10886 END Migrate_Source_Warehouses;
10887
10888 /**********************************************************************
10889 * PROCEDURE: *
10890 * Migrate_Items *
10891 * *
10892 * DESCRIPTION: *
10893 * This PL/SQL procedure is used to migrate all OPM Financials Items *
10894 * *
10895 * PARAMETERS: *
10896 * *
10897 * SYNOPSIS: *
10898 * Migrate_Items; *
10899 * *
10900 * HISTORY *
10901 * 26-May-2006 Created Anand Thiyagarajan *
10902 * 05-Jul-2006 rseshadr bug 5374823 - removed cm_cmpt_mtl and *
10903 * burden_percentages from cursor as these are now done inline *
10904 * 07-Mar-2012 rpatangy bug 13801023 - added condition *
10905 * *
10906 **********************************************************************/
10907 PROCEDURE Migrate_Items
10908 (
10909 P_migration_run_id IN NUMBER,
10910 P_commit IN VARCHAR2,
10911 X_failure_count OUT NOCOPY NUMBER
10912 )
10913 IS
10914
10915 /***************************
10916 * PL/SQL Table Definitions *
10917 ***************************/
10918
10919 /************************
10920 * Local Variables *
10921 ************************/
10922
10923 l_inventory_item_id NUMBER;
10924 l_failure_count NUMBER;
10925
10926 /****************
10927 * Cursors *
10928 ****************/
10929
10930 CURSOR cur_get_gmf_items IS
10931 SELECT DISTINCT
10932 item_id,
10933 organization_id
10934 FROM
10935 (
10936 SELECT a.item_id,
10937 NVL(DECODE(b.cost_organization_id, -1, b.mtl_organization_id, b.cost_organization_id), b.mtl_organization_id) organization_id
10938 FROM cm_acst_led a,
10939 ic_whse_mst b
10940 WHERE a.item_id IS NOT NULL
10941 AND a.whse_code = b.whse_code
10942 UNION
10943 SELECT a.item_id,
10944 NVL(DECODE(b.cost_organization_id, -1, b.mtl_organization_id, b.cost_organization_id), b.mtl_organization_id) organization_id
10945 FROM cm_adjs_dtl a,
10946 ic_whse_mst b
10947 WHERE a.item_id IS NOT NULL
10948 AND a.whse_code = b.whse_code
10949 UNION
10950 SELECT a.item_id,
10951 NVL(DECODE(b.cost_organization_id, -1, b.mtl_organization_id, b.cost_organization_id), b.mtl_organization_id) organization_id
10952 FROM cm_brdn_dtl a,
10953 ic_whse_mst b
10954 WHERE a.item_id IS NOT NULL
10955 AND a.whse_code = b.whse_code
10956 UNION
10957 SELECT a.item_id,
10958 NVL(DECODE(b.cost_organization_id, -1, b.mtl_organization_id, b.cost_organization_id), b.mtl_organization_id) organization_id
10959 FROM cm_cmpt_dtl a,
10960 ic_whse_mst b
10961 WHERE a.item_id IS NOT NULL
10962 AND a.whse_code = b.whse_code
10963 UNION
10964 SELECT a.item_id,
10965 NVL(DECODE(b.cost_organization_id, -1, b.mtl_organization_id, b.cost_organization_id), b.mtl_organization_id) organization_id
10966 FROM cm_scst_led a,
10967 ic_whse_mst b
10968 WHERE a.item_id IS NOT NULL
10969 AND a.whse_code = b.whse_code
10970 UNION
10971 SELECT a.item_id,
10972 nvl(DECODE(NVL(c.subinventory_ind_flag,'N'), 'Y', c.organization_id, c.mtl_organization_id), DECODE(NVL(b.subinventory_ind_flag,'N'), 'Y', b.organization_id, b.mtl_organization_id)) organization_id
10973 FROM cm_whse_src a,
10974 ic_whse_mst b,
10975 ic_whse_mst c
10976 WHERE a.item_id IS NOT NULL
10977 AND b.orgn_code = a.orgn_code
10978 AND c.whse_code(+) = a.whse_code
10979 UNION
10980 SELECT a.item_id,
10981 NVL(DECODE(b.cost_organization_id, -1, b.mtl_organization_id, b.cost_organization_id), b.mtl_organization_id) organization_id
10982 FROM gl_item_cst a,
10983 ic_whse_mst b
10984 WHERE a.item_id IS NOT NULL
10985 AND a.whse_code = b.whse_code
10986 UNION
10987 SELECT a.item_id,
10988 DECODE(NVL(c.subinventory_ind_flag,'N'), 'Y', c.organization_id, c.mtl_organization_id) organization_id
10989 FROM gmf_lot_costed_items a,
10990 sy_orgn_mst b,
10991 ic_whse_mst c
10992 WHERE a.item_id IS NOT NULL
10993 AND a.co_code = b.co_Code
10994 AND b.orgn_code = c.orgn_code
10995 AND nvl(c.subinventory_ind_flag,'N') <> 'Y'
10996 UNION
10997 SELECT a.item_id,
10998 NVL(DECODE(b.cost_organization_id, -1, b.mtl_organization_id, b.cost_organization_id), b.mtl_organization_id) organization_id
10999 FROM gmf_lot_Costs a,
11000 ic_whse_mst b
11001 WHERE a.item_id IS NOT NULL
11002 AND a.whse_code = b.whse_code
11003 UNION
11004 SELECT a.item_id,
11005 NVL(DECODE(b.cost_organization_id, -1, b.mtl_organization_id, b.cost_organization_id), b.mtl_organization_id) organization_id
11006 FROM gmf_lot_Cost_adjustments a,
11007 ic_whse_mst b
11008 WHERE a.item_id IS NOT NULL
11009 AND a.whse_code = b.whse_code
11010 UNION
11011 SELECT a.item_id,
11012 NVL(DECODE(b.cost_organization_id, -1, b.mtl_organization_id, b.cost_organization_id), b.mtl_organization_id) organization_id
11013 FROM gmf_lot_Cost_burdens a,
11014 ic_whse_mst b
11015 WHERE a.item_id IS NOT NULL
11016 AND a.whse_code = b.whse_code
11017 ) x
11018 WHERE NOT EXISTS
11019 (
11020 SELECT 'X'
11021 FROM ic_item_mst_b_mig y
11022 WHERE y.item_id = x.item_id
11023 AND y.organization_id = x.organization_id
11024 AND NVL(y.migrated_ind,0) = 1
11025 );
11026
11027 BEGIN
11028
11029 G_Migration_run_id := P_migration_run_id;
11030 G_Table_name := 'GMF_ITEMS_MIGRATION';
11031 G_Context := 'Process Costing Items Migration';
11032 X_failure_count := 0;
11033
11034 /********************************
11035 * Migration Started Log Message *
11036 ********************************/
11037
11038 GMA_COMMON_LOGGING.gma_migration_central_log
11039 (
11040 p_run_id => G_migration_run_id,
11041 p_log_level => FND_LOG.LEVEL_STATEMENT,
11042 p_message_token => 'GMA_MIGRATION_TABLE_STARTED',
11043 p_table_name => G_Table_name,
11044 p_context => G_Context,
11045 p_db_error => NULL,
11046 p_app_short_name => 'GMA'
11047 );
11048
11049 /****************************************
11050 * Call Item Migration API in a loop *
11051 ****************************************/
11052
11053 FOR i IN cur_get_gmf_items
11054 LOOP
11055 IF i.item_id IS NOT NULL AND i.organization_id IS NOT NULL THEN
11056 inv_opm_item_migration.get_odm_item
11057 (
11058 p_migration_run_id => p_migration_run_id,
11059 p_item_id => i.item_id,
11060 p_organization_id => i.organization_id,
11061 p_mode => NULL,
11062 p_commit => FND_API.G_TRUE,
11063 x_inventory_item_id => l_inventory_item_id,
11064 x_failure_count => l_failure_count
11065 );
11066 END IF;
11067 x_failure_count := nvl(x_failure_count,0) + nvl(l_failure_count,0);
11068 END LOOP;
11069
11070 /****************************************************************
11071 * Lets save the changes now based on the commit parameter *
11072 ****************************************************************/
11073
11074 IF NVL(p_commit,'~') = FND_API.G_TRUE THEN
11075 COMMIT;
11076 END IF;
11077
11078 EXCEPTION
11079 WHEN OTHERS THEN
11080
11081 /************************************************
11082 * Increment Failure Count for Failed Migrations *
11083 ************************************************/
11084 x_failure_count := x_failure_count + 1;
11085
11086 /**************************************
11087 * Migration DB Error Log Message *
11088 **************************************/
11089
11090 GMA_COMMON_LOGGING.gma_migration_central_log
11091 (
11092 p_run_id => G_migration_run_id,
11093 p_log_level => FND_LOG.LEVEL_ERROR,
11094 p_message_token => 'GMA_MIGRATION_DB_ERROR',
11095 p_table_name => G_Table_name,
11096 p_context => G_Context,
11097 p_db_error => SQLERRM,
11098 p_app_short_name => 'GMA'
11099 );
11100
11101 /**************************************
11102 * Migration Failure Log Message *
11103 **************************************/
11104
11105 GMA_COMMON_LOGGING.gma_migration_central_log
11106 (
11107 p_run_id => G_migration_run_id,
11108 p_log_level => FND_LOG.LEVEL_ERROR,
11109 p_message_token => 'GMA_TABLE_MIGRATION_TABLE_FAIL',
11110 p_table_name => G_Table_name,
11111 p_context => G_Context,
11112 p_db_error => NULL,
11113 p_app_short_name => 'GMA'
11114 );
11115
11116 END Migrate_Items;
11117
11118 /**********************************************************************
11119 * PROCEDURE: *
11120 * Migrate_ActualCost_control *
11121 * *
11122 * DESCRIPTION: *
11123 * This PL/SQL procedure is used to migrate the Actual cost control *
11124 * date Records *
11125 * *
11126 * PARAMETERS: *
11127 * P_migration_run_id - id to use to right to migration log *
11128 * x_exception_count - Number of exceptions occurred. *
11129 * *
11130 * SYNOPSIS: *
11131 * Migrate_ActualCost_control(p_migartion_id => l_migration_id, *
11132 * p_commit => 'T', *
11133 * x_exception_count => l_exception_count ); *
11134 * *
11135 * HISTORY *
11136 * 22-Aug-2006 Created Prasad Marada, bug 5473343 *
11137 * *
11138 **********************************************************************/
11139 PROCEDURE Migrate_ActualCost_control
11140 (
11141 P_migration_run_id IN NUMBER,
11142 P_commit IN VARCHAR2,
11143 X_failure_count OUT NOCOPY NUMBER
11144 )
11145 IS
11146
11147 /***************************
11148 * PL/SQL Table Definitions *
11149 ***************************/
11150
11151 /******************
11152 * Local Variables *
11153 ******************/
11154
11155 BEGIN
11156
11157 G_Migration_run_id := P_migration_run_id;
11158 G_Table_name := 'CM_ACPR_CTL';
11159 G_Context := 'Actual cost control data Migration';
11160 X_failure_count := 0;
11161
11162 /********************************
11163 * Migration Started Log Message *
11164 ********************************/
11165
11166 GMA_COMMON_LOGGING.gma_migration_central_log
11167 (
11168 p_run_id => G_migration_run_id,
11169 p_log_level => FND_LOG.LEVEL_STATEMENT,
11170 p_message_token => 'GMA_MIGRATION_TABLE_STARTED',
11171 p_table_name => G_Table_name,
11172 p_context => G_context,
11173 p_db_error => NULL,
11174 p_app_short_name => 'GMA'
11175 );
11176
11177
11178 /**********************************
11179 * Update row in CM_ACPR_CTL table *
11180 ***********************************/
11181
11182 BEGIN
11183 UPDATE cm_acpr_ctl cac
11184 SET (
11185 cac.legal_entity_id,
11186 cac.period_id,
11187 cac.cost_type_id
11188 )
11189 =
11190 (
11191 select gps.legal_entity_id, gps.period_id, gps.cost_type_id
11192 from gmf_period_statuses gps,
11193 cm_mthd_mst cmm,
11194 cm_cldr_hdr_b cch,
11195 gl_plcy_mst gpm
11196 where gps.calendar_code = cac.calendar_code
11197 and cch.calendar_code = cac.calendar_code
11198 and cch.co_code = gpm.co_code
11199 and gps.legal_entity_id = gpm.legal_entity_id
11200 and gps.period_code = cac.period_code
11201 and cmm.cost_mthd_code = cac.cost_mthd_code
11202 and cmm.cost_type_id = gps.cost_type_id
11203 )
11204 where (cac.calendar_code is not null and cac.legal_entity_id is null)
11205 OR (cac.cost_mthd_code is not null AND cac.cost_type_id is null)
11206 OR (cac.calendar_code is not null and cac.period_code is not NULL AND cac.period_id is null);
11207
11208 EXCEPTION
11209 WHEN OTHERS THEN
11210
11211 /************************************************
11212 * Increment Failure Count for Failed Migrations *
11213 ************************************************/
11214
11215 x_failure_count := x_failure_count + 1;
11216
11217 /**************************************
11218 * Migration DB Error Log Message *
11219 **************************************/
11220
11221 GMA_COMMON_LOGGING.gma_migration_central_log
11222 (
11223 p_run_id => G_migration_run_id,
11224 p_log_level => FND_LOG.LEVEL_ERROR,
11225 p_message_token => 'GMA_MIGRATION_DB_ERROR',
11226 p_table_name => G_Table_name,
11227 p_context => G_context,
11228 p_db_error => SQLERRM,
11229 p_app_short_name => 'GMA'
11230 );
11231
11232 /**************************************
11233 * Migration Failure Log Message *
11234 **************************************/
11235
11236 GMA_COMMON_LOGGING.gma_migration_central_log
11237 (
11238 p_run_id => G_migration_run_id,
11239 p_log_level => FND_LOG.LEVEL_ERROR,
11240 p_message_token => 'GMA_TABLE_MIGRATION_TABLE_FAIL',
11241 p_table_name => G_Table_name,
11242 p_context => G_context,
11243 p_db_error => NULL,
11244 p_app_short_name => 'GMA'
11245 );
11246
11247 END;
11248
11249 /**********************************************
11250 * Handle all the rows which were not migrated *
11251 **********************************************/
11252 gmf_migration.Log_Errors (
11253 p_log_level => 1,
11254 p_from_rowid => NULL,
11255 p_to_rowid => NULL
11256 );
11257
11258 /****************************************************************
11259 * Lets save the changes now based on the commit parameter *
11260 ****************************************************************/
11261
11262 IF NVL(p_commit,'~') = FND_API.G_TRUE THEN
11263 COMMIT;
11264 END IF;
11265
11266 EXCEPTION
11267
11268 WHEN OTHERS THEN
11269
11270 /************************************************
11271 * Increment Failure Count for Failed Migrations *
11272 ************************************************/
11273
11274 x_failure_count := x_failure_count + 1;
11275
11276 /**************************************
11277 * Migration DB Error Log Message *
11278 **************************************/
11279
11280 GMA_COMMON_LOGGING.gma_migration_central_log
11281 (
11282 p_run_id => G_migration_run_id,
11283 p_log_level => FND_LOG.LEVEL_ERROR,
11284 p_message_token => 'GMA_MIGRATION_DB_ERROR',
11285 p_table_name => G_Table_name,
11286 p_context => G_context,
11287 p_param1 => NULL,
11288 p_param2 => NULL,
11289 p_db_error => SQLERRM,
11290 p_app_short_name => 'GMA'
11291 );
11292
11293 /**************************************
11294 * Migration Failure Log Message *
11295 **************************************/
11296
11297 GMA_COMMON_LOGGING.gma_migration_central_log
11298 (
11299 p_run_id => G_migration_run_id,
11300 p_log_level => FND_LOG.LEVEL_ERROR,
11301 p_message_token => 'GMA_TABLE_MIGRATION_TABLE_FAIL',
11302 p_table_name => G_Table_name,
11303 p_context => G_context,
11304 p_db_error => NULL,
11305 p_app_short_name => 'GMA'
11306 );
11307
11308 END Migrate_ActualCost_control;
11309
11310 /**********************************************************************
11311 * PROCEDURE: *
11312 * Migrate_Rollup_control *
11313 * *
11314 * DESCRIPTION: *
11315 * This PL/SQL procedure is used to migrate the rollup cost control *
11316 * data Records *
11317 * *
11318 * PARAMETERS: *
11319 * P_migration_run_id - id to use to right to migration log *
11320 * x_exception_count - Number of exceptions occurred. *
11321 * *
11322 * SYNOPSIS: *
11323 * Migrate_rollup_control(p_migartion_id => l_migration_id, *
11324 * p_commit => 'T', *
11325 * x_exception_count => l_exception_count ); *
11326 * *
11327 * HISTORY *
11328 * 30-Aug-2006 Created Prasad Marada, bug 5473343 *
11329 * *
11330 **********************************************************************/
11331 PROCEDURE Migrate_Rollup_control
11332 (
11333 P_migration_run_id IN NUMBER,
11334 P_commit IN VARCHAR2,
11335 X_failure_count OUT NOCOPY NUMBER
11336 )
11337 IS
11338
11339 /***************************
11340 * PL/SQL Table Definitions *
11341 ***************************/
11342
11343 /******************
11344 * Local Variables *
11345 ******************/
11346
11347 BEGIN
11348
11349 G_Migration_run_id := P_migration_run_id;
11350 G_Table_name := 'CM_RLUP_CTL';
11351 G_Context := 'Rollup Control Record Migration';
11352 X_failure_count := 0;
11353
11354 /********************************
11355 * Migration Started Log Message *
11356 ********************************/
11357
11358 GMA_COMMON_LOGGING.gma_migration_central_log
11359 (
11360 p_run_id => G_migration_run_id,
11361 p_log_level => FND_LOG.LEVEL_STATEMENT,
11362 p_message_token => 'GMA_MIGRATION_TABLE_STARTED',
11363 p_table_name => G_Table_name,
11364 p_context => G_context,
11365 p_db_error => NULL,
11366 p_app_short_name => 'GMA'
11367 );
11368
11369 /**********************************
11370 * Update row in CM_RLUP_CTL table *
11371 ***********************************/
11372
11373 BEGIN
11374
11375 UPDATE cm_rlup_ctl crc
11376 SET (
11377 crc.legal_entity_id,
11378 crc.period_id,
11379 crc.cost_type_id
11380 )
11381 =
11382 (
11383 SELECT gps.legal_entity_id,
11384 gps.period_id,
11385 gps.cost_type_id
11386 FROM gmf_period_statuses gps,
11387 cm_mthd_mst cmm,
11388 cm_cldr_hdr_b cch,
11389 gl_plcy_mst gpm
11390 WHERE gps.calendar_code = crc.calendar_code
11391 AND cch.calendar_code = crc.calendar_code
11392 AND cch.co_code = gpm.co_code
11393 AND gps.legal_entity_id = gpm.legal_entity_id
11394 AND gps.period_code = crc.period_code
11395 AND cmm.cost_mthd_code = crc.cost_mthd_code
11396 AND cmm.cost_type_id = gps.cost_type_id
11397 )
11398 WHERE (crc.CALENDAR_CODE IS NOT NULL AND crc.PERIOD_CODE IS NOT NULL AND crc.PERIOD_ID IS NULL)
11399 OR (crc.COST_MTHD_CODE IS NOT NULL AND crc.COST_TYPE_ID IS NULL)
11400 OR (crc.CALENDAR_CODE IS NOT NULL AND crc.LEGAL_ENTITY_ID IS NULL);
11401
11402 UPDATE cm_rlup_ctl a
11403 SET (
11404 a.master_organization_id,
11405 a.inventory_item_id
11406 )
11407 = (
11408 SELECT z.master_organization_id,
11409 y.inventory_item_id
11410 FROM ic_item_mst_b_mig y,
11411 mtl_parameters z,
11412 hr_organization_information hoi
11413 WHERE y.item_id = a.item_id
11414 AND y.organization_id = z.organization_id
11415 AND hoi.organization_id = z.organization_id
11416 AND hoi.org_information_context = 'Accounting Information'
11417 AND hoi.org_information2 = a.legal_entity_id
11418 AND ROWNUM = 1
11419 )
11420 WHERE (a.inventory_item_id IS NULL AND a.item_id IS NOT NULL)
11421 OR (a.master_organization_id IS NULL AND a.item_id IS NOT NULL);
11422
11423 EXCEPTION
11424 WHEN OTHERS THEN
11425
11426 /************************************************
11427 * Increment Failure Count for Failed Migrations *
11428 ************************************************/
11429
11430 x_failure_count := x_failure_count + 1;
11431
11432 /**************************************
11433 * Migration DB Error Log Message *
11434 **************************************/
11435
11436 GMA_COMMON_LOGGING.gma_migration_central_log
11437 (
11438 p_run_id => G_migration_run_id,
11439 p_log_level => FND_LOG.LEVEL_ERROR,
11440 p_message_token => 'GMA_MIGRATION_DB_ERROR',
11441 p_table_name => G_Table_name,
11442 p_context => G_context,
11443 p_db_error => SQLERRM,
11444 p_app_short_name => 'GMA'
11445 );
11446
11447 /**************************************
11448 * Migration Failure Log Message *
11449 **************************************/
11450
11451 GMA_COMMON_LOGGING.gma_migration_central_log
11452 (
11453 p_run_id => G_migration_run_id,
11454 p_log_level => FND_LOG.LEVEL_ERROR,
11455 p_message_token => 'GMA_TABLE_MIGRATION_TABLE_FAIL',
11456 p_table_name => G_Table_name,
11457 p_context => G_context,
11458 p_db_error => NULL,
11459 p_app_short_name => 'GMA'
11460 );
11461
11462 END;
11463
11464 /**********************************************
11465 * Handle all the rows which were not migrated *
11466 **********************************************/
11467 gmf_migration.Log_Errors (
11468 p_log_level => 1,
11469 p_from_rowid => NULL,
11470 p_to_rowid => NULL
11471 );
11472
11473 G_Table_name := 'CM_RLUP_ITM';
11474 G_Context := 'Rollup Items Migration';
11475 X_failure_count := 0;
11476
11477 /********************************
11478 * Migration Started Log Message *
11479 ********************************/
11480
11481 GMA_COMMON_LOGGING.gma_migration_central_log
11482 (
11483 p_run_id => G_migration_run_id,
11484 p_log_level => FND_LOG.LEVEL_STATEMENT,
11485 p_message_token => 'GMA_MIGRATION_TABLE_STARTED',
11486 p_table_name => G_Table_name,
11487 p_context => G_context,
11488 p_db_error => NULL,
11489 p_app_short_name => 'GMA'
11490 );
11491
11492 /**********************************
11493 * Update row in CM_RLUP_ITM table *
11494 ***********************************/
11495
11496 BEGIN
11497
11498 UPDATE cm_rlup_itm a
11499 SET (
11500 a.organization_id,
11501 a.inventory_item_id
11502 )
11503 = (
11504 SELECT z.master_organization_id,
11505 y.inventory_item_id
11506 FROM ic_item_mst_b_mig y,
11507 mtl_parameters z,
11508 hr_organization_information hoi,
11509 cm_rlup_ctl x
11510 WHERE y.item_id = a.item_id
11511 AND y.organization_id = z.organization_id
11512 AND hoi.organization_id = z.organization_id
11513 AND hoi.org_information_context = 'Accounting Information'
11514 AND hoi.org_information2 = x.legal_entity_id
11515 AND x.rollup_id = a.rollup_id
11516 AND ROWNUM = 1
11517 )
11518 WHERE (a.inventory_item_id IS NULL AND a.item_id IS NOT NULL)
11519 OR (a.organization_id IS NULL AND a.item_id IS NOT NULL);
11520
11521 EXCEPTION
11522 WHEN OTHERS THEN
11523
11524 /************************************************
11525 * Increment Failure Count for Failed Migrations *
11526 ************************************************/
11527
11528 x_failure_count := x_failure_count + 1;
11529
11530 /**************************************
11531 * Migration DB Error Log Message *
11532 **************************************/
11533
11534 GMA_COMMON_LOGGING.gma_migration_central_log
11535 (
11536 p_run_id => G_migration_run_id,
11537 p_log_level => FND_LOG.LEVEL_ERROR,
11538 p_message_token => 'GMA_MIGRATION_DB_ERROR',
11539 p_table_name => G_Table_name,
11540 p_context => G_context,
11541 p_db_error => SQLERRM,
11542 p_app_short_name => 'GMA'
11543 );
11544
11545 /**************************************
11546 * Migration Failure Log Message *
11547 **************************************/
11548
11549 GMA_COMMON_LOGGING.gma_migration_central_log
11550 (
11551 p_run_id => G_migration_run_id,
11552 p_log_level => FND_LOG.LEVEL_ERROR,
11553 p_message_token => 'GMA_TABLE_MIGRATION_TABLE_FAIL',
11554 p_table_name => G_Table_name,
11555 p_context => G_context,
11556 p_db_error => NULL,
11557 p_app_short_name => 'GMA'
11558 );
11559
11560 END;
11561
11562 /**********************************************
11563 * Handle all the rows which were not migrated *
11564 **********************************************/
11565 gmf_migration.Log_Errors (
11566 p_log_level => 1,
11567 p_from_rowid => NULL,
11568 p_to_rowid => NULL
11569 );
11570
11571 /****************************************************************
11572 * Lets save the changes now based on the commit parameter *
11573 ****************************************************************/
11574
11575 IF NVL(p_commit,'~') = FND_API.G_TRUE THEN
11576 COMMIT;
11577 END IF;
11578
11579 EXCEPTION
11580
11581 WHEN OTHERS THEN
11582
11583 /************************************************
11584 * Increment Failure Count for Failed Migrations *
11585 ************************************************/
11586
11587 x_failure_count := x_failure_count + 1;
11588
11589 /**************************************
11590 * Migration DB Error Log Message *
11591 **************************************/
11592
11593 GMA_COMMON_LOGGING.gma_migration_central_log
11594 (
11595 p_run_id => G_migration_run_id,
11596 p_log_level => FND_LOG.LEVEL_ERROR,
11597 p_message_token => 'GMA_MIGRATION_DB_ERROR',
11598 p_table_name => G_Table_name,
11599 p_context => G_context,
11600 p_param1 => NULL,
11601 p_param2 => NULL,
11602 p_db_error => SQLERRM,
11603 p_app_short_name => 'GMA'
11604 );
11605
11606 /**************************************
11607 * Migration Failure Log Message *
11608 **************************************/
11609
11610 GMA_COMMON_LOGGING.gma_migration_central_log
11611 (
11612 p_run_id => G_migration_run_id,
11613 p_log_level => FND_LOG.LEVEL_ERROR,
11614 p_message_token => 'GMA_TABLE_MIGRATION_TABLE_FAIL',
11615 p_table_name => G_Table_name,
11616 p_context => G_context,
11617 p_db_error => NULL,
11618 p_app_short_name => 'GMA'
11619 );
11620
11621 END Migrate_Rollup_control;
11622
11623 /**********************************************************************
11624 * PROCEDURE: *
11625 * Migrate_CostUpdate_control *
11626 * *
11627 * DESCRIPTION: *
11628 * This PL/SQL procedure is used to migrate the Cost Update control *
11629 * date Records *
11630 * *
11631 * PARAMETERS: *
11632 * P_migration_run_id - id to use to right to migration log *
11633 * x_exception_count - Number of exceptions occurred. *
11634 * *
11635 * SYNOPSIS: *
11636 * Migrate_CostUpdate_control(p_migartion_id => l_migration_id, *
11637 * p_commit => 'T', *
11638 * x_exception_count => l_exception_count ); *
11639 * *
11640 * HISTORY *
11641 * 08-Sep-2006 Created Anand Thiyagarajan *
11642 * *
11643 **********************************************************************/
11644 PROCEDURE Migrate_CostUpdate_control
11645 (
11646 P_migration_run_id IN NUMBER,
11647 P_commit IN VARCHAR2,
11648 X_failure_count OUT NOCOPY NUMBER
11649 )
11650 IS
11651
11652 /***************************
11653 * PL/SQL Table Definitions *
11654 ***************************/
11655
11656 /******************
11657 * Local Variables *
11658 ******************/
11659
11660 BEGIN
11661
11662 G_Migration_run_id := P_migration_run_id;
11663 G_Table_name := 'CM_CUPD_CTL';
11664 G_Context := 'Cost Update control data Migration';
11665 X_failure_count := 0;
11666
11667 /********************************
11668 * Migration Started Log Message *
11669 ********************************/
11670
11671 GMA_COMMON_LOGGING.gma_migration_central_log
11672 (
11673 p_run_id => G_migration_run_id,
11674 p_log_level => FND_LOG.LEVEL_STATEMENT,
11675 p_message_token => 'GMA_MIGRATION_TABLE_STARTED',
11676 p_table_name => G_Table_name,
11677 p_context => G_context,
11678 p_db_error => NULL,
11679 p_app_short_name => 'GMA'
11680 );
11681
11682
11683 /**********************************
11684 * Update row in CM_ACPR_CTL table *
11685 ***********************************/
11686
11687 BEGIN
11688 UPDATE cm_cupd_ctl ccc
11689 SET (
11690 ccc.legal_entity_id,
11691 ccc.period_id,
11692 ccc.cost_type_id
11693 )
11694 =
11695 (
11696 select gps.legal_entity_id, gps.period_id, gps.cost_type_id
11697 from gmf_period_statuses gps,
11698 cm_mthd_mst cmm,
11699 gl_plcy_mst gpm
11700 where gps.calendar_code = ccc.calendar_code
11701 and gpm.co_code = ccc.co_code
11702 and gps.period_code = ccc.period_code
11703 and cmm.cost_mthd_code = ccc.cost_mthd_code
11704 and gps.legal_entity_id = gpm.legal_entity_id
11705 and cmm.cost_type_id = gps.cost_type_id
11706 )
11707 where (ccc.calendar_code is not null and ccc.legal_entity_id is null)
11708 OR (ccc.cost_mthd_code is not null AND ccc.cost_type_id is null)
11709 OR (ccc.calendar_code is not null and ccc.period_code is not NULL AND ccc.period_id is null);
11710
11711 EXCEPTION
11712 WHEN OTHERS THEN
11713
11714 /************************************************
11715 * Increment Failure Count for Failed Migrations *
11716 ************************************************/
11717
11718 x_failure_count := x_failure_count + 1;
11719
11720 /**************************************
11721 * Migration DB Error Log Message *
11722 **************************************/
11723
11724 GMA_COMMON_LOGGING.gma_migration_central_log
11725 (
11726 p_run_id => G_migration_run_id,
11727 p_log_level => FND_LOG.LEVEL_ERROR,
11728 p_message_token => 'GMA_MIGRATION_DB_ERROR',
11729 p_table_name => G_Table_name,
11730 p_context => G_context,
11731 p_db_error => SQLERRM,
11732 p_app_short_name => 'GMA'
11733 );
11734
11735 /**************************************
11736 * Migration Failure Log Message *
11737 **************************************/
11738
11739 GMA_COMMON_LOGGING.gma_migration_central_log
11740 (
11741 p_run_id => G_migration_run_id,
11742 p_log_level => FND_LOG.LEVEL_ERROR,
11743 p_message_token => 'GMA_TABLE_MIGRATION_TABLE_FAIL',
11744 p_table_name => G_Table_name,
11745 p_context => G_context,
11746 p_db_error => NULL,
11747 p_app_short_name => 'GMA'
11748 );
11749
11750 END;
11751
11752 /**********************************************
11753 * Handle all the rows which were not migrated *
11754 **********************************************/
11755 gmf_migration.Log_Errors (
11756 p_log_level => 1,
11757 p_from_rowid => NULL,
11758 p_to_rowid => NULL
11759 );
11760
11761 /****************************************************************
11762 * Lets save the changes now based on the commit parameter *
11763 ****************************************************************/
11764
11765 IF NVL(p_commit,'~') = FND_API.G_TRUE THEN
11766 COMMIT;
11767 END IF;
11768
11769 EXCEPTION
11770
11771 WHEN OTHERS THEN
11772
11773 /************************************************
11774 * Increment Failure Count for Failed Migrations *
11775 ************************************************/
11776
11777 x_failure_count := x_failure_count + 1;
11778
11779 /**************************************
11780 * Migration DB Error Log Message *
11781 **************************************/
11782
11783 GMA_COMMON_LOGGING.gma_migration_central_log
11784 (
11785 p_run_id => G_migration_run_id,
11786 p_log_level => FND_LOG.LEVEL_ERROR,
11787 p_message_token => 'GMA_MIGRATION_DB_ERROR',
11788 p_table_name => G_Table_name,
11789 p_context => G_context,
11790 p_param1 => NULL,
11791 p_param2 => NULL,
11792 p_db_error => SQLERRM,
11793 p_app_short_name => 'GMA'
11794 );
11795
11796 /**************************************
11797 * Migration Failure Log Message *
11798 **************************************/
11799
11800 GMA_COMMON_LOGGING.gma_migration_central_log
11801 (
11802 p_run_id => G_migration_run_id,
11803 p_log_level => FND_LOG.LEVEL_ERROR,
11804 p_message_token => 'GMA_TABLE_MIGRATION_TABLE_FAIL',
11805 p_table_name => G_Table_name,
11806 p_context => G_context,
11807 p_db_error => NULL,
11808 p_app_short_name => 'GMA'
11809 );
11810
11811 END Migrate_CostUpdate_control;
11812
11813 /**********************************************************************
11814 * PROCEDURE: *
11815 * Migrate_SubLedger_control *
11816 * *
11817 * DESCRIPTION: *
11818 * This PL/SQL procedure is used to migrate the Sub Ledger control *
11819 * date Records *
11820 * *
11821 * PARAMETERS: *
11822 * P_migration_run_id - id to use to right to migration log *
11823 * x_exception_count - Number of exceptions occurred. *
11824 * *
11825 * SYNOPSIS: *
11826 * Migrate_SubLedger_control(p_migartion_id => l_migration_id, *
11827 * p_commit => 'T', *
11828 * x_exception_count => l_exception_count ); *
11829 * *
11830 * HISTORY *
11831 * 08-Sep-2006 Created Anand Thiyagarajan *
11832 * *
11833 **********************************************************************/
11834 PROCEDURE Migrate_SubLedger_control
11835 (
11836 P_migration_run_id IN NUMBER,
11837 P_commit IN VARCHAR2,
11838 X_failure_count OUT NOCOPY NUMBER
11839 )
11840 IS
11841
11842 /***************************
11843 * PL/SQL Table Definitions *
11844 ***************************/
11845
11846 /******************
11847 * Local Variables *
11848 ******************/
11849
11850 BEGIN
11851
11852 G_Migration_run_id := P_migration_run_id;
11853 G_Table_name := 'GL_SUBR_STA';
11854 G_Context := 'Sub Ledger control data Migration';
11855 X_failure_count := 0;
11856
11857 /********************************
11858 * Migration Started Log Message *
11859 ********************************/
11860
11861 GMA_COMMON_LOGGING.gma_migration_central_log
11862 (
11863 p_run_id => G_migration_run_id,
11864 p_log_level => FND_LOG.LEVEL_STATEMENT,
11865 p_message_token => 'GMA_MIGRATION_TABLE_STARTED',
11866 p_table_name => G_Table_name,
11867 p_context => G_context,
11868 p_db_error => NULL,
11869 p_app_short_name => 'GMA'
11870 );
11871
11872
11873 /**********************************
11874 * Update row in GL_SUBR_STA table *
11875 ***********************************/
11876
11877 BEGIN
11878 UPDATE gl_subr_sta a
11879 SET (
11880 a.legal_entity_id,
11881 a.legal_entity_name,
11882 a.base_currency,
11883 a.ledger_id,
11884 a.cost_mthd_code,
11885 a.cost_type,
11886 a.cost_type_id,
11887 a.default_cost_mthd_code,
11888 a.default_cost_type_id,
11889 a.cost_basis
11890 )
11891 =
11892 (
11893 select gfp.legal_entity_id,
11894 xep.name,
11895 gfp.base_currency_code,
11896 gfp.ledger_id,
11897 cmm.cost_mthd_code,
11898 cmm.cost_type,
11899 cmm.cost_type_id,
11900 dcmm.cost_mthd_code default_lot_cost_mthd_code,
11901 cmm.default_lot_cost_type_id,
11902 gfp.cost_basis
11903 from cm_mthd_mst cmm,
11904 cm_mthd_mst dcmm,
11905 gl_plcy_mst gpm,
11906 gmf_fiscal_policies gfp,
11907 xle_entity_profiles xep
11908 where gpm.co_code = a.co_code
11909 and gfp.legal_entity_id = gpm.legal_entity_id
11910 and xep.legal_entity_id = gfp.legal_entity_id
11911 and cmm.cost_type_id = gfp.cost_type_id
11912 and cmm.default_lot_cost_type_id = dcmm.cost_type_id(+)
11913 ),
11914 a.post_cm_rval = decode(a.post_cm, 1, 1, 0),
11915 a.post_cm_cadj = 0
11916 where (a.co_code is not null and a.legal_entity_id is null)
11917 OR (a.co_code is not null and a.cost_type_id is null);
11918
11919 UPDATE gl_subr_sta gss
11920 SET (
11921 gss.crev_curr_cost_type_id,
11922 gss.crev_curr_period_id
11923 )
11924 =
11925 (
11926 select gps.cost_type_id , gps.period_id
11927 from gmf_period_statuses gps,
11928 cm_mthd_mst cmm
11929 where gps.calendar_code = gss.crev_curr_calendar
11930 and gps.period_code = gss.crev_curr_period
11931 and cmm.cost_mthd_code = gss.crev_curr_mthd
11932 and gps.legal_entity_id = gss.legal_entity_id
11933 and cmm.cost_type_id = gps.cost_type_id
11934 ),
11935 (
11936 gss.crev_prev_cost_type_id,
11937 gss.crev_prev_period_id
11938 )
11939 =
11940 (
11941 select gps.cost_type_id , gps.period_id
11942 from gmf_period_statuses gps,
11943 cm_mthd_mst cmm
11944 where gps.calendar_code = gss.crev_prev_calendar
11945 and gps.period_code = gss.crev_prev_period
11946 and cmm.cost_mthd_code = gss.crev_prev_mthd
11947 and gps.legal_entity_id = gss.legal_entity_id
11948 and cmm.cost_type_id = gps.cost_type_id
11949 ),
11950 gss.period_id
11951 = (
11952 SELECT x.period_id
11953 FROM gmf_period_statuses x
11954 WHERE x.legal_entity_id = gss.legal_entity_id
11955 AND x.cost_type_id = gss.cost_type_id
11956 AND gss.period_start_date between x.start_date and x.end_date
11957 AND gss.period_end_date between x.start_date and x.end_date
11958 AND x.delete_mark <> 1
11959 AND ROWNUM = 1
11960 )
11961 where (gss.crev_curr_mthd is not null AND gss.crev_curr_cost_type_id IS NULL)
11962 OR (gss.crev_curr_calendar is not null and gss.crev_curr_period is not NULL AND gss.crev_curr_period_id is null)
11963 OR (gss.crev_prev_mthd is not null AND gss.crev_prev_cost_type_id IS NULL)
11964 OR (gss.crev_prev_calendar is not null and gss.crev_prev_period is not NULL AND gss.crev_prev_period_id is null)
11965 OR (gss.legal_entity_id IS NOT NULL AND gss.cost_type_id IS NOT NULL AND gss.period_id IS NULL);
11966
11967 EXCEPTION
11968 WHEN OTHERS THEN
11969
11970 /************************************************
11971 * Increment Failure Count for Failed Migrations *
11972 ************************************************/
11973
11974 x_failure_count := x_failure_count + 1;
11975
11976 /**************************************
11977 * Migration DB Error Log Message *
11978 **************************************/
11979
11980 GMA_COMMON_LOGGING.gma_migration_central_log
11981 (
11982 p_run_id => G_migration_run_id,
11983 p_log_level => FND_LOG.LEVEL_ERROR,
11984 p_message_token => 'GMA_MIGRATION_DB_ERROR',
11985 p_table_name => G_Table_name,
11986 p_context => G_context,
11987 p_db_error => SQLERRM,
11988 p_app_short_name => 'GMA'
11989 );
11990
11991 /**************************************
11992 * Migration Failure Log Message *
11993 **************************************/
11994
11995 GMA_COMMON_LOGGING.gma_migration_central_log
11996 (
11997 p_run_id => G_migration_run_id,
11998 p_log_level => FND_LOG.LEVEL_ERROR,
11999 p_message_token => 'GMA_TABLE_MIGRATION_TABLE_FAIL',
12000 p_table_name => G_Table_name,
12001 p_context => G_context,
12002 p_db_error => NULL,
12003 p_app_short_name => 'GMA'
12004 );
12005
12006 END;
12007
12008 /**********************************************
12009 * Handle all the rows which were not migrated *
12010 **********************************************/
12011 gmf_migration.Log_Errors (
12012 p_log_level => 1,
12013 p_from_rowid => NULL,
12014 p_to_rowid => NULL
12015 );
12016
12017 /****************************************************************
12018 * Lets save the changes now based on the commit parameter *
12019 ****************************************************************/
12020
12021 IF NVL(p_commit,'~') = FND_API.G_TRUE THEN
12022 COMMIT;
12023 END IF;
12024
12025 EXCEPTION
12026
12027 WHEN OTHERS THEN
12028
12029 /************************************************
12030 * Increment Failure Count for Failed Migrations *
12031 ************************************************/
12032
12033 x_failure_count := x_failure_count + 1;
12034
12035 /**************************************
12036 * Migration DB Error Log Message *
12037 **************************************/
12038
12039 GMA_COMMON_LOGGING.gma_migration_central_log
12040 (
12041 p_run_id => G_migration_run_id,
12042 p_log_level => FND_LOG.LEVEL_ERROR,
12043 p_message_token => 'GMA_MIGRATION_DB_ERROR',
12044 p_table_name => G_Table_name,
12045 p_context => G_context,
12046 p_param1 => NULL,
12047 p_param2 => NULL,
12048 p_db_error => SQLERRM,
12049 p_app_short_name => 'GMA'
12050 );
12051
12052 /**************************************
12053 * Migration Failure Log Message *
12054 **************************************/
12055
12056 GMA_COMMON_LOGGING.gma_migration_central_log
12057 (
12058 p_run_id => G_migration_run_id,
12059 p_log_level => FND_LOG.LEVEL_ERROR,
12060 p_message_token => 'GMA_TABLE_MIGRATION_TABLE_FAIL',
12061 p_table_name => G_Table_name,
12062 p_context => G_context,
12063 p_db_error => NULL,
12064 p_app_short_name => 'GMA'
12065 );
12066
12067 END Migrate_SubLedger_control;
12068
12069 /**********************************************************************
12070 * PROCEDURE: *
12071 * Migrate_Cost_Warehouses *
12072 * *
12073 * DESCRIPTION: *
12074 * This PL/SQL procedure is used to transform the Cost Warehouses *
12075 * data in CM_WHSE_ASC *
12076 * *
12077 * PARAMETERS: *
12078 * P_migration_run_id - id to use to right to migration log *
12079 * x_exception_count - Number of exceptions occurred. *
12080 * *
12081 * SYNOPSIS: *
12082 * Migrate_Cost_Warehouses(p_migartion_id => l_migration_id, *
12083 * p_commit => 'T', *
12084 * x_exception_count => l_exception_count ); *
12085 * *
12086 * HISTORY *
12087 * 04-Nov-2005 Created rseshadr *
12088 * *
12089 **********************************************************************/
12090 PROCEDURE Migrate_Cost_Warehouses
12091 (
12092 P_migration_run_id IN NUMBER,
12093 P_commit IN VARCHAR2,
12094 X_failure_count OUT NOCOPY NUMBER
12095 )
12096 IS
12097
12098 /****************
12099 * PL/SQL Tables *
12100 ****************/
12101
12102 /******************
12103 * Local Variables *
12104 ******************/
12105
12106 l_costing_organization_id NUMBER;
12107
12108 /**********
12109 * Cursors *
12110 **********/
12111 CURSOR cur_ic_whse_mst
12112 IS
12113 SELECT a.whse_code,
12114 NVL(a.subinventory_ind_flag, 'N') subinventory_ind_flag,
12115 a.mtl_organization_id,
12116 a.organization_id,
12117 b.orgn_code,
12118 NVL(b.inventory_org_ind, 'N') inventory_org_ind,
12119 NVL(b.migrate_as_ind, 0) orgn_migrated_as_ind,
12120 decode(a.organization_id, a.mtl_organization_id, 'Y', 'N') same_plant_whse,
12121 SUM(decode(NVL(c.subinventory_ind_flag, 'N'), 'N', 0, 1)) Subinventory_count,
12122 DECODE(COUNT(d.cost_whse_code), 0, 'N', 'Y') cost_warehouse,
12123 DECODE(COUNT(f.cost_whse_code), 0, 'N', 'Y') same_plant_cost_warehouse,
12124 DECODE(SUM(DECODE(f.cost_whse_code, NULL, 0, DECODE(NVL(c.subinventory_ind_flag, 'N'), 'N', 0, 1))), 0, 'N', 'Y') cost_whse_is_subinv,
12125 DECODE(COUNT(e.whse_code), 0, 'N', 'Y') inv_warehouse
12126 FROM ic_whse_mst a,
12127 sy_orgn_mst b,
12128 ic_whse_mst c,
12129 cm_whse_asc d,
12130 cm_whse_asc e,
12131 cm_whse_asc f
12132 WHERE a.orgn_code = b.orgn_code
12133 AND c.orgn_code = a.orgn_code
12134 AND d.cost_whse_code(+) = a.whse_code
12135 AND f.cost_whse_code(+) = c.whse_code
12136 AND e.whse_code(+) = a.whse_code
12137 AND SYSDATE BETWEEN d.eff_start_date(+) AND d.eff_end_date(+)
12138 AND SYSDATE BETWEEN e.eff_start_date(+) AND e.eff_end_date(+)
12139 AND SYSDATE BETWEEN f.eff_start_date(+) AND f.eff_end_date(+)
12140 GROUP BY a.whse_code,
12141 a.subinventory_ind_flag,
12142 a.mtl_organization_id,
12143 a.organization_id,
12144 b.orgn_code,
12145 b.inventory_org_ind,
12146 b.migrate_as_ind,
12147 b.organization_id
12148 ORDER BY a.whse_code;
12149 BEGIN
12150
12151 G_Migration_run_id := P_migration_run_id;
12152 G_Table_name := 'CM_WHSE_ASC';
12153 G_Context := 'Cost Warehouses Migration';
12154 X_failure_count := 0;
12155
12156 /********************************
12157 * Migration Started Log Message *
12158 ********************************/
12159
12160 GMA_COMMON_LOGGING.gma_migration_central_log
12161 (
12162 p_run_id => G_migration_run_id,
12163 p_log_level => FND_LOG.LEVEL_STATEMENT,
12164 p_message_token => 'GMA_MIGRATION_TABLE_STARTED',
12165 p_table_name => G_table_name,
12166 p_context => G_context,
12167 p_db_error => NULL,
12168 p_app_short_name => 'GMA'
12169 );
12170
12171 /***********************************************************************************
12172 * Migrate warehouse records in IC_WHSE_MST to facilitate Cost Warehouse Derivation *
12173 ***********************************************************************************/
12174 FOR i IN cur_ic_whse_mst LOOP
12175 IF nvl(i.subinventory_ind_flag, 'N') <> 'Y' THEN /* Migrated as Inventory Organization */
12176 l_costing_organization_id := i.mtl_organization_id;
12177 ELSE /* Migrated as Sub-Inventory */
12178 IF nvl(i.Subinventory_count,0) = 1 THEN /* Only Warehouse under the plant Migrated as Sub-Inventory */
12179 l_costing_organization_id := i.organization_id;
12180 ELSE /* More than One Sub-inventory under the plant */
12181 IF NVL(i.cost_warehouse,'N') = 'Y' THEN /* Exists as Cost Warehoue */
12182 IF NVL(i.orgn_migrated_as_ind, 0) IN (1, 2) THEN /* OPM Plant Migrated as New or Existing Organization*/
12183 l_costing_organization_id := i.organization_id;
12184 ELSE /* OPM Plant Migrated as None or Inactive */
12185 l_costing_organization_id := i.mtl_organization_id;
12186 END IF;
12187 ELSIF NVL(i.inv_warehouse,'N') = 'Y' THEN /* Exists as Inventory Warehoue under a Cost Warehouse */
12188 IF nvl(i.same_plant_whse, 'N') = 'Y'
12189 AND nvl(i.same_plant_cost_warehouse, 'N') = 'Y'
12190 AND nvl(i.cost_whse_is_subinv, 'N') = 'Y' THEN /* OPM Plant Migrated to Own Warehouse's Organization Id */
12191 l_costing_organization_id := -1;
12192 ELSE /* Migrated to Different Warehouse's Organization Id */
12193 l_costing_organization_id := i.mtl_organization_id;
12194 END IF;
12195 ELSE /* Doesnt Exist as INV or Cost Warehouse */
12196 l_costing_organization_id := i.mtl_organization_id;
12197 END IF;
12198 END IF;
12199 END IF;
12200
12201 UPDATE ic_whse_mst a
12202 SET a.cost_organization_id = l_costing_organization_id
12203 WHERE a.whse_code = i.whse_code;
12204 END LOOP;
12205
12206 UPDATE cm_whse_asc a
12207 SET (
12208 a.organization_id
12209 )
12210 = (
12211 SELECT x.cost_organization_id
12212 FROM ic_whse_mst x
12213 WHERE x.whse_code = a.whse_code
12214 ),
12215 (
12216 a.cost_organization_id
12217 )
12218 = (
12219 SELECT x.cost_organization_id
12220 FROM ic_whse_mst x
12221 WHERE x.whse_code = a.cost_whse_code
12222 );
12223
12224 UPDATE cm_whse_asc a
12225 SET delete_mark = 1
12226 WHERE (
12227 ROWID NOT IN (
12228 SELECT MIN(ROWID)
12229 FROM cm_whse_asc x
12230 WHERE x.cost_organization_id = a.cost_organization_id
12231 AND x.organization_id = a.organization_id
12232 AND x.delete_mark <> 1
12233 AND (
12234 (a.eff_start_date BETWEEN x.eff_start_date AND x.eff_end_date)
12235 OR
12236 (a.eff_end_date BETWEEN x.eff_start_date AND x.eff_end_date)
12237 )
12238 )
12239 )
12240 OR cost_organization_id = -1;
12241
12242 /**********************************************
12243 * Handle all the rows which were not migrated *
12244 **********************************************/
12245
12246 SELECT count(*)
12247 INTO x_failure_count
12248 FROM cm_whse_asc
12249 WHERE (organization_id IS NULL AND whse_code IS NOT NULL)
12250 OR (cost_organization_id IS NULL AND cost_whse_code IS NOT NULL);
12251
12252 IF nvl(x_failure_count,0) > 0 THEN
12253
12254 /**************************************
12255 * Migration Failure Log Message *
12256 **************************************/
12257
12258 GMA_COMMON_LOGGING.gma_migration_central_log
12259 (
12260 p_run_id => gmf_migration.G_migration_run_id,
12261 p_log_level => FND_LOG.LEVEL_PROCEDURE,
12262 p_message_token => 'GMA_TABLE_MIGRATION_TABLE_FAIL',
12263 p_table_name => gmf_migration.G_Table_name,
12264 p_context => gmf_migration.G_context,
12265 p_db_error => NULL,
12266 p_app_short_name => 'GMA'
12267 );
12268
12269 ELSE
12270
12271 /**************************************
12272 * Migration Success Log Message *
12273 **************************************/
12274
12275 GMA_COMMON_LOGGING.gma_migration_central_log
12276 (
12277 p_run_id => G_migration_run_id,
12278 p_log_level => FND_LOG.LEVEL_STATEMENT,
12279 p_message_token => 'GMA_MIGRATION_TABLE_SUCCESS',
12280 p_table_name => G_Table_name,
12281 p_context => G_Context,
12282 p_param1 => 1,
12283 p_param2 => 0,
12284 p_db_error => NULL,
12285 p_app_short_name => 'GMA'
12286 );
12287
12288 END IF;
12289
12290 /****************************************************************
12291 * Lets save the changes now based on the commit parameter *
12292 ****************************************************************/
12293
12294 IF NVL(p_commit,'~') = FND_API.G_TRUE THEN
12295 COMMIT;
12296 END IF;
12297
12298 EXCEPTION
12299 WHEN OTHERS THEN
12300
12301 /************************************************
12302 * Increment Failure Count for Failed Migrations *
12303 ************************************************/
12304 x_failure_count := x_failure_count + 1;
12305
12306 /**************************************
12307 * Migration DB Error Log Message *
12308 **************************************/
12309
12310 GMA_COMMON_LOGGING.gma_migration_central_log
12311 (
12312 p_run_id => G_migration_run_id,
12313 p_log_level => FND_LOG.LEVEL_ERROR,
12314 p_message_token => 'GMA_MIGRATION_DB_ERROR',
12315 p_table_name => G_table_name,
12316 p_context => G_context,
12317 p_db_error => SQLERRM,
12318 p_app_short_name => 'GMA'
12319 );
12320
12321 /**************************************
12322 * Migration Failure Log Message *
12323 **************************************/
12324
12325 GMA_COMMON_LOGGING.gma_migration_central_log
12326 (
12327 p_run_id => G_migration_run_id,
12328 p_log_level => FND_LOG.LEVEL_ERROR,
12329 p_message_token => 'GMA_TABLE_MIGRATION_TABLE_FAIL',
12330 p_table_name => G_table_name,
12331 p_context => G_context,
12332 p_db_error => NULL,
12333 p_app_short_name => 'GMA'
12334 );
12335
12336 END Migrate_Cost_Warehouses;
12337
12338 /**********************************************************************
12339 * PROCEDURE: *
12340 * Log_Errors *
12341 * *
12342 * DESCRIPTION: *
12343 * This PL/SQL procedure is used to Log Errors from the Migration Run*
12344 * *
12345 * PARAMETERS: *
12346 * *
12347 * SYNOPSIS: *
12348 * Log Errors; *
12349 * *
12350 * HISTORY *
12351 * 23-Sep-2006 Created Anand Thiyagarajan *
12352 * *
12353 **********************************************************************/
12354 PROCEDURE Log_Errors
12355 (
12356 p_log_level IN PLS_INTEGER DEFAULT 2,
12357 p_from_rowid IN ROWID,
12358 p_to_rowid IN ROWID
12359 )
12360 IS
12361
12362 /****************
12363 * PL/SQL Tables *
12364 ****************/
12365 TYPE p_error_rec IS RECORD (table_name VARCHAR2(30), column_name VARCHAR2(30), parameters VARCHAR2(1000), records BINARY_INTEGER);
12366 TYPE p_error_tbl IS TABLE OF p_error_rec INDEX BY BINARY_INTEGER;
12367
12368 TYPE p_cur_gmf_log_errors IS REF CURSOR;
12369
12370 /******************
12371 * Local Variables *
12372 ******************/
12373 l_error_tbl p_error_tbl;
12374 l_table_name VARCHAR2(256) := gmf_migration.G_Table_name;
12375 l_sql_statement VARCHAR2(32000) := 'SELECT count(*) FROM '||l_table_name||' WHERE ';
12376 l_failure_count NUMBER;
12377 l_legal_entity_count PLS_INTEGER := 0;
12378 l_organization_count PLS_INTEGER := 0;
12379 l_source_organization_count PLS_INTEGER := 0;
12380 l_master_organization_count PLS_INTEGER := 0;
12381 l_inventory_item_count PLS_INTEGER := 0;
12382 l_lot_number_count PLS_INTEGER := 0;
12383 l_cost_type_count PLS_INTEGER := 0;
12384 l_prev_cost_type_count PLS_INTEGER := 0;
12385 l_curr_cost_type_count PLS_INTEGER := 0;
12386 l_period_count PLS_INTEGER := 0;
12387 l_prev_period_count PLS_INTEGER := 0;
12388 l_curr_period_count PLS_INTEGER := 0;
12389 l_adjustment_ind_count PLS_INTEGER := 0;
12390 l_uom_count1 PLS_INTEGER := 0;
12391 l_uom_count2 PLS_INTEGER := 0;
12392 l_uom_count3 PLS_INTEGER := 0;
12393 l_unique_error_count PLS_INTEGER := 0;
12394 l_not_null_error_count PLS_INTEGER := 0;
12395 l_value_error_count PLS_INTEGER := 0;
12396 l_parent_key_error_count PLS_INTEGER := 0;
12397 l_too_long_error_count PLS_INTEGER := 0;
12398 l_invalid_number_error_count PLS_INTEGER := 0;
12399 l_not_picked_up_error_count PLS_INTEGER := 0;
12400 l_total_error_count PLS_INTEGER := 0;
12401
12402 l_cm_rsrc_dtl VARCHAR2(32000) := 'SELECT ''CM_RSRC_DTL'' table_name,
12403 cm_rsrc_dtl.*
12404 FROM (
12405 SELECT ''LEGAL_ENTITY_ID'' column_name,
12406 ''Orgn Code: ''|| orgn_code parameters,
12407 count(*) records
12408 FROM cm_rsrc_dtl
12409 WHERE (legal_entity_id IS NULL AND orgn_code IS NOT NULL)
12410 GROUP BY orgn_code
12411 HAVING count(*) > 0
12412 UNION
12413 SELECT ''ORGANIZATION_ID'' column_name,
12414 ''Orgn Code: ''|| orgn_code parameters,
12415 count(*) records
12416 FROM cm_rsrc_dtl
12417 WHERE (organization_id IS NULL AND delete_mark = 0 AND orgn_code IS NOT NULL)
12418 GROUP BY orgn_code
12419 HAVING count(*) > 0
12420 UNION
12421 SELECT ''COST_TYPE_ID'' column_name,
12422 ''Cost Method Code: ''|| cost_mthd_code parameters,
12423 count(*) records
12424 FROM cm_rsrc_dtl
12425 WHERE (cost_type_id IS NULL AND cost_mthd_code IS NOT NULL)
12426 GROUP BY cost_mthd_code
12427 HAVING count(*) > 0
12428 UNION
12429 SELECT ''PERIOD_ID'' column_name,
12430 ''Calendar Code: ''|| calendar_code ||'', Period Code: ''|| period_code parameters,
12431 count(*) records
12432 FROM cm_rsrc_dtl
12433 WHERE (period_id IS NULL AND calendar_code IS NOT NULL AND period_code IS NOT NULL)
12434 GROUP BY calendar_code, period_code
12435 HAVING count(*) > 0
12436 UNION
12437 SELECT ''USAGE_UOM'' column_name,
12438 ''UM Code: ''|| usage_um parameters,
12439 count(*) records
12440 FROM cm_rsrc_dtl
12441 WHERE (usage_uom IS NULL AND usage_um IS NOT NULL)
12442 GROUP BY usage_um
12443 HAVING count(*) > 0
12444 ) cm_rsrc_dtl';
12445 l_cm_adjs_dtl VARCHAR2(32000) := 'SELECT ''CM_ADJS_DTL'' table_name,
12446 cm_adjs_dtl.*
12447 FROM (
12448 SELECT ''ORGANIZATION_ID'' column_name,
12449 ''Warehouse Code: ''|| whse_code parameters,
12450 count(*) records
12451 FROM cm_adjs_dtl
12452 WHERE (organization_id IS NULL AND whse_code IS NOT NULL)
12453 GROUP BY whse_code
12454 HAVING count(*) > 0
12455 UNION
12456 SELECT ''INVENTORY_ITEM_ID'' column_name,
12457 ''Item No: ''|| b.item_no parameters,
12458 count(*) records
12459 FROM cm_adjs_dtl a, ic_item_mst b
12460 WHERE (a.inventory_item_id IS NULL AND a.item_id IS NOT NULL)
12461 AND b.item_id = a.item_id
12462 GROUP BY b.item_no
12463 HAVING count(*) > 0
12464 UNION
12465 SELECT ''COST_TYPE_ID'' column_name,
12466 ''Cost Method Code: ''|| cost_mthd_code parameters,
12467 count(*) records
12468 FROM cm_adjs_dtl
12469 WHERE (cost_type_id IS NULL AND cost_mthd_code IS NOT NULL)
12470 GROUP BY cost_mthd_code
12471 HAVING count(*) > 0
12472 UNION
12473 SELECT ''PERIOD_ID'' column_name,
12474 ''Calendar Code: ''|| calendar_code ||'', Period Code: ''|| period_code parameters,
12475 count(*) records
12476 FROM cm_adjs_dtl
12477 WHERE (period_id IS NULL AND calendar_code IS NOT NULL AND period_code IS NOT NULL)
12478 GROUP BY calendar_code, period_code
12479 HAVING count(*) > 0
12480 UNION
12481 SELECT ''ADJUST_QTY_UOM'' column_name,
12482 ''Adjust qty UM: ''|| adjust_qty_um parameters,
12483 count(*) records
12484 FROM cm_adjs_dtl
12485 WHERE (adjust_qty_uom IS NULL AND adjust_qty_um IS NOT NULL)
12486 GROUP BY adjust_qty_um
12487 HAVING count(*) > 0
12488 UNION
12489 SELECT ''ADJUSTMENT_IND'' column_name,
12490 ''NULL'' parameters,
12491 count(*) records
12492 FROM cm_adjs_dtl
12493 WHERE (adjustment_ind IS NULL)
12494 HAVING count(*) > 0
12495 ) cm_adjs_dtl';
12496 l_cm_cmpt_dtl VARCHAR2(32000) := 'SELECT ''CM_CMPT_DTL'' table_name,
12497 cm_cmpt_dtl.*
12498 FROM (
12499 SELECT ''ORGANIZATION_ID'' column_name,
12500 ''Warehouse Code: ''|| whse_code parameters,
12501 count(*) records
12502 FROM cm_cmpt_dtl
12503 WHERE (organization_id IS NULL AND whse_code IS NOT NULL)
12504 GROUP BY whse_code
12505 HAVING count(*) > 0
12506 UNION
12507 SELECT ''INVENTORY_ITEM_ID'' column_name,
12508 ''Item No: ''|| b.item_no parameters,
12509 count(*) records
12510 FROM cm_cmpt_dtl a, ic_item_mst b
12511 WHERE (a.inventory_item_id IS NULL AND a.item_id IS NOT NULL)
12512 AND b.item_id = a.item_id
12513 GROUP BY b.item_no
12514 HAVING count(*) > 0
12515 UNION
12516 SELECT ''COST_TYPE_ID'' column_name,
12517 ''Cost Method Code: ''|| cost_mthd_code parameters,
12518 count(*) records
12519 FROM cm_cmpt_dtl
12520 WHERE (cost_type_id IS NULL AND cost_mthd_code IS NOT NULL)
12521 GROUP BY cost_mthd_code
12522 HAVING count(*) > 0
12523 UNION
12524 SELECT ''PERIOD_ID'' column_name,
12525 ''Calendar Code: ''|| calendar_code ||'', Period Code: ''|| period_code parameters,
12526 count(*) records
12527 FROM cm_cmpt_dtl
12528 WHERE (period_id IS NULL AND calendar_code IS NOT NULL AND period_code IS NOT NULL)
12529 GROUP BY calendar_code, period_code
12530 HAVING count(*) > 0
12531 ) cm_cmpt_dtl';
12532 l_cm_brdn_dtl VARCHAR2(32000) := 'SELECT ''CM_BRDN_DTL'' table_name,
12533 cm_brdn_dtl.*
12534 FROM (
12535 SELECT ''ORGANIZATION_ID'' column_name,
12536 ''Warehouse Code: ''|| whse_code parameters,
12537 count(*) records
12538 FROM cm_brdn_dtl
12539 WHERE (organization_id IS NULL AND whse_code IS NOT NULL)
12540 GROUP BY whse_code
12541 HAVING count(*) > 0
12542 UNION
12543 SELECT ''INVENTORY_ITEM_ID'' column_name,
12544 ''Item No: ''|| b.item_no parameters,
12545 count(*) records
12546 FROM cm_brdn_dtl a, ic_item_mst b
12547 WHERE (a.inventory_item_id IS NULL AND a.item_id IS NOT NULL)
12548 AND b.item_id = a.item_id
12549 GROUP BY b.item_no
12550 HAVING count(*) > 0
12551 UNION
12552 SELECT ''COST_TYPE_ID'' column_name,
12553 ''Cost Method Code: ''|| cost_mthd_code parameters,
12554 count(*) records
12555 FROM cm_brdn_dtl
12556 WHERE (cost_type_id IS NULL AND cost_mthd_code IS NOT NULL)
12557 GROUP BY cost_mthd_code
12558 HAVING count(*) > 0
12559 UNION
12560 SELECT ''PERIOD_ID'' column_name,
12561 ''Calendar Code: ''|| calendar_code ||'', Period Code: ''|| period_code parameters,
12562 count(*) records
12563 FROM cm_brdn_dtl
12564 WHERE (period_id IS NULL AND calendar_code IS NOT NULL AND period_code IS NOT NULL)
12565 GROUP BY calendar_code, period_code
12566 HAVING count(*) > 0
12567 UNION
12568 SELECT ''ITEM_UOM'' column_name,
12569 ''Item UM: ''|| item_um parameters,
12570 count(*) records
12571 FROM cm_brdn_dtl
12572 WHERE (item_uom IS NULL AND item_um IS NOT NULL)
12573 GROUP BY item_um
12574 HAVING count(*) > 0
12575 UNION
12576 SELECT ''BURDEN_UOM'' column_name,
12577 ''Burden UM: ''|| burden_um parameters,
12578 count(*) records
12579 FROM cm_brdn_dtl
12580 WHERE (burden_uom IS NULL AND burden_um IS NOT NULL)
12581 GROUP BY burden_um
12582 HAVING count(*) > 0
12583 ) cm_brdn_dtl';
12584 l_gl_item_cst VARCHAR2(32000) := 'SELECT ''GL_ITEM_CST'' table_name,
12585 gl_item_cst.*
12586 FROM (
12587 SELECT ''ORGANIZATION_ID'' column_name,
12588 ''Warehouse Code: ''|| whse_code parameters,
12589 count(*) records
12590 FROM gl_item_cst
12591 WHERE (organization_id IS NULL AND whse_code IS NOT NULL)
12592 GROUP BY whse_code
12593 HAVING count(*) > 0
12594 UNION
12595 SELECT ''INVENTORY_ITEM_ID'' column_name,
12596 ''Item No: ''|| b.item_no parameters,
12597 count(*) records
12598 FROM gl_item_cst a, ic_item_mst b
12599 WHERE (a.inventory_item_id IS NULL AND a.item_id IS NOT NULL)
12600 AND b.item_id = a.item_id
12601 GROUP BY b.item_no
12602 HAVING count(*) > 0
12603 UNION
12604 SELECT ''COST_TYPE_ID'' column_name,
12605 ''Cost Method Code: ''|| cost_mthd_code parameters,
12606 count(*) records
12607 FROM gl_item_cst
12608 WHERE (cost_type_id IS NULL AND cost_mthd_code IS NOT NULL)
12609 GROUP BY cost_mthd_code
12610 HAVING count(*) > 0
12611 UNION
12612 SELECT ''PERIOD_ID'' column_name,
12613 ''Calendar Code: ''|| calendar_code ||'', Period Code: ''|| period_code parameters,
12614 count(*) records
12615 FROM gl_item_cst
12616 WHERE (period_id IS NULL AND calendar_code IS NOT NULL AND period_code IS NOT NULL)
12617 GROUP BY calendar_code, period_code
12618 HAVING count(*) > 0
12619 ) gl_item_cst';
12620 l_cm_scst_led VARCHAR2(32000) := 'SELECT ''CM_SCST_LED'' table_name,
12621 cm_scst_led.*
12622 FROM (
12623 SELECT ''ORGANIZATION_ID'' column_name,
12624 ''Warehouse Code: ''|| whse_code parameters,
12625 count(*) records
12626 FROM cm_scst_led
12627 WHERE (organization_id IS NULL AND whse_code IS NOT NULL)
12628 GROUP BY whse_code
12629 HAVING count(*) > 0
12630 UNION
12631 SELECT ''INVENTORY_ITEM_ID'' column_name,
12632 ''Item No: ''|| b.item_no parameters,
12633 count(*) records
12634 FROM cm_scst_led a, ic_item_mst b
12635 WHERE (a.inventory_item_id IS NULL AND a.item_id IS NOT NULL)
12636 AND b.item_id = a.item_id
12637 GROUP BY b.item_no
12638 HAVING count(*) > 0
12639 UNION
12640 SELECT ''FORM_PROD_UOM'' column_name,
12641 ''Formula UM: ''|| form_prod_um parameters,
12642 count(*) records
12643 FROM cm_scst_led
12644 WHERE (form_prod_uom IS NULL AND form_prod_um IS NOT NULL)
12645 GROUP BY form_prod_um
12646 HAVING count(*) > 0
12647 UNION
12648 SELECT ''ITEM_FMQTY_UOM'' column_name,
12649 ''Item UOM: ''|| item_fmqty_um parameters,
12650 count(*) records
12651 FROM cm_scst_led
12652 WHERE (item_fmqty_uom IS NULL AND item_fmqty_um IS NOT NULL)
12653 GROUP BY item_fmqty_um
12654 HAVING count(*) > 0
12655 UNION
12656 SELECT ''USAGE_UOM'' column_name,
12657 ''Usage UOM: ''|| usage_um parameters,
12658 count(*) records
12659 FROM cm_scst_led
12660 WHERE (usage_uom IS NULL AND usage_um IS NOT NULL)
12661 GROUP BY usage_um
12662 HAVING count(*) > 0
12663 ) cm_scst_led';
12664 l_cm_acst_led VARCHAR2(32000) := 'SELECT ''CM_ACST_LED'' table_name,
12665 cm_acst_led.*
12666 FROM (
12667 SELECT ''ORGANIZATION_ID'' column_name,
12668 ''Warehouse Code: ''|| whse_code parameters,
12669 count(*) records
12670 FROM cm_acst_led
12671 WHERE (organization_id IS NULL AND whse_code IS NOT NULL)
12672 GROUP BY whse_code
12673 HAVING count(*) > 0
12674 UNION
12675 SELECT ''INVENTORY_ITEM_ID'' column_name,
12676 ''Item No: ''|| b.item_no parameters,
12677 count(*) records
12678 FROM cm_acst_led a, ic_item_mst b
12679 WHERE (a.inventory_item_id IS NULL AND a.item_id IS NOT NULL)
12680 AND b.item_id = a.item_id
12681 GROUP BY b.item_no
12682 HAVING count(*) > 0
12683 UNION
12684 SELECT ''COST_TYPE_ID'' column_name,
12685 ''Cost Method Code: ''|| cost_mthd_code parameters,
12686 count(*) records
12687 FROM cm_acst_led
12688 WHERE (cost_type_id IS NULL AND cost_mthd_code IS NOT NULL)
12689 GROUP BY cost_mthd_code
12690 HAVING count(*) > 0
12691 UNION
12692 SELECT ''PERIOD_ID'' column_name,
12693 ''Calendar Code: ''|| calendar_code ||'', Period Code: ''|| period_code parameters,
12694 count(*) records
12695 FROM cm_acst_led
12696 WHERE (period_id IS NULL AND calendar_code IS NOT NULL AND period_code IS NOT NULL)
12697 GROUP BY calendar_code, period_code
12698 HAVING count(*) > 0
12699 ) cm_acst_led';
12700 l_gmf_lot_costs VARCHAR2(32000) := 'SELECT ''GMF_LOT_COSTS'' table_name,
12701 gmf_lot_costs.*
12702 FROM (
12703 SELECT ''ORGANIZATION_ID'' column_name,
12704 ''Warehouse Code: ''|| whse_code parameters,
12705 count(*) records
12706 FROM gmf_lot_costs
12707 WHERE (organization_id IS NULL AND whse_code IS NOT NULL)
12708 GROUP BY whse_code
12709 HAVING count(*) > 0
12710 UNION
12711 SELECT ''INVENTORY_ITEM_ID'' column_name,
12712 ''Item No: ''|| b.item_no parameters,
12713 count(*) records
12714 FROM gmf_lot_costs a, ic_item_mst b
12715 WHERE (a.inventory_item_id IS NULL AND a.item_id IS NOT NULL)
12716 AND b.item_id = a.item_id
12717 GROUP BY b.item_no
12718 HAVING count(*) > 0
12719 UNION
12720 SELECT ''COST_TYPE_ID'' column_name,
12721 ''Cost Method Code: ''|| cost_mthd_code parameters,
12722 count(*) records
12723 FROM gmf_lot_costs
12724 WHERE (cost_type_id IS NULL AND cost_mthd_code IS NOT NULL)
12725 GROUP BY cost_mthd_code
12726 HAVING count(*) > 0
12727 UNION
12728 SELECT ''LOT_NUMBER'' column_name,
12729 ''Lot Id: ''|| lot_id parameters,
12730 count(*) records
12731 FROM gmf_lot_costs
12732 WHERE (lot_number IS NULL AND lot_id IS NOT NULL)
12733 GROUP BY lot_id
12734 HAVING count(*) > 0
12735 ) gmf_lot_costs';
12736 l_gmf_lot_costed_items VARCHAR2(32000) := 'SELECT ''GMF_LOT_COSTED_ITEMS'' table_name,
12737 gmf_lot_costed_items.*
12738 FROM (
12739 SELECT ''LEGAL_ENTITY_ID'' column_name,
12740 ''Co Code: ''|| co_code parameters,
12741 count(*) records
12742 FROM gmf_lot_costed_items
12743 WHERE (legal_entity_id IS NULL AND co_code IS NOT NULL)
12744 GROUP BY co_code
12745 HAVING count(*) > 0
12746 UNION
12747 SELECT ''MASTER_ORGANIZATION_ID'' column_name,
12748 ''Item No: ''|| b.item_no ||'' Legal Entity: ''||a.legal_entity_id parameters,
12749 count(*) records
12750 FROM gmf_lot_costed_items a, ic_item_mst b
12751 WHERE (a.legal_entity_id IS NULL AND a.item_id IS NOT NULL)
12752 AND b.item_id = a.item_id
12753 GROUP BY b.item_no, a.legal_entity_id
12754 HAVING count(*) > 0
12755 UNION
12756 SELECT ''INVENTORY_ITEM_ID'' column_name,
12757 ''Item No: ''|| b.item_no parameters,
12758 count(*) records
12759 FROM gmf_lot_costed_items a, ic_item_mst b
12760 WHERE (a.inventory_item_id IS NULL AND a.item_id IS NOT NULL)
12761 AND b.item_id = a.item_id
12762 GROUP BY b.item_no
12763 HAVING count(*) > 0
12764 UNION
12765 SELECT ''COST_TYPE_ID'' column_name,
12766 ''Cost Method Code: ''|| cost_mthd_code parameters,
12767 count(*) records
12768 FROM gmf_lot_costed_items
12769 WHERE (cost_type_id IS NULL AND cost_mthd_code IS NOT NULL)
12770 GROUP BY cost_mthd_code
12771 HAVING count(*) > 0
12772 ) gmf_lot_costed_items';
12773 l_gmf_lot_cost_burdens VARCHAR2(32000) := 'SELECT ''GMF_LOT_COST_BURDENS'' table_name,
12774 gmf_lot_cost_burdens.*
12775 FROM (
12776 SELECT ''ORGANIZATION_ID'' column_name,
12777 ''Warehouse Code: ''|| whse_code parameters,
12778 count(*) records
12779 FROM gmf_lot_cost_burdens
12780 WHERE (organization_id IS NULL AND whse_code IS NOT NULL)
12781 GROUP BY whse_code
12782 HAVING count(*) > 0
12783 UNION
12784 SELECT ''INVENTORY_ITEM_ID'' column_name,
12785 ''Item No: ''|| b.item_no parameters,
12786 count(*) records
12787 FROM gmf_lot_cost_burdens a, ic_item_mst b
12788 WHERE (a.inventory_item_id IS NULL AND a.item_id IS NOT NULL)
12789 AND b.item_id = a.item_id
12790 GROUP BY b.item_no
12791 HAVING count(*) > 0
12792 UNION
12793 SELECT ''COST_TYPE_ID'' column_name,
12794 ''Cost Method Code: ''|| cost_mthd_code parameters,
12795 count(*) records
12796 FROM gmf_lot_cost_burdens
12797 WHERE (cost_type_id IS NULL AND cost_mthd_code IS NOT NULL)
12798 GROUP BY cost_mthd_code
12799 HAVING count(*) > 0
12800 UNION
12801 SELECT ''ITEM_UOM'' column_name,
12802 ''Item UOM: ''|| Item_um parameters,
12803 count(*) records
12804 FROM gmf_lot_cost_burdens
12805 WHERE (item_uom IS NULL AND item_um IS NOT NULL)
12806 GROUP BY item_um
12807 HAVING count(*) > 0
12808 UNION
12809 SELECT ''RESOURCE_UOM'' column_name,
12810 ''Resource UOM: ''|| Resource_um parameters,
12811 count(*) records
12812 FROM gmf_lot_cost_burdens
12813 WHERE (resource_uom IS NULL AND resource_um IS NOT NULL)
12814 GROUP BY resource_um
12815 HAVING count(*) > 0
12816 UNION
12817 SELECT ''LOT_NUMBER'' column_name,
12818 ''Lot Id: ''|| lot_id parameters,
12819 count(*) records
12820 FROM gmf_lot_cost_burdens
12821 WHERE (lot_number IS NULL AND lot_id IS NOT NULL)
12822 GROUP BY lot_id
12823 HAVING count(*) > 0
12824 ) gmf_lot_cost_burdens';
12825 l_gmf_lot_cost_adjustments VARCHAR2(32000) := 'SELECT ''GMF_LOT_COST_ADJUSTMENTS'' table_name,
12826 gmf_lot_cost_adjustments.*
12827 FROM (
12828 SELECT ''ORGANIZATION_ID'' column_name,
12829 ''Warehouse Code: ''|| whse_code parameters,
12830 count(*) records
12831 FROM gmf_lot_cost_adjustments
12832 WHERE (organization_id IS NULL AND whse_code IS NOT NULL)
12833 GROUP BY whse_code
12834 HAVING count(*) > 0
12835 UNION
12836 SELECT ''INVENTORY_ITEM_ID'' column_name,
12837 ''Item No: ''|| b.item_no parameters,
12838 count(*) records
12839 FROM gmf_lot_cost_adjustments a, ic_item_mst b
12840 WHERE (a.inventory_item_id IS NULL AND a.item_id IS NOT NULL)
12841 AND b.item_id = a.item_id
12842 GROUP BY b.item_no
12843 HAVING count(*) > 0
12844 UNION
12845 SELECT ''COST_TYPE_ID'' column_name,
12846 ''Cost Method Code: ''|| cost_mthd_code parameters,
12847 count(*) records
12848 FROM gmf_lot_cost_adjustments
12849 WHERE (cost_type_id IS NULL AND cost_mthd_code IS NOT NULL)
12850 GROUP BY cost_mthd_code
12851 HAVING count(*) > 0
12852 UNION
12853 SELECT ''LEGAL_ENTITY_ID'' column_name,
12854 ''Co Code: ''|| co_code parameters,
12855 count(*) records
12856 FROM gmf_lot_cost_adjustments
12857 WHERE (legal_entity_id IS NULL AND co_code IS NOT NULL)
12858 GROUP BY co_code
12859 HAVING count(*) > 0
12860 UNION
12861 SELECT ''LOT_NUMBER'' column_name,
12862 ''Lot Id: ''|| lot_id parameters,
12863 count(*) records
12864 FROM gmf_lot_cost_adjustments
12865 WHERE (lot_number IS NULL AND lot_id IS NOT NULL)
12866 GROUP BY lot_id
12867 HAVING count(*) > 0
12868 ) gmf_lot_cost_adjustments';
12869 l_gmf_material_lot_cost_txns VARCHAR2(32000) := 'SELECT ''GMF_MATERIAL_LOT_COST_TXNS'' table_name,
12870 gmf_material_lot_cost_txns.*
12871 FROM (
12872 SELECT ''COST_TYPE_ID'' column_name,
12873 ''Cost Type Code: ''|| cost_type_code parameters,
12874 count(*) records
12875 FROM gmf_material_lot_cost_txns
12876 WHERE (cost_type_id IS NULL AND cost_type_code IS NOT NULL)
12877 GROUP BY cost_type_code
12878 HAVING count(*) > 0
12879 UNION
12880 SELECT ''COST_TRANS_UOM'' column_name,
12881 ''Cost Trans UOM: ''|| cost_trans_uom parameters,
12882 count(*) records
12883 FROM gmf_material_lot_cost_txns
12884 WHERE (cost_trans_um IS NULL AND cost_trans_uom IS NOT NULL)
12885 GROUP BY cost_trans_uom
12886 HAVING count(*) > 0
12887 ) gmf_material_lot_cost_txns';
12888 l_cm_whse_src VARCHAR2(32000) := 'SELECT ''CM_WHSE_SRC'' table_name,
12889 cm_whse_src.*
12890 FROM (
12891 SELECT ''SOURCE_ORGANIZATION_ID'' column_name,
12892 ''Warehouse Code: ''|| whse_code parameters,
12893 count(*) records
12894 FROM cm_whse_src
12895 WHERE (source_organization_id IS NULL AND whse_code IS NOT NULL)
12896 GROUP BY whse_code
12897 HAVING count(*) > 0
12898 UNION
12899 SELECT ''ORGANIZATION_ID'' column_name,
12900 ''Orgn Code: ''|| orgn_code parameters,
12901 count(*) records
12902 FROM cm_whse_src
12903 WHERE (organization_id IS NULL AND orgn_code IS NOT NULL AND delete_mark = 0)
12904 GROUP BY orgn_code
12905 HAVING count(*) > 0
12906 UNION
12907 SELECT ''MASTER_ORGANIZATION_ID'' column_name,
12908 ''Item No: ''|| b.item_no ||'' Legal Entity: ''||a.legal_entity_id parameters,
12909 count(*) records
12910 FROM cm_whse_src a, ic_item_mst b
12911 WHERE (a.legal_entity_id IS NULL AND a.item_id IS NOT NULL)
12912 AND b.item_id = a.item_id
12913 GROUP BY b.item_no, a.legal_entity_id
12914 HAVING count(*) > 0
12915 UNION
12916 SELECT ''INVENTORY_ITEM_ID'' column_name,
12917 ''Item No: ''|| b.item_no parameters,
12918 count(*) records
12919 FROM cm_whse_src a, ic_item_mst b
12920 WHERE (a.inventory_item_id IS NULL AND a.item_id IS NOT NULL)
12921 AND b.item_id = a.item_id
12922 GROUP BY b.item_no
12923 HAVING count(*) > 0
12924 UNION
12925 SELECT ''LEGAL_ENTITY_ID'' column_name,
12926 ''Orgn Code: ''|| orgn_code parameters,
12927 count(*) records
12928 FROM cm_whse_src
12929 WHERE (legal_entity_id IS NULL AND orgn_code IS NOT NULL)
12930 GROUP BY orgn_code
12931 HAVING count(*) > 0
12932 ) cm_whse_src';
12933 l_cm_acpr_ctl VARCHAR2(32000) := 'SELECT ''CM_ACPR_CTL'' table_name,
12934 cm_acpr_ctl.*
12935 FROM (
12936 SELECT ''COST_TYPE_ID'' column_name,
12937 ''Cost Method Code: ''|| cost_mthd_code parameters,
12938 count(*) records
12939 FROM cm_acpr_ctl
12940 WHERE (cost_type_id IS NULL AND cost_mthd_code IS NOT NULL)
12941 GROUP BY cost_mthd_code
12942 HAVING count(*) > 0
12943 UNION
12944 SELECT ''PERIOD_ID'' column_name,
12945 ''Calendar Code: ''|| calendar_code ||'', Period Code: ''|| period_code parameters,
12946 count(*) records
12947 FROM cm_acpr_ctl
12948 WHERE (period_id IS NULL AND calendar_code IS NOT NULL AND period_code IS NOT NULL)
12949 GROUP BY calendar_code, period_code
12950 HAVING count(*) > 0
12951 UNION
12952 SELECT ''LEGAL_ENTITY_ID'' column_name,
12953 ''Calendar Code: ''|| calendar_code parameters,
12954 count(*) records
12955 FROM cm_acpr_ctl
12956 WHERE (legal_entity_id IS NULL AND calendar_code IS NOT NULL)
12957 GROUP BY calendar_code
12958 HAVING count(*) > 0
12959 ) cm_acpr_ctl';
12960 l_cm_rlup_ctl VARCHAR2(32000) := 'SELECT ''CM_RLUP_CTL'' table_name,
12961 cm_rlup_ctl.*
12962 FROM (
12963 SELECT ''COST_TYPE_ID'' column_name,
12964 ''Cost Method Code: ''|| cost_mthd_code parameters,
12965 count(*) records
12966 FROM cm_rlup_ctl
12967 WHERE (cost_type_id IS NULL AND cost_mthd_code IS NOT NULL)
12968 GROUP BY cost_mthd_code
12969 HAVING count(*) > 0
12970 UNION
12971 SELECT ''PERIOD_ID'' column_name,
12972 ''Calendar Code: ''|| calendar_code ||'', Period Code: ''|| period_code parameters,
12973 count(*) records
12974 FROM cm_rlup_ctl
12975 WHERE (period_id IS NULL AND calendar_code IS NOT NULL AND period_code IS NOT NULL)
12976 GROUP BY calendar_code, period_code
12977 HAVING count(*) > 0
12978 UNION
12979 SELECT ''LEGAL_ENTITY_ID'' column_name,
12980 ''Calendar Code: ''|| calendar_code parameters,
12981 count(*) records
12982 FROM cm_rlup_ctl
12983 WHERE (legal_entity_id IS NULL AND calendar_code IS NOT NULL)
12984 GROUP BY calendar_code
12985 HAVING count(*) > 0
12986 UNION
12987 SELECT ''MASTER_ORGANIZATION_ID'' column_name,
12988 ''Item No: ''|| b.item_no ||'' Legal Entity: ''||a.legal_entity_id parameters,
12989 count(*) records
12990 FROM cm_rlup_ctl a, ic_item_mst b
12991 WHERE (a.legal_entity_id IS NULL AND a.item_id IS NOT NULL)
12992 AND b.item_id = a.item_id
12993 GROUP BY b.item_no, a.legal_entity_id
12994 HAVING count(*) > 0
12995 UNION
12996 SELECT ''INVENTORY_ITEM_ID'' column_name,
12997 ''Item No: ''|| b.item_no parameters,
12998 count(*) records
12999 FROM cm_rlup_ctl a, ic_item_mst b
13000 WHERE (a.inventory_item_id IS NULL AND a.item_id IS NOT NULL)
13001 AND b.item_id = a.item_id
13002 GROUP BY b.item_no
13003 HAVING count(*) > 0
13004 ) cm_rlup_ctl';
13005 l_cm_rlup_itm VARCHAR2(32000) := 'SELECT ''CM_RLUP_ITM'' table_name,
13006 cm_rlup_itm.*
13007 FROM (
13008 SELECT ''ORGANIZATION_ID'' column_name,
13009 ''Item No: ''|| b.item_no ||'' Legal Entity: ''||c.legal_entity_id parameters,
13010 count(*) records
13011 FROM cm_rlup_ctl a, ic_item_mst b, cm_rlup_ctl c
13012 WHERE (a.legal_entity_id IS NULL AND a.item_id IS NOT NULL)
13013 AND b.item_id = a.item_id
13014 AND c.rollup_id = a.rollup_id
13015 GROUP BY b.item_no, c.legal_entity_id
13016 HAVING count(*) > 0
13017 UNION
13018 SELECT ''INVENTORY_ITEM_ID'' column_name,
13019 ''Item No: ''|| b.item_no parameters,
13020 count(*) records
13021 FROM cm_rlup_itm a, ic_item_mst b
13022 WHERE (a.inventory_item_id IS NULL AND a.item_id IS NOT NULL)
13023 AND b.item_id = a.item_id
13024 GROUP BY b.item_no
13025 HAVING count(*) > 0
13026 ) cm_rlup_itm';
13027 l_cm_cupd_ctl VARCHAR2(32000) := 'SELECT ''CM_CUPD_CTL'' table_name,
13028 cm_cupd_ctl.*
13029 FROM (
13030 SELECT ''COST_TYPE_ID'' column_name,
13031 ''Cost Method Code: ''|| cost_mthd_code parameters,
13032 count(*) records
13033 FROM cm_cupd_ctl
13034 WHERE (cost_type_id IS NULL AND cost_mthd_code IS NOT NULL)
13035 GROUP BY cost_mthd_code
13036 HAVING count(*) > 0
13037 UNION
13038 SELECT ''PERIOD_ID'' column_name,
13039 ''Calendar Code: ''|| calendar_code ||'', Period Code: ''|| period_code parameters,
13040 count(*) records
13041 FROM cm_cupd_ctl
13042 WHERE (period_id IS NULL AND calendar_code IS NOT NULL AND period_code IS NOT NULL)
13043 GROUP BY calendar_code, period_code
13044 HAVING count(*) > 0
13045 UNION
13046 SELECT ''LEGAL_ENTITY_ID'' column_name,
13047 ''Calendar Code: ''|| calendar_code parameters,
13048 count(*) records
13049 FROM cm_cupd_ctl
13050 WHERE (legal_entity_id IS NULL AND calendar_code IS NOT NULL)
13051 GROUP BY calendar_code
13052 HAVING count(*) > 0
13053 ) cm_cupd_ctl';
13054 l_gl_subr_sta VARCHAR2(32000) := 'SELECT ''GL_SUBR_STA'' table_name,
13055 gl_subr_sta.*
13056 FROM (
13057 SELECT ''CREV_CURR_COST_TYPE_ID'' column_name,
13058 ''Current Cost Method Code: ''|| crev_curr_mthd parameters,
13059 count(*) records
13060 FROM gl_subr_sta
13061 WHERE (crev_curr_cost_type_id IS NULL AND crev_curr_mthd IS NOT NULL)
13062 GROUP BY crev_curr_mthd
13063 HAVING count(*) > 0
13064 UNION
13065 SELECT ''CREV_CURR_PERIOD_ID'' column_name,
13066 ''Current Calendar Code: ''|| crev_curr_calendar ||'', Period Code: ''|| crev_curr_period parameters,
13067 count(*) records
13068 FROM gl_subr_sta
13069 WHERE (crev_curr_calendar is not null and crev_curr_period is not NULL AND crev_curr_period_id is null)
13070 GROUP BY crev_curr_calendar, crev_curr_period
13071 HAVING count(*) > 0
13072 UNION
13073 SELECT ''CREV_PREV_COST_TYPE_ID'' column_name,
13074 ''Previous Cost Method Code: ''|| crev_prev_mthd parameters,
13075 count(*) records
13076 FROM gl_subr_sta
13077 WHERE (crev_prev_cost_type_id IS NULL AND crev_prev_mthd IS NOT NULL)
13078 GROUP BY crev_prev_mthd
13079 HAVING count(*) > 0
13080 UNION
13081 SELECT ''CREV_PREV_PERIOD_ID'' column_name,
13082 ''Previous Calendar Code: ''|| crev_prev_calendar ||'', Period Code: ''|| crev_prev_period parameters,
13083 count(*) records
13084 FROM gl_subr_sta
13085 WHERE (crev_prev_calendar is not null and crev_prev_period is not NULL AND crev_prev_period_id is null)
13086 GROUP BY crev_prev_calendar, crev_prev_period
13087 HAVING count(*) > 0
13088 UNION
13089 SELECT ''LEGAL_ENTITY_ID'' column_name,
13090 ''Co Code: ''|| co_code parameters,
13091 count(*) records
13092 FROM gl_subr_sta
13093 WHERE (legal_entity_id IS NULL AND co_code IS NOT NULL)
13094 GROUP BY co_code
13095 HAVING count(*) > 0
13096 UNION
13097 SELECT ''COST_TYPE_ID'' column_name,
13098 ''Co Code: ''|| co_code parameters,
13099 count(*) records
13100 FROM gl_subr_sta
13101 WHERE (cost_type_id IS NULL AND co_code IS NOT NULL)
13102 GROUP BY co_code
13103 HAVING count(*) > 0
13104 ) gl_subr_sta';
13105 l_xla_rules_t VARCHAR2(32000) := 'SELECT ''XLA_RULES_T'' table_name,
13106 xla_rules_t.*
13107 FROM (
13108 SELECT ''ALL'' column_name,
13109 ''Unique Constraint Error'' parameters,
13110 count(*) records
13111 FROM xla_rules_t
13112 WHERE error_value = -1
13113 HAVING count(*) > 0
13114 UNION
13115 SELECT ''ALL'' column_name,
13116 ''Not Null Constraint'' parameters,
13117 count(*) records
13118 FROM xla_rules_t
13119 WHERE error_value = -1400
13120 HAVING count(*) > 0
13121 UNION
13122 SELECT ''ALL'' column_name,
13123 ''Invalid Value Error'' parameters,
13124 count(*) records
13125 FROM xla_rules_t
13126 WHERE error_value = -6502
13127 HAVING count(*) > 0
13128 UNION
13129 SELECT ''ALL'' column_name,
13130 ''Parent-Key Not Found Error'' parameters,
13131 count(*) records
13132 FROM xla_rules_t
13133 WHERE error_value = -2291
13134 HAVING count(*) > 0
13135 UNION
13136 SELECT ''ALL'' column_name,
13137 ''Value Too Long Error'' parameters,
13138 count(*) records
13139 FROM xla_rules_t
13140 WHERE error_value in (-1438, -12899)
13141 HAVING count(*) > 0
13142 UNION
13143 SELECT ''ALL'' column_name,
13144 ''Invalid Number Error'' parameters,
13145 count(*) records
13146 FROM xla_rules_t
13147 WHERE error_value = -1722
13148 HAVING count(*) > 0
13149 UNION
13150 SELECT ''ALL'' column_name,
13151 ''Records not Picked up'' parameters,
13152 count(*) records
13153 FROM xla_rules_t
13154 WHERE error_value = 0
13155 HAVING count(*) > 0
13156 UNION
13157 SELECT ''ALL'' column_name,
13158 ''Other Errors'' parameters,
13159 count(*) records
13160 FROM xla_rules_t
13161 WHERE error_value not in (-1, -1400, -6502, -2291, -1438, -12899, -1722, 1, 0)
13162 HAVING count(*) > 0
13163 ) xla_rules_t';
13164 l_xla_rule_details_t VARCHAR2(32000) := 'SELECT ''XLA_RULE_DETAILS_T'' table_name,
13165 xla_rule_details_t.*
13166 FROM (
13167 SELECT ''ALL'' column_name,
13168 ''Unique Constraint Error'' parameters,
13169 count(*) records
13170 FROM xla_rule_details_t
13171 WHERE error_value = -1
13172 HAVING count(*) > 0
13173 UNION
13174 SELECT ''ALL'' column_name,
13175 ''Not Null Constraint'' parameters,
13176 count(*) records
13177 FROM xla_rule_details_t
13178 WHERE error_value = -1400
13179 HAVING count(*) > 0
13180 UNION
13181 SELECT ''ALL'' column_name,
13182 ''Invalid Value Error'' parameters,
13183 count(*) records
13184 FROM xla_rule_details_t
13185 WHERE error_value = -6502
13186 HAVING count(*) > 0
13187 UNION
13188 SELECT ''ALL'' column_name,
13189 ''Parent-Key Not Found Error'' parameters,
13190 count(*) records
13191 FROM xla_rule_details_t
13192 WHERE error_value = -2291
13193 HAVING count(*) > 0
13194 UNION
13195 SELECT ''ALL'' column_name,
13196 ''Value Too Long Error'' parameters,
13197 count(*) records
13198 FROM xla_rule_details_t
13199 WHERE error_value in (-1438, -12899)
13200 HAVING count(*) > 0
13201 UNION
13202 SELECT ''ALL'' column_name,
13203 ''Invalid Number Error'' parameters,
13204 count(*) records
13205 FROM xla_rule_details_t
13206 WHERE error_value = -1722
13207 HAVING count(*) > 0
13208 UNION
13209 SELECT ''ALL'' column_name,
13210 ''Records not Picked up'' parameters,
13211 count(*) records
13212 FROM xla_rule_details_t
13213 WHERE error_value = 0
13214 HAVING count(*) > 0
13215 UNION
13216 SELECT ''ALL'' column_name,
13217 ''Other Errors'' parameters,
13218 count(*) records
13219 FROM xla_rule_details_t
13220 WHERE error_value not in (-1, -1400, -6502, -2291, -1438, -12899, -1722, 1, 0)
13221 HAVING count(*) > 0
13222 ) xla_rule_details_t';
13223 l_xla_conditions_t VARCHAR2(32000) := 'SELECT ''XLA_CONDITIONS_T'' table_name,
13224 xla_conditions_t.*
13225 FROM (
13226 SELECT ''ALL'' column_name,
13227 ''Unique Constraint Error'' parameters,
13228 count(*) records
13229 FROM xla_conditions_t
13230 WHERE error_value = -1
13231 HAVING count(*) > 0
13232 UNION
13233 SELECT ''ALL'' column_name,
13234 ''Not Null Constraint'' parameters,
13235 count(*) records
13236 FROM xla_conditions_t
13237 WHERE error_value = -1400
13238 HAVING count(*) > 0
13239 UNION
13240 SELECT ''ALL'' column_name,
13241 ''Invalid Value Error'' parameters,
13242 count(*) records
13243 FROM xla_conditions_t
13244 WHERE error_value = -6502
13245 HAVING count(*) > 0
13246 UNION
13247 SELECT ''ALL'' column_name,
13248 ''Parent-Key Not Found Error'' parameters,
13249 count(*) records
13250 FROM xla_conditions_t
13251 WHERE error_value = -2291
13252 HAVING count(*) > 0
13253 UNION
13254 SELECT ''ALL'' column_name,
13255 ''Value Too Long Error'' parameters,
13256 count(*) records
13257 FROM xla_conditions_t
13258 WHERE error_value in (-1438, -12899)
13259 HAVING count(*) > 0
13260 UNION
13261 SELECT ''ALL'' column_name,
13262 ''Invalid Number Error'' parameters,
13263 count(*) records
13264 FROM xla_conditions_t
13265 WHERE error_value = -1722
13266 HAVING count(*) > 0
13267 UNION
13268 SELECT ''ALL'' column_name,
13269 ''Records not Picked up'' parameters,
13270 count(*) records
13271 FROM xla_conditions_t
13272 WHERE error_value = 0
13273 HAVING count(*) > 0
13274 UNION
13275 SELECT ''ALL'' column_name,
13276 ''Other Errors'' parameters,
13277 count(*) records
13278 FROM xla_conditions_t
13279 WHERE error_value not in (-1, -1400, -6502, -2291, -1438, -12899, -1722, 1, 0)
13280 HAVING count(*) > 0
13281 ) xla_conditions_t';
13282 l_xla_line_assgns_t VARCHAR2(32000) := 'SELECT ''XLA_LINE_ASSGNS_T'' table_name,
13283 xla_line_assgns_t.*
13284 FROM (
13285 SELECT ''ALL'' column_name,
13286 ''Unique Constraint Error'' parameters,
13287 count(*) records
13288 FROM xla_line_assgns_t
13289 WHERE error_value = -1
13290 HAVING count(*) > 0
13291 UNION
13292 SELECT ''ALL'' column_name,
13293 ''Not Null Constraint'' parameters,
13294 count(*) records
13295 FROM xla_line_assgns_t
13296 WHERE error_value = -1400
13297 HAVING count(*) > 0
13298 UNION
13299 SELECT ''ALL'' column_name,
13300 ''Invalid Value Error'' parameters,
13301 count(*) records
13302 FROM xla_line_assgns_t
13303 WHERE error_value = -6502
13304 HAVING count(*) > 0
13305 UNION
13306 SELECT ''ALL'' column_name,
13307 ''Parent-Key Not Found Error'' parameters,
13308 count(*) records
13309 FROM xla_line_assgns_t
13310 WHERE error_value = -2291
13311 HAVING count(*) > 0
13312 UNION
13313 SELECT ''ALL'' column_name,
13314 ''Value Too Long Error'' parameters,
13315 count(*) records
13316 FROM xla_line_assgns_t
13317 WHERE error_value in (-1438, -12899)
13318 HAVING count(*) > 0
13319 UNION
13320 SELECT ''ALL'' column_name,
13321 ''Invalid Number Error'' parameters,
13322 count(*) records
13323 FROM xla_line_assgns_t
13324 WHERE error_value = -1722
13325 HAVING count(*) > 0
13326 UNION
13327 SELECT ''ALL'' column_name,
13328 ''Records not Picked up'' parameters,
13329 count(*) records
13330 FROM xla_line_assgns_t
13331 WHERE error_value = 0
13332 HAVING count(*) > 0
13333 UNION
13334 SELECT ''ALL'' column_name,
13335 ''Other Errors'' parameters,
13336 count(*) records
13337 FROM xla_line_assgns_t
13338 WHERE error_value not in (-1, -1400, -6502, -2291, -1438, -12899, -1722, 1, 0)
13339 HAVING count(*) > 0
13340 ) xla_line_assgns_t';
13341
13342 /*****************
13343 * PL/SQL Cursors *
13344 *****************/
13345 cur_gmf_log_errors p_cur_gmf_log_errors;
13346
13347 BEGIN
13348 /*****************************************************************************
13349 * ROWID's are required only when called from inside a LTU Migration Loop and *
13350 * it cannot be passed for a Detailed Error Log *
13351 *****************************************************************************/
13352 IF p_from_rowid IS NOT NULL AND p_to_rowid IS NOT NULL THEN
13353 IF p_log_level <> 1 THEN
13354 RETURN;
13355 ELSE
13356 l_sql_statement := l_sql_statement||' ROWID BETWEEN :1 AND :2 AND ';
13357 END IF;
13358 END IF;
13359 /**************************************************************************
13360 * Printing Error Log's for all tables cannot be done in Log Level 1 and 2 *
13361 **************************************************************************/
13362 IF l_table_name = 'GMF_LOG_ERRORS' AND p_log_level IN (1, 2) THEN
13363 RETURN;
13364 END IF;
13365 IF p_log_level IN (1, 2) THEN
13366 /************************************************
13367 * Migration Error Logging for table CM_RSRC_DTL *
13368 ************************************************/
13369 IF l_table_name IN ('CM_RSRC_DTL') THEN
13370 IF p_log_level = 1 THEN
13371 l_sql_statement := l_sql_statement
13372 ||
13373 '( (legal_entity_id IS NULL AND orgn_code IS NOT NULL)
13374 OR (cost_type_id IS NULL AND cost_mthd_code IS NOT NULL)
13375 OR (period_id IS NULL AND period_code IS NOT NULL AND calendar_code is not null)
13376 OR (usage_uom IS NULL AND usage_um IS NOT NULL)
13377 OR (organization_id IS NULL AND delete_mark = 0 AND orgn_code IS NOT NULL)
13378 )';
13379 IF p_from_rowid IS NOT NULL AND p_to_rowid IS NOT NULL THEN
13380 execute IMMEDIATE l_sql_statement INTO l_failure_count using p_from_rowid, p_to_rowid;
13381 ELSE
13382 execute IMMEDIATE l_sql_statement INTO l_failure_count;
13383 END IF;
13384 ELSIF p_log_level = 2 THEN
13385 SELECT SUM(CASE WHEN (legal_entity_id IS NULL AND orgn_code IS NOT NULL) THEN 1 ELSE 0 END),
13386 SUM(CASE WHEN (cost_type_id IS NULL AND cost_mthd_code IS NOT NULL) THEN 1 ELSE 0 END),
13387 SUM(CASE WHEN (period_id IS NULL AND period_code IS NOT NULL AND calendar_code IS NOT NULL) THEN 1 ELSE 0 END),
13388 SUM(CASE WHEN (usage_uom IS NULL AND usage_um IS NOT NULL) THEN 1 ELSE 0 END),
13389 SUM(CASE WHEN (organization_id IS NULL AND delete_mark = 0 AND orgn_code IS NOT NULL) THEN 1 ELSE 0 END)
13390 INTO l_legal_entity_count,
13391 l_cost_type_count,
13392 l_period_count,
13393 l_uom_count1,
13394 l_organization_count
13395 FROM cm_rsrc_dtl;
13396 END IF;
13397 END IF;
13398 /************************************************
13399 * Migration Error Logging for table CM_ADJS_DTL *
13400 ************************************************/
13401 IF l_table_name IN ('CM_ADJS_DTL') THEN
13402 IF p_log_level = 1 THEN
13403 l_sql_statement := l_sql_statement
13404 ||
13405 '( (organization_id IS NULL AND whse_code IS NOT NULL)
13406 OR (inventory_item_id IS NULL AND item_id IS NOT NULL)
13407 OR (cost_type_id IS NULL AND cost_mthd_code IS NOT NULL)
13408 OR (period_id IS NULL AND period_code IS NOT NULL AND calendar_code IS NOT NULL)
13409 OR (adjust_qty_uom IS NULL AND adjust_qty_um IS NOT NULL)
13410 OR (adjustment_ind IS NULL)
13411 )';
13412 IF p_from_rowid IS NOT NULL AND p_to_rowid IS NOT NULL THEN
13413 execute IMMEDIATE l_sql_statement INTO l_failure_count using p_from_rowid, p_to_rowid;
13414 ELSE
13415 execute IMMEDIATE l_sql_statement INTO l_failure_count;
13416 END IF;
13417 ELSIF p_log_level = 2 THEN
13418 SELECT SUM(CASE WHEN (organization_id IS NULL AND whse_code IS NOT NULL) THEN 1 ELSE 0 END),
13419 SUM(CASE WHEN (inventory_item_id IS NULL AND item_id IS NOT NULL) THEN 1 ELSE 0 END),
13420 SUM(CASE WHEN (cost_type_id IS NULL AND cost_mthd_code IS NOT NULL) THEN 1 ELSE 0 END),
13421 SUM(CASE WHEN (period_id IS NULL AND period_code IS NOT NULL AND calendar_code IS NOT NULL) THEN 1 ELSE 0 END),
13422 SUM(CASE WHEN (adjust_qty_uom IS NULL AND adjust_qty_um IS NOT NULL) THEN 1 ELSE 0 END),
13423 SUM(CASE WHEN (adjustment_ind IS NULL) THEN 1 ELSE 0 END)
13424 INTO l_organization_count,
13425 l_inventory_item_count,
13426 l_cost_type_count,
13427 l_period_count,
13428 l_uom_count1,
13429 l_adjustment_ind_count
13430 FROM cm_adjs_dtl;
13431 END IF;
13432 END IF;
13433 /************************************************
13434 * Migration Error Logging for table CM_CMPT_DTL *
13435 ************************************************/
13436 IF l_table_name IN ('CM_CMPT_DTL') THEN
13437 IF p_log_level = 1 THEN
13438 l_sql_statement := l_sql_statement
13439 ||
13440 '( (organization_id IS NULL AND whse_code IS NOT NULL)
13441 OR (inventory_item_id IS NULL AND item_id IS NOT NULL)
13442 OR (cost_type_id IS NULL AND cost_mthd_code IS NOT NULL)
13443 OR (period_id IS NULL AND period_code IS NOT NULL)
13444 )';
13445 IF p_from_rowid IS NOT NULL AND p_to_rowid IS NOT NULL THEN
13446 execute IMMEDIATE l_sql_statement INTO l_failure_count using p_from_rowid, p_to_rowid;
13447 ELSE
13448 execute IMMEDIATE l_sql_statement INTO l_failure_count;
13449 END IF;
13450 ELSIF p_log_level = 2 THEN
13451 SELECT SUM(CASE WHEN (organization_id IS NULL AND whse_code IS NOT NULL) THEN 1 ELSE 0 END),
13452 SUM(CASE WHEN (inventory_item_id IS NULL AND item_id IS NOT NULL) THEN 1 ELSE 0 END),
13453 SUM(CASE WHEN (cost_type_id IS NULL AND cost_mthd_code IS NOT NULL) THEN 1 ELSE 0 END),
13454 SUM(CASE WHEN (period_id IS NULL AND period_code IS NOT NULL AND calendar_code IS NOT NULL) THEN 1 ELSE 0 END)
13455 INTO l_organization_count,
13456 l_inventory_item_count,
13457 l_cost_type_count,
13458 l_period_count
13459 FROM cm_cmpt_dtl;
13460 END IF;
13461 END IF;
13462 /************************************************
13463 * Migration Error Logging for table CM_BRDN_DTL *
13464 ************************************************/
13465 IF l_table_name IN ('CM_BRDN_DTL') THEN
13466 IF p_log_level = 1 THEN
13467 l_sql_statement := l_sql_statement
13468 ||
13469 '( (organization_id IS NULL AND whse_code IS NOT NULL)
13470 OR (inventory_item_id IS NULL AND item_id IS NOT NULL)
13471 OR (cost_type_id IS NULL AND cost_mthd_code IS NOT NULL)
13472 OR (period_id IS NULL AND period_code IS NOT NULL)
13473 OR (item_uom IS NULL AND item_um IS NOT NULL)
13474 OR (burden_uom IS NULL AND burden_um IS NOT NULL)
13475 )';
13476 IF p_from_rowid IS NOT NULL AND p_to_rowid IS NOT NULL THEN
13477 execute IMMEDIATE l_sql_statement INTO l_failure_count using p_from_rowid, p_to_rowid;
13478 ELSE
13479 execute IMMEDIATE l_sql_statement INTO l_failure_count;
13480 END IF;
13481 ELSIF p_log_level = 2 THEN
13482 SELECT SUM(CASE WHEN (organization_id IS NULL AND whse_code IS NOT NULL) THEN 1 ELSE 0 END),
13483 SUM(CASE WHEN (inventory_item_id IS NULL AND item_id IS NOT NULL) THEN 1 ELSE 0 END),
13484 SUM(CASE WHEN (cost_type_id IS NULL AND cost_mthd_code IS NOT NULL) THEN 1 ELSE 0 END),
13485 SUM(CASE WHEN (period_id IS NULL AND period_code IS NOT NULL AND calendar_code IS NOT NULL) THEN 1 ELSE 0 END),
13486 SUM(CASE WHEN (item_uom IS NULL AND item_um IS NOT NULL) THEN 1 ELSE 0 END),
13487 SUM(CASE WHEN (burden_uom IS NULL AND burden_um IS NOT NULL) THEN 1 ELSE 0 END)
13488 INTO l_organization_count,
13489 l_inventory_item_count,
13490 l_cost_type_count,
13491 l_period_count,
13492 l_uom_count1,
13493 l_uom_count2
13494 FROM cm_brdn_dtl;
13495 END IF;
13496 END IF;
13497 /************************************************
13498 * Migration Error Logging for table GL_ITEM_CST *
13499 ************************************************/
13500 IF l_table_name IN ('GL_ITEM_CST') THEN
13501 IF p_log_level = 1 THEN
13502 l_sql_statement := l_sql_statement
13503 ||
13504 '( (organization_id IS NULL AND whse_code IS NOT NULL)
13505 OR (inventory_item_id IS NULL AND item_id IS NOT NULL)
13506 OR (cost_type_id IS NULL AND cost_mthd_code IS NOT NULL)
13507 OR (period_id IS NULL AND period_code IS NOT NULL)
13508 )';
13509 IF p_from_rowid IS NOT NULL AND p_to_rowid IS NOT NULL THEN
13510 execute IMMEDIATE l_sql_statement INTO l_failure_count using p_from_rowid, p_to_rowid;
13511 ELSE
13512 execute IMMEDIATE l_sql_statement INTO l_failure_count;
13513 END IF;
13514 ELSIF p_log_level = 2 THEN
13515 SELECT SUM(CASE WHEN (organization_id IS NULL AND whse_code IS NOT NULL) THEN 1 ELSE 0 END),
13516 SUM(CASE WHEN (inventory_item_id IS NULL AND item_id IS NOT NULL) THEN 1 ELSE 0 END),
13517 SUM(CASE WHEN (cost_type_id IS NULL AND cost_mthd_code IS NOT NULL) THEN 1 ELSE 0 END),
13518 SUM(CASE WHEN (period_id IS NULL AND period_code IS NOT NULL AND calendar_code IS NOT NULL) THEN 1 ELSE 0 END)
13519 INTO l_organization_count,
13520 l_inventory_item_count,
13521 l_cost_type_count,
13522 l_period_count
13523 FROM gl_item_cst;
13524 END IF;
13525 END IF;
13526 /************************************************
13527 * Migration Error Logging for table CM_SCST_LED *
13528 ************************************************/
13529 IF l_table_name IN ('CM_SCST_LED') THEN
13530 IF p_log_level = 1 THEN
13531 l_sql_statement := l_sql_statement
13532 ||
13533 '( (organization_id IS NULL AND whse_code IS NOT NULL)
13534 OR (inventory_item_id IS NULL AND item_id IS NOT NULL)
13535 OR (form_prod_uom IS NULL AND form_prod_um IS NOT NULL)
13536 OR (item_fmqty_uom IS NULL AND item_fmqty_um IS NOT NULL)
13537 OR (usage_uom IS NULL AND usage_um IS NOT NULL)
13538 )';
13539 IF p_from_rowid IS NOT NULL AND p_to_rowid IS NOT NULL THEN
13540 execute IMMEDIATE l_sql_statement INTO l_failure_count using p_from_rowid, p_to_rowid;
13541 ELSE
13542 execute IMMEDIATE l_sql_statement INTO l_failure_count;
13543 END IF;
13544 ELSIF p_log_level = 2 THEN
13545 SELECT SUM(CASE WHEN (organization_id IS NULL AND whse_code IS NOT NULL) THEN 1 ELSE 0 END),
13546 SUM(CASE WHEN (inventory_item_id IS NULL AND item_id IS NOT NULL) THEN 1 ELSE 0 END),
13547 SUM(CASE WHEN (form_prod_uom IS NULL AND form_prod_um IS NOT NULL) THEN 1 ELSE 0 END),
13548 SUM(CASE WHEN (item_fmqty_uom IS NULL AND item_fmqty_um IS NOT NULL) THEN 1 ELSE 0 END),
13549 SUM(CASE WHEN (usage_uom IS NULL AND usage_um IS NOT NULL) THEN 1 ELSE 0 END)
13550 INTO l_organization_count,
13551 l_inventory_item_count,
13552 l_uom_count1,
13553 l_uom_count2,
13554 l_uom_count3
13555 FROM cm_scst_led;
13556 END IF;
13557 END IF;
13558 /************************************************
13559 * Migration Error Logging for table CM_ACST_LED *
13560 ************************************************/
13561 IF l_table_name IN ('CM_ACST_LED') THEN
13562 IF p_log_level = 1 THEN
13563 l_sql_statement := l_sql_statement
13564 ||
13565 '( (organization_id IS NULL AND whse_code IS NOT NULL)
13566 OR (inventory_item_id IS NULL AND item_id IS NOT NULL)
13567 OR (cost_type_id IS NULL AND cost_mthd_code IS NOT NULL)
13568 OR (period_id IS NULL AND period_code IS NOT NULL)
13569 )';
13570 IF p_from_rowid IS NOT NULL AND p_to_rowid IS NOT NULL THEN
13571 execute IMMEDIATE l_sql_statement INTO l_failure_count using p_from_rowid, p_to_rowid;
13572 ELSE
13573 execute IMMEDIATE l_sql_statement INTO l_failure_count;
13574 END IF;
13575 ELSIF p_log_level = 2 THEN
13576 SELECT SUM(CASE WHEN (organization_id IS NULL AND whse_code IS NOT NULL) THEN 1 ELSE 0 END),
13577 SUM(CASE WHEN (inventory_item_id IS NULL AND item_id IS NOT NULL) THEN 1 ELSE 0 END),
13578 SUM(CASE WHEN (cost_type_id IS NULL AND cost_mthd_code IS NOT NULL) THEN 1 ELSE 0 END),
13579 SUM(CASE WHEN (period_id IS NULL AND period_code IS NOT NULL AND calendar_code IS NOT NULL) THEN 1 ELSE 0 END)
13580 INTO l_organization_count,
13581 l_inventory_item_count,
13582 l_cost_type_count,
13583 l_period_count
13584 FROM cm_acst_led;
13585 END IF;
13586 END IF;
13587 /************************************************
13588 * Migration Error Logging for table XLA_RULES_T *
13589 ************************************************/
13590 IF l_table_name IN ('XLA_RULES_T') THEN
13591 IF p_log_level = 1 THEN
13592 l_sql_statement := l_sql_statement || ' ERROR_VALUE <> 1 ';
13593 execute IMMEDIATE l_sql_statement INTO l_failure_count;
13594 ELSIF p_log_level = 2 THEN
13595 SELECT SUM(DECODE(error_value, -1, 1, 0)),
13596 SUM(DECODE(error_value, -1400, 1, 0)),
13597 SUM(DECODE(error_value, -6502, 1, 0)),
13598 SUM(DECODE(error_value, -2291, 1, 0)),
13599 SUM(DECODE(error_value, -1438, 1, -12899, 1, 0)),
13600 SUM(DECODE(error_value, -1722, 1, 0)),
13601 SUM(DECODE(error_value, 0, 1, 0)),
13602 SUM(DECODE(error_value, 1, 0, 1))
13603 INTO l_unique_error_count,
13604 l_not_null_error_count,
13605 l_value_error_count,
13606 l_parent_key_error_count,
13607 l_too_long_error_count,
13608 l_invalid_number_error_count,
13609 l_not_picked_up_error_count,
13610 l_total_error_count
13611 FROM xla_rules_t;
13612 END IF;
13613 END IF;
13614 /*******************************************************
13615 * Migration Error Logging for table XLA_RULE_DETAILS_T *
13616 *******************************************************/
13617 IF l_table_name IN ('XLA_RULE_DETAILS_T') THEN
13618 IF p_log_level = 1 THEN
13619 l_sql_statement := l_sql_statement || ' ERROR_VALUE <> 1 ';
13620 execute IMMEDIATE l_sql_statement INTO l_failure_count;
13621 ELSIF p_log_level = 2 THEN
13622 SELECT SUM(DECODE(error_value, -1, 1, 0)),
13623 SUM(DECODE(error_value, -1400, 1, 0)),
13624 SUM(DECODE(error_value, -6502, 1, 0)),
13625 SUM(DECODE(error_value, -2291, 1, 0)),
13626 SUM(DECODE(error_value, -1438, 1, -12899, 1, 0)),
13627 SUM(DECODE(error_value, -1722, 1, 0)),
13628 SUM(DECODE(error_value, 0, 1, 0)),
13629 SUM(DECODE(error_value, 1, 0, 1))
13630 INTO l_unique_error_count,
13631 l_not_null_error_count,
13632 l_value_error_count,
13633 l_parent_key_error_count,
13634 l_too_long_error_count,
13635 l_invalid_number_error_count,
13636 l_not_picked_up_error_count,
13637 l_total_error_count
13638 FROM xla_rule_details_t;
13639 END IF;
13640 END IF;
13641 /*******************************************************
13642 * Migration Error Logging for table XLA_CONDITIONS_T *
13643 *******************************************************/
13644 IF l_table_name IN ('XLA_CONDITIONS_T') THEN
13645 IF p_log_level = 1 THEN
13646 l_sql_statement := l_sql_statement || ' ERROR_VALUE <> 1 ';
13647 execute IMMEDIATE l_sql_statement INTO l_failure_count;
13648 ELSIF p_log_level = 2 THEN
13649 SELECT SUM(DECODE(error_value, -1, 1, 0)),
13650 SUM(DECODE(error_value, -1400, 1, 0)),
13651 SUM(DECODE(error_value, -6502, 1, 0)),
13652 SUM(DECODE(error_value, -2291, 1, 0)),
13653 SUM(DECODE(error_value, -1438, 1, -12899, 1, 0)),
13654 SUM(DECODE(error_value, -1722, 1, 0)),
13655 SUM(DECODE(error_value, 0, 1, 0)),
13656 SUM(DECODE(error_value, 1, 0, 1))
13657 INTO l_unique_error_count,
13658 l_not_null_error_count,
13659 l_value_error_count,
13660 l_parent_key_error_count,
13661 l_too_long_error_count,
13662 l_invalid_number_error_count,
13663 l_not_picked_up_error_count,
13664 l_total_error_count
13665 FROM xla_conditions_t;
13666 END IF;
13667 END IF;
13668 /*******************************************************
13669 * Migration Error Logging for table XLA_LINE_ASSGNS_T *
13670 *******************************************************/
13671 IF l_table_name IN ('XLA_LINE_ASSGNS_T') THEN
13672 IF p_log_level = 1 THEN
13673 l_sql_statement := l_sql_statement || ' ERROR_VALUE <> 1 ';
13674 execute IMMEDIATE l_sql_statement INTO l_failure_count;
13675 ELSIF p_log_level = 2 THEN
13676 SELECT SUM(DECODE(error_value, -1, 1, 0)),
13677 SUM(DECODE(error_value, -1400, 1, 0)),
13678 SUM(DECODE(error_value, -6502, 1, 0)),
13679 SUM(DECODE(error_value, -2291, 1, 0)),
13680 SUM(DECODE(error_value, -1438, 1, -12899, 1, 0)),
13681 SUM(DECODE(error_value, -1722, 1, 0)),
13682 SUM(DECODE(error_value, 0, 1, 0)),
13683 SUM(DECODE(error_value, 1, 0, 1))
13684 INTO l_unique_error_count,
13685 l_not_null_error_count,
13686 l_value_error_count,
13687 l_parent_key_error_count,
13688 l_too_long_error_count,
13689 l_invalid_number_error_count,
13690 l_not_picked_up_error_count,
13691 l_total_error_count
13692 FROM xla_line_assgns_t;
13693 END IF;
13694 END IF;
13695 /**************************************************
13696 * Migration Error Logging for table GMF_LOT_COSTS *
13697 **************************************************/
13698 IF l_table_name IN ('GMF_LOT_COSTS') THEN
13699 IF p_log_level = 1 THEN
13700 l_sql_statement := l_sql_statement
13701 ||
13702 '( (cost_type_id IS NULL AND cost_mthd_code IS NOT NULL)
13703 OR (organization_id IS NULL AND whse_code IS NOT NULL)
13704 OR (inventory_item_id IS NULL AND item_id IS NOT NULL)
13705 OR (lot_number IS NULL AND lot_id IS NOT NULL)
13706 )';
13707 execute IMMEDIATE l_sql_statement INTO l_failure_count;
13708 ELSIF p_log_level = 2 THEN
13709 SELECT SUM(CASE WHEN (organization_id IS NULL AND whse_code IS NOT NULL) THEN 1 ELSE 0 END),
13710 SUM(CASE WHEN (inventory_item_id IS NULL AND item_id IS NOT NULL) THEN 1 ELSE 0 END),
13711 SUM(CASE WHEN (cost_type_id IS NULL AND cost_mthd_code IS NOT NULL) THEN 1 ELSE 0 END),
13712 SUM(CASE WHEN (lot_number IS NULL AND lot_id IS NOT NULL) THEN 1 ELSE 0 END)
13713 INTO l_organization_count,
13714 l_inventory_item_count,
13715 l_cost_type_count,
13716 l_lot_number_count
13717 FROM gmf_lot_costs;
13718 END IF;
13719 END IF;
13720 /*********************************************************
13721 * Migration Error Logging for table GMF_LOT_COSTED_ITEMS *
13722 *********************************************************/
13723 IF l_table_name IN ('GMF_LOT_COSTED_ITEMS') THEN
13724 IF p_log_level = 1 THEN
13725 l_sql_statement := l_sql_statement
13726 ||
13727 '( (cost_type_id IS NULL AND cost_mthd_code IS NOT NULL)
13728 OR (legal_entity_id IS NULL AND co_code IS NOT NULL)
13729 OR (inventory_item_id IS NULL AND item_id IS NOT NULL)
13730 OR (master_organization_id IS NULL AND item_id IS NOT NULL)
13731 )';
13732 execute IMMEDIATE l_sql_statement INTO l_failure_count;
13733 ELSIF p_log_level = 2 THEN
13734 SELECT SUM(CASE WHEN (master_organization_id IS NULL AND item_id IS NOT NULL) THEN 1 ELSE 0 END),
13735 SUM(CASE WHEN (inventory_item_id IS NULL AND item_id IS NOT NULL) THEN 1 ELSE 0 END),
13736 SUM(CASE WHEN (cost_type_id IS NULL AND cost_mthd_code IS NOT NULL) THEN 1 ELSE 0 END),
13737 SUM(CASE WHEN (legal_entity_id IS NULL AND co_code IS NOT NULL) THEN 1 ELSE 0 END)
13738 INTO l_master_organization_count,
13739 l_inventory_item_count,
13740 l_cost_type_count,
13741 l_legal_entity_count
13742 FROM gmf_lot_costed_items;
13743 END IF;
13744 END IF;
13745 /*********************************************************
13746 * Migration Error Logging for table GMF_LOT_COST_BURDENS *
13747 *********************************************************/
13748 IF l_table_name IN ('GMF_LOT_COST_BURDENS') THEN
13749 IF p_log_level = 1 THEN
13750 l_sql_statement := l_sql_statement
13751 ||
13752 '( (cost_type_id IS NULL AND cost_mthd_code IS NOT NULL)
13753 OR (organization_id IS NULL AND whse_code IS NOT NULL)
13754 OR (inventory_item_id IS NULL AND item_id IS NOT NULL)
13755 OR (item_uom IS NULL AND item_um IS NOT NULL)
13756 OR (resource_uom IS NULL AND resource_um IS NOT NULL)
13757 OR (lot_number IS NULL AND lot_id IS NOT NULL)
13758 )';
13759 execute IMMEDIATE l_sql_statement INTO l_failure_count;
13760 ELSIF p_log_level = 2 THEN
13761 SELECT SUM(CASE WHEN (organization_id IS NULL AND whse_code IS NOT NULL) THEN 1 ELSE 0 END),
13762 SUM(CASE WHEN (inventory_item_id IS NULL AND item_id IS NOT NULL) THEN 1 ELSE 0 END),
13763 SUM(CASE WHEN (cost_type_id IS NULL AND cost_mthd_code IS NOT NULL) THEN 1 ELSE 0 END),
13764 SUM(CASE WHEN (item_uom IS NULL AND item_um IS NOT NULL) THEN 1 ELSE 0 END),
13765 SUM(CASE WHEN (resource_uom IS NULL AND resource_um IS NOT NULL) THEN 1 ELSE 0 END),
13766 SUM(CASE WHEN (lot_number IS NULL AND lot_id IS NOT NULL) THEN 1 ELSE 0 END)
13767 INTO l_organization_count,
13768 l_inventory_item_count,
13769 l_cost_type_count,
13770 l_uom_count1,
13771 l_uom_count2,
13772 l_lot_number_count
13773 FROM gmf_lot_cost_burdens;
13774 END IF;
13775 END IF;
13776 /*************************************************************
13777 * Migration Error Logging for table GMF_LOT_COST_ADJUSTMENTS *
13778 *************************************************************/
13779 IF l_table_name IN ('GMF_LOT_COST_ADJUSTMENTS') THEN
13780 IF p_log_level = 1 THEN
13781 l_sql_statement := l_sql_statement
13782 ||
13783 '( (cost_type_id IS NULL AND cost_mthd_code IS NOT NULL)
13784 OR (organization_id IS NULL AND whse_code IS NOT NULL)
13785 OR (inventory_item_id IS NULL AND item_id IS NOT NULL)
13786 OR (legal_entity_id IS NULL AND co_code IS NOT NULL)
13787 OR (lot_number IS NULL AND lot_id IS NOT NULL)
13788 )';
13789 execute IMMEDIATE l_sql_statement INTO l_failure_count;
13790 ELSIF p_log_level = 2 THEN
13791 SELECT SUM(CASE WHEN (organization_id IS NULL AND whse_code IS NOT NULL) THEN 1 ELSE 0 END),
13792 SUM(CASE WHEN (inventory_item_id IS NULL AND item_id IS NOT NULL) THEN 1 ELSE 0 END),
13793 SUM(CASE WHEN (cost_type_id IS NULL AND cost_mthd_code IS NOT NULL) THEN 1 ELSE 0 END),
13794 SUM(CASE WHEN (legal_entity_id IS NULL AND co_code IS NOT NULL) THEN 1 ELSE 0 END),
13795 SUM(CASE WHEN (lot_number IS NULL AND lot_id IS NOT NULL) THEN 1 ELSE 0 END)
13796 INTO l_organization_count,
13797 l_inventory_item_count,
13798 l_cost_type_count,
13799 l_legal_entity_count,
13800 l_lot_number_count
13801 FROM gmf_lot_cost_adjustments;
13802 END IF;
13803 END IF;
13804 /***************************************************************
13805 * Migration Error Logging for table GMF_MATERIAL_LOT_COST_TXNS *
13806 ***************************************************************/
13807 IF l_table_name IN ('GMF_MATERIAL_LOT_COST_TXNS') THEN
13808 IF p_log_level = 1 THEN
13809 l_sql_statement := l_sql_statement
13810 ||
13811 '( (cost_type_id IS NULL AND cost_type_code IS NOT NULL)
13812 OR (cost_trans_um IS NULL AND cost_trans_uom IS NOT NULL)
13813 )';
13814 execute IMMEDIATE l_sql_statement INTO l_failure_count;
13815 ELSIF p_log_level = 2 THEN
13816 SELECT SUM(CASE WHEN (cost_type_id IS NULL AND cost_type_code IS NOT NULL) THEN 1 ELSE 0 END),
13817 SUM(CASE WHEN (cost_trans_um IS NULL AND cost_trans_uom IS NOT NULL) THEN 1 ELSE 0 END)
13818 INTO l_cost_type_count,
13819 l_uom_count1
13820 FROM gmf_material_lot_cost_txns;
13821 END IF;
13822 END IF;
13823 /************************************************
13824 * Migration Error Logging for table CM_WHSE_SRC *
13825 ************************************************/
13826 IF l_table_name IN ('CM_WHSE_SRC') THEN
13827 IF p_log_level = 1 THEN
13828 l_sql_statement := l_sql_statement
13829 ||
13830 '( (legal_entity_id IS NULL AND orgn_code IS NOT NULL)
13831 OR (source_organization_id IS NULL AND whse_code IS NOT NULL)
13832 OR (inventory_item_id IS NULL AND item_id IS NOT NULL)
13833 OR (master_organization_id IS NULL AND item_id IS NOT NULL)
13834 OR (organization_id IS NULL AND delete_mark = 0 AND orgn_code IS NOT NULL)
13835 )';
13836 execute IMMEDIATE l_sql_statement INTO l_failure_count;
13837 ELSIF p_log_level = 2 THEN
13838 SELECT SUM(CASE WHEN (source_organization_id IS NULL AND whse_code IS NOT NULL) THEN 1 ELSE 0 END),
13839 SUM(CASE WHEN (inventory_item_id IS NULL AND item_id IS NOT NULL) THEN 1 ELSE 0 END),
13840 SUM(CASE WHEN (organization_id IS NULL AND delete_mark = 0 AND orgn_code IS NOT NULL) THEN 1 ELSE 0 END),
13841 SUM(CASE WHEN (legal_entity_id IS NULL AND orgn_code IS NOT NULL) THEN 1 ELSE 0 END),
13842 SUM(CASE WHEN (master_organization_id IS NULL AND item_id IS NOT NULL) THEN 1 ELSE 0 END)
13843 INTO l_source_organization_count,
13844 l_inventory_item_count,
13845 l_organization_count,
13846 l_legal_entity_count,
13847 l_master_organization_count
13848 FROM cm_whse_src;
13849 END IF;
13850 END IF;
13851 /************************************************
13852 * Migration Error Logging for table CM_ACPR_CTL *
13853 ************************************************/
13854 IF l_table_name IN ('CM_ACPR_CTL') THEN
13855 IF p_log_level = 1 THEN
13856 l_sql_statement := l_sql_statement
13857 ||
13858 '( (calendar_code IS NOT NULL AND period_code IS NOT NULL and period_id IS NULL)
13859 OR (cost_mthd_code IS NOT NULL AND cost_type_id is NULL)
13860 OR (calendar_code IS NOT NULL AND legal_entity_id IS NULL)
13861 )';
13862 execute IMMEDIATE l_sql_statement INTO l_failure_count;
13863 ELSIF p_log_level = 2 THEN
13864 SELECT SUM(CASE WHEN (calendar_code IS NOT NULL AND period_code IS NOT NULL and period_id IS NULL) THEN 1 ELSE 0 END),
13865 SUM(CASE WHEN (cost_mthd_code IS NOT NULL AND cost_type_id is NULL) THEN 1 ELSE 0 END),
13866 SUM(CASE WHEN (calendar_code IS NOT NULL AND legal_entity_id IS NULL) THEN 1 ELSE 0 END)
13867 INTO l_period_count,
13868 l_cost_type_count,
13869 l_legal_entity_count
13870 FROM cm_acpr_ctl;
13871 END IF;
13872 END IF;
13873 /************************************************
13874 * Migration Error Logging for table CM_RLUP_CTL *
13875 ************************************************/
13876 IF l_table_name IN ('CM_RLUP_CTL') THEN
13877 IF p_log_level = 1 THEN
13878 l_sql_statement := l_sql_statement
13879 ||
13880 '( (calendar_code is not null and period_code is not null and period_id is null)
13881 or (cost_mthd_code is not null and cost_type_id is null)
13882 or (calendar_code is not null and legal_entity_id is null)
13883 or (inventory_item_id is null and item_id is not null)
13884 or (master_organization_id is null and item_id is not null)
13885 )';
13886 execute IMMEDIATE l_sql_statement INTO l_failure_count;
13887 ELSIF p_log_level = 2 THEN
13888 SELECT SUM(CASE WHEN (calendar_code IS NOT NULL AND period_code IS NOT NULL and period_id IS NULL) THEN 1 ELSE 0 END),
13889 SUM(CASE WHEN (cost_mthd_code IS NOT NULL AND cost_type_id is NULL) THEN 1 ELSE 0 END),
13890 SUM(CASE WHEN (calendar_code IS NOT NULL AND legal_entity_id IS NULL) THEN 1 ELSE 0 END),
13891 SUM(CASE WHEN (inventory_item_id IS NULL AND item_id IS NOT NULL) THEN 1 ELSE 0 END),
13892 SUM(CASE WHEN (master_organization_id IS NULL AND item_id IS NOT NULL) THEN 1 ELSE 0 END)
13893 INTO l_period_count,
13894 l_cost_type_count,
13895 l_legal_entity_count,
13896 l_inventory_item_count,
13897 l_master_organization_count
13898 FROM cm_rlup_ctl;
13899 END IF;
13900 END IF;
13901 /************************************************
13902 * Migration Error Logging for table CM_RLUP_ITM *
13903 ************************************************/
13904 IF l_table_name IN ('CM_RLUP_ITM') THEN
13905 IF p_log_level = 1 THEN
13906 l_sql_statement := l_sql_statement
13907 ||
13908 '( (inventory_item_id is null and item_id is not null)
13909 or (organization_id is null and item_id is not null)
13910 )';
13911 execute IMMEDIATE l_sql_statement INTO l_failure_count;
13912 ELSIF p_log_level = 2 THEN
13913 SELECT SUM(CASE WHEN (inventory_item_id IS NULL AND item_id IS NOT NULL) THEN 1 ELSE 0 END),
13914 SUM(CASE WHEN (organization_id IS NULL AND item_id IS NOT NULL) THEN 1 ELSE 0 END)
13915 INTO l_inventory_item_count,
13916 l_master_organization_count
13917 FROM cm_rlup_itm;
13918 END IF;
13919 END IF;
13920 /************************************************
13921 * Migration Error Logging for table CM_CUPD_CTL *
13922 ************************************************/
13923 IF l_table_name IN ('CM_CUPD_CTL') THEN
13924 IF p_log_level = 1 THEN
13925 l_sql_statement := l_sql_statement
13926 ||
13927 '( (calendar_code IS NOT NULL AND period_code IS NOT NULL and period_id IS NULL)
13928 OR (cost_mthd_code IS NOT NULL AND cost_type_id is NULL)
13929 OR (calendar_code IS NOT NULL AND legal_entity_id IS NULL)
13930 )';
13931 execute IMMEDIATE l_sql_statement INTO l_failure_count;
13932 ELSIF p_log_level = 2 THEN
13933 SELECT SUM(CASE WHEN (calendar_code IS NOT NULL AND period_code IS NOT NULL and period_id IS NULL) THEN 1 ELSE 0 END),
13934 SUM(CASE WHEN (cost_mthd_code IS NOT NULL AND cost_type_id is NULL) THEN 1 ELSE 0 END),
13935 SUM(CASE WHEN (calendar_code IS NOT NULL AND legal_entity_id IS NULL) THEN 1 ELSE 0 END)
13936 INTO l_period_count,
13937 l_cost_type_count,
13938 l_legal_entity_count
13939 FROM cm_cupd_ctl;
13940 END IF;
13941 END IF;
13942 /************************************************
13943 * Migration Error Logging for table GL_SUBR_STA *
13944 ************************************************/
13945 IF l_table_name IN ('GL_SUBR_STA') THEN
13946 IF p_log_level = 1 THEN
13947 l_sql_statement := l_sql_statement
13948 ||
13949 '( (crev_curr_mthd is not null AND crev_curr_cost_type_id IS NULL)
13950 OR (crev_curr_calendar is not null and crev_curr_period is not NULL AND crev_curr_period_id is null)
13951 OR (crev_prev_mthd is not null AND crev_prev_cost_type_id IS NULL)
13952 OR (crev_prev_calendar is not null and crev_prev_period is not NULL AND crev_prev_period_id is null)
13953 OR (co_code is not null and legal_entity_id is null)
13954 OR (co_code is not null AND cost_type_id is null)
13955 )';
13956 execute IMMEDIATE l_sql_statement INTO l_failure_count;
13957 ELSIF p_log_level = 2 THEN
13958 SELECT SUM(CASE WHEN (crev_curr_mthd is not null AND crev_curr_cost_type_id IS NULL) THEN 1 ELSE 0 END),
13959 SUM(CASE WHEN (crev_curr_calendar is not null and crev_curr_period is not NULL AND crev_curr_period_id is null) THEN 1 ELSE 0 END),
13960 SUM(CASE WHEN (crev_prev_mthd is not null AND crev_prev_cost_type_id IS NULL) THEN 1 ELSE 0 END),
13961 SUM(CASE WHEN (crev_prev_calendar is not null and crev_prev_period is not NULL AND crev_prev_period_id is null) THEN 1 ELSE 0 END),
13962 SUM(CASE WHEN (co_code is not null and legal_entity_id is null) THEN 1 ELSE 0 END),
13963 SUM(CASE WHEN (co_code is not null AND cost_type_id is null) THEN 1 ELSE 0 END)
13964 INTO l_curr_cost_type_count,
13965 l_curr_period_count,
13966 l_prev_cost_type_count,
13967 l_prev_period_count,
13968 l_legal_entity_count,
13969 l_cost_type_count
13970 FROM gl_subr_sta;
13971 END IF;
13972 END IF;
13973 ELSIF p_log_level = 3 THEN
13974 IF l_table_name = 'CM_RSRC_DTL' THEN
13975 OPEN cur_gmf_log_errors FOR l_cm_rsrc_dtl;
13976 FETCH cur_gmf_log_errors bulk collect INTO l_error_tbl;
13977 CLOSE cur_gmf_log_errors;
13978 ELSIF l_table_name = 'CM_ADJS_DTL' THEN
13979 OPEN cur_gmf_log_errors FOR l_cm_adjs_dtl;
13980 FETCH cur_gmf_log_errors bulk collect INTO l_error_tbl;
13981 CLOSE cur_gmf_log_errors;
13982 ELSIF l_table_name = 'CM_CMPT_DTL' THEN
13983 OPEN cur_gmf_log_errors FOR l_cm_cmpt_dtl;
13984 FETCH cur_gmf_log_errors bulk collect INTO l_error_tbl;
13985 CLOSE cur_gmf_log_errors;
13986 ELSIF l_table_name = 'CM_BRDN_DTL' THEN
13987 OPEN cur_gmf_log_errors FOR l_cm_brdn_dtl;
13988 FETCH cur_gmf_log_errors bulk collect INTO l_error_tbl;
13989 CLOSE cur_gmf_log_errors;
13990 ELSIF l_table_name = 'GL_ITEM_CST' THEN
13991 OPEN cur_gmf_log_errors FOR l_gl_item_cst;
13992 FETCH cur_gmf_log_errors bulk collect INTO l_error_tbl;
13993 CLOSE cur_gmf_log_errors;
13994 ELSIF l_table_name = 'CM_SCST_LED' THEN
13995 OPEN cur_gmf_log_errors FOR l_cm_scst_led;
13996 FETCH cur_gmf_log_errors bulk collect INTO l_error_tbl;
13997 CLOSE cur_gmf_log_errors;
13998 ELSIF l_table_name = 'CM_ACST_LED' THEN
13999 OPEN cur_gmf_log_errors FOR l_cm_acst_led;
14000 FETCH cur_gmf_log_errors bulk collect INTO l_error_tbl;
14001 CLOSE cur_gmf_log_errors;
14002 ELSIF l_table_name = 'XLA_RULES_T' THEN
14003 OPEN cur_gmf_log_errors FOR l_xla_rules_t;
14004 FETCH cur_gmf_log_errors bulk collect INTO l_error_tbl;
14005 CLOSE cur_gmf_log_errors;
14006 ELSIF l_table_name = 'XLA_RULE_DETAILS_T' THEN
14007 OPEN cur_gmf_log_errors FOR l_xla_rule_details_t;
14008 FETCH cur_gmf_log_errors bulk collect INTO l_error_tbl;
14009 CLOSE cur_gmf_log_errors;
14010 ELSIF l_table_name = 'XLA_CONDITIONS_T' THEN
14011 OPEN cur_gmf_log_errors FOR l_xla_conditions_t;
14012 FETCH cur_gmf_log_errors bulk collect INTO l_error_tbl;
14013 CLOSE cur_gmf_log_errors;
14014 ELSIF l_table_name = 'XLA_LINE_ASSGNS_T' THEN
14015 OPEN cur_gmf_log_errors FOR l_xla_line_assgns_t;
14016 FETCH cur_gmf_log_errors bulk collect INTO l_error_tbl;
14017 CLOSE cur_gmf_log_errors;
14018 ELSIF l_table_name = 'GMF_LOT_COSTS' THEN
14019 OPEN cur_gmf_log_errors FOR l_gmf_lot_costs;
14020 FETCH cur_gmf_log_errors bulk collect INTO l_error_tbl;
14021 CLOSE cur_gmf_log_errors;
14022 ELSIF l_table_name = 'GMF_LOT_COSTED_ITEMS' THEN
14023 OPEN cur_gmf_log_errors FOR l_gmf_lot_costed_items;
14024 FETCH cur_gmf_log_errors bulk collect INTO l_error_tbl;
14025 CLOSE cur_gmf_log_errors;
14026 ELSIF l_table_name = 'GMF_LOT_COST_BURDENS' THEN
14027 OPEN cur_gmf_log_errors FOR l_gmf_lot_cost_burdens;
14028 FETCH cur_gmf_log_errors bulk collect INTO l_error_tbl;
14029 CLOSE cur_gmf_log_errors;
14030 ELSIF l_table_name = 'GMF_LOT_COST_ADJUSTMENTS' THEN
14031 OPEN cur_gmf_log_errors FOR l_gmf_lot_cost_adjustments;
14032 FETCH cur_gmf_log_errors bulk collect INTO l_error_tbl;
14033 CLOSE cur_gmf_log_errors;
14034 ELSIF l_table_name = 'GMF_MATERIAL_LOT_COST_TXNS' THEN
14035 OPEN cur_gmf_log_errors FOR l_gmf_material_lot_cost_txns;
14036 FETCH cur_gmf_log_errors bulk collect INTO l_error_tbl;
14037 CLOSE cur_gmf_log_errors;
14038 ELSIF l_table_name = 'CM_WHSE_SRC' THEN
14039 OPEN cur_gmf_log_errors FOR l_cm_whse_src;
14040 FETCH cur_gmf_log_errors bulk collect INTO l_error_tbl;
14041 CLOSE cur_gmf_log_errors;
14042 ELSIF l_table_name = 'CM_ACPR_CTL' THEN
14043 OPEN cur_gmf_log_errors FOR l_cm_acpr_ctl;
14044 FETCH cur_gmf_log_errors bulk collect INTO l_error_tbl;
14045 CLOSE cur_gmf_log_errors;
14046 ELSIF l_table_name = 'CM_RLUP_CTL' THEN
14047 OPEN cur_gmf_log_errors FOR l_cm_rlup_ctl;
14048 FETCH cur_gmf_log_errors bulk collect INTO l_error_tbl;
14049 CLOSE cur_gmf_log_errors;
14050 ELSIF l_table_name = 'CM_RLUP_ITM' THEN
14051 OPEN cur_gmf_log_errors FOR l_cm_rlup_itm;
14052 FETCH cur_gmf_log_errors bulk collect INTO l_error_tbl;
14053 CLOSE cur_gmf_log_errors;
14054 ELSIF l_table_name = 'CM_CUPD_CTL' THEN
14055 OPEN cur_gmf_log_errors FOR l_cm_cupd_ctl;
14056 FETCH cur_gmf_log_errors bulk collect INTO l_error_tbl;
14057 CLOSE cur_gmf_log_errors;
14058 ELSIF l_table_name = 'GL_SUBR_STA' THEN
14059 OPEN cur_gmf_log_errors FOR l_gl_subr_sta;
14060 FETCH cur_gmf_log_errors bulk collect INTO l_error_tbl;
14061 CLOSE cur_gmf_log_errors;
14062 END IF;
14063 END IF;
14064 /********************************************
14065 * Logging Errors in GMA_MIGRATION_LOG table *
14066 ********************************************/
14067 IF p_log_level = 1 THEN
14068 IF nvl(l_failure_count,0) > 0 THEN
14069 /**************************************
14070 * Migration Failure Log Message *
14071 **************************************/
14072 GMA_COMMON_LOGGING.gma_migration_central_log
14073 (
14074 p_run_id => gmf_migration.G_migration_run_id,
14075 p_log_level => FND_LOG.LEVEL_PROCEDURE,
14076 p_message_token => 'GMA_TABLE_MIGRATION_TABLE_FAIL',
14077 p_table_name => gmf_migration.G_Table_name,
14078 p_context => gmf_migration.G_context,
14079 p_db_error => NULL,
14080 p_app_short_name => 'GMA'
14081 );
14082 ELSE
14083 /**************************************
14084 * Migration Success Log Message *
14085 **************************************/
14086 GMA_COMMON_LOGGING.gma_migration_central_log
14087 (
14088 p_run_id => gmf_migration.G_migration_run_id,
14089 p_log_level => FND_LOG.LEVEL_PROCEDURE,
14090 p_message_token => 'GMA_MIGRATION_TABLE_SUCCESS',
14091 p_table_name => gmf_migration.G_Table_name,
14092 p_context => gmf_migration.G_context,
14093 p_param1 => 1,
14094 p_param2 => 0,
14095 p_db_error => NULL,
14096 p_app_short_name => 'GMA'
14097 );
14098 END IF;
14099 ELSIF p_log_level = 2 THEN
14100 l_failure_count := nvl(l_legal_entity_count, 0) + nvl(l_organization_count, 0) + nvl(l_cost_type_count, 0) +
14101 nvl(l_period_count, 0) + nvl(l_uom_count1, 0) + nvl(l_uom_count2, 0) + nvl(l_uom_count3, 0) +
14102 nvl(l_inventory_item_count, 0) + nvl(l_adjustment_ind_count, 0) + nvl(l_source_organization_count, 0) +
14103 nvl(l_master_organization_count, 0) + nvl(l_prev_cost_type_count, 0) + nvl(l_prev_period_count, 0) +
14104 nvl(l_curr_cost_type_count, 0) + nvl(l_curr_period_count, 0) + nvl(l_total_error_count, 0) +
14105 nvl(l_lot_number_count, 0);
14106 IF nvl(l_failure_count,0) > 0 THEN
14107 /***********************************
14108 * Legal Entity Migration Error Log *
14109 ***********************************/
14110 IF nvl(l_legal_entity_count,0) > 0 THEN
14111 GMA_COMMON_LOGGING.gma_migration_central_log
14112 (
14113 p_run_id => gmf_migration.G_migration_run_id,
14114 p_log_level => FND_LOG.LEVEL_ERROR,
14115 p_message_token => 'GMA_MIGRATION_ERROR_ABSTRACT',
14116 p_table_name => gmf_migration.G_Table_name,
14117 p_context => gmf_migration.G_Context,
14118 p_token1 => 'TABLE_NAME',
14119 p_token2 => 'COLUMN_NAME',
14120 p_token3 => 'RECORD_COUNT',
14121 p_param1 => gmf_migration.G_Table_name,
14122 p_param2 => 'Legal Entities',
14123 p_param3 => l_legal_entity_count,
14124 p_db_error => NULL,
14125 p_app_short_name => 'GMA'
14126 );
14127 END IF;
14128 /***********************************
14129 * Organization Migration Error Log *
14130 ***********************************/
14131 IF nvl(l_organization_count,0) > 0 THEN
14132 GMA_COMMON_LOGGING.gma_migration_central_log
14133 (
14134 p_run_id => gmf_migration.G_migration_run_id,
14135 p_log_level => FND_LOG.LEVEL_ERROR,
14136 p_message_token => 'GMA_MIGRATION_ERROR_ABSTRACT',
14137 p_table_name => gmf_migration.G_Table_name,
14138 p_context => gmf_migration.G_Context,
14139 p_token1 => 'TABLE_NAME',
14140 p_token2 => 'COLUMN_NAME',
14141 p_token3 => 'RECORD_COUNT',
14142 p_param1 => gmf_migration.G_Table_name,
14143 p_param2 => 'Organizations',
14144 p_param3 => l_organization_count,
14145 p_db_error => NULL,
14146 p_app_short_name => 'GMA'
14147 );
14148 END IF;
14149 /******************************************
14150 * Source Organization Migration Error Log *
14151 ******************************************/
14152 IF nvl(l_source_organization_count,0) > 0 THEN
14153 GMA_COMMON_LOGGING.gma_migration_central_log
14154 (
14155 p_run_id => gmf_migration.G_migration_run_id,
14156 p_log_level => FND_LOG.LEVEL_ERROR,
14157 p_message_token => 'GMA_MIGRATION_ERROR_ABSTRACT',
14158 p_table_name => gmf_migration.G_Table_name,
14159 p_context => gmf_migration.G_Context,
14160 p_token1 => 'TABLE_NAME',
14161 p_token2 => 'COLUMN_NAME',
14162 p_token3 => 'RECORD_COUNT',
14163 p_param1 => gmf_migration.G_Table_name,
14164 p_param2 => 'Source Organizations',
14165 p_param3 => l_source_organization_count,
14166 p_db_error => NULL,
14167 p_app_short_name => 'GMA'
14168 );
14169 END IF;
14170 /******************************************
14171 * Master Organization Migration Error Log *
14172 ******************************************/
14173 IF nvl(l_master_organization_count,0) > 0 THEN
14174 GMA_COMMON_LOGGING.gma_migration_central_log
14175 (
14176 p_run_id => gmf_migration.G_migration_run_id,
14177 p_log_level => FND_LOG.LEVEL_ERROR,
14178 p_message_token => 'GMA_MIGRATION_ERROR_ABSTRACT',
14179 p_table_name => gmf_migration.G_Table_name,
14180 p_context => gmf_migration.G_Context,
14181 p_token1 => 'TABLE_NAME',
14182 p_token2 => 'COLUMN_NAME',
14183 p_token3 => 'RECORD_COUNT',
14184 p_param1 => gmf_migration.G_Table_name,
14185 p_param2 => 'Master Organizations',
14186 p_param3 => l_master_organization_count,
14187 p_db_error => NULL,
14188 p_app_short_name => 'GMA'
14189 );
14190 END IF;
14191 /***************************
14192 * Item Migration Error Log *
14193 ***************************/
14194 IF nvl(l_inventory_item_count,0) > 0 THEN
14195 GMA_COMMON_LOGGING.gma_migration_central_log
14196 (
14197 p_run_id => gmf_migration.G_migration_run_id,
14198 p_log_level => FND_LOG.LEVEL_ERROR,
14199 p_message_token => 'GMA_MIGRATION_ERROR_ABSTRACT',
14200 p_table_name => gmf_migration.G_Table_name,
14201 p_context => gmf_migration.G_Context,
14202 p_token1 => 'TABLE_NAME',
14203 p_token2 => 'COLUMN_NAME',
14204 p_token3 => 'RECORD_COUNT',
14205 p_param1 => gmf_migration.G_Table_name,
14206 p_param2 => 'Items',
14207 p_param3 => l_inventory_item_count,
14208 p_db_error => NULL,
14209 p_app_short_name => 'GMA'
14210 );
14211 END IF;
14212 /***********************************
14213 * Cost Type Migration Error Log *
14214 ***********************************/
14215 IF nvl(l_cost_type_count,0) > 0 THEN
14216 GMA_COMMON_LOGGING.gma_migration_central_log
14217 (
14218 p_run_id => gmf_migration.G_migration_run_id,
14219 p_log_level => FND_LOG.LEVEL_ERROR,
14220 p_message_token => 'GMA_MIGRATION_ERROR_ABSTRACT',
14221 p_table_name => gmf_migration.G_Table_name,
14222 p_context => gmf_migration.G_Context,
14223 p_token1 => 'TABLE_NAME',
14224 p_token2 => 'COLUMN_NAME',
14225 p_token3 => 'RECORD_COUNT',
14226 p_param1 => gmf_migration.G_Table_name,
14227 p_param2 => 'Cost Types',
14228 p_param3 => l_cost_type_count,
14229 p_db_error => NULL,
14230 p_app_short_name => 'GMA'
14231 );
14232 END IF;
14233 /********************************************
14234 * Previous Cost Type Migration Error Log *
14235 ********************************************/
14236 IF nvl(l_prev_cost_type_count,0) > 0 THEN
14237 GMA_COMMON_LOGGING.gma_migration_central_log
14238 (
14239 p_run_id => gmf_migration.G_migration_run_id,
14240 p_log_level => FND_LOG.LEVEL_ERROR,
14241 p_message_token => 'GMA_MIGRATION_ERROR_ABSTRACT',
14242 p_table_name => gmf_migration.G_Table_name,
14243 p_context => gmf_migration.G_Context,
14244 p_token1 => 'TABLE_NAME',
14245 p_token2 => 'COLUMN_NAME',
14246 p_token3 => 'RECORD_COUNT',
14247 p_param1 => gmf_migration.G_Table_name,
14248 p_param2 => 'Previous Cost Types',
14249 p_param3 => l_prev_cost_type_count,
14250 p_db_error => NULL,
14251 p_app_short_name => 'GMA'
14252 );
14253 END IF;
14254 /*******************************************
14255 * Current Cost Type Migration Error Log *
14256 *******************************************/
14257 IF nvl(l_curr_cost_type_count,0) > 0 THEN
14258 GMA_COMMON_LOGGING.gma_migration_central_log
14259 (
14260 p_run_id => gmf_migration.G_migration_run_id,
14261 p_log_level => FND_LOG.LEVEL_ERROR,
14262 p_message_token => 'GMA_MIGRATION_ERROR_ABSTRACT',
14263 p_table_name => gmf_migration.G_Table_name,
14264 p_context => gmf_migration.G_Context,
14265 p_token1 => 'TABLE_NAME',
14266 p_token2 => 'COLUMN_NAME',
14267 p_token3 => 'RECORD_COUNT',
14268 p_param1 => gmf_migration.G_Table_name,
14269 p_param2 => 'Current Cost Types',
14270 p_param3 => l_curr_cost_type_count,
14271 p_db_error => NULL,
14272 p_app_short_name => 'GMA'
14273 );
14274 END IF;
14275 /***********************************
14276 * Periods Migration Error Log *
14277 ***********************************/
14278 IF nvl(l_period_count,0) > 0 THEN
14279 GMA_COMMON_LOGGING.gma_migration_central_log
14280 (
14281 p_run_id => gmf_migration.G_migration_run_id,
14282 p_log_level => FND_LOG.LEVEL_ERROR,
14283 p_message_token => 'GMA_MIGRATION_ERROR_ABSTRACT',
14284 p_table_name => gmf_migration.G_Table_name,
14285 p_context => gmf_migration.G_Context,
14286 p_token1 => 'TABLE_NAME',
14287 p_token2 => 'COLUMN_NAME',
14288 p_token3 => 'RECORD_COUNT',
14289 p_param1 => gmf_migration.G_Table_name,
14290 p_param2 => 'Periods',
14291 p_param3 => l_period_count,
14292 p_db_error => NULL,
14293 p_app_short_name => 'GMA'
14294 );
14295 END IF;
14296 /********************************************
14297 * Previous Periods Migration Error Log *
14298 ********************************************/
14299 IF nvl(l_prev_period_count,0) > 0 THEN
14300 GMA_COMMON_LOGGING.gma_migration_central_log
14301 (
14302 p_run_id => gmf_migration.G_migration_run_id,
14303 p_log_level => FND_LOG.LEVEL_ERROR,
14304 p_message_token => 'GMA_MIGRATION_ERROR_ABSTRACT',
14305 p_table_name => gmf_migration.G_Table_name,
14306 p_context => gmf_migration.G_Context,
14307 p_token1 => 'TABLE_NAME',
14308 p_token2 => 'COLUMN_NAME',
14309 p_token3 => 'RECORD_COUNT',
14310 p_param1 => gmf_migration.G_Table_name,
14311 p_param2 => 'Previous Periods',
14312 p_param3 => l_prev_period_count,
14313 p_db_error => NULL,
14314 p_app_short_name => 'GMA'
14315 );
14316 END IF;
14317 /********************************************
14318 * Current Periods Migration Error Log *
14319 ********************************************/
14320 IF nvl(l_curr_period_count,0) > 0 THEN
14321 GMA_COMMON_LOGGING.gma_migration_central_log
14322 (
14323 p_run_id => gmf_migration.G_migration_run_id,
14324 p_log_level => FND_LOG.LEVEL_ERROR,
14325 p_message_token => 'GMA_MIGRATION_ERROR_ABSTRACT',
14326 p_table_name => gmf_migration.G_Table_name,
14327 p_context => gmf_migration.G_Context,
14328 p_token1 => 'TABLE_NAME',
14329 p_token2 => 'COLUMN_NAME',
14330 p_token3 => 'RECORD_COUNT',
14331 p_param1 => gmf_migration.G_Table_name,
14332 p_param2 => 'Current Periods',
14333 p_param3 => l_curr_period_count,
14334 p_db_error => NULL,
14335 p_app_short_name => 'GMA'
14336 );
14337 END IF;
14338 /***********************************
14339 * UOM-1 Migration Error Log *
14340 ***********************************/
14341 IF nvl(l_uom_count1,0) > 0 THEN
14342 GMA_COMMON_LOGGING.gma_migration_central_log
14343 (
14344 p_run_id => gmf_migration.G_migration_run_id,
14345 p_log_level => FND_LOG.LEVEL_ERROR,
14346 p_message_token => 'GMA_MIGRATION_ERROR_ABSTRACT',
14347 p_table_name => gmf_migration.G_Table_name,
14348 p_context => gmf_migration.G_Context,
14349 p_token1 => 'TABLE_NAME',
14350 p_token2 => 'COLUMN_NAME',
14351 p_token3 => 'RECORD_COUNT',
14352 p_param1 => gmf_migration.G_Table_name,
14353 p_param2 => 'UOMs',
14354 p_param3 => l_uom_count1,
14355 p_db_error => NULL,
14356 p_app_short_name => 'GMA'
14357 );
14358 END IF;
14359 /***********************************
14360 * UOM-2 Migration Error Log *
14361 ***********************************/
14362 IF nvl(l_uom_count2,0) > 0 THEN
14363 GMA_COMMON_LOGGING.gma_migration_central_log
14364 (
14365 p_run_id => gmf_migration.G_migration_run_id,
14366 p_log_level => FND_LOG.LEVEL_ERROR,
14367 p_message_token => 'GMA_MIGRATION_ERROR_ABSTRACT',
14368 p_table_name => gmf_migration.G_Table_name,
14369 p_context => gmf_migration.G_Context,
14370 p_token1 => 'TABLE_NAME',
14371 p_token2 => 'COLUMN_NAME',
14372 p_token3 => 'RECORD_COUNT',
14373 p_param1 => gmf_migration.G_Table_name,
14374 p_param2 => 'UOMs',
14375 p_param3 => l_uom_count2,
14376 p_db_error => NULL,
14377 p_app_short_name => 'GMA'
14378 );
14379 END IF;
14380 /***********************************
14381 * UOM-3 Migration Error Log *
14382 ***********************************/
14383 IF nvl(l_uom_count3,0) > 0 THEN
14384 GMA_COMMON_LOGGING.gma_migration_central_log
14385 (
14386 p_run_id => gmf_migration.G_migration_run_id,
14387 p_log_level => FND_LOG.LEVEL_ERROR,
14388 p_message_token => 'GMA_MIGRATION_ERROR_ABSTRACT',
14389 p_table_name => gmf_migration.G_Table_name,
14390 p_context => gmf_migration.G_Context,
14391 p_token1 => 'TABLE_NAME',
14392 p_token2 => 'COLUMN_NAME',
14393 p_token3 => 'RECORD_COUNT',
14394 p_param1 => gmf_migration.G_Table_name,
14395 p_param2 => 'UOMs',
14396 p_param3 => l_uom_count3,
14397 p_db_error => NULL,
14398 p_app_short_name => 'GMA'
14399 );
14400 END IF;
14401 /*******************************************
14402 * Adjustment Indicator Migration Error Log *
14403 *******************************************/
14404 IF nvl(l_adjustment_ind_count,0) > 0 THEN
14405 GMA_COMMON_LOGGING.gma_migration_central_log
14406 (
14407 p_run_id => gmf_migration.G_migration_run_id,
14408 p_log_level => FND_LOG.LEVEL_ERROR,
14409 p_message_token => 'GMA_MIGRATION_ERROR_ABSTRACT',
14410 p_table_name => gmf_migration.G_Table_name,
14411 p_context => gmf_migration.G_Context,
14412 p_token1 => 'TABLE_NAME',
14413 p_token2 => 'COLUMN_NAME',
14414 p_token3 => 'RECORD_COUNT',
14415 p_param1 => gmf_migration.G_Table_name,
14416 p_param2 => 'Adjustment Indicators',
14417 p_param3 => l_adjustment_ind_count,
14418 p_db_error => NULL,
14419 p_app_short_name => 'GMA'
14420 );
14421 END IF;
14422 /***********************************
14423 * Lot Number Migration Error Log *
14424 ***********************************/
14425 IF nvl(l_lot_number_count,0) > 0 THEN
14426 GMA_COMMON_LOGGING.gma_migration_central_log
14427 (
14428 p_run_id => gmf_migration.G_migration_run_id,
14429 p_log_level => FND_LOG.LEVEL_ERROR,
14430 p_message_token => 'GMA_MIGRATION_ERROR_ABSTRACT',
14431 p_table_name => gmf_migration.G_Table_name,
14432 p_context => gmf_migration.G_Context,
14433 p_token1 => 'TABLE_NAME',
14434 p_token2 => 'COLUMN_NAME',
14435 p_token3 => 'RECORD_COUNT',
14436 p_param1 => gmf_migration.G_Table_name,
14437 p_param2 => 'Lot Numbers',
14438 p_param3 => l_lot_number_count,
14439 p_db_error => NULL,
14440 p_app_short_name => 'GMA'
14441 );
14442 END IF;
14443 /****************************************
14444 * Unique Constraint Migration Error Log *
14445 ****************************************/
14446 IF nvl(l_unique_error_count,0) > 0 THEN
14447 GMA_COMMON_LOGGING.gma_migration_central_log
14448 (
14449 p_run_id => gmf_migration.G_migration_run_id,
14450 p_log_level => FND_LOG.LEVEL_ERROR,
14451 p_message_token => 'GMA_MIGRATION_ERROR_ABSTRACT',
14452 p_table_name => gmf_migration.G_Table_name,
14453 p_context => gmf_migration.G_Context,
14454 p_token1 => 'TABLE_NAME',
14455 p_token2 => 'COLUMN_NAME',
14456 p_token3 => 'RECORD_COUNT',
14457 p_param1 => gmf_migration.G_Table_name,
14458 p_param2 => 'Unique Constraint',
14459 p_param3 => l_unique_error_count,
14460 p_db_error => NULL,
14461 p_app_short_name => 'GMA'
14462 );
14463 END IF;
14464 /******************************************
14465 * Not Null Constraint Migration Error Log *
14466 ******************************************/
14467 IF nvl(l_not_null_error_count,0) > 0 THEN
14468 GMA_COMMON_LOGGING.gma_migration_central_log
14469 (
14470 p_run_id => gmf_migration.G_migration_run_id,
14471 p_log_level => FND_LOG.LEVEL_ERROR,
14472 p_message_token => 'GMA_MIGRATION_ERROR_ABSTRACT',
14473 p_table_name => gmf_migration.G_Table_name,
14474 p_context => gmf_migration.G_Context,
14475 p_token1 => 'TABLE_NAME',
14476 p_token2 => 'COLUMN_NAME',
14477 p_token3 => 'RECORD_COUNT',
14478 p_param1 => gmf_migration.G_Table_name,
14479 p_param2 => 'Not Null Constraint',
14480 p_param3 => l_not_null_error_count,
14481 p_db_error => NULL,
14482 p_app_short_name => 'GMA'
14483 );
14484 END IF;
14485 /************************************
14486 * Invalid Value Migration Error Log *
14487 ************************************/
14488 IF nvl(l_value_error_count,0) > 0 THEN
14489 GMA_COMMON_LOGGING.gma_migration_central_log
14490 (
14491 p_run_id => gmf_migration.G_migration_run_id,
14492 p_log_level => FND_LOG.LEVEL_ERROR,
14493 p_message_token => 'GMA_MIGRATION_ERROR_ABSTRACT',
14494 p_table_name => gmf_migration.G_Table_name,
14495 p_context => gmf_migration.G_Context,
14496 p_token1 => 'TABLE_NAME',
14497 p_token2 => 'COLUMN_NAME',
14498 p_token3 => 'RECORD_COUNT',
14499 p_param1 => gmf_migration.G_Table_name,
14500 p_param2 => 'Invalid Value',
14501 p_param3 => l_value_error_count,
14502 p_db_error => NULL,
14503 p_app_short_name => 'GMA'
14504 );
14505 END IF;
14506 /*******************************************
14507 * Parent Key Not-found Migration Error Log *
14508 *******************************************/
14509 IF nvl(l_parent_key_error_count,0) > 0 THEN
14510 GMA_COMMON_LOGGING.gma_migration_central_log
14511 (
14512 p_run_id => gmf_migration.G_migration_run_id,
14513 p_log_level => FND_LOG.LEVEL_ERROR,
14514 p_message_token => 'GMA_MIGRATION_ERROR_ABSTRACT',
14515 p_table_name => gmf_migration.G_Table_name,
14516 p_context => gmf_migration.G_Context,
14517 p_token1 => 'TABLE_NAME',
14518 p_token2 => 'COLUMN_NAME',
14519 p_token3 => 'RECORD_COUNT',
14520 p_param1 => gmf_migration.G_Table_name,
14521 p_param2 => 'Parent Key Constraint',
14522 p_param3 => l_parent_key_error_count,
14523 p_db_error => NULL,
14524 p_app_short_name => 'GMA'
14525 );
14526 END IF;
14527 /*************************************
14528 * Value Too Long Migration Error Log *
14529 *************************************/
14530 IF nvl(l_too_long_error_count,0) > 0 THEN
14531 GMA_COMMON_LOGGING.gma_migration_central_log
14532 (
14533 p_run_id => gmf_migration.G_migration_run_id,
14534 p_log_level => FND_LOG.LEVEL_ERROR,
14535 p_message_token => 'GMA_MIGRATION_ERROR_ABSTRACT',
14536 p_table_name => gmf_migration.G_Table_name,
14537 p_context => gmf_migration.G_Context,
14538 p_token1 => 'TABLE_NAME',
14539 p_token2 => 'COLUMN_NAME',
14540 p_token3 => 'RECORD_COUNT',
14541 p_param1 => gmf_migration.G_Table_name,
14542 p_param2 => 'Value Too Long Error',
14543 p_param3 => l_too_long_error_count,
14544 p_db_error => NULL,
14545 p_app_short_name => 'GMA'
14546 );
14547 END IF;
14548 /*************************************
14549 * Invalid Number Migration Error Log *
14550 *************************************/
14551 IF nvl(l_invalid_number_error_count,0) > 0 THEN
14552 GMA_COMMON_LOGGING.gma_migration_central_log
14553 (
14554 p_run_id => gmf_migration.G_migration_run_id,
14555 p_log_level => FND_LOG.LEVEL_ERROR,
14556 p_message_token => 'GMA_MIGRATION_ERROR_ABSTRACT',
14557 p_table_name => gmf_migration.G_Table_name,
14558 p_context => gmf_migration.G_Context,
14559 p_token1 => 'TABLE_NAME',
14560 p_token2 => 'COLUMN_NAME',
14561 p_token3 => 'RECORD_COUNT',
14562 p_param1 => gmf_migration.G_Table_name,
14563 p_param2 => 'Invalid Number Error',
14564 p_param3 => l_invalid_number_error_count,
14565 p_db_error => NULL,
14566 p_app_short_name => 'GMA'
14567 );
14568 END IF;
14569 /********************************************
14570 * Records not picked up Migration Error Log *
14571 ********************************************/
14572 IF nvl(l_not_picked_up_error_count,0) > 0 THEN
14573 GMA_COMMON_LOGGING.gma_migration_central_log
14574 (
14575 p_run_id => gmf_migration.G_migration_run_id,
14576 p_log_level => FND_LOG.LEVEL_ERROR,
14577 p_message_token => 'GMA_MIGRATION_ERROR_ABSTRACT',
14578 p_table_name => gmf_migration.G_Table_name,
14579 p_context => gmf_migration.G_Context,
14580 p_token1 => 'TABLE_NAME',
14581 p_token2 => 'COLUMN_NAME',
14582 p_token3 => 'RECORD_COUNT',
14583 p_param1 => gmf_migration.G_Table_name,
14584 p_param2 => 'Records not Picked up Error',
14585 p_param3 => l_not_picked_up_error_count,
14586 p_db_error => NULL,
14587 p_app_short_name => 'GMA'
14588 );
14589 END IF;
14590 /***********************************
14591 * Other Errors Migration Error Log *
14592 ***********************************/
14593 IF nvl(l_total_error_count,0) - (
14594 nvl(l_unique_error_count,0) +
14595 nvl(l_not_null_error_count,0) +
14596 nvl(l_value_error_count,0) +
14597 nvl(l_parent_key_error_count,0) +
14598 nvl(l_invalid_number_error_count,0) +
14599 nvl(l_not_picked_up_error_count,0) +
14600 nvl(l_too_long_error_count,0)
14601 ) > 0 THEN
14602 GMA_COMMON_LOGGING.gma_migration_central_log
14603 (
14604 p_run_id => gmf_migration.G_migration_run_id,
14605 p_log_level => FND_LOG.LEVEL_ERROR,
14606 p_message_token => 'GMA_MIGRATION_ERROR_ABSTRACT',
14607 p_table_name => gmf_migration.G_Table_name,
14608 p_context => gmf_migration.G_Context,
14609 p_token1 => 'TABLE_NAME',
14610 p_token2 => 'COLUMN_NAME',
14611 p_token3 => 'RECORD_COUNT',
14612 p_param1 => gmf_migration.G_Table_name,
14613 p_param2 => 'Other Errors',
14614 p_param3 => nvl(l_total_error_count,0) - (
14615 nvl(l_unique_error_count,0) +
14616 nvl(l_not_null_error_count,0) +
14617 nvl(l_value_error_count,0) +
14618 nvl(l_parent_key_error_count,0) +
14619 nvl(l_invalid_number_error_count,0) +
14620 nvl(l_not_picked_up_error_count,0) +
14621 nvl(l_too_long_error_count,0)
14622 ),
14623 p_db_error => NULL,
14624 p_app_short_name => 'GMA'
14625 );
14626 END IF;
14627 ELSE
14628 /**************************************
14629 * Migration Success Log Message *
14630 **************************************/
14631 GMA_COMMON_LOGGING.gma_migration_central_log
14632 (
14633 p_run_id => gmf_migration.G_migration_run_id,
14634 p_log_level => FND_LOG.LEVEL_PROCEDURE,
14635 p_message_token => 'GMA_MIGRATION_TABLE_SUCCESS',
14636 p_table_name => gmf_migration.G_Table_name,
14637 p_context => gmf_migration.G_context,
14638 p_param1 => 1,
14639 p_param2 => 0,
14640 p_db_error => NULL,
14641 p_app_short_name => 'GMA'
14642 );
14643 END IF;
14644 ELSIF p_log_level = 3 THEN
14645 IF l_error_tbl.count > 0 THEN
14646 FOR i IN l_error_tbl.first..l_error_tbl.last LOOP
14647 GMA_COMMON_LOGGING.gma_migration_central_log
14648 (
14649 p_run_id => gmf_migration.G_migration_run_id,
14650 p_log_level => FND_LOG.LEVEL_ERROR,
14651 p_message_token => 'GMA_MIGRATION_ERROR_DETAIL',
14652 p_table_name => gmf_migration.G_Table_name,
14653 p_context => gmf_migration.G_Context,
14654 p_token1 => 'TABLE_NAME',
14655 p_token2 => 'COLUMN_NAME',
14656 p_token3 => 'PARAMETERS',
14657 p_token4 => 'RECORD_COUNT',
14658 p_param1 => l_error_tbl(i).table_name,
14659 p_param2 => l_error_tbl(i).column_name,
14660 p_param3 => l_error_tbl(i).parameters,
14661 p_param4 => l_error_tbl(i).records,
14662 p_db_error => NULL,
14663 p_app_short_name => 'GMA'
14664 );
14665 END LOOP;
14666 ELSE
14667 /**************************************
14668 * Migration Success Log Message *
14669 **************************************/
14670 GMA_COMMON_LOGGING.gma_migration_central_log
14671 (
14672 p_run_id => gmf_migration.G_migration_run_id,
14673 p_log_level => FND_LOG.LEVEL_PROCEDURE,
14674 p_message_token => 'GMA_MIGRATION_TABLE_SUCCESS',
14675 p_table_name => gmf_migration.G_Table_name,
14676 p_context => gmf_migration.G_context,
14677 p_param1 => 1,
14678 p_param2 => 0,
14679 p_db_error => NULL,
14680 p_app_short_name => 'GMA'
14681 );
14682 END IF;
14683 END IF;
14684 END Log_Errors;
14685
14686 /**********************************************************************
14687 * PROCEDURE: *
14688 * Migrate_Vendor Id *
14689 * *
14690 * DESCRIPTION: *
14691 * This PL/SQL procedure is used to transform the Vendor Id *
14692 * data in GL_ACCT_MAP *
14693 * *
14694 * PARAMETERS: *
14695 * P_migration_run_id - id to use to right to migration log *
14696 * x_exception_count - Number of exceptions occurred. *
14697 * *
14698 * SYNOPSIS: *
14699 * Migrate_Vendor_id(p_migartion_id => l_migration_id, *
14700 * p_commit => 'T', *
14701 * x_exception_count => l_exception_count ); *
14702 * *
14703 * HISTORY *
14704 * 05-Oct-2006 Created Anand Thiyagarajan *
14705 * 12-Oct-2006 Modified Anand Thiyagarajan *
14706 * Stubbed PROCEDURE not to migrate records as this being done *
14707 * in the ADR migration scripts itself *
14708 * *
14709 **********************************************************************/
14710 PROCEDURE Migrate_Vendor_id
14711 (
14712 P_migration_run_id IN NUMBER,
14713 P_commit IN VARCHAR2,
14714 X_failure_count OUT NOCOPY NUMBER
14715 )
14716 IS
14717 /****************
14718 * PL/SQL Tables *
14719 ****************/
14720
14721 /******************
14722 * Local Variables *
14723 ******************/
14724
14725 BEGIN
14726
14727 /****************************************************************************************
14728 * Commented the following code snippet to avoid migrating the records for vendor Id, *
14729 * as the fetching of_vendor_site_id vendor_site_id is done ine the ADR migration script *
14730 * itself directly. *
14731 ****************************************************************************************/
14732 /****************************************************************************************
14733 G_Migration_run_id := P_migration_run_id;
14734 G_Table_name := 'GL_ACCT_MAP';
14735 G_Context := 'Vendor Id Migration';
14736 X_failure_count := 0;
14737
14738 GMA_COMMON_LOGGING.gma_migration_central_log
14739 (
14740 p_run_id => G_migration_run_id,
14741 p_log_level => FND_LOG.LEVEL_STATEMENT,
14742 p_message_token => 'GMA_MIGRATION_TABLE_STARTED',
14743 p_table_name => G_table_name,
14744 p_context => G_context,
14745 p_db_error => NULL,
14746 p_app_short_name => 'GMA'
14747 );
14748
14749 UPDATE gl_acct_map gam
14750 SET gam.vendor_id
14751 = (
14752 SELECT v.of_vendor_site_id
14753 FROM po_vend_mst v
14754 WHERE v.vendor_id = gam.vendor_id
14755 ),
14756 gam.migrated_ind = 1
14757 WHERE gam.vendor_id IS NOT NULL
14758 AND nvl(gam.migrated_ind, -1) <> 1;
14759
14760 IF NVL(p_commit,'~') = FND_API.G_TRUE THEN
14761 COMMIT;
14762 END IF;
14763 ****************************************************************************************/
14764 NULL;
14765
14766 EXCEPTION
14767 WHEN OTHERS THEN
14768 /************************************************
14769 * Increment Failure Count for Failed Migrations *
14770 ************************************************/
14771 x_failure_count := x_failure_count + 1;
14772
14773 /**************************************
14774 * Migration DB Error Log Message *
14775 **************************************/
14776 GMA_COMMON_LOGGING.gma_migration_central_log
14777 (
14778 p_run_id => G_migration_run_id,
14779 p_log_level => FND_LOG.LEVEL_ERROR,
14780 p_message_token => 'GMA_MIGRATION_DB_ERROR',
14781 p_table_name => G_table_name,
14782 p_context => G_context,
14783 p_db_error => SQLERRM,
14784 p_app_short_name => 'GMA'
14785 );
14786
14787 /**************************************
14788 * Migration Failure Log Message *
14789 **************************************/
14790 GMA_COMMON_LOGGING.gma_migration_central_log
14791 (
14792 p_run_id => G_migration_run_id,
14793 p_log_level => FND_LOG.LEVEL_ERROR,
14794 p_message_token => 'GMA_TABLE_MIGRATION_TABLE_FAIL',
14795 p_table_name => G_table_name,
14796 p_context => G_context,
14797 p_db_error => NULL,
14798 p_app_short_name => 'GMA'
14799 );
14800 END Migrate_Vendor_id;
14801
14802 END GMF_MIGRATION;