摘自:Document Display (oracle.com)
Is There Any Public API To Cancel Move Orders? (Answer: Yes) (Doc ID 1925418.1) |
In this Document
Goal |
Solution |
API Example |
References |
APPLIES TO:
Oracle Inventory Management - Version 11.5.9 and later
Information in this document applies to any platform.
GOAL
Is there any public API to cancel move orders which are not processed yet?
SOLUTION
The Move Order Admin API (INV_MO_ADMIN_PUB) provides the public procedures to Cancel, Close or Purge orders and order lines.
For lines:
- Cancel_Line
- Close_Line
For orders:
- Cancel_Order
- Close_Order
- Purge_Order
API Example
Here is an example of closing lines. The benefit of closing lines is that it will also clear the allocations (pending transactions in MTL_MATERIAL_TRANSACTIONS_TEMP).
The script uses values like user id, responsibility id, and move order line id. To find the values, you can use these SQL scripts:
-- a) You can confirm user id with this query:
select user_id, user_name from fnd_user where user_id = &UserID;
-- b) You can select a responsibility id with SQL like this -- This looks for the the inventory responsibility:
SELECT responsibility_id
FROM FND_RESPONSIBILITY
WHERE responsibility_key = 'ORACLE_INVENTORY';
-- c) Confirm the application id (401) with this query:
SELECT application_id
FROM FND_APPLICATION
WHERE application_short_name = 'INV';
-- d) Confirm move order line id:
select a.line_id, a.header_id, b.request_number
from mtl_txn_request_lines a, mtl_txn_request_headers b
where a.header_id = b.header_id
and a.line_id = &YourLineID
and b.request_number = '&YourMoveOrder';
2. Here is an example of using the API:
-- SQL SCRIPT : Close Move Order Line and Remove Pending Record
set serveroutput on;
DECLARE
l_status VARCHAR2(1);
l_msg_count NUMBER;
l_msg_data VARCHAR2(240);
l_error_message_list error_handler.error_tbl_type;
BEGIN
DBMS_OUTPUT.put_line('Starting');
fnd_global.APPS_INITIALIZE(
&UserID, -- User ID: You can use the ame user id that created Move order (MO). Replace with yours from query a)
&Responsibility, -- Responsibility ID: This is my inventory responsibility. Replace with yours from query b)
401);
INV_MO_ADMIN_PUB.Close_Line
(
p_api_version => 1.0
, p_line_Id => &LineID -- Confirm line id with SQL d)
, x_msg_count => l_msg_count
, x_msg_data => l_msg_data
, x_return_status => l_status
);
IF l_status = fnd_api.g_ret_sts_success THEN
DBMS_OUTPUT.put_line('ok');
ELSE
DBMS_OUTPUT.put_line('Error.');
DBMS_OUTPUT.PUT_LINE('Error Message :'||l_msg_data);
Error_Handler.Get_Message_List (x_message_list => l_error_message_list);
for i in 1..l_error_message_list.COUNT LOOP
dbms_output.put_line('Entity Id : '||l_error_message_list(i).entity_id);
dbms_output.put_line('Index : '||l_error_message_list(i).entity_index);
dbms_output.put_line('Message Type : '||l_error_message_list(i).message_type);
dbms_output.put_line('Mesg : '||SUBSTR(l_error_message_list(i).message_text,1,500));
dbms_output.put_line('-------------------------------------------------------------------');
end loop;
END IF;
-- commit;
DBMS_OUTPUT.put_line('Finishing');
end;
/