set serveroutput on
DECLARE
l_num_api_version NUMBER := 1;
l_num_loop_count NUMBER := 0;
l_chr_return_status VARCHAR2 (2000);
l_num_msg_count NUMBER;
l_chr_msg_data VARCHAR2 (4000);
l_num_req_id NUMBER;
l_num_rep_req_id NUMBER;
-- IN Variables --
l_rec_header oe_order_pub.header_rec_type;
l_tbl_line oe_order_pub.line_tbl_type;
l_tbl_action_request oe_order_pub.request_tbl_type;
l_tbl_line_adj oe_order_pub.line_adj_tbl_type;
l_request_rec oe_order_pub.request_rec_type;
-- OUT Variables --
l_out_rec_header oe_order_pub.header_rec_type;
l_out_rec_header_val oe_order_pub.header_val_rec_type;
l_out_tbl_header_adj oe_order_pub.header_adj_tbl_type;
l_out_tbl_header_adj_val oe_order_pub.header_adj_val_tbl_type;
l_out_tbl_header_price_att oe_order_pub.header_price_att_tbl_type;
l_out_tbl_header_adj_att oe_order_pub.header_adj_att_tbl_type;
l_out_tbl_header_adj_assoc oe_order_pub.header_adj_assoc_tbl_type;
l_out_tbl_header_scredit oe_order_pub.header_scredit_tbl_type;
l_out_tbl_header_scredit_val oe_order_pub.header_scredit_val_tbl_type;
l_out_tbl_line oe_order_pub.line_tbl_type;
l_out_tbl_line_val oe_order_pub.line_val_tbl_type;
l_out_tbl_line_adj oe_order_pub.line_adj_tbl_type;
l_out_tbl_line_adj_val oe_order_pub.line_adj_val_tbl_type;
l_out_tbl_line_price_att oe_order_pub.line_price_att_tbl_type;
l_out_tbl_line_adj_att oe_order_pub.line_adj_att_tbl_type;
l_out_tbl_line_adj_assoc oe_order_pub.line_adj_assoc_tbl_type;
l_out_tbl_line_scredit oe_order_pub.line_scredit_tbl_type;
l_out_tbl_line_scredit_val oe_order_pub.line_scredit_val_tbl_type;
l_out_tbl_lot_serial oe_order_pub.lot_serial_tbl_type;
l_out_tbl_lot_serial_val oe_order_pub.lot_serial_val_tbl_type;
l_out_tbl_action_request oe_order_pub.request_tbl_type;
g_clob_err_message CLOB;
l_dte_ack_date VARCHAR2 (30) := NULL;
l_num_counter NUMBER := 0;
l_msg_index_out NUMBER := 0;
l_msg_data VARCHAR2(1000);
BEGIN
DBMS_OUTPUT.PUT_LINE ('Starting of Custom Anonymous block for Sales Order API');
DBMS_OUTPUT.PUT_LINE ('Starting of API');
l_rec_header := oe_order_pub.g_miss_header_rec;
l_tbl_action_request := oe_order_pub.g_miss_request_tbl; -- Added as part of V1.7
l_request_rec := oe_order_pub.g_miss_request_rec; -- Added as part of V1.7
l_rec_header.operation := oe_globals.g_opr_update;
l_rec_header.header_id :=5204205;
l_rec_header.attribute3 := 'AWAITING ACKNOWLEDGEMENT';
DBMS_OUTPUT.PUT_LINE ('variable intiatilization done ' || l_rec_header.attribute3);
fnd_global.apps_initialize (12498, 51358, 660);
mo_global.set_policy_context ('S' , 101);
mo_global.init ('ONT');
-- Calling the API to update the header details of an existing Order --
DBMS_OUTPUT.PUT_LINE ('Starting of API Oe_order_pub.process_order');
Oe_order_pub.process_order (
p_org_id => 101,
p_api_version_number => l_num_api_version,
p_init_msg_list => fnd_api.g_true,
p_header_rec => l_rec_header,
p_line_tbl => l_tbl_line,
p_action_request_tbl => l_tbl_action_request,
p_line_adj_tbl => l_tbl_line_adj ,
x_header_rec => l_out_rec_header,
x_header_val_rec => l_out_rec_header_val,
x_header_adj_tbl => l_out_tbl_header_adj,
x_header_adj_val_tbl => l_out_tbl_header_adj_val,
x_header_price_att_tbl => l_out_tbl_header_price_att,
x_header_adj_att_tbl => l_out_tbl_header_adj_att,
x_header_adj_assoc_tbl => l_out_tbl_header_adj_assoc,
x_header_scredit_tbl => l_out_tbl_header_scredit,
x_header_scredit_val_tbl => l_out_tbl_header_scredit_val,
x_line_tbl => l_out_tbl_line,
x_line_val_tbl => l_out_tbl_line_val,
x_line_adj_tbl => l_out_tbl_line_adj,
x_line_adj_val_tbl => l_out_tbl_line_adj_val,
x_line_price_att_tbl => l_out_tbl_line_price_att,
x_line_adj_att_tbl => l_out_tbl_line_adj_att,
x_line_adj_assoc_tbl => l_out_tbl_line_adj_assoc,
x_line_scredit_tbl => l_out_tbl_line_scredit,
x_line_scredit_val_tbl => l_out_tbl_line_scredit_val,
x_lot_serial_tbl => l_out_tbl_lot_serial,
x_lot_serial_val_tbl => l_out_tbl_lot_serial_val,
x_action_request_tbl => l_out_tbl_action_request,
x_return_status => l_chr_return_status,
x_msg_count => l_num_msg_count,
x_msg_data => l_chr_msg_data);
DBMS_OUTPUT.PUT_LINE ('COMPLETION OF API:');
DBMS_OUTPUT.PUT_LINE ('API Return Status:' || l_chr_return_status);
DBMS_OUTPUT.PUT_LINE ('fnd_api.g_ret_sts_success:' || fnd_api.g_ret_sts_success);
DBMS_OUTPUT.PUT_LINE ('Action Request Count:' || l_tbl_action_request.COUNT);
DBMS_OUTPUT.PUT_LINE ('BEFORE IF COUDNTION Action Output Request Count:' || l_out_tbl_action_request.COUNT);
IF l_chr_return_status = fnd_api.g_ret_sts_success
THEN
IF l_tbl_action_request.COUNT > 0
AND l_out_tbl_action_request.COUNT > 0
THEN
DBMS_OUTPUT.PUT_LINE(
'Action Output Request Status:'
|| l_out_tbl_action_request (1).return_status);
IF l_out_tbl_action_request (1).return_status <>
fnd_api.g_ret_sts_success
THEN
ROLLBACK;
g_clob_err_message :=
SUBSTR (
g_clob_err_message
|| CHR (10)
|| 'Process Order API Failed for Order#:'
|| CHR (10)
|| 'Error(s):',
1,
32000);
FOR i IN 1 .. l_num_msg_count
LOOP
l_chr_msg_data :=
oe_msg_pub.get (p_msg_index => i, p_encoded => 'F');
DBMS_OUTPUT.PUT_LINE(
i || ') ' || l_chr_msg_data);
g_clob_err_message :=
SUBSTR (
g_clob_err_message
|| CHR (10)
|| i
|| ') '
|| l_chr_msg_data,
1,
32000);
END LOOP;
END IF; --l_out_tbl_action_request(1).return_status <> fnd_api.g_ret_sts_success THEN
ELSE
DBMS_OUTPUT.PUT_LINE(
'Order Header Updation Success for Order :'
);
END IF; --IF l_tbl_action_request.count > 0 THEN
COMMIT;
ELSE
DBMS_OUTPUT.PUT_LINE(
'Order Header Updation failed for Order: '
|| '-'
|| SUBSTR (l_chr_msg_data, 1, 250));
ROLLBACK;
g_clob_err_message :=
SUBSTR (
g_clob_err_message
|| CHR (10)
|| 'Process Order API Failed for Order#:'
|| CHR (10)
|| 'Error(s):',
1,
32000);
FOR i IN 1 .. l_num_msg_count
LOOP
l_chr_msg_data :=
oe_msg_pub.get (p_msg_index => i, p_encoded => 'F');
DBMS_OUTPUT.PUT_LINE( i || ') ' || l_chr_msg_data);
g_clob_err_message :=
SUBSTR (
g_clob_err_message
|| CHR (10)
|| i
|| ') '
|| l_chr_msg_data,
1,
32000);
END LOOP;
END IF;
END;
/
0 Commentaires