/* Formatted on 2014-10-6 16:33:22 (QP5 v5.115.810.9015) */
DECLARE
-- Local variables here
I INTEGER;
L_HEADER_REC PO.PO_HEADERS_INTERFACE%ROWTYPE;
L_LINE_REC PO.PO_LINES_INTERFACE%ROWTYPE;
L_DIST_REC PO.PO_DISTRIBUTIONS_INTERFACE%ROWTYPE;
L_ERROR_MESSAGE VARCHAR2(4000);
BEGIN
-- Test statements here
MO_GLOBAL.INIT('PO');
MO_GLOBAL.SET_POLICY_CONTEXT('S', 85);
FND_GLOBAL.APPS_INITIALIZE(USER_ID => 11236
,RESP_ID => 50623
,RESP_APPL_ID => 201
);
--PO头
L_HEADER_REC.ORG_ID := 85;
SELECT PO.PO_HEADERS_INTERFACE_S.NEXTVAL
INTO L_HEADER_REC.INTERFACE_HEADER_ID
FROM DUAL;
dbms_output.PUT_LINE('HEADER_ID:' || L_HEADER_REC.INTERFACE_HEADER_ID);
L_HEADER_REC.BATCH_ID := L_HEADER_REC.INTERFACE_HEADER_ID;
L_HEADER_REC.PROCESS_CODE := 'PENDING';
L_HEADER_REC.ACTION := 'ORIGINAL';
L_HEADER_REC.DOCUMENT_TYPE_CODE := 'STANDARD'; --'BLANKET';
--l_iface_rec.document_subtype := NULL;
L_HEADER_REC.APPROVAL_STATUS := 'APPROVED';
L_HEADER_REC.VENDOR_ID := 253;
L_HEADER_REC.VENDOR_SITE_ID := 2708;
L_HEADER_REC.AGENT_ID := 10750;
L_HEADER_REC.CURRENCY_CODE := 'CNY'; --USD是本位币
L_HEADER_REC.RATE_TYPE_CODE := NULL;
L_HEADER_REC.RATE_DATE :=NULL;
L_HEADER_REC.RATE := NULL;
INSERT INTO PO.PO_HEADERS_INTERFACE
VALUES L_HEADER_REC;
--PO行
L_LINE_REC.INTERFACE_HEADER_ID := L_HEADER_REC.INTERFACE_HEADER_ID;
SELECT PO.PO_LINES_INTERFACE_S.NEXTVAL
INTO L_LINE_REC.INTERFACE_LINE_ID
FROM DUAL;
L_LINE_REC.LINE_NUM := 1;
-- L_LINE_REC.LINE_TYPE := 'GOODS';--'货物';
L_LINE_REC.ACTION := 'ORIGINAL';
L_LINE_REC.PROCESS_CODE := 'PENDING';
L_LINE_REC.ITEM_ID := 51277;
L_LINE_REC.UOM_CODE := 'EA';
L_LINE_REC.UNIT_PRICE := 60;
L_LINE_REC.QUANTITY := 10;
L_LINE_REC.NEED_BY_DATE := SYSDATE;
L_LINE_REC.SHIP_TO_ORGANIZATION_ID := 104;
L_LINE_REC.SHIP_TO_LOCATION_ID := 147;
INSERT INTO PO.PO_LINES_INTERFACE
VALUES L_LINE_REC;
-- PO分配
L_DIST_REC.INTERFACE_HEADER_ID := L_HEADER_REC.INTERFACE_HEADER_ID;
L_DIST_REC.INTERFACE_LINE_ID := L_LINE_REC.INTERFACE_LINE_ID;
SELECT PO.PO_DISTRIBUTIONS_INTERFACE_S.NEXTVAL
INTO L_DIST_REC.INTERFACE_DISTRIBUTION_ID
FROM DUAL;
L_DIST_REC.QUANTITY_ORDERED := 10;
INSERT INTO PO.PO_DISTRIBUTIONS_INTERFACE
VALUES L_DIST_REC;
PO_DOCS_INTERFACE_SV5.PROCESS_PO_HEADERS_INTERFACE(
X_SELECTED_BATCH_ID => L_HEADER_REC.BATCH_ID
,X_BUYER_ID => NULL
,X_DOCUMENT_TYPE => L_HEADER_REC.DOCUMENT_TYPE_CODE
,X_DOCUMENT_SUBTYPE => L_HEADER_REC.DOCUMENT_SUBTYPE
,X_CREATE_ITEMS => 'N'
,X_CREATE_SOURCING_RULES_FLAG => NULL
,X_REL_GEN_METHOD => NULL
,X_APPROVED_STATUS => L_HEADER_REC.APPROVAL_STATUS
,X_COMMIT_INTERVAL => 1
,X_PROCESS_CODE => 'PENDING'
,X_INTERFACE_HEADER_ID => NULL
,X_ORG_ID_PARAM => NULL
,X_GA_FLAG => NULL
);
SELECT MAX(PIE.ERROR_MESSAGE)
INTO L_ERROR_MESSAGE
FROM PO_INTERFACE_ERRORS PIE
WHERE PIE.INTERFACE_HEADER_ID = L_HEADER_REC.INTERFACE_HEADER_ID;
dbms_output.PUT_LINE('头错误信息:' || L_ERROR_MESSAGE);
END;
--
select * FROM PO_HEADERS_INTERFACE
WHERE PO_HEADER_ID =26074620
select * FROM PO_HEADERS_ALL
WHERE CREATED_BY = 11236