--Sales Order Lines to backorder API
--===================================
--SET serveroutput on size 1000000
DECLARE
l_return_status VARCHAR2(100);
l_msg_count NUMBER;
l_msg_data VARCHAR2(2000);
l_msg_index NUMBER;
l_user_id NUMBER;
l_resp_id NUMBER;
l_appl_id NUMBER;
l_org_id NUMBER := &org_id;
l_move_order_line_id NUMBER := &mo_line_id ;
BEGIN
SELECT user_id
INTO l_user_id
FROM fnd_user
WHERE user_name = ‘SYSADMIN‘;
SELECT responsibility_id
,application_id
INTO l_resp_id
,l_appl_id
FROM fnd_responsibility_vl
WHERE responsibility_name = ‘KW_ALL_制造及供应链全职责‘;
FND_GLOBAL.apps_initialize (l_user_id, l_resp_id, l_appl_id);
MO_GLOBAL.set_policy_context (‘S‘, l_org_id);
--MO_GLOBAL.init;
DBMS_OUTPUT.put_line (‘Calling INV_MO_BACKORDER_PVT to Backorder MO‘);
DBMS_OUTPUT.put_line (‘===============================‘);
inv_mo_backorder_pvt.backorder (p_line_id => l_move_order_line_id
,x_return_status => l_return_status
,x_msg_count => l_msg_count
,x_msg_data => l_msg_data);
DBMS_OUTPUT.put_line (‘Return Status is : ‘|| l_return_status);
-- Check Return Status
IF l_return_status = fnd_api.g_ret_sts_success THEN
DBMS_OUTPUT.put_line (‘Successfully BackOrdered the Move Order Line‘);
COMMIT;
ELSE
DBMS_OUTPUT.put_line (‘Could not able to Back Order Line Due to Following Reasons‘ );
ROLLBACK;
FOR j IN 1 .. l_msg_count LOOP
FND_MSG_PUB.get(p_msg_index => j
,p_encoded => fnd_api.g_false
,p_data => l_msg_data
,p_msg_index_out => l_msg_index);
DBMS_OUTPUT.put_line (‘Error Message is : ‘|| l_msg_data);
END LOOP;
END IF;
END;