{"id":15650,"date":"2017-11-20T12:32:44","date_gmt":"2017-11-20T14:32:44","guid":{"rendered":"http:\/\/orabr.com\/?p=15650"},"modified":"2017-11-20T12:32:44","modified_gmt":"2017-11-20T14:32:44","slug":"chamando-workflow-de-aprovacao-de-po-via-api-plsql","status":"publish","type":"post","link":"https:\/\/orabr.virttus.com\/?p=15650","title":{"rendered":"Chamando WorkFlow de aprova\u00e7\u00e3o de PO via API &#8211; PLSQL"},"content":{"rendered":"<p><HTML><HTML>PO_REQAPPROVAL_INIT1.START_WF_PROCESS \u00a0&#8211;\u00a0API para Aprovar Ordens de Compra, Contratos de Compra Geral e Requisi\u00e7\u00e3o de Compra &#8230;<\/p>\n<p>Algumas vezes, estamos nos perguntando o que exatamente a Oracle est\u00e1 fazendo quando estamos clicando no bot\u00e3o Aprovar no Formul\u00e1rio de Pedido \/ Requisi\u00e7\u00e3o de Compra. E como o bot\u00e3o Aprovar chama o fluxo de trabalho de aprova\u00e7\u00e3o de compras.<br \/>\nQuando o bot\u00e3o Aprovar \u00e9 clicado, o formul\u00e1rio de forma modal de aprova\u00e7\u00e3o para compras de aprova\u00e7\u00f5es \u00e9 chamado (este \u00e9 o formul\u00e1rio POXDOAPP.fmb e o arquivo de biblioteca correspondente em anexo POXAPAPC.pll.). Os formul\u00e1rios Enter Requisition e Enter Purchase Order chamam o mesmo formul\u00e1rio de aprova\u00e7\u00e3o.<br \/>\nO arquivo de biblioteca POXAPAPC.pll possui um procedimento PO_WF_APPROVE_C.SetUpWorkFlow que chama o procedimento PO_REQAPPROVAL_INIT1.Start_WF_Process no arquivo de pacote POXWPA1B.pls.<br \/>\nEste procedimento do lado do servidor chama o fluxo de trabalho e inicia o fluxo de trabalho e processa o documento atrav\u00e9s do fluxo de trabalho &#8230;<\/p>\n<p><span style=\"color: #0000ff;\"><strong>\u2014 R12 \u2013 PO \u2013 SAMPLE SCRIPT TO APPROVE PURCHASE ORDER<\/strong><\/span><br \/>\nDECLARE<br \/>\nv_item_key VARCHAR2(100);<\/p>\n<p>Cursor c_po_details is<\/p>\n<p>SELECT<br \/>\npha.po_header_id,<br \/>\npha.org_id,<br \/>\npha.segment1,<br \/>\npha.agent_id,<br \/>\npdt.document_subtype,<br \/>\npdt.document_type_code,<br \/>\npha.authorization_status<br \/>\nFROM apps.po_headers_all pha, apps.po_document_types_all pdt<br \/>\nWHERE pha.type_lookup_code = pdt.document_subtype<br \/>\nAND pha.org_id = pdt.org_id<br \/>\nAND pdt.document_type_code = \u2018PO\u2019<br \/>\nAND authorization_status in (\u2018INCOMPLETE\u2019, \u2018REQUIRES REAPPROVAL\u2019)<br \/>\nAND segment1 = \u201811170000860\u2019; \u2014 Enter the Purchase Order Number<br \/>\nBEGIN<br \/>\nfnd_global.apps_initialize (user_id =&gt; 2083,<br \/>\nresp_id =&gt; 20707,<br \/>\nresp_appl_id =&gt; 201);<br \/>\nFOR p_rec IN c_po_details<br \/>\nLOOP<\/p>\n<p>mo_global.init (p_rec.document_type_code);<br \/>\nmo_global.set_policy_context (\u2018S\u2019, p_rec.org_id);<\/p>\n<p>SELECT p_rec.po_header_id \u2018-\u2018 to_char(po_wf_itemkey_s.NEXTVAL)<br \/>\nINTO v_item_key FROM dual;<br \/>\ndbms_output.put_line (\u2018 Calling po_reqapproval_init1.start_wf_process for po_id=&gt;\u2019 p_rec.segment1);<\/p>\n<p>po_reqapproval_init1.start_wf_process(<br \/>\nItemType =&gt; \u2018POAPPRV\u2019<br \/>\n, ItemKey =&gt; v_item_key<br \/>\n, WorkflowProcess =&gt; \u2018POAPPRV_TOP\u2019<br \/>\n, ActionOriginatedFrom =&gt; \u2018PO_FORM\u2019<br \/>\n, DocumentID =&gt; p_rec.po_header_id \u2014 po_header_id<br \/>\n, DocumentNumber =&gt; p_rec.segment1 \u2014 Purchase Order Number<br \/>\n, PreparerID =&gt; p_rec.agent_id \u2014 Buyer\/Preparer_id<br \/>\n, DocumentTypeCode =&gt; p_rec.document_type_code\u2013\u2018PO\u2019<br \/>\n, DocumentSubtype =&gt; p_rec.document_subtype \u2013\u2018STANDARD\u2019<br \/>\n, SubmitterAction =&gt; \u2018APPROVE\u2019<br \/>\n, forwardToID =&gt; NULL<br \/>\n, forwardFromID =&gt; NULL<br \/>\n, DefaultApprovalPathID =&gt; NULL<br \/>\n, Note =&gt; NULL<br \/>\n, PrintFlag =&gt; \u2018N\u2019<br \/>\n, FaxFlag =&gt; \u2018N\u2019<br \/>\n, FaxNumber =&gt; NULL<br \/>\n, EmailFlag =&gt; \u2018N\u2019<br \/>\n, EmailAddress =&gt; NULL<br \/>\n, CreateSourcingRule =&gt; \u2018N\u2019<br \/>\n, ReleaseGenMethod =&gt; \u2018N\u2019<br \/>\n, UpdateSourcingRule =&gt; \u2018N\u2019<br \/>\n, MassUpdateReleases =&gt; \u2018N\u2019<br \/>\n, RetroactivePriceChange =&gt; \u2018N\u2019<br \/>\n, OrgAssignChange =&gt; \u2018N\u2019<br \/>\n, CommunicatePriceChange =&gt; \u2018N\u2019<br \/>\n, p_Background_Flag =&gt; \u2018N\u2019<br \/>\n, p_Initiator =&gt; NULL<br \/>\n, p_xml_flag =&gt; NULL<br \/>\n, FpdsngFlag =&gt; \u2018N\u2019<br \/>\n, p_source_type_code =&gt; NULL);<br \/>\ncommit;<\/p>\n<p>DBMS_OUTPUT.PUT_LINE (\u2018The PO which is Approved Now =&gt;\u2019 p_rec.segment1);<br \/>\nEND LOOP;<br \/>\nEND;<\/p>\n<p><span style=\"color: #0000ff;\"><strong>\u2014 R12 \u2013 PO \u2013 SAMPLE SCRIPT TO APPROVE BLANKET PURCHASE AGREEMENT<\/strong><\/span><\/p>\n<p>DECLARE<\/p>\n<p>v_item_key VARCHAR2(100);<\/p>\n<p>Cursor c_po_details is<br \/>\nSELECT<br \/>\npha.po_header_id,<br \/>\npha.org_id,<br \/>\npha.segment1,<br \/>\npha.agent_id,<br \/>\npdt.document_subtype,<br \/>\npdt.document_type_code,<br \/>\npha.authorization_status,<br \/>\npha.approved_flag,<br \/>\npha.wf_item_type,<br \/>\npha.wf_item_key<br \/>\nFROM apps.po_headers_all pha, apps.po_document_types_all pdt<br \/>\nWHERE pha.type_lookup_code = pdt.document_subtype<br \/>\nAND pha.org_id = pdt.org_id<br \/>\nAND pdt.document_type_code = \u2018PA\u2019<br \/>\nAND authorization_status in (\u2018INCOMPLETE\u2019, \u2018REQUIRES REAPPROVAL\u2019)<br \/>\nAND segment1 = \u201811170000021\u2019; \u2014 Enter the BPA Number<\/p>\n<p>BEGIN<\/p>\n<p>fnd_global.apps_initialize (user_id =&gt; 2083,<br \/>\nresp_id =&gt; 20707,<br \/>\nresp_appl_id =&gt; 201);<\/p>\n<p>FOR p_rec IN c_po_details<\/p>\n<p>LOOP<br \/>\nmo_global.init (\u2018PO\u2019);<br \/>\nmo_global.set_policy_context (\u2018S\u2019, p_rec.org_id);<\/p>\n<p>SELECT p_rec.po_header_id \u2018-\u2018 to_char(po_wf_itemkey_s.NEXTVAL)<br \/>\nINTO v_item_key FROM dual;<\/p>\n<p>dbms_output.put_line (\u2018Calling po_reqapproval_init1.start_wf_process for po_id=&gt;\u2019 p_rec.segment1);<\/p>\n<p>po_reqapproval_init1.start_wf_process(<br \/>\nItemType =&gt; \u2018POAPPRV\u2019<br \/>\n, ItemKey =&gt; v_item_key<br \/>\n, WorkflowProcess =&gt; \u2018POAPPRV_TOP\u2019<br \/>\n, ActionOriginatedFrom =&gt; \u2018PO_FORM\u2019<br \/>\n, DocumentID =&gt; p_rec.po_header_id \u2014 po_header_id<br \/>\n, DocumentNumber =&gt; p_rec.segment1 \u2014 Purchase Order Number<br \/>\n, PreparerID =&gt; p_rec.agent_id \u2014 Buer\/Preparer_id<br \/>\n, DocumentTypeCode =&gt; p_rec.document_type_code\u2013\u2018PA\u2019<br \/>\n, DocumentSubtype =&gt; p_rec.document_subtype \u2013\u2018BLANKET\u2019<br \/>\n, SubmitterAction =&gt; \u2018APPROVE\u2019<br \/>\n, forwardToID =&gt; NULL<br \/>\n, forwardFromID =&gt; NULL<br \/>\n, DefaultApprovalPathID =&gt; NULL<br \/>\n, Note =&gt; NULL<br \/>\n, PrintFlag =&gt; \u2018N\u2019<br \/>\n, FaxFlag =&gt; \u2018N\u2019<br \/>\n, FaxNumber =&gt; NULL<br \/>\n, EmailFlag =&gt; \u2018N\u2019<br \/>\n, EmailAddress =&gt; NULL<br \/>\n, CreateSourcingRule =&gt; \u2018N\u2019<br \/>\n, ReleaseGenMethod =&gt; \u2018N\u2019<br \/>\n, UpdateSourcingRule =&gt; \u2018N\u2019<br \/>\n, MassUpdateReleases =&gt; \u2018N\u2019<br \/>\n, RetroactivePriceChange =&gt; \u2018N\u2019<br \/>\n, OrgAssignChange =&gt; \u2018N\u2019<br \/>\n, CommunicatePriceChange =&gt; \u2018N\u2019<br \/>\n, p_Background_Flag =&gt; \u2018N\u2019<br \/>\n, p_Initiator =&gt; NULL<br \/>\n, p_xml_flag =&gt; NULL<br \/>\n, FpdsngFlag =&gt; \u2018N\u2019<br \/>\n, p_source_type_code =&gt; NULL);<br \/>\ncommit;<br \/>\ndbms_output.put_line (\u2018The BPA which is Approved Now =&gt;\u2019 p_rec.segment1);<\/p>\n<p>END LOOP;<br \/>\nEND;<\/p>\n<p><span style=\"color: #0000ff;\"><strong>\u2014 R12 \u2013 PO \u2013 SAMPLE SCRIPT TO APPROVE PURCHASE REQUISITION<\/strong><\/span><\/p>\n<p>DECLARE<\/p>\n<p>v_item_key VARCHAR2(100);<\/p>\n<p>Cursor c_req_details is<\/p>\n<p>SELECT<br \/>\nprh.requisition_header_id,<br \/>\nprh.org_id,<br \/>\nprh.preparer_id,<br \/>\nprh.segment1,<br \/>\npdt.document_subtype,<br \/>\npdt.document_type_code,<br \/>\nprh.authorization_status<br \/>\nFROM apps.po_requisition_headers_all prh, apps.po_document_types_all pdt<br \/>\nWHERE prh.type_lookup_code = pdt.document_subtype<br \/>\nAND prh.org_id = pdt.org_id<br \/>\nAND pdt.document_type_code = \u2018REQUISITION\u2019<br \/>\nAND NVL (authorization_status, \u2018INCOMPLETE\u2019) = \u2018INCOMPLETE\u2019<br \/>\nAND segment1 = \u201821170000200\u2019; \u2014 Enter The Requisition Number<br \/>\nBEGIN<\/p>\n<p>fnd_global.apps_initialize (user_id =&gt; 1805,<br \/>\nresp_id =&gt; 20707,<br \/>\nresp_appl_id =&gt; 201);<\/p>\n<p>FOR p_rec IN c_req_details<\/p>\n<p>LOOP<\/p>\n<p>mo_global.init (\u2018PO\u2019);<br \/>\nmo_global.set_policy_context (\u2018S\u2019, p_rec.org_id);<\/p>\n<p>SELECT p_rec.requisition_header_id \u2018-\u2018 to_char(po_wf_itemkey_s.NEXTVAL)<br \/>\nINTO v_item_key FROM dual;<\/p>\n<p>dbms_output.put_line (\u2018 Calling po_reqapproval_init1.start_wf_process for requisition =&gt;\u2019 p_rec.segment1);<\/p>\n<p>po_reqapproval_init1.start_wf_process(<br \/>\nItemType =&gt; NULL<br \/>\n, ItemKey =&gt; v_item_key<br \/>\n, WorkflowProcess =&gt; \u2018POAPPRV_TOP\u2019<br \/>\n, ActionOriginatedFrom =&gt; \u2018PO_FORM\u2019<br \/>\n, DocumentID =&gt; p_rec.requisition_header_id \u2014 requisition_header_id<br \/>\n, DocumentNumber =&gt; p_rec.segment1 \u2014 Requisition Number<br \/>\n, PreparerID =&gt; p_rec.preparer_id<br \/>\n, DocumentTypeCode =&gt; p_rec.document_type_code\u2013 REQUISITION<br \/>\n, DocumentSubtype =&gt; p_rec.document_subtype \u2014 PURCHASE<br \/>\n, SubmitterAction =&gt; \u2018APPROVE\u2019<br \/>\n, forwardToID =&gt; NULL<br \/>\n, forwardFromID =&gt; NULL<br \/>\n, DefaultApprovalPathID =&gt; NULL<br \/>\n, Note =&gt; NULL<br \/>\n, PrintFlag =&gt; \u2018N\u2019<br \/>\n, FaxFlag =&gt; \u2018N\u2019<br \/>\n, FaxNumber =&gt; NULL<br \/>\n, EmailFlag =&gt; \u2018N\u2019<br \/>\n, EmailAddress =&gt; NULL<br \/>\n, CreateSourcingRule =&gt; \u2018N\u2019<br \/>\n, ReleaseGenMethod =&gt; \u2018N\u2019<br \/>\n, UpdateSourcingRule =&gt; \u2018N\u2019<br \/>\n, MassUpdateReleases =&gt; \u2018N\u2019<br \/>\n, RetroactivePriceChange =&gt; \u2018N\u2019<br \/>\n, OrgAssignChange =&gt; \u2018N\u2019<br \/>\n, CommunicatePriceChange =&gt; \u2018N\u2019<br \/>\n, p_Background_Flag =&gt; \u2018N\u2019<br \/>\n, p_Initiator =&gt; NULL<br \/>\n, p_xml_flag =&gt; NULL<br \/>\n, FpdsngFlag =&gt; \u2018N\u2019<br \/>\n, p_source_type_code =&gt; NULL);<\/p>\n<p>commit;<\/p>\n<p>dbms_output.put_line (\u2018The Requisition which is Approved =&gt;\u2019 p_rec.segment1);<br \/>\nEND LOOP;<br \/>\nEND;<\/HTML><\/HTML><\/p>\n","protected":false},"excerpt":{"rendered":"<p>PO_REQAPPROVAL_INIT1.START_WF_PROCESS \u00a0&#8211;\u00a0API para Aprovar Ordens de Compra, Contratos de Compra Geral e Requisi\u00e7\u00e3o de Compra &#8230; Algumas vezes, estamos nos perguntando o que exatamente a&hellip; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[29,127],"tags":[],"class_list":["post-15650","post","type-post","status-publish","format-standard","hentry","category-base-de-conhecimentos","category-applications"],"_links":{"self":[{"href":"https:\/\/orabr.virttus.com\/index.php?rest_route=\/wp\/v2\/posts\/15650","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/orabr.virttus.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/orabr.virttus.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/orabr.virttus.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/orabr.virttus.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=15650"}],"version-history":[{"count":1,"href":"https:\/\/orabr.virttus.com\/index.php?rest_route=\/wp\/v2\/posts\/15650\/revisions"}],"predecessor-version":[{"id":15651,"href":"https:\/\/orabr.virttus.com\/index.php?rest_route=\/wp\/v2\/posts\/15650\/revisions\/15651"}],"wp:attachment":[{"href":"https:\/\/orabr.virttus.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=15650"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/orabr.virttus.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=15650"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/orabr.virttus.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=15650"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}