Tuesday, 7 January 2014

Change PO API




What are the steps required in order to use the Change PO API to update a Standard Purchase Order ?

The example shown in this note is based on data in the Vision Demo database including User, Responsibility, Item, Inventory Organization, Supplier, Site, etc.

FIX

Login to the application using the seeded user/password Operations/welcome then Navigate to the Purchasing Responsibility : Purchasing Vision Operations (USA)

Navigate to the Purchase Order form and create a PO with a single line with quantity = 10, price = 1 and promised date = 31-MAR-2010 (use any date in the future as long as it is in an open period). The Purchase Order screen will look like the following screenshot :

Querying the same PO through the PO Summary form, all the relevant line data can be seen :

Clicking on the Shipments button shows the relevant Shipment information :

The first run of the API will demonstrate updating the Quantity of Line 1 of the PO to 25. Submit the change API using sqlplus as follows :
DECLARE
l_result NUMBER;
l_api_errors PO_API_ERRORS_REC_TYPE;
BEGIN
-- This needs to be changed according to your environment setup.
fnd_global.apps_initialize(1318,50578,201);
-- mo_global.init('PO'); -- need for R12
l_result := PO_CHANGE_API1_S.update_po (
x_po_number => 23998,
x_release_number => NULL,
x_revision_number => 0,
x_line_number => 1,
x_shipment_number => 1,
new_quantity => 25,
new_price => NULL,
new_promised_date => NULL,
launch_approvals_flag =>'N',
update_source => NULL,
version => '1.0',
x_override_date => NULL,
x_api_errors => l_api_errors,
p_buyer_name => null
);
IF (l_result <> 1) THEN
-- Display the errors
FOR i IN 1..l_api_errors.message_text.COUNT LOOP
dbms_output.put_line ( l_api_errors.message_text(i) );
END LOOP;
END IF;
END;

commit;

Querying the PO line again in the PO Summary form shows :

The second run of the API will demonstrate updating the Price of Line 1 of the PO to 0.9. Submit the change API using sqlplus as follows :
DECLARE
l_result NUMBER;
l_api_errors PO_API_ERRORS_REC_TYPE;
BEGIN
-- This needs to be changed according to your environment setup.
fnd_global.apps_initialize(1318,50578,201);
-- mo_global.init('PO'); -- need for R12
l_result := PO_CHANGE_API1_S.update_po (
x_po_number => 23998,
x_release_number => NULL,
x_revision_number => 0,
x_line_number => 1,
x_shipment_number => 1,
new_quantity => NULL,
new_price => 0.9,
new_promised_date => NULL,
launch_approvals_flag =>'N',
update_source => NULL,
version => '1.0',
x_override_date => NULL,
x_api_errors => l_api_errors,
p_buyer_name => null
);
IF (l_result <> 1) THEN
-- Display the errors
FOR i IN 1..l_api_errors.message_text.COUNT LOOP
dbms_output.put_line ( l_api_errors.message_text(i) );
END LOOP;
END IF;
END;

commit;

Requerying the PO line shows that the price has been changed as expected :

The third run of the API will demonstrate updating the Promised Date of Shipment 1 (of Line 1) of the PO to 30-Mar-2010. Submit the change API using sqlplus as follows :
DECLARE
l_result NUMBER;
l_api_errors PO_API_ERRORS_REC_TYPE;
BEGIN
-- This needs to be changed according to your environment setup.
fnd_global.apps_initialize(1318,50578,201);
-- mo_global.init('PO'); -- need for R12
l_result := PO_CHANGE_API1_S.update_po (
x_po_number => 23998,
x_release_number => NULL,
x_revision_number => 0,
x_line_number => 1,
x_shipment_number => 1,
new_quantity => NULL,
new_price => NULL,
new_promised_date => '30-MAR-2010',
launch_approvals_flag =>'N',
update_source => NULL,
version => '1.0',
x_override_date => NULL,
x_api_errors => l_api_errors,
p_buyer_name => null
);
IF (l_result <> 1) THEN
-- Display the errors
FOR i IN 1..l_api_errors.message_text.COUNT LOOP
dbms_output.put_line ( l_api_errors.message_text(i) );
END LOOP;
END IF;
END;

commit;

Querying the PO Shipment from the PO Summary form shows that the update was successful :




The following information from Page 131 of the Oracle Manufacturing APIs and Open Interfaces Manual explains setting the org context :

Setting Context
Prior to calling the API you should set your global context to reflect the application, user and responsibility used to perform the change action. If you do not set this context, the API will not be able to identify or update your data. If you are calling the API from an environment that already has the context set you do not need to set it again.
The call that may be used to set the global context is: fnd_global.apps_initialize(user_id, resp_id, resp_application_id); user_id is an FND_USER who would be allowed to perform the change action. Resp_id is the id of the responsibility that is being used to modify the document. This id will also set the context for the operating unit for the document being updated.

The Oracle Manufacturing APIs and Open Interfaces Manual can be found in Note 67108.1.


2 comments:

CREATING A SUPPLIER IN R12 (Functional and SUPPLIERS IN TCA)

Who is a Supplier? Let us now understand who is a Supplier with the help of a simple example: We consider us as a business, who sell...