/* Formatted on 8/5/2015 4:15:47 PM (QP5 v5.265.14096.37972) */
DECLARE
l_transaction_id NUMBER;
L_GROUP_ID NUMBER := apps.rcv_interface_groups_s.NEXTVAL;
v_uom VARCHAR2 (100);
v_uom_code VARCHAR2 (200);
v_location_id NUMBER;
v_SHIPMENT_LINE_ID NUMBER;
v_SHIPMENT_HEADER_ID NUMBER;
V_lot_control_code VARCHAR2 (100);
V_ITEM_TYPE VARCHAR2 (200);
v_lot_number VARCHAR2 (100);
v_item_location_id NUMBER;
v_subinventory_code VARCHAR2 (200);
BEGIN
-- FOR r_rec
-- IN (SELECT *
-- FROM apps.mtl_material_transactions b
-- WHERE b.transaction_date >
-- TO_DATE ('29-JUL-2015', 'DD-MON-YYYY')
-- AND b.transaction_date <
-- TO_DATE ('30-JUL-2015', 'DD-MON-YYYY')
-- AND b.transaction_type_id = 21)
FOR r_rec IN (SELECT *
FROM rbc_mtl_material_transactions
WHERE transaction_id <> 395078283)
LOOP
l_transaction_id := apps.rcv_transactions_interface_s.NEXTVAL;
v_item_location_id := NULL;
v_subinventory_code := NULL;
SELECT PRIMARY_UOM_CODE,
PRIMARY_UNIT_OF_MEASURE,
lot_control_code,
ITEM_TYPE
INTO v_uom_code,
v_uom,
v_lot_control_code,
V_ITEM_TYPE
FROM apps.mtl_system_items_b
WHERE inventory_item_id = r_rec.inventory_item_id
AND organization_id = r_rec.organization_id;
SELECT LOCATION_ID
INTO v_LOCATION_ID
FROM apps.HR_ORGANIZATION_UNITS
WHERE organization_id = r_rec.TRANSFER_ORGANIZATION_ID;
SELECT SHIPMENT_LINE_ID, SHIPMENT_HEADER_ID
INTO v_SHIPMENT_LINE_ID, v_SHIPMENT_HEADER_ID
FROM apps.rcv_shipment_lines
WHERE mmt_transaction_id = r_rec.transaction_id
AND item_id = r_rec.inventory_item_id
AND creation_date > TO_DATE ('29-JUL-2015', 'DD-MON-YYYY')
AND creation_date < TO_DATE ('30-JUL-2015', 'DD-MON-YYYY');
SELECT inventory_location_id, subinventory_code
INTO v_item_location_id, v_subinventory_code
FROM apps.mtl_item_locations
WHERE segment1 =
CASE
WHEN V_ITEM_TYPE LIKE 'FG%' THEN 'FGCONV'
ELSE 'RAWCONV'
END
AND organization_id = r_rec.TRANSFER_ORGANIZATION_ID;
INSERT INTO apps.RCV_HEADERS_INTERFACE (HEADER_INTERFACE_ID,
GROUP_ID,
PROCESSING_STATUS_CODE,
RECEIPT_SOURCE_CODE,
TRANSACTION_TYPE,
AUTO_TRANSACT_CODE,
LAST_UPDATE_DATE,
LAST_UPDATED_BY,
LAST_UPDATE_LOGIN,
CREATION_DATE,
CREATED_BY,
--VENDOR_ID,
from_organization_id,
SHIP_TO_ORGANIZATION_ID,
EXPECTED_RECEIPT_DATE,
VALIDATION_FLAG,
ORG_ID,
SHIPMENT_NUM)
VALUES (apps.rcv_headers_interface_s.NEXTVAL, --Header_Interface_Id
L_GROUP_ID, --Group_Id
'PENDING', --Processing_Status_Code
'INVENTORY', --Receipt_Source_Code
'RECEIVE', --Transaction_Type
'DELIVER', --Auto_Transact_Code
SYSDATE, --Last_Update_Date
0, --Last_Updated_By
0, --Last_Update_Login
SYSDATE, --Creation_Date
0, --Created_By
-- 7927, --Vendor_Id
r_rec.organization_id, --Ship_from _Organization_Id,
r_rec.TRANSFER_ORGANIZATION_ID, --Ship_To_Organization_Id,
SYSDATE, --Expected_Receipt_Date
'Y', --Validation_Flag
83, --Org_id_Operating_Unit_Id
r_rec.SHIPMENT_NUMBER);
INSERT INTO apps.rcv_transactions_interface (interface_transaction_id,
GROUP_ID,
last_update_date,
last_updated_by,
creation_date,
created_by,
transaction_type,
transaction_date,
processing_status_code,
processing_mode_code,
transaction_status_code,
quantity,
uom_code,
interface_source_code,
item_id,
employee_id,
shipment_header_id,
shipment_line_id,
receipt_source_code,
from_organization_id,
to_organization_id,
source_document_code,
destination_type_code,
subinventory,
shipment_num,
-- SHIPPED_DATE,
--expected_receipt_date,
validation_flag,
locator_id,
UNIT_OF_MEASURE,
AUTO_TRANSACT_CODE,
PRIMARY_QUANTITY,
PRIMARY_UNIT_OF_MEASURE,
ROUTING_HEADER_ID,
ROUTING_STEP_ID,
INSPECTION_STATUS_CODE,
USE_MTL_LOT,
-- USE_MTL_SERIAL,
CATEGORY_ID,
org_id,
deliver_to_location_id,
header_interface_id)
VALUES (l_transaction_id, --INTERFACE_TRANSACTION_ID
l_group_id, --GROUP_ID
SYSDATE, --LAST_UPDATE_DATE
19087, --LAST_UPDATED_BY
SYSDATE, --CREATION_DATE
19087, --CREATED_BY
'RECEIVE', --TRANSACTION_TYPE
SYSDATE, --nvl(fnd_date.canonical_to_date(p_receipt_date),sysdate),--TRANSACTION_DATE
'PENDING', --PROCESSING_STATUS_CODE
'BATCH', --PROCESSING_MODE_CODE
'PENDING', --TRANSACTION_STATUS_CODE
- (r_rec.transaction_quantity), --QUANTITY
v_uom_code, --UNIT_OF_MEASURE
'RCV', --INTERFACE_SOURCE_CODE
r_rec.inventory_item_id, --ITEM_ID
19087, --EMPLOYEE_ID
--‘DELIVER’, --AUTO_TRANSACT_CODE
v_SHIPMENT_HEADER_ID, --SHIPMENT_HEADER_ID
v_SHIPMENT_LINE_ID, --SHIPMENT_LINE_ID
'INVENTORY', --RECEIPT_SOURCE_CODE
r_rec.organization_id, -- From org ID
r_rec.TRANSFER_ORGANIZATION_ID, --TO_ORGANIZATION_ID
'INVENTORY', --SOURCE_DOCUMENT_CODE
'INVENTORY', --DESTINATION_TYPE_CODE
v_subinventory_code, --SUBINVENTORY
r_rec.SHIPMENT_NUMBER, --SHIPMENT_NUM
-- SYSDATE, --EXPECTED_RECEIPT_DATE,
'Y', --VALIDATION_FLAG
v_item_location_id, --l_locator_id
v_uom,
'DELIVER',
- (r_rec.transaction_quantity),
v_uom,
3,
1,
'NOT INSPECTED',
DECODE (V_lot_control_code, '1', NULL, 1),
-- 1,
144,
83,
v_LOCATION_ID,
apps.rcv_headers_interface_s.CURRVAL);
IF V_lot_control_code <> '1'
THEN
v_lot_number := NULL;
SELECT lot_number
INTO v_lot_number
FROM apps.MTL_TRANSACTION_LOT_NUMBERS
WHERE transaction_id = r_rec.transaction_id;
INSERT
INTO apps.MTL_TRANSACTION_LOTS_INTERFACE (TRANSACTION_INTERFACE_ID,
LAST_UPDATE_DATE,
LAST_UPDATED_BY,
CREATION_DATE,
CREATED_BY,
LAST_UPDATE_LOGIN,
LOT_NUMBER,
TRANSACTION_QUANTITY,
PRIMARY_QUANTITY,
-- SERIAL_TRANSACTION_TEMP_ID,
PRODUCT_CODE,
PRODUCT_TRANSACTION_ID)
VALUES (apps.MTL_MATERIAL_TRANSACTIONS_S.NEXTVAL, --TRANSACTION_INTERFACE_ID
SYSDATE, --LAST_UPDATE_DATE
19087, --LAST_UPDATED_BY
SYSDATE, --CREATION_DATE
19087, --CREATED_BY
19087, --LAST_UPDATE_LOGIN
v_lot_number, --LOT_NUMBER
- (r_rec.transaction_quantity), --TRANSACTION_QUANTITY
- (r_rec.transaction_quantity), --PRIMARY_QUANTITY
--MTL_MATERIAL_TRANSACTIONS_S.NEXTVAL, --SERIAL_TRANSACTION_TEMP_ID
'RCV', --PRODUCT_CODE
l_transaction_id --PRODUCT_TRANSACTION_ID
);
END IF;
END LOOP;
-- COMMIT;
END;
/
select * from apps.RCV_HEADERS_INTERFACE
where group_id > 14510884
commit;
In Purchasing we need to run PO Receiving Transaction Manager to create Receipts.
DECLARE
l_transaction_id NUMBER;
L_GROUP_ID NUMBER := apps.rcv_interface_groups_s.NEXTVAL;
v_uom VARCHAR2 (100);
v_uom_code VARCHAR2 (200);
v_location_id NUMBER;
v_SHIPMENT_LINE_ID NUMBER;
v_SHIPMENT_HEADER_ID NUMBER;
V_lot_control_code VARCHAR2 (100);
V_ITEM_TYPE VARCHAR2 (200);
v_lot_number VARCHAR2 (100);
v_item_location_id NUMBER;
v_subinventory_code VARCHAR2 (200);
BEGIN
-- FOR r_rec
-- IN (SELECT *
-- FROM apps.mtl_material_transactions b
-- WHERE b.transaction_date >
-- TO_DATE ('29-JUL-2015', 'DD-MON-YYYY')
-- AND b.transaction_date <
-- TO_DATE ('30-JUL-2015', 'DD-MON-YYYY')
-- AND b.transaction_type_id = 21)
FOR r_rec IN (SELECT *
FROM rbc_mtl_material_transactions
WHERE transaction_id <> 395078283)
LOOP
l_transaction_id := apps.rcv_transactions_interface_s.NEXTVAL;
v_item_location_id := NULL;
v_subinventory_code := NULL;
SELECT PRIMARY_UOM_CODE,
PRIMARY_UNIT_OF_MEASURE,
lot_control_code,
ITEM_TYPE
INTO v_uom_code,
v_uom,
v_lot_control_code,
V_ITEM_TYPE
FROM apps.mtl_system_items_b
WHERE inventory_item_id = r_rec.inventory_item_id
AND organization_id = r_rec.organization_id;
SELECT LOCATION_ID
INTO v_LOCATION_ID
FROM apps.HR_ORGANIZATION_UNITS
WHERE organization_id = r_rec.TRANSFER_ORGANIZATION_ID;
SELECT SHIPMENT_LINE_ID, SHIPMENT_HEADER_ID
INTO v_SHIPMENT_LINE_ID, v_SHIPMENT_HEADER_ID
FROM apps.rcv_shipment_lines
WHERE mmt_transaction_id = r_rec.transaction_id
AND item_id = r_rec.inventory_item_id
AND creation_date > TO_DATE ('29-JUL-2015', 'DD-MON-YYYY')
AND creation_date < TO_DATE ('30-JUL-2015', 'DD-MON-YYYY');
SELECT inventory_location_id, subinventory_code
INTO v_item_location_id, v_subinventory_code
FROM apps.mtl_item_locations
WHERE segment1 =
CASE
WHEN V_ITEM_TYPE LIKE 'FG%' THEN 'FGCONV'
ELSE 'RAWCONV'
END
AND organization_id = r_rec.TRANSFER_ORGANIZATION_ID;
INSERT INTO apps.RCV_HEADERS_INTERFACE (HEADER_INTERFACE_ID,
GROUP_ID,
PROCESSING_STATUS_CODE,
RECEIPT_SOURCE_CODE,
TRANSACTION_TYPE,
AUTO_TRANSACT_CODE,
LAST_UPDATE_DATE,
LAST_UPDATED_BY,
LAST_UPDATE_LOGIN,
CREATION_DATE,
CREATED_BY,
--VENDOR_ID,
from_organization_id,
SHIP_TO_ORGANIZATION_ID,
EXPECTED_RECEIPT_DATE,
VALIDATION_FLAG,
ORG_ID,
SHIPMENT_NUM)
VALUES (apps.rcv_headers_interface_s.NEXTVAL, --Header_Interface_Id
L_GROUP_ID, --Group_Id
'PENDING', --Processing_Status_Code
'INVENTORY', --Receipt_Source_Code
'RECEIVE', --Transaction_Type
'DELIVER', --Auto_Transact_Code
SYSDATE, --Last_Update_Date
0, --Last_Updated_By
0, --Last_Update_Login
SYSDATE, --Creation_Date
0, --Created_By
-- 7927, --Vendor_Id
r_rec.organization_id, --Ship_from _Organization_Id,
r_rec.TRANSFER_ORGANIZATION_ID, --Ship_To_Organization_Id,
SYSDATE, --Expected_Receipt_Date
'Y', --Validation_Flag
83, --Org_id_Operating_Unit_Id
r_rec.SHIPMENT_NUMBER);
INSERT INTO apps.rcv_transactions_interface (interface_transaction_id,
GROUP_ID,
last_update_date,
last_updated_by,
creation_date,
created_by,
transaction_type,
transaction_date,
processing_status_code,
processing_mode_code,
transaction_status_code,
quantity,
uom_code,
interface_source_code,
item_id,
employee_id,
shipment_header_id,
shipment_line_id,
receipt_source_code,
from_organization_id,
to_organization_id,
source_document_code,
destination_type_code,
subinventory,
shipment_num,
-- SHIPPED_DATE,
--expected_receipt_date,
validation_flag,
locator_id,
UNIT_OF_MEASURE,
AUTO_TRANSACT_CODE,
PRIMARY_QUANTITY,
PRIMARY_UNIT_OF_MEASURE,
ROUTING_HEADER_ID,
ROUTING_STEP_ID,
INSPECTION_STATUS_CODE,
USE_MTL_LOT,
-- USE_MTL_SERIAL,
CATEGORY_ID,
org_id,
deliver_to_location_id,
header_interface_id)
VALUES (l_transaction_id, --INTERFACE_TRANSACTION_ID
l_group_id, --GROUP_ID
SYSDATE, --LAST_UPDATE_DATE
19087, --LAST_UPDATED_BY
SYSDATE, --CREATION_DATE
19087, --CREATED_BY
'RECEIVE', --TRANSACTION_TYPE
SYSDATE, --nvl(fnd_date.canonical_to_date(p_receipt_date),sysdate),--TRANSACTION_DATE
'PENDING', --PROCESSING_STATUS_CODE
'BATCH', --PROCESSING_MODE_CODE
'PENDING', --TRANSACTION_STATUS_CODE
- (r_rec.transaction_quantity), --QUANTITY
v_uom_code, --UNIT_OF_MEASURE
'RCV', --INTERFACE_SOURCE_CODE
r_rec.inventory_item_id, --ITEM_ID
19087, --EMPLOYEE_ID
--‘DELIVER’, --AUTO_TRANSACT_CODE
v_SHIPMENT_HEADER_ID, --SHIPMENT_HEADER_ID
v_SHIPMENT_LINE_ID, --SHIPMENT_LINE_ID
'INVENTORY', --RECEIPT_SOURCE_CODE
r_rec.organization_id, -- From org ID
r_rec.TRANSFER_ORGANIZATION_ID, --TO_ORGANIZATION_ID
'INVENTORY', --SOURCE_DOCUMENT_CODE
'INVENTORY', --DESTINATION_TYPE_CODE
v_subinventory_code, --SUBINVENTORY
r_rec.SHIPMENT_NUMBER, --SHIPMENT_NUM
-- SYSDATE, --EXPECTED_RECEIPT_DATE,
'Y', --VALIDATION_FLAG
v_item_location_id, --l_locator_id
v_uom,
'DELIVER',
- (r_rec.transaction_quantity),
v_uom,
3,
1,
'NOT INSPECTED',
DECODE (V_lot_control_code, '1', NULL, 1),
-- 1,
144,
83,
v_LOCATION_ID,
apps.rcv_headers_interface_s.CURRVAL);
IF V_lot_control_code <> '1'
THEN
v_lot_number := NULL;
SELECT lot_number
INTO v_lot_number
FROM apps.MTL_TRANSACTION_LOT_NUMBERS
WHERE transaction_id = r_rec.transaction_id;
INSERT
INTO apps.MTL_TRANSACTION_LOTS_INTERFACE (TRANSACTION_INTERFACE_ID,
LAST_UPDATE_DATE,
LAST_UPDATED_BY,
CREATION_DATE,
CREATED_BY,
LAST_UPDATE_LOGIN,
LOT_NUMBER,
TRANSACTION_QUANTITY,
PRIMARY_QUANTITY,
-- SERIAL_TRANSACTION_TEMP_ID,
PRODUCT_CODE,
PRODUCT_TRANSACTION_ID)
VALUES (apps.MTL_MATERIAL_TRANSACTIONS_S.NEXTVAL, --TRANSACTION_INTERFACE_ID
SYSDATE, --LAST_UPDATE_DATE
19087, --LAST_UPDATED_BY
SYSDATE, --CREATION_DATE
19087, --CREATED_BY
19087, --LAST_UPDATE_LOGIN
v_lot_number, --LOT_NUMBER
- (r_rec.transaction_quantity), --TRANSACTION_QUANTITY
- (r_rec.transaction_quantity), --PRIMARY_QUANTITY
--MTL_MATERIAL_TRANSACTIONS_S.NEXTVAL, --SERIAL_TRANSACTION_TEMP_ID
'RCV', --PRODUCT_CODE
l_transaction_id --PRODUCT_TRANSACTION_ID
);
END IF;
END LOOP;
-- COMMIT;
END;
/
select * from apps.RCV_HEADERS_INTERFACE
where group_id > 14510884
commit;
In Purchasing we need to run PO Receiving Transaction Manager to create Receipts.
No comments:
Post a Comment