The PL/SQL procedure, PO_Document_Control_PUB.control_document , provides the ability to cancel Oracle Purchasing documents directly through an API. The API will perform all of the same processing that would be done if a cancellation was requested through the PO Summary Control Window.
Prior to calling the API you should set your global context to reflect the application, user and responsibility used to perform the cancel action. If you do not set this context, the API will not be able to identify or update your data.
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 cancellation action. Resp_id is the id of the responsibility that is being used to cancel the document. This id will also set the context for the operating unit for the document being canceled.
In R12 you have to also set the Multi-Org context.
begin
fnd_global.apps_initialize(&user_id,&responsibility_id,&responsibility_application_id);
mo_global.init('&product_short_name');
end;
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 cancellation action. Resp_id is the id of the responsibility that is being used to cancel the document. This id will also set the context for the operating unit for the document being canceled.
In R12 you have to also set the Multi-Org context.
begin
fnd_global.apps_initialize(&user_id,&responsibility_id,&responsibility_application_id);
mo_global.init('&product_short_name');
end;
After returning from the call to the API you may check for any messages returned by the API by using the FND_MSG_PUB package. The following code will display all of the messages returned by the API:
FOR i IN 1..FND_MSG_PUB.count_msg
LOOP
DBMS_OUTPUT.put_line(FND_MSG_PUB.Get(p_msg_index => i,
p_encoded => 'F'));
END LOOP;
All Parameters must be provided, even if provided as NULL. Nulls are allowed unless otherwise indicated
EXAMPLE:
=========
DECLARE
l_return_status VARCHAR2(1);
BEGIN
fnd_global.apps_initialize(( user_id => 1318, resp_id => 50578, resp_appl_id => 201 );;
-- mo_global.init('PO'); -- need for R12
--call the Cancel API for PO number PO123
PO_Document_Control_PUB.control_document (
1.0, -- p_api_version
FND_API.G_TRUE, -- p_init_msg_list
FND_API.G_TRUE, -- p_commit
l_return_status, -- x_return_status
'PO', -- p_doc_type
'STANDARD', -- p_doc_subtype
null, -- p_doc_id
'PO123, -- p_doc_num
null, -- p_release_id
null, -- p_release_num
null, -- p_doc_line_id
null, -- p_doc_line_num
null, -- p_doc_line_loc_id
null, -- p_doc_shipment_num
'CANCEL', -- p_action
SYSDATE, -- p_action_date
null, -- p_cancel_reason
'N', -- p_cancel_reqs_flag
null, -- p_print_flag
null ); -- p_note_to_vendor
-- Get any messages returned by the Cancel API
FOR i IN 1..FND_MSG_PUB.count_msg
LOOP
DBMS_OUTPUT.put_line(FND_MSG_PUB.Get(p_msg_index => i,
p_encoded => 'F'));
END LOOP;
END;
FOR i IN 1..FND_MSG_PUB.count_msg
LOOP
DBMS_OUTPUT.put_line(FND_MSG_PUB.Get(p_msg_index => i,
p_encoded => 'F'));
END LOOP;
All Parameters must be provided, even if provided as NULL. Nulls are allowed unless otherwise indicated
EXAMPLE:
=========
DECLARE
l_return_status VARCHAR2(1);
BEGIN
fnd_global.apps_initialize(( user_id => 1318, resp_id => 50578, resp_appl_id => 201 );;
-- mo_global.init('PO'); -- need for R12
--call the Cancel API for PO number PO123
PO_Document_Control_PUB.control_document (
1.0, -- p_api_version
FND_API.G_TRUE, -- p_init_msg_list
FND_API.G_TRUE, -- p_commit
l_return_status, -- x_return_status
'PO', -- p_doc_type
'STANDARD', -- p_doc_subtype
null, -- p_doc_id
'PO123, -- p_doc_num
null, -- p_release_id
null, -- p_release_num
null, -- p_doc_line_id
null, -- p_doc_line_num
null, -- p_doc_line_loc_id
null, -- p_doc_shipment_num
'CANCEL', -- p_action
SYSDATE, -- p_action_date
null, -- p_cancel_reason
'N', -- p_cancel_reqs_flag
null, -- p_print_flag
null ); -- p_note_to_vendor
-- Get any messages returned by the Cancel API
FOR i IN 1..FND_MSG_PUB.count_msg
LOOP
DBMS_OUTPUT.put_line(FND_MSG_PUB.Get(p_msg_index => i,
p_encoded => 'F'));
END LOOP;
END;
No comments:
Post a Comment