0% found this document useful (0 votes)
15 views3 pages

XX Allocate Move Order Proc New

Uploaded by

satish1981
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views3 pages

XX Allocate Move Order Proc New

Uploaded by

satish1981
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

CREATE OR REPLACE PROCEDURE xx_allocate_move_order_proc

IS
-- Common Declarations
l_api_version NUMBER := 1.0;
l_init_msg_list VARCHAR2 (2) := fnd_api.g_true;
l_return_values VARCHAR2 (2) := fnd_api.g_false;
l_commit VARCHAR2 (2) := fnd_api.g_true;
x_return_status VARCHAR2 (200);
x_msg_count NUMBER := 0;
x_msg_data VARCHAR2 (255);
-- WHO columns
l_user_id NUMBER := -1;
l_resp_id NUMBER := -1;
l_application_id NUMBER := -1;
l_row_cnt NUMBER := 1;
l_user_name VARCHAR2 (30) :=
'IN_STD_COSTING';
l_resp_name VARCHAR2 (30) :=
'XXWSH_SE_SHIPPER_FACTORY_ENPI';
-- API specific declarations
l_trohdr_rec inv_move_order_pub.trohdr_rec_type;
l_trohdr_val_rec inv_move_order_pub.trohdr_val_rec_type;
x_trohdr_rec inv_move_order_pub.trohdr_rec_type;
x_trohdr_val_rec inv_move_order_pub.trohdr_val_rec_type;
l_validation_flag VARCHAR2 (2)
:= inv_move_order_pub.g_validation_yes;
l_trolin_tbl inv_move_order_pub.trolin_tbl_type;
l_trolin_val_tbl inv_move_order_pub.trolin_val_tbl_type;
x_trolin_tbl inv_move_order_pub.trolin_tbl_type;
x_trolin_val_tbl inv_move_order_pub.trolin_val_tbl_type;
l_line_id mtl_txn_request_lines.line_id%TYPE ; ---
p_move_order_line_id-- check with SELECT * FROM MTL_TXN_REQUEST_LINES WHERE
INVENTORY_ITEM_ID=
l_move_order_type mtl_txn_request_headers.move_order_type%TYPE:=3; ---
check with SELECT * FROM MTL_TXN_REQUEST_HEADERS WHERE HEADER_ID =
--x_detailed_qty NUMBER := 0;
x_number_of_rows NUMBER :=100;
x_revision VARCHAR2 (3);
x_locator_id NUMBER := 0;
x_transfer_to_location NUMBER := 0;
x_lot_number VARCHAR2 (30);
x_expiration_date DATE;
x_transaction_temp_id NUMBER := 0;
CURSOR move_order_cur IS SELECT * FROM xx_txn_request_lines_stg1 ;--
WHERE alloc_process_flag='New';
BEGIN
-- Get the user_id
SELECT user_id
INTO l_user_id
FROM fnd_user
WHERE user_name = l_user_name;
-- Get the application_id and responsibility_id
SELECT application_id, responsibility_id
INTO l_application_id, l_resp_id
FROM fnd_responsibility
WHERE responsibility_key = l_resp_name;
fnd_global.apps_initialize (l_user_id, l_resp_id, l_application_id);
BEGIN
FOR move_order_rec IN move_order_cur LOOP
-- Allocate each line of the Move Order
inv_replenish_detail_pub.line_details_pub
(p_line_id => move_order_rec.line_id,
x_number_of_rows => x_number_of_rows,
x_detailed_qty =>
move_order_rec.quantity,
x_return_status => x_return_status,
x_msg_count => x_msg_count,
x_msg_data => x_msg_data,
x_revision => x_revision,
x_locator_id => x_locator_id,
x_transfer_to_location => x_transfer_to_location,
x_lot_number => x_lot_number,
x_expiration_date => x_expiration_date,
x_transaction_temp_id => x_transaction_temp_id,
p_transaction_header_id => NULL,
p_transaction_mode => NULL,
p_move_order_type =>
move_order_rec.move_order_type,
p_serial_flag => fnd_api.g_false,
p_plan_tasks => FALSE,
p_auto_pick_confirm => FALSE,
p_commit => TRUE
--FND_API.G_FALSE
);
dbms_output.put_line
('==========================================================');
dbms_output.put_line ('Return Status: ' || x_return_status||' and ID : '||
x_transaction_temp_id);
IF (x_return_status <> fnd_api.g_ret_sts_success)
THEN
dbms_output.put_line ('Error Message :' || x_msg_data);
UPDATE xx_txn_request_lines_stg SET alloc_process_flag
='SE',alloc_error_msg=x_msg_data
WHERE alloc_process_flag='New'
AND line_id=move_order_rec.line_id;
END IF;
IF (x_return_status = fnd_api.g_ret_sts_success)
THEN
COMMIT;
dbms_output.put_line ('Detailed Qty: ' || move_order_rec.quantity);
dbms_output.put_line ('Number of rows: ' || x_number_of_rows);
dbms_output.put_line ('Trx temp ID: ' || x_transaction_temp_id);
UPDATE xx_txn_request_lines_stg SET alloc_process_flag
='S',alloc_error_msg='Record Sucess'
WHERE alloc_process_flag='New'
AND line_id=move_order_rec.line_id;
END IF;
END LOOP;
COMMIT;
dbms_output.put_line
('==========================================================');
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line('Exception Occured while calling API :'||sqlerrm);
END;
EXCEPTION
WHEN OTHERS
THEN
dbms_output.put_line ('Main Exception Occured :');
dbms_output.put_line (SQLCODE || ':' || sqlerrm);
dbms_output.put_line
('=======================================================');
END xx_allocate_move_order_proc;

set serveroutput on;


exec xx_allocate_move_order_proc;

You might also like