CREATE OR REPLACE PROCEDURE XX_PO_APPROVE_ACTION(I_HEADER_ID IN NUMBER,
X_RET_CODE OUT VARCHAR2, --S : Success / E : Error
X_RET_MSG OUT VARCHAR2 --Error message
)
IS
/**********************************************************************
I_ACTION ==>
*********************************************************************/
V_STATUS VARCHAR2(100); --For check this HEADER_ID Status. (Is 'INCOMPLETE' ?)
V_RETURN_CODE VARCHAR2(1) := 'S'; --Process status code ==> S : Success / E : Error
V_RETURN_MSG VARCHAR2(2000); --Error message
V_ITEM_KEY VARCHAR2(200); --For API
V_ITEM_TYPE VARCHAR2(20);
V_SEGMENT1 PO_HEADERS_ALL.SEGMENT1%TYPE; --For API
V_PREPARER_ID PO_HEADERS_ALL.AGENT_ID%TYPE; --For API
V_DOCUMENT_TYPE_CODE PO_DOCUMENT_TYPES_ALL.DOCUMENT_TYPE_CODE%TYPE; --For API
V_DOCUMENT_SUBTYPE PO_DOCUMENT_TYPES_ALL.DOCUMENT_SUBTYPE%TYPE; --For API
BEGIN
--Check PO HEADER_ID is exists ?
BEGIN
SELECT AUTHORIZATION_STATUS
INTO V_STATUS
FROM PO_HEADERS_ALL A
WHERE A.PO_HEADER_ID = I_HEADER_ID;
EXCEPTION
WHEN NO_DATA_FOUND THEN
V_STATUS := NULL;
V_RETURN_MSG := 'No data found : PO_HEADER_ID ==> '||I_HEADER_ID;
V_RETURN_CODE := 'E';
END;
IF V_RETURN_CODE = 'S' THEN
BEGIN
--Find API parameters
SELECT pha.org_id,
pha.agent_id,
pha.segment1,
pha.wf_item_type,
pha.wf_item_key,
pdt.document_subtype,
pdt.document_type_code
INTO V_ORG_ID,
V_PREPARER_ID,
V_SEGMENT1,
v_ITEM_TYPE,
V_ITEM_KEY,
V_DOCUMENT_SUBTYPE,
V_DOCUMENT_TYPE_CODE
FROM apps.po_headers_all pha, apps.po_document_types_all pdt
WHERE pha.type_lookup_code = pdt.document_subtype
AND pha.org_id = pdt.org_id
AND pdt.document_type_code = 'PO'
AND pha.PO_HEADER_ID = I_HEADER_ID;
EXCEPTION
WHEN OTHERS THEN
V_RETURN_MSG := 'No data found : po_document_types_all - ' || sqlerrm;
V_RETURN_CODE := 'E';
END;
END IF;
IF V_RETURN_CODE = 'S' THEN
mo_global.init('PO');
mo_global.set_policy_context('S', V_ORG_ID);
SELECT I_HEADER_ID /*P_EP_PO_HEADER_ID*/
|| '-' || TO_CHAR(PO_WF_ITEMKEY_S.NEXTVAL)
INTO V_ITEM_KEY
FROM DUAL;
--ORACLE API
BEGIN
--Restart WorkFlow
PO_REQAPPROVAL_INIT1.START_WF_PROCESS(ItemType => V_ITEM_TYPE, --'POAPPRV',
ItemKey => V_ITEM_KEY,
WorkflowProcess => 'POAPPRV_TOP',
ActionOriginatedFrom => 'PO_FORM',
DocumentID => I_HEADER_ID,
DocumentNumber => V_SEGMENT1, -- Purchase Order Number
PreparerID => V_PREPARER_ID, -- Buyer/Preparer_id
DocumentTypeCode => V_DOCUMENT_TYPE_CODE,
DocumentSubtype => V_DOCUMENT_SUBTYPE,
SubmitterAction => 'APPROVE',
forwardToID => NULL,
forwardFromID => NULL,
DefaultApprovalPathID => NULL,
Note => NULL,
PrintFlag => 'N',
FaxFlag => 'N',
FaxNumber => NULL,
EmailFlag => 'N',
EmailAddress => NULL,
CreateSourcingRule => 'N',
ReleaseGenMethod => 'N',
UpdateSourcingRule => 'N',
MassUpdateReleases => 'N',
RetroactivePriceChange => 'N',
OrgAssignChange => 'N',
CommunicatePriceChange => 'N',
p_Background_Flag => 'N', --N:標準API會COMMIT
p_Initiator => NULL,
p_xml_flag => NULL,
FpdsngFlag => 'N',
p_source_type_code => NULL);
--API
PO_REQAPPROVAL_ACTION.APPROVE_DOC(V_ITEM_TYPE,
V_ITEM_KEY,
NULL,
'RUN',
X_RET_MSG); --20120303
END;
IF NVL(V_RETURN_CODE, 'S') <> 'E' THEN
V_RETURN_CODE := 'S';
END IF;
END IF;
FND_FILE.PUT_LINE(FND_FILE.LOG, 'V_RETURN_CODE=' || V_RETURN_CODE);
FND_FILE.PUT_LINE(FND_FILE.LOG, 'V_RETURN_MSG=' || V_RETURN_MSG);
X_RET_CODE := V_RETURN_CODE;
X_RET_MSG := V_RETURN_MSG;
END XX_PO_APPROVE_ACTION;
look look
回覆刪除