, , , , , , ,

API for Closing/Finally Closing PO Using po_actions.close_po

Do we have any API for Finally Closing PO??
Yes, we are having an API for closing or finally closing the POs. In the API, there is a parameter “p_action” which we need to set as either CLOSE (if we want to close the PO) or FINALLY CLOSE (If we want to Finally Close) the PO. Another Parameter which needs to set properly is “p_auto_close”. This parameter should be set to ‘N’.
— R12 – PO – Script to Close / Finally Close PO using PO_ACTIONS CLOSE_PO API.sql

DECLARE

x_action constant varchar2(20) := ‘FINALLY CLOSE’; — Change this parameter as per requirement
x_calling_mode constant varchar2(2) := ‘PO’;
x_conc_flag constant varchar2(1) := ‘N’;
x_return_code_h varchar2(100);
x_auto_close constant varchar2(1) := ‘N’;
x_origin_doc_id number;
x_returned boolean;

CURSOR c_po_details IS

SELECT
pha.po_header_id,
pha.org_id,
pha.segment1,
pha.agent_id,
pdt.document_subtype,
pdt.document_type_code,
pha.closed_code,
pha.closed_date
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 = ‘APPROVED’
AND pha.closed_code <> ‘FINALLY CLOSED’
AND segment1 = ‘379329’; — Enter the PO Number if one PO needs to be finally closed/Closed

begin

fnd_global.apps_initialize (user_id => 1805,
resp_id => 20707,
resp_appl_id => 201);

for po_head in c_po_details

LOOP

mo_global.init (po_head.document_type_code);
mo_global.set_policy_context (‘S’, po_head.org_id);

DBMS_OUTPUT.PUT_LINE (‘Calling PO_Actions.close_po for Closing/Finally Closing PO =>’ po_head.segment1);

x_returned :=
po_actions.close_po(
p_docid => po_head.po_header_id,
p_doctyp => po_head.document_type_code,
p_docsubtyp => po_head.document_subtype,
p_lineid => NULL,
p_shipid => NULL,
p_action => x_action,
p_reason => NULL,
p_calling_mode => x_calling_mode,
p_conc_flag => x_conc_flag,
p_return_code => x_return_code_h,
p_auto_close => x_auto_close,
p_action_date => SYSDATE,
p_origin_doc_id => NULL);

IF x_returned = TRUE THEN

DBMS_OUTPUT.PUT_LINE (‘Purchase Order which just got Closed/Finally Closed is ‘ po_head.segment1);

COMMIT;

ELSE

DBMS_OUTPUT.PUT_LINE (‘API Failed to Close/Finally Close the Purchase Order’);

END IF;

END LOOP;

END;

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply