In Order to close only lines/shipments pass values to p_line_id / p_shipment_id arguments in the API along with header level details.
Eg: If only line has to be closed then pass line_id along with header_id. Same way if shipment line has to be closed then header_id, line_id, line_location_id(shipment_id) has to be passed.
DECLARE
v_returned BOOLEAN;
v_return_code_h VARCHAR2(1);
lc_return_status VARCHAR2(50);
lc_exception_msg VARCHAR2(4000);
lc_return_code VARCHAR2(50);
ln_online_report_id NUMBER;
lc_doc_type VARCHAR2(240);
BEGIN
FOR po_head IN
(SELECT * FROM PO_CLOSED_TBL opc WHERE process_flag = 'N'
)
LOOP
FND_GLOBAL.APPS_INITIALIZE (user_id,resp_id, 201);
select decode(po_head.document_type_code,'STANDARD','PO','PA') INTO lc_doc_type from dual;
PO_DOCUMENT_ACTION_PVT.do_manual_close( p_action => 'FINALLY CLOSE' ,
p_document_id => po_head.po_header_id ,
p_document_type => lc_doc_type ,
p_document_subtype => po_head.document_type_code ,
p_line_id => null,--po_head.po_line_id ,
p_shipment_id => NULL ,
p_reason => 'Put reason for close' ,
p_action_date => SYSDATE ,
p_calling_mode => 'PO' ,
p_origin_doc_id => NULL ,
p_called_from_conc => FALSE ,
p_use_gl_date => 'N' ,
x_return_status => lc_return_status ,
x_exception_msg => lc_exception_msg ,
x_return_code => lc_return_code ,
x_online_report_id => ln_online_report_id );
IF lc_return_status = 'S' THEN
--do your thing
ELSE
--do your thing
END IF;
COMMIT;
END LOOP;
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line(' Exception closing PO using PO_ACTIONS.CLOSE_PO'||SQLERRM);
END;
This code snippet is returning SUBMISSION_ERROR. DO you have any clue on the reason behind.
ReplyDeleteThanks for sharing. Very Useful.
ReplyDelete