[Home] [Help]
1: PACKAGE BODY MSC_CL_GMP_UTILITY as --body
2: /* $Header: MSCCLGMB.pls 120.4.12020000.3 2013/04/05 09:33:52 vkinduri ship $ */
3:
4: /*======== GLOBAL OPM Data Collection Declaration =========*/
5:
1481:
1482: dbms_session.free_unused_user_memory;/* akaruppa B5007729 */
1483:
1484: /* populate the org_string */
1485: IF MSC_CL_GMP_UTILITY.org_string(g_instance_id) THEN
1486: NULL ;
1487: ELSE
1488: log_message(MSC_CL_GMP_UTILITY.g_in_str_org);
1489: RAISE invalid_string_value ;
1484: /* populate the org_string */
1485: IF MSC_CL_GMP_UTILITY.org_string(g_instance_id) THEN
1486: NULL ;
1487: ELSE
1488: log_message(MSC_CL_GMP_UTILITY.g_in_str_org);
1489: RAISE invalid_string_value ;
1490: END IF;
1491:
1492: -- l_in_str_org := 'IN (1381,1382,1383,1383,5172)' ;
1489: RAISE invalid_string_value ;
1490: END IF;
1491:
1492: -- l_in_str_org := 'IN (1381,1382,1383,1383,5172)' ;
1493: l_in_str_org := MSC_CL_GMP_UTILITY.g_in_str_org ; /* B3491625 */
1494: log_message(' retrieve_effectivities org string is : ' || l_in_str_org) ;
1495:
1496: /* Bug:6156957 Vpedarla select organisations to restrict the data collections */
1497:
6057: log_message('Effectivity export failed');
6058: return_status := FALSE;
6059:
6060: WHEN NO_DATA_FOUND THEN /* B3577871 */
6061: log_message(' NO_DATA_FOUND exception raised in Procedure: MSC_CL_GMP_UTILITY.Extract_effectivities ' );
6062: return_status := TRUE;
6063: WHEN OTHERS THEN
6064: log_message('Untrapped effectivity extraction error');
6065: log_message(sqlerrm);
6182: v_cp_enabled := FALSE;
6183: END IF;
6184:
6185: /* populate the org_string */
6186: IF MSC_CL_GMP_UTILITY.org_string(instance) THEN
6187: NULL ;
6188: ELSE
6189: RAISE invalid_string_value ;
6190: END IF;
6188: ELSE
6189: RAISE invalid_string_value ;
6190: END IF;
6191:
6192: l_in_str_org := MSC_CL_GMP_UTILITY.g_in_str_org ; /* 3491625 */
6193: log_message('Extract_items : l_in_str_org = '||l_in_str_org );
6194:
6195: org_str := l_in_str_org ;
6196:
6406: v_cp_enabled := FALSE;
6407: END IF;
6408:
6409: /* populate the org_string */
6410: IF MSC_CL_GMP_UTILITY.org_string(instance) THEN
6411: NULL ;
6412: ELSE
6413: RAISE invalid_string_value ;
6414: END IF;
6412: ELSE
6413: RAISE invalid_string_value ;
6414: END IF;
6415:
6416: l_in_str_org := MSC_CL_GMP_UTILITY.g_in_str_org ; /* B3491625 */
6417:
6418: /* New Changes - Using mtl_organization_id from ic_whse_mst , instead of
6419: organization_id from sy_orgn_mst , Bug# 1252322 */
6420:
8056:
8057: RETURN -1;
8058:
8059: EXCEPTION WHEN OTHERS THEN
8060: log_message(' Error in MSC_CL_GMP_UTILITY.enh_bsearch_stpno: '||SQLERRM);
8061: RETURN -1;
8062: END enh_bsearch_stpno ;
8063:
8064: /*
8617: v_cp_enabled := FALSE;
8618: END IF;
8619:
8620: /* populate the org_string */
8621: IF MSC_CL_GMP_UTILITY.org_string(pinstance_id) THEN
8622: NULL ;
8623: ELSE
8624: RAISE invalid_string_value ;
8625: END IF;
8936: || ' AND nvl(c.inactive_ind,0) = 0 ' ;
8937:
8938: -- Bug: 9760218 Commented the below code.
8939: -- as resource requirements are not collected for batches with resource warehouses not in collection group.
8940: -- IF MSC_CL_GMP_UTILITY.g_in_str_org IS NOT NULL THEN
8941: -- v_rsrc_cursor := v_rsrc_cursor
8942: -- ||' AND EXISTS ( SELECT 1 FROM sy_orgn_mst'||pdblink||' som '
8943: -- ||' WHERE h.wip_whse_code = som.resource_whse_code )' ;
8944: -- END IF;
9023: ||' AND crd.resources = gbsc.resources '
9024: ||' AND h.wip_whse_code = iwm.whse_code'
9025: ||' AND gbs.step_status in (1, 2) ';
9026:
9027: IF MSC_CL_GMP_UTILITY.g_in_str_org IS NOT NULL THEN
9028: stp_chg_cursor := stp_chg_cursor
9029: ||' AND EXISTS ( SELECT 1 FROM sy_orgn_mst'||pdblink||' som '
9030: ||' WHERE h.wip_whse_code = som.resource_whse_code )' ;
9031: END IF;
10231: ||' AND som.delete_mark = 0 '
10232: ||' AND som.resource_whse_code = iwm.whse_code ' ;
10233:
10234:
10235: IF MSC_CL_GMP_UTILITY.g_in_str_org IS NOT NULL THEN
10236: sql_stmt := sql_stmt
10237: ||' AND iwm.mtl_organization_id ' || MSC_CL_GMP_UTILITY.g_in_str_org ;
10238: END IF;
10239:
10233:
10234:
10235: IF MSC_CL_GMP_UTILITY.g_in_str_org IS NOT NULL THEN
10236: sql_stmt := sql_stmt
10237: ||' AND iwm.mtl_organization_id ' || MSC_CL_GMP_UTILITY.g_in_str_org ;
10238: END IF;
10239:
10240: EXECUTE IMMEDIATE sql_stmt USING pinstance_id;
10241: /* NAVIN: ------------ END: Complex Route -- Collect Batch Step Dependencies in one insert-select ------------*/
11559: || ' and i.experimental_ind = 0 ' ;
11560: END IF;
11561:
11562: --Bug: 6030499 Vpedarla
11563: IF MSC_CL_GMP_UTILITY.g_in_str_org is NOT NULL THEN
11564: v_sql_stmt := v_sql_stmt || ' AND i.organization_id ' || MSC_CL_GMP_UTILITY.g_in_str_org ;
11565: END IF ;
11566:
11567: EXECUTE IMMEDIATE v_sql_stmt USING pinstance_id, pdoc_type, pdelimiter, pdelimiter ,pdoc_type, pdelimiter ;
11560: END IF;
11561:
11562: --Bug: 6030499 Vpedarla
11563: IF MSC_CL_GMP_UTILITY.g_in_str_org is NOT NULL THEN
11564: v_sql_stmt := v_sql_stmt || ' AND i.organization_id ' || MSC_CL_GMP_UTILITY.g_in_str_org ;
11565: END IF ;
11566:
11567: EXECUTE IMMEDIATE v_sql_stmt USING pinstance_id, pdoc_type, pdelimiter, pdelimiter ,pdoc_type, pdelimiter ;
11568:
11605: || ' 2, ' /* deleted_flag */
11606: || ' 0 ' /* refresh_id */
11607: || ' FROM mtl_parameters'||pdblink
11608: || ' WHERE process_enabled_flag = ' || '''Y''' ;
11609: IF MSC_CL_GMP_UTILITY.g_in_str_org is NOT NULL THEN
11610: stmt_design := stmt_design || ' AND organization_id ' || MSC_CL_GMP_UTILITY.g_in_str_org ;
11611: END IF ;
11612: log_message(stmt_design) ;
11613:
11606: || ' 0 ' /* refresh_id */
11607: || ' FROM mtl_parameters'||pdblink
11608: || ' WHERE process_enabled_flag = ' || '''Y''' ;
11609: IF MSC_CL_GMP_UTILITY.g_in_str_org is NOT NULL THEN
11610: stmt_design := stmt_design || ' AND organization_id ' || MSC_CL_GMP_UTILITY.g_in_str_org ;
11611: END IF ;
11612: log_message(stmt_design) ;
11613:
11614: EXECUTE IMMEDIATE stmt_design USING pdoc_type, pdelimiter, pinstance_id, pdescription ;
11930: BEGIN
11931:
11932: lv_cp_enabled := p_cp_enabled;
11933:
11934: MSC_CL_GMP_UTILITY.extract_items(
11935: at_apps_link => NULL,
11936: instance => NULL,
11937: run_date => p_run_date,
11938: return_status => lv_cp_enabled );
12494:
12495: log_message('Primary Rate = ' || b_profile);
12496:
12497: /* populate the org_string */
12498: IF MSC_CL_GMP_UTILITY.org_string(pinstance_id) THEN
12499: NULL ;
12500: ELSE
12501: RAISE invalid_string_value ;
12502: END IF;
12678: ||' AND h.org_id = aspa.org_id(+) '
12679: ||' AND aspa.set_of_books_id = gsb.set_of_books_id(+) '
12680: ||' AND h.org_id is not null ' ;
12681:
12682: IF MSC_CL_GMP_UTILITY.g_in_str_org IS NOT NULL THEN
12683: v_sql_stmt := v_sql_stmt
12684: || ' AND i.organization_id ' || MSC_CL_GMP_UTILITY.g_in_str_org ;
12685: END IF;
12686:
12680: ||' AND h.org_id is not null ' ;
12681:
12682: IF MSC_CL_GMP_UTILITY.g_in_str_org IS NOT NULL THEN
12683: v_sql_stmt := v_sql_stmt
12684: || ' AND i.organization_id ' || MSC_CL_GMP_UTILITY.g_in_str_org ;
12685: END IF;
12686:
12687: log_message('OMSO for Entity 1 = '||v_sql_stmt);
12688:
12860: ||' AND h.org_id = nvl(aspa.org_id,-99) '
12861: ||' AND aspa.set_of_books_id = gsb.set_of_books_id(+) '
12862: ||' AND h.org_id is null ' ;
12863:
12864: IF MSC_CL_GMP_UTILITY.g_in_str_org IS NOT NULL THEN
12865: v_sql_stmt := v_sql_stmt
12866: || ' AND i.organization_id ' || MSC_CL_GMP_UTILITY.g_in_str_org ;
12867: END IF;
12868:
12862: ||' AND h.org_id is null ' ;
12863:
12864: IF MSC_CL_GMP_UTILITY.g_in_str_org IS NOT NULL THEN
12865: v_sql_stmt := v_sql_stmt
12866: || ' AND i.organization_id ' || MSC_CL_GMP_UTILITY.g_in_str_org ;
12867: END IF;
12868:
12869: log_message('OMSO for Entity 1 (Part 2) = '||v_sql_stmt);
12870:
12873:
12874: END IF ;
12875:
12876: IF v_entity = 2 THEN
12877: -- log_message(MSC_CL_GMP_UTILITY.g_in_str_org);
12878:
12879: /* For Engine Reseration record inserted */
12880: --Bug 6056320. Insert MTL_DEMAND_S.nextval as transaction_id to avoid unique constraint violation.
12881: v_sql_stmt := 'INSERT into msc_st_reservations ('
12930: || ' and ool.open_flag = ' || '''Y'''
12931: || ' AND t.trans_qty <> 0 '
12932: || ' AND t.delete_mark = 0 ' ;
12933:
12934: IF MSC_CL_GMP_UTILITY.g_in_str_org IS NOT NULL THEN
12935: v_sql_stmt := v_sql_stmt
12936: || ' and i.organization_id ' || MSC_CL_GMP_UTILITY.g_in_str_org ;
12937: END IF;
12938:
12932: || ' AND t.delete_mark = 0 ' ;
12933:
12934: IF MSC_CL_GMP_UTILITY.g_in_str_org IS NOT NULL THEN
12935: v_sql_stmt := v_sql_stmt
12936: || ' and i.organization_id ' || MSC_CL_GMP_UTILITY.g_in_str_org ;
12937: END IF;
12938:
12939: log_message('OMSO for Entity 2 = '||v_sql_stmt);
12940:
13047: prev_fcst_set := '-1' ;
13048: prev_fcst := '-1';
13049:
13050: /* populate the org_string */
13051: IF MSC_CL_GMP_UTILITY.org_string(pinstance_id) THEN
13052: NULL ;
13053: ELSE
13054: RAISE invalid_string_value ;
13055: END IF;
13073: || ' fc_fcst_dtl'||pdblink||' d '
13074: || ' WHERE '
13075: || ' msi.organization_id = wm.mtl_organization_id ' ;
13076:
13077: IF MSC_CL_GMP_UTILITY.g_in_str_org IS NOT NULL THEN
13078: l_fcst_stmt := l_fcst_stmt
13079: || ' and msi.organization_id ' || MSC_CL_GMP_UTILITY.g_in_str_org ;
13080: END IF;
13081:
13075: || ' msi.organization_id = wm.mtl_organization_id ' ;
13076:
13077: IF MSC_CL_GMP_UTILITY.g_in_str_org IS NOT NULL THEN
13078: l_fcst_stmt := l_fcst_stmt
13079: || ' and msi.organization_id ' || MSC_CL_GMP_UTILITY.g_in_str_org ;
13080: END IF;
13081:
13082: l_fcst_stmt := l_fcst_stmt
13083: || ' and msi.segment1 = iim.item_no '
13505: ************************************************************************/
13506: PROCEDURE LOG_MESSAGE(pBUFF IN VARCHAR2) IS
13507: MSG VARCHAR2(32000) ;
13508: BEGIN
13509: MSG :='MSC_CL_GMP_UTILITY - ' ||pBUFF ;
13510: IF v_cp_enabled THEN
13511: IF fnd_global.conc_request_id > 0 THEN
13512: FND_FILE.PUT_LINE( FND_FILE.LOG, MSG);
13513: ELSE
14332: ||' AND gbo.delete_mark = 0 '
14333: ||' AND gbo.so_line_id = ool.line_id '
14334: ||' AND ool.project_id = ppp.project_id (+) ';
14335:
14336: IF MSC_CL_GMP_UTILITY.g_in_str_org IS NOT NULL THEN
14337: v_stmt_alt_rsrc := v_stmt_alt_rsrc
14338: ||' AND EXISTS ( SELECT 1 FROM sy_orgn_mst'||pdblink||' som '
14339: ||' WHERE gia.whse_code = som.resource_whse_code )' ;
14340: END IF;
14608:
14609: log_message('Before Org_string call RSRC_EXTRACT');
14610:
14611: /* populate the org_string */
14612: IF MSC_CL_GMP_UTILITY.org_string(p_instance_id) THEN
14613: NULL ;
14614: ELSE
14615: RAISE invalid_string_value ;
14616: END IF;
14616: END IF;
14617:
14618: log_message('After Org_string call RSRC_EXTRACT');
14619:
14620: l_in_str_org := MSC_CL_GMP_UTILITY.g_in_str_org ; /* 3491625 */
14621: log_message('Extract_items : l_in_str_org = '||l_in_str_org );
14622:
14623: /* note that we introduced substr(resources) as the
14624: final msc table has the column at 10 char only. If and when the MSC
14722: || ' AND w.mtl_organization_id = mrp.organization_id '
14723: || ' AND r.resources = rsm.resources ' /* B4081551 */
14724: || ' AND p.resource_whse_code = w.whse_code ' ;
14725:
14726: IF MSC_CL_GMP_UTILITY.g_in_str_org IS NOT NULL THEN
14727: ins_dept_res := ins_dept_res
14728: ||' AND w.mtl_organization_id ' || l_in_str_org ;
14729: END IF;
14730:
14797: ||' AND NVL(sou.disable_date, sysdate+1) > sysdate '
14798: -- Bug 6467457 modified as below ||' AND sou.um_code = r.capacity_uom ';
14799: ||' AND ( sou.unit_of_measure = r.capacity_uom OR sou.uom_code = r.capacity_uom) ';
14800:
14801: IF MSC_CL_GMP_UTILITY.g_in_str_org IS NOT NULL THEN
14802: ins_dept_res := ins_dept_res
14803: ||' AND w.mtl_organization_id ' || l_in_str_org ;
14804: END IF;
14805: log_message('msc_st_department_resources Insert statement '||ins_dept_res);
14834: || ' AND crd.resources = crm.resources '
14835: || ' AND crd.group_resource = crm.resources '
14836: || ' AND crd.delete_mark = 0 ';
14837:
14838: IF MSC_CL_GMP_UTILITY.g_in_str_org IS NOT NULL THEN
14839: ins_res_group := ins_res_group
14840: || ' AND EXISTS ( SELECT 1 FROM gmp_item_aps'||p_db_link||' gia '
14841: || ' WHERE gia.whse_code = sy.resource_whse_code )' ;
14842: END IF;
14891: ||' AND som.delete_mark = 0'
14892: ||' AND iwm.delete_mark = 0'
14893: ||' AND som.resource_whse_code = iwm.whse_code' ;
14894:
14895: IF MSC_CL_GMP_UTILITY.g_in_str_org IS NOT NULL THEN
14896: ins_res_instance := ins_res_instance
14897: ||' AND EXISTS ( SELECT 1 FROM gmp_item_aps'||p_db_link||' gia '
14898: ||' WHERE gia.whse_code = som.resource_whse_code )' ;
14899: END IF;
14909: WHEN invalid_string_value THEN
14910: log_message('APS string is Invalid, check for Error condition' );
14911: return_status := FALSE;
14912: WHEN NO_DATA_FOUND THEN /* B3577871 */
14913: log_message(' NO_DATA_FOUND exception raised in Procedure: MSC_CL_GMP_UTILITY.Rsrc_extract ' );
14914: return_status := TRUE;
14915: WHEN OTHERS THEN
14916: log_message('Error in department/Res Group Insert: '||p_instance_id);
14917: log_message('stmt_no: ' || stmt_no || '--' || sqlerrm);
16766: return_status := TRUE;
16767:
16768: EXCEPTION
16769: WHEN NO_DATA_FOUND THEN
16770: log_message('NO DATA FOUND : MSC_CL_GMP_UTILITY.net_rsrc_insert' || stmt_no);
16771: return_status := TRUE;
16772: WHEN OTHERS THEN
16773: log_message('Error in Net Resource Insert: '||stmt_no);
16774: log_message(sqlerrm);
17170:
17171: /* Check if the org string have the organization */
17172: BEGIN
17173: stmt_no := 51;
17174: IF MSC_CL_GMP_UTILITY.org_string(p_instance_id) THEN
17175: NULL ;
17176: ELSE
17177: RAISE invalid_string_value ;
17178: END IF;
17178: END IF;
17179:
17180: l_opm_org := plsqltbl_rec(k).organization_id ;
17181:
17182: IF MSC_CL_GMP_UTILITY.g_in_str_org IS NOT NULL THEN
17183: l_stmt := 'SELECT 1 FROM dual WHERE '||
17184: l_opm_org||MSC_CL_GMP_UTILITY.g_in_str_org ;
17185: OPEN l_cur for l_stmt ;
17186: FETCH l_cur INTO l_org_specific ;
17180: l_opm_org := plsqltbl_rec(k).organization_id ;
17181:
17182: IF MSC_CL_GMP_UTILITY.g_in_str_org IS NOT NULL THEN
17183: l_stmt := 'SELECT 1 FROM dual WHERE '||
17184: l_opm_org||MSC_CL_GMP_UTILITY.g_in_str_org ;
17185: OPEN l_cur for l_stmt ;
17186: FETCH l_cur INTO l_org_specific ;
17187: IF l_cur%NOTFOUND THEN
17188: l_org_specific := 0;
17624: WHEN invalid_string_value THEN
17625: log_message('APS string is Invalid, check for Error condition' );
17626: return_status := FALSE;
17627: WHEN NO_DATA_FOUND THEN /* B3577871 */
17628: log_message(' NO_DATA_FOUND exception : MSC_CL_GMP_UTILITY.Populate_rsrc_cal ' );
17629: return_status := TRUE;
17630: WHEN OTHERS THEN
17631: log_message('Error in Populate Rsrc cal construct: '||stmt_no);
17632: log_message('Error : '||v_icode);
17685: old_calendar_id := -1;
17686:
17687: stmt_no := 610;
17688: /* populate the org_string */
17689: IF MSC_CL_GMP_UTILITY.org_string(p_instance_id) THEN
17690: NULL ;
17691: ELSE
17692: RAISE invalid_string_value ;
17693: END IF;
17704: ||' AND crd.calendar_id IS NOT NULL '
17705: ||' AND crd.calendar_id = shcl.calendar_id '
17706: ||' AND iwm.whse_code = sy.resource_whse_code ' ;
17707:
17708: IF MSC_CL_GMP_UTILITY.g_in_str_org IS NOT NULL THEN
17709: sql_get_cal := sql_get_cal
17710: ||' AND iwm.mtl_organization_id '||MSC_CL_GMP_UTILITY.g_in_str_org;
17711: END IF;
17712:
17706: ||' AND iwm.whse_code = sy.resource_whse_code ' ;
17707:
17708: IF MSC_CL_GMP_UTILITY.g_in_str_org IS NOT NULL THEN
17709: sql_get_cal := sql_get_cal
17710: ||' AND iwm.mtl_organization_id '||MSC_CL_GMP_UTILITY.g_in_str_org;
17711: END IF;
17712:
17713: sql_get_cal := sql_get_cal
17714: ||' AND shcl.delete_mark = 0 '
17789: WHEN invalid_string_value THEN
17790: log_message('APS string is Invalid, check for Error condition' );
17791: return_status := FALSE;
17792: WHEN NO_DATA_FOUND THEN
17793: log_message('NO DATA FOUND exception: MSC_CL_GMP_UTILITY.rsrcal_based_availability');
17794: return_status := TRUE;
17795: WHEN OTHERS THEN
17796: log_message('Error in MSC_CL_GMP_UTILITY.rsrcal_based_availability '||p_instance_id);
17797: log_message(sqlerrm);
17792: WHEN NO_DATA_FOUND THEN
17793: log_message('NO DATA FOUND exception: MSC_CL_GMP_UTILITY.rsrcal_based_availability');
17794: return_status := TRUE;
17795: WHEN OTHERS THEN
17796: log_message('Error in MSC_CL_GMP_UTILITY.rsrcal_based_availability '||p_instance_id);
17797: log_message(sqlerrm);
17798: return_status := FALSE;
17799:
17800: END rsrcal_based_availability;
18826:
18827: return_status := TRUE ;
18828: EXCEPTION
18829: WHEN NO_DATA_FOUND THEN
18830: log_message('NO DATA FOUND exception: MSC_CL_GMP_UTILITY.net_rsrc_avail_calculate');
18831: return_status := TRUE;
18832: WHEN OTHERS THEN
18833: log_message('Error in Net Resource Instance Insert: '||stmt_no);
18834: log_message(sqlerrm);
18935: l_aps_compatible := 0 ;
18936: org_str := NULL ;
18937: in_position := -10 ;
18938:
18939: SELECT MSC_CL_GMP_UTILITY.is_aps_compatible
18940: INTO l_aps_compatible FROM DUAL ;
18941:
18942: IF l_aps_compatible = 1 THEN
18943:
18956: We have to find the IN part in the string, otherwise have to raise
18957: Exception message for error condition */
18958:
18959: IF in_position > 0 THEN
18960: MSC_CL_GMP_UTILITY.g_in_str_org := org_str ;
18961: return TRUE ;
18962: ELSE
18963: MSC_CL_GMP_UTILITY.g_in_str_org := NULL ;
18964: return FALSE ;
18959: IF in_position > 0 THEN
18960: MSC_CL_GMP_UTILITY.g_in_str_org := org_str ;
18961: return TRUE ;
18962: ELSE
18963: MSC_CL_GMP_UTILITY.g_in_str_org := NULL ;
18964: return FALSE ;
18965: END IF;
18966:
18967:
18966:
18967:
18968: ELSE
18969: /* For older patchset This value should be TRUE */
18970: MSC_CL_GMP_UTILITY.g_in_str_org := NULL ;
18971: return TRUE ;
18972: END IF;
18973:
18974: EXCEPTION
18973:
18974: EXCEPTION
18975: WHEN OTHERS THEN
18976: log_message('Error in org_string ' || sqlerrm);
18977: MSC_CL_GMP_UTILITY.g_in_str_org := NULL ;
18978: return FALSE ;
18979: END ORG_STRING;
18980:
18981: FUNCTION GMP_CAL_UTILITY1_R10
19023: BEGIN
19024: RETURN 1 ;
19025: END is_aps_compatible ;
19026:
19027: END MSC_CL_GMP_UTILITY;