This script is intended as a tool to allow easier implementation of the Receiving Open Interface (ROI). Through the use of this script, a user provides a standard purchase order number, user id and an organization id and the script will take the minimal data from the purchase order (PO) document and insert data into the Receiving Open Interface for a Receive transaction.
The Receiving Transaction Processor can then be run to process the row(s) of data that have been inserted.
This script can now be run against a multi-line po with multiple corresponding shipment lines for each po line.
Script
--**********************************************************
--*** eZROI ***
--*** by ***
--*** Preston D. Davenport ***
--*** Oracle Premium Applications Support ***
--*** Oracle Worldwide Global Support Services ***
--**********************************************************
--*** Date: 23-JUL-2003 - Beta release ***
--*** Date: 09-SEP-2003 - Rev A Added multi- ***
--*** shipment line capability ***
--**********************************************************
--*** Parameters: ***
--*** ORG_ID Organization ID ***
--*** USER_NAME FND User Name ***
--*** PO_NUMBER Purchase Order Number ***
--*** ***
--*** This script intended for a standard Purchase ***
--*** Order document to be inserted into the Oracle ***
--*** Receiving Open Interface (ROI) via the standard ***
--*** Oracle open interface api for a simple Receive ***
--*** transaction. ***
--*** ***
--*** Note: This script only considers open Purchase ***
--*** Orders. This script will not allow over- ***
--*** receipt, cancelled or closed PO's to be ***
--*** inserted into the ROI and received ***
--*** ***
--**********************************************************
CLEAR BUFFER
SET VERIFY OFF
SET LINESIZE 140
SET PAGESIZE 60
SET ARRAYSIZE 1
SET SERVEROUTPUT ON SIZE 100000
SET FEEDBACK OFF
SET ECHO OFF
DECLARE
X_USER_ID NUMBER;
X_PO_HEADER_ID NUMBER;
X_VENDOR_ID NUMBER;
X_SEGMENT1 VARCHAR2(20);
X_ORG_ID NUMBER;
X_LINE_NUM NUMBER;
BEGIN
DBMS_OUTPUT.PUT_LINE('***ezROI RCV API Insert Script***');
SELECT PO_HEADER_ID , VENDOR_ID , SEGMENT1 , ORG_ID
INTO X_PO_HEADER_ID , X_VENDOR_ID , X_SEGMENT1 , X_ORG_ID
FROM PO_HEADERS_ALL
WHERE SEGMENT1 = '&PO_NUMBER'
AND ORG_ID = &ORG_ID;
SELECT USER_ID INTO X_USER_ID
FROM FND_USER
WHERE USER_NAME = UPPER('&USER_NAME');
INSERT INTO RCV_HEADERS_INTERFACE
(
HEADER_INTERFACE_ID ,
GROUP_ID ,
PROCESSING_STATUS_CODE ,
RECEIPT_SOURCE_CODE ,
TRANSACTION_TYPE ,
LAST_UPDATE_DATE ,
LAST_UPDATED_BY ,
LAST_UPDATE_LOGIN ,
VENDOR_ID ,
EXPECTED_RECEIPT_DATE ,
VALIDATION_FLAG
)
SELECT
RCV_HEADERS_INTERFACE_S.NEXTVAL ,
RCV_INTERFACE_GROUPS_S.NEXTVAL ,
'PENDING' ,
'VENDOR' ,
'NEW' ,
SYSDATE ,
X_USER_ID ,
0 ,
X_VENDOR_ID ,
SYSDATE ,
'Y'
FROM DUAL;
DECLARE
CURSOR PO_LINE IS
SELECT PL.ITEM_ID , PL.PO_LINE_ID , PL.LINE_NUM ,
PLL.QUANTITY , PL.UNIT_MEAS_LOOKUP_CODE ,
MP.ORGANIZATION_CODE , PLL.LINE_LOCATION_ID ,
PLL.CLOSED_CODE , PLL.QUANTITY_RECEIVED ,
PLL.CANCEL_FLAG, PLL.SHIPMENT_NUM
FROM PO_LINES_ALL PL ,
PO_LINE_LOCATIONS_ALL PLL ,
MTL_PARAMETERS MP
WHERE PL.PO_HEADER_ID = X_PO_HEADER_ID
AND PL.PO_LINE_ID = PLL.PO_LINE_ID
AND PLL.SHIP_TO_ORGANIZATION_ID = MP.ORGANIZATION_ID;
BEGIN
FOR CURSOR1 IN PO_LINE LOOP
IF CURSOR1.CLOSED_CODE IN ('APPROVED','OPEN')
AND CURSOR1.QUANTITY_RECEIVED < CURSOR1.QUANTITY
AND NVL(CURSOR1.CANCEL_FLAG,'N') = 'N'
THEN
INSERT INTO RCV_TRANSACTIONS_INTERFACE
(
INTERFACE_TRANSACTION_ID ,
GROUP_ID ,
LAST_UPDATE_DATE ,
LAST_UPDATED_BY ,
CREATION_DATE ,
CREATED_BY ,
LAST_UPDATE_LOGIN ,
TRANSACTION_TYPE ,
TRANSACTION_DATE ,
PROCESSING_STATUS_CODE ,
PROCESSING_MODE_CODE ,
TRANSACTION_STATUS_CODE ,
PO_LINE_ID ,
ITEM_ID ,
QUANTITY ,
UNIT_OF_MEASURE ,
PO_LINE_LOCATION_ID ,
AUTO_TRANSACT_CODE ,
RECEIPT_SOURCE_CODE ,
TO_ORGANIZATION_CODE ,
SOURCE_DOCUMENT_CODE ,
DOCUMENT_NUM ,
HEADER_INTERFACE_ID ,
VALIDATION_FLAG
)
SELECT
RCV_TRANSACTIONS_INTERFACE_S.NEXTVAL ,
RCV_INTERFACE_GROUPS_S.CURRVAL ,
SYSDATE ,
X_USER_ID ,
SYSDATE ,
X_USER_ID ,
0 ,
'RECEIVE' ,
SYSDATE ,
'PENDING' ,
'BATCH' ,
'PENDING' ,
CURSOR1.PO_LINE_ID ,
CURSOR1.ITEM_ID ,
CURSOR1.QUANTITY ,
CURSOR1.UNIT_MEAS_LOOKUP_CODE ,
CURSOR1.LINE_LOCATION_ID ,
'RECEIVE' ,
'VENDOR' ,
CURSOR1.ORGANIZATION_CODE ,
'PO' ,
X_SEGMENT1 ,
RCV_HEADERS_INTERFACE_S.CURRVAL ,
'Y'
FROM DUAL;
DBMS_OUTPUT.PUT_LINE('PO line: '||CURSOR1.LINE_NUM||' Shipment: '||CURSOR1.SHIPMENT_NUM||' has been inserted into ROI.');
ELSE
DBMS_OUTPUT.PUT_LINE('PO line '||CURSOR1.LINE_NUM||' is either closed, cancelled, received.');
END IF;
END LOOP;
DBMS_OUTPUT.PUT_LINE('*** ezROI COMPLETE - End ***');
END;
COMMIT;
END;
/
--
SET VERIFY ON