SET DEFINE OFF;
EXPECTED_ARRIVAL_DATE - You can calcualte based on intransit time from one org location to other Org
/* Formatted on 8/6/2015 11:15:11 AM (QP5 v5.265.14096.37972) */
SET DEFINE OFF;
DECLARE
v_uom VARCHAR2 (100);
v_transaction_id NUMBER;
v_locator_id NUMBER;
v_subinventory_code VARCHAR2 (100);
v_INTRANSIT_TIME NUMBER;
BEGIN
FOR r_record IN (SELECT *
FROM apps.rbc_qad_onhand_qty_stg
WHERE process_status = 9)
LOOP
v_transaction_id := mtl_material_transactions_s.NEXTVAL;
SELECT PRIMARY_UOM_CODE
INTO v_uom
FROM apps.mtl_system_items_b
WHERE inventory_item_id = r_record.inventory_item_id
AND organization_id = r_record.organization_id;
SELECT INVENTORY_LOCATION_ID, subinventory_code
INTO v_locator_id, v_subinventory_code
FROM apps.mtl_item_locations
WHERE segment1 = r_records.locator
AND organization_id = r_records.organization_id;
SELECT INTRANSIT_TIME
INTO v_INTRANSIT_TIME
FROM MTL_INTERORG_SHIP_METHODS
WHERE from_organization_id = REC_INTERORG.organization_id
AND to_organization_id = REC_INTERORG.TRANSFER_ORG_ID
AND DEFAULT_FLAG = '1';
INSERT
INTO APPS.MTL_TRANSACTIONS_INTERFACE (TRANSACTION_INTERFACE_ID,
TRANSACTION_HEADER_ID,
SOURCE_CODE,
SOURCE_LINE_ID,
SOURCE_HEADER_ID,
PROCESS_FLAG,
TRANSACTION_MODE,
LOCK_FLAG,
LAST_UPDATE_DATE,
LAST_UPDATED_BY,
CREATION_DATE,
CREATED_BY,
INVENTORY_ITEM_ID,
ORGANIZATION_ID,
TRANSACTION_QUANTITY,
PRIMARY_QUANTITY,
TRANSACTION_UOM,
TRANSACTION_DATE,
SUBINVENTORY_CODE,
LOCATOR_ID,
TRANSACTION_SOURCE_TYPE_ID,
TRANSACTION_ACTION_ID,
TRANSACTION_TYPE_ID,
TRANSFER_ORGANIZATION,
SHIPMENT_NUMBER,
FINAL_COMPLETION_FLAG,
EXPECTED_ARRIVAL_DATE)
VALUES (v_transaction_id,
v_transaction_id,
'Onhand Conversion',
v_transaction_id,
v_transaction_id,
1, -- Process Flag
3, --Transaction mode
2, -- Lock Flag
SYSDATE,
19087,
SYSDATE,
19087,
r_record.inventory_item_id,
r_record.organization_id,
-r_record.transaction_quantity,
-r_record.transaction_quantity,
v_uom,
SYSDATE,
v_subinventory_code,
v_locator_id,
13,
21,
21,
5815,
r_record.shipment_number,
'N',
SYSDATE + v_INTRANSIT_TIME);
COMMIT;
END LOOP;
END;
No comments:
Post a Comment