The major difference between 11i API parameter and R12 parameter is Org_Id . In R12 Org_ID as parameter we need to pass it to the API.
DECLARE
l_return_status VARCHAR2 (2000);
l_msg_count NUMBER;
l_msg_data VARCHAR2 (2000);
-- PARAMETERS
l_debug_level NUMBER := 5; -- OM DEBUG LEVEL (MAX 5)
l_org VARCHAR2 (20) := '111'; -- OPERATING UNIT
l_no_orders NUMBER := 1; -- NO OF ORDERS
-- INPUT VARIABLES FOR PROCESS_ORDER API
l_header_rec oe_order_pub.header_rec_type;
l_line_tbl oe_order_pub.line_tbl_type;
l_action_request_tbl oe_order_pub.request_tbl_type;
-- OUT VARIABLES FOR PROCESS_ORDER API
l_header_rec_out oe_order_pub.header_rec_type;
l_header_val_rec_out oe_order_pub.header_val_rec_type;
l_header_adj_tbl_out oe_order_pub.header_adj_tbl_type;
l_header_adj_val_tbl_out oe_order_pub.header_adj_val_tbl_type;
l_header_price_att_tbl_out oe_order_pub.header_price_att_tbl_type;
l_header_adj_att_tbl_out oe_order_pub.header_adj_att_tbl_type;
l_header_adj_assoc_tbl_out oe_order_pub.header_adj_assoc_tbl_type;
l_header_scredit_tbl_out oe_order_pub.header_scredit_tbl_type;
l_header_scredit_val_tbl_out oe_order_pub.header_scredit_val_tbl_type;
l_line_tbl_out oe_order_pub.line_tbl_type;
l_line_val_tbl_out oe_order_pub.line_val_tbl_type;
l_line_adj_tbl_out oe_order_pub.line_adj_tbl_type;
l_line_adj_val_tbl_out oe_order_pub.line_adj_val_tbl_type;
l_line_price_att_tbl_out oe_order_pub.line_price_att_tbl_type;
l_line_adj_att_tbl_out oe_order_pub.line_adj_att_tbl_type;
l_line_adj_assoc_tbl_out oe_order_pub.line_adj_assoc_tbl_type;
l_line_scredit_tbl_out oe_order_pub.line_scredit_tbl_type;
l_line_scredit_val_tbl_out oe_order_pub.line_scredit_val_tbl_type;
l_lot_serial_tbl_out oe_order_pub.lot_serial_tbl_type;
l_lot_serial_val_tbl_out oe_order_pub.lot_serial_val_tbl_type;
l_action_request_tbl_out oe_order_pub.request_tbl_type;
l_msg_index NUMBER;
l_data VARCHAR2 (2000);
l_loop_count NUMBER;
l_debug_file VARCHAR2 (200);
l_user_id NUMBER;
l_resp_id NUMBER;
l_resp_appl_id NUMBER;
BEGIN
-- INITIALIZATION REQUIRED FOR R12
mo_global.set_policy_context ('S', l_org);
mo_global.init ('ONT');
-- INITIALIZE DEBUG INFO
IF (l_debug_level > 0)
THEN
l_debug_file := oe_debug_pub.set_debug_mode ('FILE');
oe_debug_pub.initialize;
oe_msg_pub.initialize;
oe_debug_pub.setdebuglevel (l_debug_level);
END IF;
-- INITIALIZE ENVIRONMENT
fnd_global.apps_initialize (l_user_id, l_resp_id, l_resp_appl_id);
-- INITIALIZE HEADER RECORD
l_header_rec := oe_order_pub.g_miss_header_rec;
-- POPULATE REQUIRED ATTRIBUTES
l_header_rec.operation := oe_globals.g_opr_create;
l_header_rec.pricing_date := SYSDATE;
l_header_rec.cust_po_number := 'TSTPO30';
l_header_rec.sold_to_org_id := 45928;
l_header_rec.price_list_id := 29061;
l_header_rec.ordered_date := SYSDATE;
l_header_rec.sold_from_org_id := 400674685;
--l_header_rec.ship_from_org_id := 857545;
l_header_rec.ship_to_org_id := 416327212;
l_header_rec.invoice_to_org_id := 401869206;
l_header_rec.salesrep_id := -3;
-- l_header_rec.flow_status_code := 'ENTERED';
l_header_rec.order_type_id := 700203;
-- INITIALIZE ACTION REQUEST RECORD
l_action_request_tbl (1) := oe_order_pub.g_miss_request_rec;
-- INITIALIZE LINE RECORD
l_line_tbl (1) := oe_order_pub.g_miss_line_rec;
l_line_tbl (1).operation := oe_globals.g_opr_create; -- Mandatory Operation to Pass
l_line_tbl (1).inventory_item_id := 4408;
l_line_tbl (1).ordered_quantity := 1;
l_line_tbl (1).ship_from_org_id := 1163;
l_line_tbl (1).subinventory := NULL;
FOR i IN 1 .. l_no_orders
LOOP -- BEGIN LOOP
-- CALLTO PROCESS ORDER API
oe_order_pub.process_order (
p_org_id=> l_org,
-- p_operating_unit => NULL,
p_api_version_number=> 1.0,
p_header_rec=> l_header_rec,
p_line_tbl=> l_line_tbl,
p_action_request_tbl=> l_action_request_tbl,
-- OUT variables
x_header_rec=> l_header_rec_out,
x_header_val_rec=> l_header_val_rec_out,
x_header_adj_tbl=> l_header_adj_tbl_out,
x_header_adj_val_tbl=> l_header_adj_val_tbl_out,
x_header_price_att_tbl=> l_header_price_att_tbl_out,
x_header_adj_att_tbl=> l_header_adj_att_tbl_out,
x_header_adj_assoc_tbl=> l_header_adj_assoc_tbl_out,
x_header_scredit_tbl=> l_header_scredit_tbl_out,
x_header_scredit_val_tbl=> l_header_scredit_val_tbl_out,
x_line_tbl=> l_line_tbl_out,
x_line_val_tbl=> l_line_val_tbl_out,
x_line_adj_tbl=> l_line_adj_tbl_out,
x_line_adj_val_tbl=> l_line_adj_val_tbl_out,
x_line_price_att_tbl=> l_line_price_att_tbl_out,
x_line_adj_att_tbl=> l_line_adj_att_tbl_out,
x_line_adj_assoc_tbl=> l_line_adj_assoc_tbl_out,
x_line_scredit_tbl=> l_line_scredit_tbl_out,
x_line_scredit_val_tbl=> l_line_scredit_val_tbl_out,
x_lot_serial_tbl=> l_lot_serial_tbl_out,
x_lot_serial_val_tbl=> l_lot_serial_val_tbl_out,
x_action_request_tbl=> l_action_request_tbl_out,
x_return_status=> l_return_status,
x_msg_count=> l_msg_count,
x_msg_data=> l_msg_data
);
-- CHECK RETURN STATUS
IF l_return_status = fnd_api.g_ret_sts_success
THEN
IF (l_debug_level > 0)
THEN
DBMS_OUTPUT.put_line ('Sales Order Successfully Created');
END IF;
COMMIT;
ELSE
IF (l_debug_level > 0)
THEN
DBMS_OUTPUT.put_line ('Failed to Create Sales Order');
END IF;
ROLLBACK;
END IF;
END LOOP;
-- DISPLAY RETURN STATUS FLAGS
IF (l_debug_level > 0)
THEN
DBMS_OUTPUT.put_line (
'Process Order Return Status is: ========>'
|| l_return_status
);
DBMS_OUTPUT.put_line (
'Process Order msg data is: ===========>'
|| l_msg_data
);
DBMS_OUTPUT.put_line (
'Process Order Message Count is:=======>'
|| l_msg_count
);
DBMS_OUTPUT.put_line (
'Sales Order Created is:===============>'
|| TO_CHAR (l_header_rec_out.order_number)
);
DBMS_OUTPUT.put_line (
'Booked Flag for the Sales Order is:======>'
|| l_header_rec_out.booked_flag
);
DBMS_OUTPUT.put_line (
'Header_id for the Sales Order is:========>'
|| l_header_rec_out.header_id
);
DBMS_OUTPUT.put_line (
'Flow_Status_Code For the Sales Order is=>:'
|| l_header_rec_out.flow_status_code
);
END IF;
-- DISPLAY ERROR MSGS
IF (l_debug_level > 0)
THEN
FOR i IN 1 .. l_msg_count
LOOP
oe_msg_pub.get (
p_msg_index=> i,
p_encoded=> fnd_api.g_false,
p_data=> l_data,
p_msg_index_out=> l_msg_index
);
DBMS_OUTPUT.put_line ( 'message is:'
|| l_data);
DBMS_OUTPUT.put_line ( 'message index is:'
|| l_msg_index);
END LOOP;
END IF;
IF (l_debug_level > 0)
THEN
DBMS_OUTPUT.put_line ( 'Debug = '
|| oe_debug_pub.g_debug);
DBMS_OUTPUT.put_line (
'Debug Level = '
|| TO_CHAR (oe_debug_pub.g_debug_level)
);
DBMS_OUTPUT.put_line (
'Debug File ='
|| oe_debug_pub.g_dir
|| '/'
|| oe_debug_pub.g_file
);
oe_debug_pub.debug_off;
END IF;
END;
DECLARE
l_return_status VARCHAR2 (2000);
l_msg_count NUMBER;
l_msg_data VARCHAR2 (2000);
-- PARAMETERS
l_debug_level NUMBER := 5; -- OM DEBUG LEVEL (MAX 5)
l_org VARCHAR2 (20) := '111'; -- OPERATING UNIT
l_no_orders NUMBER := 1; -- NO OF ORDERS
-- INPUT VARIABLES FOR PROCESS_ORDER API
l_header_rec oe_order_pub.header_rec_type;
l_line_tbl oe_order_pub.line_tbl_type;
l_action_request_tbl oe_order_pub.request_tbl_type;
-- OUT VARIABLES FOR PROCESS_ORDER API
l_header_rec_out oe_order_pub.header_rec_type;
l_header_val_rec_out oe_order_pub.header_val_rec_type;
l_header_adj_tbl_out oe_order_pub.header_adj_tbl_type;
l_header_adj_val_tbl_out oe_order_pub.header_adj_val_tbl_type;
l_header_price_att_tbl_out oe_order_pub.header_price_att_tbl_type;
l_header_adj_att_tbl_out oe_order_pub.header_adj_att_tbl_type;
l_header_adj_assoc_tbl_out oe_order_pub.header_adj_assoc_tbl_type;
l_header_scredit_tbl_out oe_order_pub.header_scredit_tbl_type;
l_header_scredit_val_tbl_out oe_order_pub.header_scredit_val_tbl_type;
l_line_tbl_out oe_order_pub.line_tbl_type;
l_line_val_tbl_out oe_order_pub.line_val_tbl_type;
l_line_adj_tbl_out oe_order_pub.line_adj_tbl_type;
l_line_adj_val_tbl_out oe_order_pub.line_adj_val_tbl_type;
l_line_price_att_tbl_out oe_order_pub.line_price_att_tbl_type;
l_line_adj_att_tbl_out oe_order_pub.line_adj_att_tbl_type;
l_line_adj_assoc_tbl_out oe_order_pub.line_adj_assoc_tbl_type;
l_line_scredit_tbl_out oe_order_pub.line_scredit_tbl_type;
l_line_scredit_val_tbl_out oe_order_pub.line_scredit_val_tbl_type;
l_lot_serial_tbl_out oe_order_pub.lot_serial_tbl_type;
l_lot_serial_val_tbl_out oe_order_pub.lot_serial_val_tbl_type;
l_action_request_tbl_out oe_order_pub.request_tbl_type;
l_msg_index NUMBER;
l_data VARCHAR2 (2000);
l_loop_count NUMBER;
l_debug_file VARCHAR2 (200);
l_user_id NUMBER;
l_resp_id NUMBER;
l_resp_appl_id NUMBER;
BEGIN
-- INITIALIZATION REQUIRED FOR R12
mo_global.set_policy_context ('S', l_org);
mo_global.init ('ONT');
-- INITIALIZE DEBUG INFO
IF (l_debug_level > 0)
THEN
l_debug_file := oe_debug_pub.set_debug_mode ('FILE');
oe_debug_pub.initialize;
oe_msg_pub.initialize;
oe_debug_pub.setdebuglevel (l_debug_level);
END IF;
-- INITIALIZE ENVIRONMENT
fnd_global.apps_initialize (l_user_id, l_resp_id, l_resp_appl_id);
-- INITIALIZE HEADER RECORD
l_header_rec := oe_order_pub.g_miss_header_rec;
-- POPULATE REQUIRED ATTRIBUTES
l_header_rec.operation := oe_globals.g_opr_create;
l_header_rec.pricing_date := SYSDATE;
l_header_rec.cust_po_number := 'TSTPO30';
l_header_rec.sold_to_org_id := 45928;
l_header_rec.price_list_id := 29061;
l_header_rec.ordered_date := SYSDATE;
l_header_rec.sold_from_org_id := 400674685;
--l_header_rec.ship_from_org_id := 857545;
l_header_rec.ship_to_org_id := 416327212;
l_header_rec.invoice_to_org_id := 401869206;
l_header_rec.salesrep_id := -3;
-- l_header_rec.flow_status_code := 'ENTERED';
l_header_rec.order_type_id := 700203;
-- INITIALIZE ACTION REQUEST RECORD
l_action_request_tbl (1) := oe_order_pub.g_miss_request_rec;
-- INITIALIZE LINE RECORD
l_line_tbl (1) := oe_order_pub.g_miss_line_rec;
l_line_tbl (1).operation := oe_globals.g_opr_create; -- Mandatory Operation to Pass
l_line_tbl (1).inventory_item_id := 4408;
l_line_tbl (1).ordered_quantity := 1;
l_line_tbl (1).ship_from_org_id := 1163;
l_line_tbl (1).subinventory := NULL;
FOR i IN 1 .. l_no_orders
LOOP -- BEGIN LOOP
-- CALLTO PROCESS ORDER API
oe_order_pub.process_order (
p_org_id=> l_org,
-- p_operating_unit => NULL,
p_api_version_number=> 1.0,
p_header_rec=> l_header_rec,
p_line_tbl=> l_line_tbl,
p_action_request_tbl=> l_action_request_tbl,
-- OUT variables
x_header_rec=> l_header_rec_out,
x_header_val_rec=> l_header_val_rec_out,
x_header_adj_tbl=> l_header_adj_tbl_out,
x_header_adj_val_tbl=> l_header_adj_val_tbl_out,
x_header_price_att_tbl=> l_header_price_att_tbl_out,
x_header_adj_att_tbl=> l_header_adj_att_tbl_out,
x_header_adj_assoc_tbl=> l_header_adj_assoc_tbl_out,
x_header_scredit_tbl=> l_header_scredit_tbl_out,
x_header_scredit_val_tbl=> l_header_scredit_val_tbl_out,
x_line_tbl=> l_line_tbl_out,
x_line_val_tbl=> l_line_val_tbl_out,
x_line_adj_tbl=> l_line_adj_tbl_out,
x_line_adj_val_tbl=> l_line_adj_val_tbl_out,
x_line_price_att_tbl=> l_line_price_att_tbl_out,
x_line_adj_att_tbl=> l_line_adj_att_tbl_out,
x_line_adj_assoc_tbl=> l_line_adj_assoc_tbl_out,
x_line_scredit_tbl=> l_line_scredit_tbl_out,
x_line_scredit_val_tbl=> l_line_scredit_val_tbl_out,
x_lot_serial_tbl=> l_lot_serial_tbl_out,
x_lot_serial_val_tbl=> l_lot_serial_val_tbl_out,
x_action_request_tbl=> l_action_request_tbl_out,
x_return_status=> l_return_status,
x_msg_count=> l_msg_count,
x_msg_data=> l_msg_data
);
-- CHECK RETURN STATUS
IF l_return_status = fnd_api.g_ret_sts_success
THEN
IF (l_debug_level > 0)
THEN
DBMS_OUTPUT.put_line ('Sales Order Successfully Created');
END IF;
COMMIT;
ELSE
IF (l_debug_level > 0)
THEN
DBMS_OUTPUT.put_line ('Failed to Create Sales Order');
END IF;
ROLLBACK;
END IF;
END LOOP;
-- DISPLAY RETURN STATUS FLAGS
IF (l_debug_level > 0)
THEN
DBMS_OUTPUT.put_line (
'Process Order Return Status is: ========>'
|| l_return_status
);
DBMS_OUTPUT.put_line (
'Process Order msg data is: ===========>'
|| l_msg_data
);
DBMS_OUTPUT.put_line (
'Process Order Message Count is:=======>'
|| l_msg_count
);
DBMS_OUTPUT.put_line (
'Sales Order Created is:===============>'
|| TO_CHAR (l_header_rec_out.order_number)
);
DBMS_OUTPUT.put_line (
'Booked Flag for the Sales Order is:======>'
|| l_header_rec_out.booked_flag
);
DBMS_OUTPUT.put_line (
'Header_id for the Sales Order is:========>'
|| l_header_rec_out.header_id
);
DBMS_OUTPUT.put_line (
'Flow_Status_Code For the Sales Order is=>:'
|| l_header_rec_out.flow_status_code
);
END IF;
-- DISPLAY ERROR MSGS
IF (l_debug_level > 0)
THEN
FOR i IN 1 .. l_msg_count
LOOP
oe_msg_pub.get (
p_msg_index=> i,
p_encoded=> fnd_api.g_false,
p_data=> l_data,
p_msg_index_out=> l_msg_index
);
DBMS_OUTPUT.put_line ( 'message is:'
|| l_data);
DBMS_OUTPUT.put_line ( 'message index is:'
|| l_msg_index);
END LOOP;
END IF;
IF (l_debug_level > 0)
THEN
DBMS_OUTPUT.put_line ( 'Debug = '
|| oe_debug_pub.g_debug);
DBMS_OUTPUT.put_line (
'Debug Level = '
|| TO_CHAR (oe_debug_pub.g_debug_level)
);
DBMS_OUTPUT.put_line (
'Debug File ='
|| oe_debug_pub.g_dir
|| '/'
|| oe_debug_pub.g_file
);
oe_debug_pub.debug_off;
END IF;
END;
No comments:
Post a Comment