252: fetch get_uom_metadata into l_table_name, l_column_name;
253:
254: if get_uom_metadata%notfound then
255: close get_uom_metadata;
256: msd_dem_common_utilities.log_message('UOM deleted. Please recreate the UOM');
257: msd_dem_common_utilities.log_debug('UOM deleted. Please recreate the UOM');
258: retcode := 1;
259: return;
260: end if;
253:
254: if get_uom_metadata%notfound then
255: close get_uom_metadata;
256: msd_dem_common_utilities.log_message('UOM deleted. Please recreate the UOM');
257: msd_dem_common_utilities.log_debug('UOM deleted. Please recreate the UOM');
258: retcode := 1;
259: return;
260: end if;
261:
276: ' and rownum < 2 ' ||
277: ')';
278:
279:
280: msd_dem_common_utilities.log_debug('p_instance_id ' || p_instance_id);
281: msd_dem_common_utilities.log_debug(l_stmt);
282:
283: msd_dem_common_utilities.log_debug('Start Time: ' || to_char(sysdate, 'DD-MON-YYYY HH24:MI:SS'));
284: execute immediate l_stmt using p_instance_id;
277: ')';
278:
279:
280: msd_dem_common_utilities.log_debug('p_instance_id ' || p_instance_id);
281: msd_dem_common_utilities.log_debug(l_stmt);
282:
283: msd_dem_common_utilities.log_debug('Start Time: ' || to_char(sysdate, 'DD-MON-YYYY HH24:MI:SS'));
284: execute immediate l_stmt using p_instance_id;
285: msd_dem_common_utilities.log_debug('End Time: ' || to_char(sysdate, 'DD-MON-YYYY HH24:MI:SS'));
279:
280: msd_dem_common_utilities.log_debug('p_instance_id ' || p_instance_id);
281: msd_dem_common_utilities.log_debug(l_stmt);
282:
283: msd_dem_common_utilities.log_debug('Start Time: ' || to_char(sysdate, 'DD-MON-YYYY HH24:MI:SS'));
284: execute immediate l_stmt using p_instance_id;
285: msd_dem_common_utilities.log_debug('End Time: ' || to_char(sysdate, 'DD-MON-YYYY HH24:MI:SS'));
286:
287: exception
281: msd_dem_common_utilities.log_debug(l_stmt);
282:
283: msd_dem_common_utilities.log_debug('Start Time: ' || to_char(sysdate, 'DD-MON-YYYY HH24:MI:SS'));
284: execute immediate l_stmt using p_instance_id;
285: msd_dem_common_utilities.log_debug('End Time: ' || to_char(sysdate, 'DD-MON-YYYY HH24:MI:SS'));
286:
287: exception
288: when others then
289: msd_dem_common_utilities.log_message(substr(SQLERRM,1,150));
285: msd_dem_common_utilities.log_debug('End Time: ' || to_char(sysdate, 'DD-MON-YYYY HH24:MI:SS'));
286:
287: exception
288: when others then
289: msd_dem_common_utilities.log_message(substr(SQLERRM,1,150));
290: msd_dem_common_utilities.log_debug(substr(SQLERRM,1,150));
291: retcode := 1;
292:
293: end;
286:
287: exception
288: when others then
289: msd_dem_common_utilities.log_message(substr(SQLERRM,1,150));
290: msd_dem_common_utilities.log_debug(substr(SQLERRM,1,150));
291: retcode := 1;
292:
293: end;
294:
347: ' minus ' ||
348: ' select distinct display_units_id from ' || get_lookup_value('MSD_DEM_TABLES', 'DCM_PRODUCTS_UNITS') || ' ' || ')' ||
349: ' and display_units like ''%EBSUOM%'' and rownum < 2';
350:
351: msd_dem_common_utilities.log_debug(l_stmt_new_uom_display_unit);
352:
353: open get_new_uom_display_unit for l_stmt_new_uom_display_unit;
354: fetch get_new_uom_display_unit into new_uom;
355: if get_new_uom_display_unit%notfound then
352:
353: open get_new_uom_display_unit for l_stmt_new_uom_display_unit;
354: fetch get_new_uom_display_unit into new_uom;
355: if get_new_uom_display_unit%notfound then
356: msd_dem_common_utilities.log_message('Seeded Display Units not Available');
357: msd_dem_common_utilities.log_debug('Seeded Display Units not Available');
358: close get_new_uom_display_unit;
359: retcode := 1;
360: return;
353: open get_new_uom_display_unit for l_stmt_new_uom_display_unit;
354: fetch get_new_uom_display_unit into new_uom;
355: if get_new_uom_display_unit%notfound then
356: msd_dem_common_utilities.log_message('Seeded Display Units not Available');
357: msd_dem_common_utilities.log_debug('Seeded Display Units not Available');
358: close get_new_uom_display_unit;
359: retcode := 1;
360: return;
361: end if;
386: ,:7
387: ,:8
388: )';
389:
390: msd_dem_common_utilities.log_debug(l_stmt);
391:
392: execute immediate l_stmt using p_uom_code, new_uom.data_table, new_uom.data_field, sysdate, fnd_global.user_id, sysdate, fnd_global.user_id, fnd_global.user_id;
393:
394: l_stmt := 'update ' || get_lookup_value('MSD_DEM_TABLES', 'DISPLAY_UNITS') ||
394: l_stmt := 'update ' || get_lookup_value('MSD_DEM_TABLES', 'DISPLAY_UNITS') ||
395: ' set display_units = :1 ' ||
396: ' where display_units_id = :2';
397:
398: msd_dem_common_utilities.log_debug(l_stmt);
399:
400: execute immediate l_stmt using p_uom_code, new_uom.display_units_id;
401:
402: l_stmt := 'insert into ' || get_lookup_value('MSD_DEM_TABLES', 'AVAIL_UNITS') ||
410: ' from ' || get_lookup_value('MSD_DEM_TABLES', 'AVAIL_UNITS') ||
411: ' where display_units_id = :2 ' ||
412: ' )';
413:
414: msd_dem_common_utilities.log_debug(l_stmt);
415: execute immediate l_stmt using new_uom.display_units_id, new_uom.display_units_id;
416:
417: l_stmt_get_component := 'select dcm_product_id from ' ||get_lookup_value('MSD_DEM_TABLES', 'DCM_PRODUCTS') || ' where product_name = ''' || msd_dem_common_utilities.get_lookup_value('MSD_DEM_COMPONENTS', 'DEMAND_MANAGEMENT') || '''';
418:
413:
414: msd_dem_common_utilities.log_debug(l_stmt);
415: execute immediate l_stmt using new_uom.display_units_id, new_uom.display_units_id;
416:
417: l_stmt_get_component := 'select dcm_product_id from ' ||get_lookup_value('MSD_DEM_TABLES', 'DCM_PRODUCTS') || ' where product_name = ''' || msd_dem_common_utilities.get_lookup_value('MSD_DEM_COMPONENTS', 'DEMAND_MANAGEMENT') || '''';
418:
419: msd_dem_common_utilities.log_debug(l_stmt_get_component);
420:
421: open get_component for l_stmt_get_component;
415: execute immediate l_stmt using new_uom.display_units_id, new_uom.display_units_id;
416:
417: l_stmt_get_component := 'select dcm_product_id from ' ||get_lookup_value('MSD_DEM_TABLES', 'DCM_PRODUCTS') || ' where product_name = ''' || msd_dem_common_utilities.get_lookup_value('MSD_DEM_COMPONENTS', 'DEMAND_MANAGEMENT') || '''';
418:
419: msd_dem_common_utilities.log_debug(l_stmt_get_component);
420:
421: open get_component for l_stmt_get_component;
422: fetch get_component into l_component_id;
423: close get_component;
424:
425: l_stmt := 'insert into ' || get_lookup_value('MSD_DEM_TABLES', 'DCM_PRODUCTS_UNITS') ||
426: ' (dcm_product_id ,display_units_id) ' ||
427: ' (select :1, :2 from dual)';
428: msd_dem_common_utilities.log_debug(l_stmt);
429: execute immediate l_stmt using l_component_id,new_uom.display_units_id;
430:
431:
432: l_stmt_get_component_sop := 'select dcm_product_id from ' ||get_lookup_value('MSD_DEM_TABLES', 'DCM_PRODUCTS') || ' where product_name = ''' || msd_dem_common_utilities.get_lookup_value('MSD_DEM_COMPONENTS', 'SOP') || '''';
428: msd_dem_common_utilities.log_debug(l_stmt);
429: execute immediate l_stmt using l_component_id,new_uom.display_units_id;
430:
431:
432: l_stmt_get_component_sop := 'select dcm_product_id from ' ||get_lookup_value('MSD_DEM_TABLES', 'DCM_PRODUCTS') || ' where product_name = ''' || msd_dem_common_utilities.get_lookup_value('MSD_DEM_COMPONENTS', 'SOP') || '''';
433:
434: msd_dem_common_utilities.log_debug(l_stmt_get_component_sop);
435:
436: open get_component_sop for l_stmt_get_component_sop;
430:
431:
432: l_stmt_get_component_sop := 'select dcm_product_id from ' ||get_lookup_value('MSD_DEM_TABLES', 'DCM_PRODUCTS') || ' where product_name = ''' || msd_dem_common_utilities.get_lookup_value('MSD_DEM_COMPONENTS', 'SOP') || '''';
433:
434: msd_dem_common_utilities.log_debug(l_stmt_get_component_sop);
435:
436: open get_component_sop for l_stmt_get_component_sop;
437: fetch get_component_sop into l_component_id_sop;
438: close get_component_sop;
439:
440: l_stmt := 'insert into ' || get_lookup_value('MSD_DEM_TABLES', 'DCM_PRODUCTS_UNITS') ||
441: ' (dcm_product_id ,display_units_id) ' ||
442: ' (select :1, :2 from dual)';
443: msd_dem_common_utilities.log_debug(l_stmt);
444: execute immediate l_stmt using l_component_id_sop,new_uom.display_units_id;
445:
446: else
447: l_stmt := null;
448: l_stmt := 'update msd_dem_entities_inuse set table_name = (select data_table from ' || get_lookup_value('MSD_DEM_TABLES', 'DISPLAY_UNITS') || ' where display_units = :1)' ||
449: ', column_name = (select data_field from ' || get_lookup_value('MSD_DEM_TABLES', 'DISPLAY_UNITS') || ' where display_units = :2)' ||
450: 'where ebs_entity = ''UOM'' and demantra_entity = ''DISPLAY_UNIT'' and internal_name = :3';
451:
452: msd_dem_common_utilities.log_debug(l_stmt);
453:
454: execute immediate l_stmt using p_uom_code, p_uom_code, p_uom_code;
455:
456: end if;
456: end if;
457:
458: exception
459: when others then
460: msd_dem_common_utilities.log_message(substr(SQLERRM,1,150));
461: msd_dem_common_utilities.log_debug(substr(SQLERRM,1,150));
462: retcode := 1;
463:
464: end;
457:
458: exception
459: when others then
460: msd_dem_common_utilities.log_message(substr(SQLERRM,1,150));
461: msd_dem_common_utilities.log_debug(substr(SQLERRM,1,150));
462: retcode := 1;
463:
464: end;
465:
528:
529: fetch get_uom_code into l_uom_code;
530: exit when get_uom_code%notfound;
531:
532: msd_dem_common_utilities.log_message('Populating UOM: ' || l_uom_code);
533: msd_dem_common_utilities.log_debug('Populating UOM: ' || l_uom_code);
534:
535: l_list2 := replace(l_list2, l_uom_code||',' , '');
536:
529: fetch get_uom_code into l_uom_code;
530: exit when get_uom_code%notfound;
531:
532: msd_dem_common_utilities.log_message('Populating UOM: ' || l_uom_code);
533: msd_dem_common_utilities.log_debug('Populating UOM: ' || l_uom_code);
534:
535: l_list2 := replace(l_list2, l_uom_code||',' , '');
536:
537: process_uom(retcode, l_uom_code);
536:
537: process_uom(retcode, l_uom_code);
538:
539: if retcode = -1 or retcode = 1 then
540: msd_dem_common_utilities.log_message('Failed processing UOM: ' || l_uom_code);
541: msd_dem_common_utilities.log_debug('Failed Processing UOM: ' || l_uom_code);
542: goto continue;
543: end if;
544:
537: process_uom(retcode, l_uom_code);
538:
539: if retcode = -1 or retcode = 1 then
540: msd_dem_common_utilities.log_message('Failed processing UOM: ' || l_uom_code);
541: msd_dem_common_utilities.log_debug('Failed Processing UOM: ' || l_uom_code);
542: goto continue;
543: end if;
544:
545: populate_uom(retcode, l_uom_code, p_instance_id);
554: l_list2 := rtrim(l_list2, ',');
555:
556: if l_list2 is not null then
557: retcode := 1;
558: msd_dem_common_utilities.log_message('Following UOM''s dont exist in source: ' || l_list2);
559: msd_dem_common_utilities.log_debug('Following UOM''s dont exist in source: ' || l_list2);
560: end if;
561:
562: exception
555:
556: if l_list2 is not null then
557: retcode := 1;
558: msd_dem_common_utilities.log_message('Following UOM''s dont exist in source: ' || l_list2);
559: msd_dem_common_utilities.log_debug('Following UOM''s dont exist in source: ' || l_list2);
560: end if;
561:
562: exception
563: when others then
560: end if;
561:
562: exception
563: when others then
564: msd_dem_common_utilities.log_message(substr(SQLERRM,1,150));
565: msd_dem_common_utilities.log_debug(substr(SQLERRM,1,150));
566: retcode := 1;
567:
568: end;
561:
562: exception
563: when others then
564: msd_dem_common_utilities.log_message(substr(SQLERRM,1,150));
565: msd_dem_common_utilities.log_debug(substr(SQLERRM,1,150));
566: retcode := 1;
567:
568: end;
569:
594: null);
595:
596: if l_stmt is null then
597:
598: msd_dem_common_utilities.log_message('Cannot find query to get UOM conversions from source');
599: msd_dem_common_utilities.log_debug('Cannot find query to get UOM conversions from source');
600: retcode := -1;
601: return;
602:
595:
596: if l_stmt is null then
597:
598: msd_dem_common_utilities.log_message('Cannot find query to get UOM conversions from source');
599: msd_dem_common_utilities.log_debug('Cannot find query to get UOM conversions from source');
600: retcode := -1;
601: return;
602:
603: end if;
601: return;
602:
603: end if;
604:
605: msd_dem_common_utilities.log_debug('Query: ' || l_stmt);
606:
607: msd_dem_common_utilities.log_debug('p_instance_id ' || p_instance_id);
608:
609: msd_dem_common_utilities.log_debug('Start Time: ' || to_char(sysdate, 'DD-MON-YYYY HH24:MI:SS'));
603: end if;
604:
605: msd_dem_common_utilities.log_debug('Query: ' || l_stmt);
606:
607: msd_dem_common_utilities.log_debug('p_instance_id ' || p_instance_id);
608:
609: msd_dem_common_utilities.log_debug('Start Time: ' || to_char(sysdate, 'DD-MON-YYYY HH24:MI:SS'));
610: execute immediate l_stmt;
611: msd_dem_common_utilities.log_debug('End Time: ' || to_char(sysdate, 'DD-MON-YYYY HH24:MI:SS'));
605: msd_dem_common_utilities.log_debug('Query: ' || l_stmt);
606:
607: msd_dem_common_utilities.log_debug('p_instance_id ' || p_instance_id);
608:
609: msd_dem_common_utilities.log_debug('Start Time: ' || to_char(sysdate, 'DD-MON-YYYY HH24:MI:SS'));
610: execute immediate l_stmt;
611: msd_dem_common_utilities.log_debug('End Time: ' || to_char(sysdate, 'DD-MON-YYYY HH24:MI:SS'));
612:
613: exception
607: msd_dem_common_utilities.log_debug('p_instance_id ' || p_instance_id);
608:
609: msd_dem_common_utilities.log_debug('Start Time: ' || to_char(sysdate, 'DD-MON-YYYY HH24:MI:SS'));
610: execute immediate l_stmt;
611: msd_dem_common_utilities.log_debug('End Time: ' || to_char(sysdate, 'DD-MON-YYYY HH24:MI:SS'));
612:
613: exception
614: when others then
615: errbuf := substr(SQLERRM,1,150);
612:
613: exception
614: when others then
615: errbuf := substr(SQLERRM,1,150);
616: msd_dem_common_utilities.log_message(errbuf);
617: msd_dem_common_utilities.log_debug(errbuf);
618: retcode := -1;
619:
620:
613: exception
614: when others then
615: errbuf := substr(SQLERRM,1,150);
616: msd_dem_common_utilities.log_message(errbuf);
617: msd_dem_common_utilities.log_debug(errbuf);
618: retcode := -1;
619:
620:
621: end;
631:
632: begin
633:
634: if p_include_all = 1 and (p_include_uom_list is not null or p_exclude_uom_list is not null) then
635: msd_dem_common_utilities.log_message('Cannot specify both collect all and include or exclude list');
636: msd_dem_common_utilities.log_debug('Cannot specify both collect all and include or exclude list');
637: retcode := -1;
638: return;
639: end if;
632: begin
633:
634: if p_include_all = 1 and (p_include_uom_list is not null or p_exclude_uom_list is not null) then
635: msd_dem_common_utilities.log_message('Cannot specify both collect all and include or exclude list');
636: msd_dem_common_utilities.log_debug('Cannot specify both collect all and include or exclude list');
637: retcode := -1;
638: return;
639: end if;
640:
639: end if;
640:
641: if p_include_all = 2 and p_include_uom_list is null and p_exclude_uom_list is null then
642:
643: msd_dem_common_utilities.log_message('Exactly one of the parameters Include UOM''s or Exclude UOM''s must be specified, when Collect All UOM''s is No');
644: msd_dem_common_utilities.log_debug('Exactly one of the parameters Include UOM''s or Exclude UOM''s must be specified, when Collect All UOM''s is No');
645: retcode := -1;
646: return;
647:
640:
641: if p_include_all = 2 and p_include_uom_list is null and p_exclude_uom_list is null then
642:
643: msd_dem_common_utilities.log_message('Exactly one of the parameters Include UOM''s or Exclude UOM''s must be specified, when Collect All UOM''s is No');
644: msd_dem_common_utilities.log_debug('Exactly one of the parameters Include UOM''s or Exclude UOM''s must be specified, when Collect All UOM''s is No');
645: retcode := -1;
646: return;
647:
648: end if;
648: end if;
649:
650: if p_include_all = 2 and p_include_uom_list is not null and p_exclude_uom_list is not null then
651:
652: msd_dem_common_utilities.log_message('Should not specify both include and exclude list');
653: msd_dem_common_utilities.log_debug('Should not specify both include and exclude list');
654: retcode := -1;
655: return;
656:
649:
650: if p_include_all = 2 and p_include_uom_list is not null and p_exclude_uom_list is not null then
651:
652: msd_dem_common_utilities.log_message('Should not specify both include and exclude list');
653: msd_dem_common_utilities.log_debug('Should not specify both include and exclude list');
654: retcode := -1;
655: return;
656:
657: end if;
655: return;
656:
657: end if;
658:
659: msd_dem_common_utilities.log_message('Collecting UOM''s');
660: msd_dem_common_utilities.log_debug('Collecting UOM''s');
661:
662: msd_dem_common_utilities.log_message('Collecting UOM conversions from source');
663: msd_dem_common_utilities.log_debug('Collecting UOM conversions from source');
656:
657: end if;
658:
659: msd_dem_common_utilities.log_message('Collecting UOM''s');
660: msd_dem_common_utilities.log_debug('Collecting UOM''s');
661:
662: msd_dem_common_utilities.log_message('Collecting UOM conversions from source');
663: msd_dem_common_utilities.log_debug('Collecting UOM conversions from source');
664: collect_from_source(errbuf, retcode, p_instance_id);
658:
659: msd_dem_common_utilities.log_message('Collecting UOM''s');
660: msd_dem_common_utilities.log_debug('Collecting UOM''s');
661:
662: msd_dem_common_utilities.log_message('Collecting UOM conversions from source');
663: msd_dem_common_utilities.log_debug('Collecting UOM conversions from source');
664: collect_from_source(errbuf, retcode, p_instance_id);
665:
666: if retcode = -1 then
659: msd_dem_common_utilities.log_message('Collecting UOM''s');
660: msd_dem_common_utilities.log_debug('Collecting UOM''s');
661:
662: msd_dem_common_utilities.log_message('Collecting UOM conversions from source');
663: msd_dem_common_utilities.log_debug('Collecting UOM conversions from source');
664: collect_from_source(errbuf, retcode, p_instance_id);
665:
666: if retcode = -1 then
667: goto error_handle;
667: goto error_handle;
668: end if;
669:
670:
671: msd_dem_common_utilities.log_message('Populating UOM''s in Demand Planning components');
672: msd_dem_common_utilities.log_debug('Populating UOM''s in Demand Planning components');
673: populate_demantra_uom_table(errbuf, retcode, p_instance_id, p_include_uom_list, p_exclude_uom_list);
674:
675: commit;
668: end if;
669:
670:
671: msd_dem_common_utilities.log_message('Populating UOM''s in Demand Planning components');
672: msd_dem_common_utilities.log_debug('Populating UOM''s in Demand Planning components');
673: populate_demantra_uom_table(errbuf, retcode, p_instance_id, p_include_uom_list, p_exclude_uom_list);
674:
675: commit;
676:
684:
685: exception
686: when others then
687: errbuf := substr(SQLERRM,1,150);
688: msd_dem_common_utilities.log_message(errbuf);
689: msd_dem_common_utilities.log_debug(errbuf);
690: retcode := -1;
691:
692:
685: exception
686: when others then
687: errbuf := substr(SQLERRM,1,150);
688: msd_dem_common_utilities.log_message(errbuf);
689: msd_dem_common_utilities.log_debug(errbuf);
690: retcode := -1;
691:
692:
693: end;