Search This Blog

Monday, April 26, 2021

Oracle Apps R12 API to submit PO Approval

 DECLARE

v_item_key VARCHAR2(100);


Cursor purchase_order is

SELECT

pha.po_header_id,

pha.org_id,

pha.segment1,

pha.agent_id,

pdt.document_subtype,

pdt.document_type_code,

pha.authorization_status

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 authorization_status in ('INCOMPLETE', 'REQUIRES REAPPROVAL')

--AND segment1 = '4456666'; -- Enter the Purchase Order Number

and pha.po_header_id = 2143276;

BEGIN


fnd_global.apps_initialize (user_id => 4131,

resp_id => 52375,

resp_appl_id => 201);


FOR i IN purchase_order

LOOP


mo_global.set_policy_context ('S', '1814');



SELECT i.po_header_id ||'-'|| to_char(po_wf_itemkey_s.NEXTVAL)

INTO v_item_key FROM dual;


dbms_output.put_line (' Calling po_reqapproval_init1.start_wf_process for po_id=>' ||i.segment1);


po_reqapproval_init1.start_wf_process(

ItemType => 'POAPPRV'

, ItemKey => v_item_key

, WorkflowProcess => 'POAPPRV_TOP'

, ActionOriginatedFrom => 'PO_FORM'

, DocumentID => i.po_header_id -- po_header_id

, DocumentNumber => i.segment1 -- Purchase Order Number

, PreparerID => i.agent_id -- Buyer/Preparer_id

, DocumentTypeCode => i.document_type_code--'PO'

, DocumentSubtype => i.document_subtype --'STANDARD'

, 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'

, p_Initiator => NULL

, p_xml_flag => NULL

, FpdsngFlag => 'N'

, p_source_type_code => NULL);

commit;


DBMS_OUTPUT.PUT_LINE ('Purchase Order has been approved=>'|| i.segment1);

END LOOP;

END;

No comments:

Post a Comment