Declare -- local variables here I integer; l_return_status varchar2 (10); p_retcode varchar2 (2000); p_errbuf varchar2 (2000); v_x_return_status varchar2 (250); v_x_exception_msg varchar2 (250 ); begin -- Test statements here for REC in (select pha.org _ id, PHA. segment1, PHA. po_header_id erp_header_id from po_headers_all PHA where 1 = 1 and pha.org _ id = 86 and PHA. segment1 like 'cxy-% 'and PHA. created_by= 1150 and PHA. cancel_flag <> 'y') loop apps. fnd_global.pai_initialize (user_id => 1150, -- v_user_id, resp_id => 50758, -- p_resp_id, 50757 50737 50758 resp_appl_id => 201); pai.mo _ global. init ('po'); -- dbms_output.put_line (p_user_id | '*' | v_user_id | '*' | p_resp_id); dbms_output.put_line ('------' | rec. segment1 | '------'); dbms_output.put_line (l_return_status); apps. po_document_control_pub.control_document (p_api_version => 1.0, -- p_api_version p_init_msg_list => apps. fnd_api.g_true, -- p_init_msg_list p_commit => apps. success, -- p_commit x_return_status => l_return_status, -- x_return_status p_doc_type => 'po', -- p_doc_type p_doc_subtype => 'standard', -- p_doc_subtype p_doc_id => null, -- p_doc_id p_doc_num => rec. segment1, -- p_doc_num p_release_id => null, -- p_release_id p_release_num => null, -- p_release_num p_doc_line_id => null, -- p_doc_line_id p_doc_line_num => null, -- rec. line_num, -- p_doc_line_num p_doc_line_loc_id => null, -- rec. line_location_id, -- cmdp_doc_shipment_num => null, -- p_doc_shipment_num p_action => 'cancel', -- p_action p_action_date => sysdate, -- p_action_date p_cancel_reason => 'start data import error ', -- p_cancel_reason p_cancel_reqs_flag => 'n', -- p_cancel_reqs_flag p_print_flag => null, -- p_print_flag p_note_to_vendor => null, p_use_gldate => null, -- <encumbrance FPJ> p_org_id => rec.org _ id); -- p_note_to_vendor -- get any messages returned by the cancel API commit; for I in 1 .. apps. fnd_msg_pub.count_msg loop dbms_output.put_line (apps. fnd_msg_pub.get (p_msg_index => I, p_encoded => 'F'); p_errbuf: = apps. fnd_msg_pub.get (p_msg_index => I, p_encoded => 'F'); End loop; commit; If l_return_status = 's' then begin apps. po_document_action_pvt.do_approve (p_document_id => rec. erp_header_id, -- po_header_id p_document_type => 'po', p_document_subtype => 'standard', p_note => null, response => null, x_return_status => v_x_return_status, x_exception_msg => response ); values ('v _ x_return_status: '| v_x_return_status); values ('v _ x_exception_msg:' | v_x_exception_msg); If v_x_return_status = 's' then commit; else rollback; end if; end; dbms_output.put_line ('y'); dbms_output.put_line ('canceled successfully'); Commit; else dbms_output.put_line ('E'); dbms_output.put_line ('canceled: '| p_errbuf); end if; commit; ---- update po_header ---- update the approval status of the header line end loop; end;
Close purchase order