2010年12月17日星期五

Oracle PO API to mass close PO

The following procedure has to be executed in Oracle environnement, but not in TOAD or SQL Developper with contexualization.

PROCEDURE Mass_close_PO(
PR_po_header_id IN NUMBER,
PR_po_line_id IN NUMBER,
PR_po_shipment_id IN NUMBER,
PR_action IN VARCHAR2,
PR_reason IN VARCHAR2,
PR_result OUT BOOLEAN,
PR_return_code OUT VARCHAR2
) IS
-- =====================================================================
-- P R O C E D U R E Mass_close_PO
-- =====================================================================
-- Description : Mass close or finally close PO
-- =====================================================================
-- I N P U T
-- =====================================================================
-- Nom Description
-- PR_po_header_id po_header_id
-- PR_po_line_id po_line_id
-- PR_po_shipment_id po_shipment_id
-- PR_action po_action
-- PR_reason po_closed_reason
-- =====================================================================
-- O U T P U T
-- =====================================================================
-- Nom Description
-- PR_result TRUE or FALSE
-- PR_return_code Error message
-- =====================================================================


BEGIN
g_step := 'Mass_close_PO - PR_po_header_id = '|| PR_po_header_id || ' PR_po_line_id = ' || PR_po_line_id || ' PR_po_shipment_id = ' || PR_po_shipment_id;
fnd_file.put_line(fnd_file.log, to_char(SYSDATE,'DD-MM-RRRR HH24:MI:SS : ') || g_step);

PR_result := PO_ACTIONS.CLOSE_PO(
P_DOCID => PR_po_header_id,
P_DOCTYP => 'PO',
P_DOCSUBTYP => 'STANDARD',
P_LINEID => PR_po_line_id,
P_SHIPID => PR_po_shipment_id,
P_ACTION => PR_action,
P_REASON => PR_reason,
P_CALLING_MODE => 'PO',
P_CONC_FLAG => 'N',
P_RETURN_CODE => PR_return_code,
P_AUTO_CLOSE => 'N' ,
P_ACTION_DATE => SYSDATE ,
P_ORIGIN_DOC_ID => NULL
);

EXCEPTION
WHEN OTHERS THEN
RAISE;
END Mass_close_PO;


Create a cursor to select eligible shipment lines in po_line_locations_all. Specify the action (CLOSE or FINALLY CLOSE) and the closed reason, call the below procedure to mass close PO.

The standard logic of this API will be the following : after closing the shipment line, the program will control the related po line, if all shipment line are closed or finally closed, api will close this po line. Item for the po header, if all related po lines are closed or finally closed, api will close the po header.

没有评论:

发表评论