Wednesday, September 10, 2014

API to Re-Open Closed Purchase Orders

Dear Reader

In this post we will cover a useful API which can be used when there is a requirement to re-open a Purchase Order in Oracle which is CLOSED

This same action can be done via the application by going to Purchase Orders Summary --> Control --> Action and then choosing the Open action

However, this API will allow the same to be done in bulk for multiple POs if needed

There are a few things to note however as below
1. This is a private API of Oracle so the parameters/signature of the API is not guaranteed against changes by Oracle
2. If you call the API at the header level (i.e. do not pass line ID or line location ID), then the API will change the CLOSED_CODE on all tables (PO_HEADERS_ALL, PO_LINES_ALL and PO_LINE_LOCATIONS_ALL) to OPEN. It will do this even for records which may be CANCELLED in the lines table which can be an issue so be careful how you use the API

And finally, here is the API code itself and I hope this helps you in case you have a similar requirement

DECLARE
l_return_status   VARCHAR2(2000);
l_return_code  VARCHAR2(2000);
l_exc_msg   VARCHAR2(2000);
l_online_report_id NUMBER;
BEGIN
      PO_DOCUMENT_ACTION_PVT.do_manual_close(
         p_action            => 'OPEN'
      ,  p_document_id       => 312269 --po_header_id
      ,  p_document_type     => 'PO'
      ,  p_document_subtype  => 'STANDARD' --pass BLANKET in case of a BPA
      ,  p_line_id           => NULL --pass a line ID if specific line is to open
      ,  p_shipment_id       => NULL --pass a line location ID if specific shipment line is to open
      ,  p_reason            => 'Testing API Open'--give any free-text reason
      ,  p_action_date       => To_date('10-SEP-2014','DD-MON-YYYY') --pass SYSDATE in specific format
      ,  p_calling_mode      => 'PO'
      ,  p_origin_doc_id     => NULL
      ,  p_called_from_conc  => TRUE--this should be TRUE as it is not called from the GUI
      ,  p_use_gl_date       => NVL(NULL, 'N')
      ,  x_return_status     => l_return_status
      ,  x_return_code       => l_return_code
      ,  x_exception_msg     => l_exc_msg
      ,  x_online_report_id  => l_online_report_id
      );
END;



Cheers
A

3 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. i am getting below error

    po.plsql.PO_DOCUMENT_ACTION_CLOSE.manual_close_po:20:user id not found

    ReplyDelete