At the customer's requirement, a script is required to close the Bonus Item procurement orders in batches. Some methods are found on metalink, but none of them can be tested. It turns out that you need to generate a concurrent program for the code. The code for successful testing is as follows.
1. Create a stored procedure, and then call PO_ACTIONS.CLOSE_PO In the stored procedure.
2. Register a stored procedure-type concurrent program
3. Test results in application.
Create or replace procedure xx_po_close
(
Err_buff out varchar2,
Retcode out number,
P_reason_desc varchar2,
P_po_from varchar2,
P_po_to varchar2)
As
Rochelle return_code varchar2 (2000 );
Rochelle result boolean;
Cursor po_close_cur
Is
Select poh. segment1,
Poll. po_header_id,
Poll. po_line_id,
Poll. line_location_id
From po_line_locations_all poll,
Po_headers_all poh,
Po_lines_all pol
Where poll. po_header_id = poh. po_header_id
And poll. po_line_id = pol. po_line_id
And pol. po_header_id = poh. po_header_id
And upper (poh. authorization_status) = 'apache'
And upper (poll. closed_code) = 'Closed FOR grouping'
And (pol. unit_price = 0 or
Poh. quantity_billed-poh. quantity> = 0)
And poh. segment1 between p_po_from and p_po_to;
Begin
For po_close_rec in po_close_cur
Loop
Rochelle result: = po_actions.close_po (
P_docid => po_close_rec.po_header_id,
P_doctyp => 'po ',
P_docsubtyp => 'standard ',
P_lineid => po_close_rec.po_line_id,
P_shipid => po_close_rec.line_location_id,
P_action => 'close ',
P_reason => p_reason_desc,
P_calling_mode => 'po ',
P_conc_flag => 'n ',
P_return_code => l_return_code,
P_auto_close => 'n ',
P_action_date => sysdate,
P_origin_doc_id => null );
If l_result then
Fnd_file.put_line (fnd_file.output,
Po_close_rec.segment1 'is Closed .');
Else
Fnd_file.put_line (fnd_file.output,
Po_close_rec.segment1 'is not Closed .');
End if;
End loop;
End;