Wednesday, August 26, 2020

API to Mass Close Purchase Order in R12 - PO_MASS_CLOSE_PO_GRP.DO_CLOSE








In this Post, we have given a script to close a single Purchase Order or mass close multiple purchase order.  

Key Constraints:

  1. PO Should not be cancelled
  2. PO should be in OPEN status
  3. PO should be in APPROVED status 
  4. The user who is executing should be a Buyer and Employee


Tested Instance: R12.2


SET SERVEROUTPUT ON; DECLARE lv_msg_data VARCHAR2(100); ln_msg_count NUMBER; lv_return_status VARCHAR2(1); ln_org_id NUMBER; ln_vendor_id NUMBER; lv_document_no VARCHAR2(200) DEFAULT '310234567'; BEGIN SELECT org_id, vendor_id INTO ln_org_id, ln_vendor_id FROM po_headers_all pha WHERE pha.segment1 = lv_document_no; -- Initialize Environment with buyer login and responsibility with org_id access fnd_global.apps_initialize(user_id => 128, resp_id => 93987, resp_appl_id => 201 ); mo_global.init('PO'); fnd_client_info.set_org_context(ln_org_id); mo_global.set_policy_context ('S', ln_org_id); po_mass_close_po_grp.do_close(p_document_type => 'STANDARD', p_document_no_from => lv_document_no, p_document_no_to => lv_document_no, p_date_from => NULL, p_date_to => NULL, p_supplier_id => ln_vendor_id, p_commit_interval => 1, p_msg_data => lv_msg_data, p_msg_count => ln_msg_count, p_return_status => lv_return_status ); DBMS_OUTPUT.PUT_LINE('Message_data :'|| lv_msg_data); DBMS_OUTPUT.PUT_LINE('Message_count :'|| ln_msg_count); DBMS_OUTPUT.PUT_LINE('Return_status :'|| lv_return_status); EXCEPTION WHEN OTHERS THEN DBMS_OUTPUT.PUT_LINE('Error: '||SQLERRM); END;

1 Responses to “API to Mass Close Purchase Order in R12 - PO_MASS_CLOSE_PO_GRP.DO_CLOSE”

Anonymous said...
June 4, 2021 at 4:45 AM

can we able to do it for Blanket PO

Post a Comment


The ideas, thoughts and concepts expressed here are my own. They, in no way reflect those of my employer or any other organization/client that I am associated. The articles presented doesn't imply to any particular organization or client and are meant only for knowledge Sharing purpose. The articles can't be reproduced or copied without the Owner's knowledge or permission.