CREATE OR REPLACE PROCEDURE APPS.ets_create_move_order_hd (
p_org_id IN NUMBER,
user_name IN VARCHAR2,
resp_name IN VARCHAR2,
resp_appl_id IN NUMBER,
p_date_required IN DATE,
p_status_date IN DATE,
p_transaction_type_name IN VARCHAR2,
p_organization_code IN VARCHAR2,
p_description IN VARCHAR2,
p_from_subinventory_code IN VARCHAR2,
p_to_subinventory_code IN VARCHAR2,
p_request_number OUT VARCHAR2
)
AS
l_hdr_rec inv_move_order_pub.trohdr_rec_type
:= inv_move_order_pub.g_miss_trohdr_rec;
x_return_status VARCHAR2 (1);
x_msg_count NUMBER;
x_msg_data VARCHAR2 (4000);
x_hdr_rec inv_move_order_pub.trohdr_rec_type
:= inv_move_order_pub.g_miss_trohdr_rec;
x_hdr_val_rec inv_move_order_pub.trohdr_val_rec_type;
v_msg_index_out NUMBER;
p_validation_flag VARCHAR2 (1);
v_transaction_type_id NUMBER;
v_organization_id NUMBER;
v_user_id NUMBER;
v_resp_id NUMBER;
BEGIN
-------------------------------------------------
BEGIN
SELECT usr.user_id
INTO v_user_id
FROM fnd_user usr
WHERE user_name = usr.user_name;
EXCEPTION
WHEN OTHERS
THEN
v_user_id := NULL;
END;
BEGIN
SELECT resp.responsibility_id
INTO v_resp_id
FROM fnd_responsibility_vl resp
WHERE resp_name = resp.responsibility_name;
EXCEPTION
WHEN OTHERS
THEN
v_resp_id := NULL;
END;
mo_global.set_policy_context ('S', p_org_id);
inv_globals.set_org_id (p_org_id);
fnd_global.apps_initialize (v_user_id, v_resp_id, resp_appl_id);
-------------------------------------------------------------
BEGIN
SELECT trx.transaction_type_id
INTO v_transaction_type_id
FROM mtl_transaction_types trx
WHERE trx.transaction_type_name = p_transaction_type_name;
EXCEPTION
WHEN OTHERS
THEN
v_transaction_type_id := 64;
END;
BEGIN
SELECT org.organization_id
INTO v_organization_id
FROM inv_organization_info_v org
WHERE org.organization_code = p_organization_code;
EXCEPTION
WHEN OTHERS
THEN
v_organization_id := 103;
END;
l_hdr_rec.date_required := p_date_required;
l_hdr_rec.header_status := inv_globals.g_to_status_incomplete;
l_hdr_rec.organization_id := v_organization_id;
l_hdr_rec.status_date := TRIM (p_status_date);
l_hdr_rec.transaction_type_id := v_transaction_type_id;
l_hdr_rec.move_order_type := inv_globals.g_move_order_requisition;
l_hdr_rec.db_flag := fnd_api.g_true;
l_hdr_rec.operation := inv_globals.g_opr_create;
l_hdr_rec.description := p_description;
l_hdr_rec.from_subinventory_code := p_from_subinventory_code;
l_hdr_rec.to_subinventory_code := p_to_subinventory_code;
-------------------------------------------------------------
inv_move_order_pub.create_move_order_header
(p_api_version_number => 1.0,
p_init_msg_list => fnd_api.g_false,
p_return_values => fnd_api.g_false,
p_commit => fnd_api.g_false,
x_return_status => x_return_status,
x_msg_count => x_msg_count,
x_msg_data => x_msg_data,
p_trohdr_rec => l_hdr_rec,
x_trohdr_val_rec => x_hdr_val_rec,
x_trohdr_rec => x_hdr_rec,
p_validation_flag => p_validation_flag
);
p_request_number := x_hdr_rec.request_number;
DBMS_OUTPUT.put_line ('Return Status is :' || x_return_status);
DBMS_OUTPUT.put_line ('Message Count is :' || x_msg_count);
DBMS_OUTPUT.put_line ('Move Order Number is :' || x_hdr_rec.request_number);
IF x_return_status = 'S'
THEN
COMMIT;
ELSE
ROLLBACK;
END IF;
IF x_msg_count > 0
THEN
FOR v_index IN 1 .. x_msg_count
LOOP
fnd_msg_pub.get (p_msg_index => v_index,
p_encoded => 'F',
p_data => x_msg_data,
p_msg_index_out => v_msg_index_out
);
x_msg_data := SUBSTR (x_msg_data, 1, 200);
DBMS_OUTPUT.put_line (x_msg_data);
DBMS_OUTPUT.put_line
('============================================================');
END LOOP;
END IF;
END;
p_org_id IN NUMBER,
user_name IN VARCHAR2,
resp_name IN VARCHAR2,
resp_appl_id IN NUMBER,
p_date_required IN DATE,
p_status_date IN DATE,
p_transaction_type_name IN VARCHAR2,
p_organization_code IN VARCHAR2,
p_description IN VARCHAR2,
p_from_subinventory_code IN VARCHAR2,
p_to_subinventory_code IN VARCHAR2,
p_request_number OUT VARCHAR2
)
AS
l_hdr_rec inv_move_order_pub.trohdr_rec_type
:= inv_move_order_pub.g_miss_trohdr_rec;
x_return_status VARCHAR2 (1);
x_msg_count NUMBER;
x_msg_data VARCHAR2 (4000);
x_hdr_rec inv_move_order_pub.trohdr_rec_type
:= inv_move_order_pub.g_miss_trohdr_rec;
x_hdr_val_rec inv_move_order_pub.trohdr_val_rec_type;
v_msg_index_out NUMBER;
p_validation_flag VARCHAR2 (1);
v_transaction_type_id NUMBER;
v_organization_id NUMBER;
v_user_id NUMBER;
v_resp_id NUMBER;
BEGIN
-------------------------------------------------
BEGIN
SELECT usr.user_id
INTO v_user_id
FROM fnd_user usr
WHERE user_name = usr.user_name;
EXCEPTION
WHEN OTHERS
THEN
v_user_id := NULL;
END;
BEGIN
SELECT resp.responsibility_id
INTO v_resp_id
FROM fnd_responsibility_vl resp
WHERE resp_name = resp.responsibility_name;
EXCEPTION
WHEN OTHERS
THEN
v_resp_id := NULL;
END;
mo_global.set_policy_context ('S', p_org_id);
inv_globals.set_org_id (p_org_id);
fnd_global.apps_initialize (v_user_id, v_resp_id, resp_appl_id);
-------------------------------------------------------------
BEGIN
SELECT trx.transaction_type_id
INTO v_transaction_type_id
FROM mtl_transaction_types trx
WHERE trx.transaction_type_name = p_transaction_type_name;
EXCEPTION
WHEN OTHERS
THEN
v_transaction_type_id := 64;
END;
BEGIN
SELECT org.organization_id
INTO v_organization_id
FROM inv_organization_info_v org
WHERE org.organization_code = p_organization_code;
EXCEPTION
WHEN OTHERS
THEN
v_organization_id := 103;
END;
l_hdr_rec.date_required := p_date_required;
l_hdr_rec.header_status := inv_globals.g_to_status_incomplete;
l_hdr_rec.organization_id := v_organization_id;
l_hdr_rec.status_date := TRIM (p_status_date);
l_hdr_rec.transaction_type_id := v_transaction_type_id;
l_hdr_rec.move_order_type := inv_globals.g_move_order_requisition;
l_hdr_rec.db_flag := fnd_api.g_true;
l_hdr_rec.operation := inv_globals.g_opr_create;
l_hdr_rec.description := p_description;
l_hdr_rec.from_subinventory_code := p_from_subinventory_code;
l_hdr_rec.to_subinventory_code := p_to_subinventory_code;
-------------------------------------------------------------
inv_move_order_pub.create_move_order_header
(p_api_version_number => 1.0,
p_init_msg_list => fnd_api.g_false,
p_return_values => fnd_api.g_false,
p_commit => fnd_api.g_false,
x_return_status => x_return_status,
x_msg_count => x_msg_count,
x_msg_data => x_msg_data,
p_trohdr_rec => l_hdr_rec,
x_trohdr_val_rec => x_hdr_val_rec,
x_trohdr_rec => x_hdr_rec,
p_validation_flag => p_validation_flag
);
p_request_number := x_hdr_rec.request_number;
DBMS_OUTPUT.put_line ('Return Status is :' || x_return_status);
DBMS_OUTPUT.put_line ('Message Count is :' || x_msg_count);
DBMS_OUTPUT.put_line ('Move Order Number is :' || x_hdr_rec.request_number);
IF x_return_status = 'S'
THEN
COMMIT;
ELSE
ROLLBACK;
END IF;
IF x_msg_count > 0
THEN
FOR v_index IN 1 .. x_msg_count
LOOP
fnd_msg_pub.get (p_msg_index => v_index,
p_encoded => 'F',
p_data => x_msg_data,
p_msg_index_out => v_msg_index_out
);
x_msg_data := SUBSTR (x_msg_data, 1, 200);
DBMS_OUTPUT.put_line (x_msg_data);
DBMS_OUTPUT.put_line
('============================================================');
END LOOP;
END IF;
END;