Implementation of PL/SQL for closing a purchase order

Source: Internet
Author: User
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;

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.