[Home] [Help]
544:
545:
546: -- Bug 2585710. Store ship set item inventory numbers into 8i temp table.
547:
548: DELETE MSC_SHIP_SET_TEMP;
549:
550: FORALL j IN 1..l_count
551: --s_cto_rearch
552: INSERT INTO MSC_SHIP_SET_TEMP(INVENTORY_ITEM_ID, VISITED_FLAG, MIN_REGION_VALUE, line_id)
548: DELETE MSC_SHIP_SET_TEMP;
549:
550: FORALL j IN 1..l_count
551: --s_cto_rearch
552: INSERT INTO MSC_SHIP_SET_TEMP(INVENTORY_ITEM_ID, VISITED_FLAG, MIN_REGION_VALUE, line_id)
553: VALUES (l_dest_ship_set_item_list(j), 0, 0, l_line_ids(j));
554:
555: ELSE
556:
627: IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
628: IF PG_DEBUG in ('Y', 'C') THEN
629: msc_sch_wb.atp_debug('Atp_Sources: ' || 'Error occured in procedure Get_Sources_Info');
630: END IF;
631: DELETE MSC_SHIP_SET_TEMP;
632: x_return_status := FND_API.G_RET_STS_ERROR;
633: return;
634: END IF;
635:
650: END IF;
651:
652: -- Fix for bug 1454524, no need to join based on assignment set as only
653: -- 1 assignment set is supported for a plan.
654: -- Bug 2585710. Rewriting the dynamic SQL in static form. Using msc_ship_set_temp
655: SELECT
656: nvl(s.source_organization_id, -1),
657: -- nvl(s.sr_instance_id2,-1),
658: decode(nvl(min(s.source_type),
687: x_atp_sources.Ship_Method,
688: x_atp_sources.Sup_Cap_Type -- For supplier intransit LT project
689: FROM
690: msc_item_sourcing s,
691: msc_ship_set_temp msst,
692: msc_trading_partner_sites mtps -- For supplier intransit LT project
693: WHERE
694: s.inventory_item_id = msst.inventory_item_id
695: AND s.organization_id = p_organization_id
746: x_atp_sources.Lead_Time,
747: x_atp_sources.Ship_Method,
748: x_atp_sources.Sup_Cap_Type -- For supplier intransit LT project
749: FROM msc_sources_v s,
750: msc_ship_set_temp msst
751: WHERE s.inventory_item_id = msst.inventory_item_id
752: AND s.organization_id = p_organization_id
753: AND s.sr_instance_id = p_instance_id
754: AND s.assignment_set_id = p_assign_set_id
1028: msc_sr_receipt_org receiptorg,
1029: msc_sr_source_org sourceorg,
1030: msc_sr_assignments msa,
1031: msc_system_items msi,
1032: msc_ship_set_temp msst
1033: WHERE
1034: msa.assignment_type = 3
1035: AND msa.assignment_set_id = p_assign_set_id
1036: AND msa.inventory_item_id = msst.inventory_item_id
1093: msc_sr_receipt_org receiptorg,
1094: msc_sr_source_org sourceorg,
1095: msc_sr_assignments msa,
1096: msc_item_categories cat,
1097: msc_ship_set_temp msst
1098: WHERE msa.assignment_type = 2 and
1099: msa.assignment_set_id = p_assign_set_id and
1100: msa.inventory_item_id = msst.inventory_item_id
1101: AND msa.sourcing_rule_id = msr.sourcing_rule_id
1167: msc_sr_receipt_org receiptorg,
1168: msc_sr_source_org sourceorg,
1169: msc_sr_assignments msa,
1170: msc_system_items msi,
1171: msc_ship_set_temp msst
1172: WHERE
1173: msa.assignment_type = 1
1174: AND msa.assignment_set_id = p_assign_set_id
1175: AND msa.sourcing_rule_id = msr.sourcing_rule_id
1231: msc_sr_receipt_org receiptorg,
1232: msc_sr_source_org sourceorg,
1233: msc_sr_assignments msa,
1234: msc_system_items msi,
1235: msc_ship_set_temp msst
1236: WHERE
1237: msa.assignment_type = 1
1238: AND msa.assignment_set_id = p_assign_set_id
1239: AND msa.sourcing_rule_id = msr.sourcing_rule_id
6415: IF PG_DEBUG in ('Y', 'C') THEN
6416: msc_sch_wb.atp_debug('Get_Sources_Info: '|| 'Searching sources at level 1 (item-org)');
6417: END IF;
6418:
6419: -- At first level, visited_flag in table msc_ship_set_temp is 0 for all rows.
6420: -- Therefore no need for clause 'AND msst.visisble_flag = 0'.
6421:
6422: -- Find and insert the sources in msc_atp_sources_temp
6423: INSERT INTO MSC_ATP_SOURCES_TEMP (inventory_item_id, Organization_Id, Instance_Id,
6441: MSC_SR_RECEIPT_ORG RECEIPT_ORG,
6442: MSC_SOURCING_RULES MSR,
6443: MSC_SR_ASSIGNMENTS MSRA,
6444: MSC_TP_SITE_ID_LID MTSIL,
6445: MSC_SHIP_SET_TEMP MSST
6446: WHERE
6447: MSRA.ASSIGNMENT_TYPE = 6 /* ITEM-ORG */
6448: AND MSRA.ASSIGNMENT_SET_ID = p_assignment_set_id
6449: AND MSRA.PARTNER_ID IS NOT NULL
6482: END IF;
6483:
6484:
6485: -- Mark all the items for which sources are/have been found.
6486: UPDATE msc_ship_set_temp
6487: set visited_flag = 1
6488: where inventory_item_id in (select inventory_item_id from msc_atp_sources_temp);
6489:
6490: l_updated_rows := SQL%ROWCOUNT;
6577: MSC_SR_RECEIPT_ORG RECEIPT_ORG_INNER,
6578: MSC_SOURCING_RULES MSR_INNER,
6579: MSC_SR_ASSIGNMENTS MSRA_INNER,
6580: MSC_REGIONS_TEMP MRT_INNER,
6581: MSC_SHIP_SET_TEMP MSST_INNER
6582: WHERE
6583: MSRA_INNER.ASSIGNMENT_TYPE = 9
6584: AND MSRA_INNER.ASSIGNMENT_SET_ID = p_assignment_set_id
6585: AND MSRA_INNER.REGION_ID = MRT_INNER.REGION_ID
6609:
6610: IF (l_inventory_item_id_arr.COUNT > 0) THEN
6611:
6612: -- Step1: All the items for which sources are found,
6613: -- update column min_region_value and visited_flag in msc_ship_set_temp.
6614: IF PG_DEBUG in ('Y', 'C') THEN
6615: msc_sch_wb.atp_debug('Get_Sources_Info: '|| 'For following items, the min region value found');
6616: FOR i IN 1..l_inventory_item_id_arr.COUNT LOOP
6617: msc_sch_wb.atp_debug('Get_Sources_Info: '|| 'Item: '|| l_inventory_item_id_arr(i)
6620: END IF;
6621:
6622:
6623: FORALL i IN l_inventory_item_id_arr.FIRST..l_inventory_item_id_arr.LAST
6624: UPDATE msc_ship_set_temp
6625: SET min_region_value = l_min_region_value_arr(i),
6626: visited_flag = 1
6627: WHERE inventory_item_id = l_inventory_item_id_arr(i);
6628:
6651: MSC_SR_RECEIPT_ORG RECEIPT_ORG,
6652: MSC_SOURCING_RULES MSR,
6653: MSC_SR_ASSIGNMENTS MSRA,
6654: MSC_REGIONS_TEMP MRT,
6655: MSC_SHIP_SET_TEMP MSST
6656: WHERE
6657: MSRA.ASSIGNMENT_TYPE = 9
6658: AND MSRA.ASSIGNMENT_SET_ID = p_assignment_set_id
6659: AND MSRA.REGION_ID = MRT.REGION_ID
6689: -- Step3: Check if I need to stop here.
6690:
6691: SELECT COUNT(*)
6692: INTO l_items_visited
6693: FROM MSC_SHIP_SET_TEMP
6694: WHERE VISITED_FLAG = 1;
6695:
6696: IF (l_items_visited = p_ship_set_item_count) THEN
6697: -- We have to stop search and return from here. But before returning,
6790: MSC_SR_RECEIPT_ORG RECEIPT_ORG,
6791: MSC_SOURCING_RULES MSR,
6792: MSC_SR_ASSIGNMENTS MSRA,
6793: MSC_TP_SITE_ID_LID MTSIL,
6794: MSC_SHIP_SET_TEMP MSST
6795: WHERE
6796: MSRA.ASSIGNMENT_TYPE = 5 /* CATEGORY-ORG */
6797: AND MSRA.ASSIGNMENT_SET_ID = p_assignment_set_id
6798: AND MSRA.PARTNER_ID IS NOT NULL
6831: msc_sch_wb.atp_debug('Get_Sources_Info: '|| 'Found some sources for some ship set items at level 3');
6832: END IF;
6833:
6834: -- Mark all the items for which sources are/have been found.
6835: UPDATE msc_ship_set_temp
6836: set visited_flag = 1
6837: where inventory_item_id in (select inventory_item_id from msc_atp_sources_temp);
6838:
6839: l_updated_rows := SQL%ROWCOUNT;
6934: MSC_SR_RECEIPT_ORG RECEIPT_ORG,
6935: MSC_SOURCING_RULES MSR,
6936: MSC_SR_ASSIGNMENTS MSRA,
6937: -- MSC_TP_SITE_ID_LID MTSIL,
6938: MSC_SHIP_SET_TEMP MSST
6939: WHERE
6940:
6941: MSRA.ASSIGNMENT_TYPE = 3 /* ITEM */
6942: AND MSRA.ASSIGNMENT_SET_ID = p_assignment_set_id
6974: msc_sch_wb.atp_debug('Get_Sources_Info: '|| 'Found some sources for some ship set items at level 4');
6975: END IF;
6976:
6977: -- Mark all the items for which sources are/have been found.
6978: UPDATE msc_ship_set_temp
6979: set visited_flag = 1
6980: where inventory_item_id in (select distinct(inventory_item_id) from msc_atp_sources_temp);
6981:
6982: l_updated_rows := SQL%ROWCOUNT;
7067: MSC_SR_RECEIPT_ORG RECEIPT_ORG_INNER,
7068: MSC_SOURCING_RULES MSR_INNER,
7069: MSC_SR_ASSIGNMENTS MSRA_INNER,
7070: MSC_REGIONS_TEMP MRT_INNER,
7071: MSC_SHIP_SET_TEMP MSST_INNER
7072: WHERE
7073:
7074: MSRA_INNER.ASSIGNMENT_TYPE = 8 /* CATEGORY-REGION */
7075: AND MSRA_INNER.ASSIGNMENT_SET_ID = p_assignment_set_id
7098: GROUP BY MSST_INNER.INVENTORY_ITEM_ID;
7099:
7100: IF (l_inventory_item_id_arr.COUNT > 0) THEN
7101:
7102: -- Step1: For all the items found, update column min_region_value in msc_ship_set_temp.
7103: -- Also update the column visited_flag
7104: IF PG_DEBUG in ('Y', 'C') THEN
7105: msc_sch_wb.atp_debug('Get_Sources_Info: '|| 'For following items, the min region value found');
7106: FOR i IN 1..l_inventory_item_id_arr.COUNT LOOP
7109: END LOOP;
7110: END IF;
7111:
7112: FORALL i IN l_inventory_item_id_arr.FIRST..l_inventory_item_id_arr.LAST
7113: UPDATE msc_ship_set_temp
7114: SET min_region_value = l_min_region_value_arr(i),
7115: visited_flag = 1
7116: WHERE inventory_item_id = l_inventory_item_id_arr(i);
7117:
7140: MSC_SR_RECEIPT_ORG RECEIPT_ORG,
7141: MSC_SOURCING_RULES MSR,
7142: MSC_SR_ASSIGNMENTS MSRA,
7143: MSC_REGIONS_TEMP MRT,
7144: MSC_SHIP_SET_TEMP MSST
7145: WHERE
7146:
7147: MSRA.ASSIGNMENT_TYPE = 8 /* CATEGORY-REGION */
7148: AND MSRA.ASSIGNMENT_SET_ID = p_assignment_set_id
7179: -- Step3: Check if I need to stop here.
7180:
7181: SELECT COUNT(*)
7182: INTO l_items_visited
7183: FROM MSC_SHIP_SET_TEMP
7184: WHERE VISITED_FLAG = 1;
7185:
7186: IF (l_items_visited = p_ship_set_item_count) THEN
7187: -- We have to stop search and return from here. But before returning,
7266: MSC_SR_RECEIPT_ORG RECEIPT_ORG,
7267: MSC_SOURCING_RULES MSR,
7268: MSC_SR_ASSIGNMENTS MSRA,
7269: -- MSC_TP_SITE_ID_LID MTSIL,
7270: MSC_SHIP_SET_TEMP MSST
7271: WHERE
7272:
7273: MSRA.ASSIGNMENT_TYPE = 2 /* CATEGORY */
7274: AND MSRA.ASSIGNMENT_SET_ID = p_assignment_set_id
7307: msc_sch_wb.atp_debug('Get_Sources_Info: '|| 'Found some sources for some ship set items at level 6');
7308: END IF;
7309:
7310: -- Mark all the items for which sources are/have been found.
7311: UPDATE msc_ship_set_temp
7312: set visited_flag = 1
7313: where inventory_item_id in (select inventory_item_id from msc_atp_sources_temp);
7314:
7315: l_updated_rows := SQL%ROWCOUNT;
7409: MSC_SR_RECEIPT_ORG RECEIPT_ORG,
7410: MSC_SOURCING_RULES MSR,
7411: MSC_SR_ASSIGNMENTS MSRA,
7412: MSC_TP_SITE_ID_LID MTSIL,
7413: MSC_SHIP_SET_TEMP MSST
7414: WHERE
7415: MSRA.ASSIGNMENT_TYPE = 4 /* ORG */
7416: AND MSRA.ASSIGNMENT_SET_ID = p_assignment_set_id
7417: AND MSRA.PARTNER_ID IS NOT NULL
7449: msc_sch_wb.atp_debug('Get_Sources_Info: '|| 'Found some sources for some ship set items at level 7');
7450: END IF;
7451:
7452: -- Mark all the items for which sources are/have been found.
7453: UPDATE msc_ship_set_temp
7454: set visited_flag = 1
7455: where inventory_item_id in (select inventory_item_id from msc_atp_sources_temp);
7456:
7457: l_updated_rows := SQL%ROWCOUNT;
7542: MSC_SR_RECEIPT_ORG RECEIPT_ORG_INNER,
7543: MSC_SOURCING_RULES MSR_INNER,
7544: MSC_SR_ASSIGNMENTS MSRA_INNER,
7545: MSC_REGIONS_TEMP MRT_INNER,
7546: MSC_SHIP_SET_TEMP MSST_INNER
7547: WHERE
7548: MSRA_INNER.ASSIGNMENT_TYPE = 7 /* REGION */
7549: AND MSRA_INNER.ASSIGNMENT_SET_ID = p_assignment_set_id
7550: AND MSRA_INNER.REGION_ID = MRT_INNER.REGION_ID
7571: GROUP BY MSST_INNER.INVENTORY_ITEM_ID;
7572:
7573: IF (l_inventory_item_id_arr.COUNT > 0) THEN
7574:
7575: -- Step1: For all the items found, update column min_region_value in msc_ship_set_temp.
7576: -- Also update the column visited_flag
7577: IF PG_DEBUG in ('Y', 'C') THEN
7578: msc_sch_wb.atp_debug('Get_Sources_Info: '|| 'For following items, the min region value found');
7579: FOR i IN 1..l_inventory_item_id_arr.COUNT LOOP
7582: END LOOP;
7583: END IF;
7584:
7585: FORALL i IN l_inventory_item_id_arr.FIRST..l_inventory_item_id_arr.LAST
7586: UPDATE msc_ship_set_temp
7587: SET min_region_value = l_min_region_value_arr(i),
7588: visited_flag = 1
7589: WHERE inventory_item_id = l_inventory_item_id_arr(i);
7590:
7613: MSC_SR_RECEIPT_ORG RECEIPT_ORG,
7614: MSC_SOURCING_RULES MSR,
7615: MSC_SR_ASSIGNMENTS MSRA,
7616: MSC_REGIONS_TEMP MRT,
7617: MSC_SHIP_SET_TEMP MSST
7618: WHERE
7619:
7620: MSRA.ASSIGNMENT_TYPE = 7 /* REGION */
7621: AND MSRA.ASSIGNMENT_SET_ID = p_assignment_set_id
7651: -- Step3: Check if I need to stop here.
7652:
7653: SELECT COUNT(*)
7654: INTO l_items_visited
7655: FROM MSC_SHIP_SET_TEMP
7656: WHERE VISITED_FLAG = 1;
7657:
7658: IF (l_items_visited = p_ship_set_item_count) THEN
7659: -- We have to stop search and return from here. But before returning,
7738: MSC_SR_RECEIPT_ORG RECEIPT_ORG,
7739: MSC_SOURCING_RULES MSR,
7740: MSC_SR_ASSIGNMENTS MSRA,
7741: -- MSC_TP_SITE_ID_LID MTSIL,
7742: MSC_SHIP_SET_TEMP MSST
7743: WHERE
7744: MSRA.ASSIGNMENT_TYPE = 1 /* GLOBAL */
7745: AND MSRA.ASSIGNMENT_SET_ID = p_assignment_set_id
7746: AND MSRA.SOURCING_RULE_ID = MSR.SOURCING_RULE_ID
7778: msc_sch_wb.atp_debug('Get_Sources_Info: '|| 'Found some sources for some ship set items at level 9');
7779: END IF;
7780:
7781: -- Mark all the items for which sources are/have been found.
7782: UPDATE msc_ship_set_temp
7783: set visited_flag = 1
7784: where inventory_item_id in (select inventory_item_id from msc_atp_sources_temp);
7785:
7786: l_updated_rows := SQL%ROWCOUNT;