Tuesday, 12 August 2025

Script to change the order status to Booked

SET SERVEROUTPUT ON SIZE 100000;

SET DEFINE OFF;

DECLARE
    l_api_version_number          NUMBER := 1;
    l_return_status               VARCHAR2(2000);
    l_msg_count                   NUMBER;
    l_msg_data                    VARCHAR2(2000);

-- IN Variables --
    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;
    l_line_adj_tbl                oe_order_pub.line_adj_tbl_type;

-- OUT Variables --
    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;
BEGIN
    dbms_output.put_line('Starting of script');

-- Setting the Enviroment --

    mo_global.init('ONT');
    fnd_global.apps_initialize(user_id => 233158, resp_id => 57420,
                              resp_appl_id => 660);

    mo_global.set_policy_context('S', 111);
    l_action_request_tbl(1) := oe_order_pub.g_miss_request_rec;
    l_action_request_tbl(1).request_type := oe_globals.g_book_order;
    l_action_request_tbl(1).entity_code := oe_globals.g_entity_header;
    l_action_request_tbl(1).entity_id := 14612797;--header_id

    dbms_output.put_line('Starting of API');

-- Calling the API to to Book an Existing Order --Buy bestselling books online

    oe_order_pub.process_order(p_api_version_number => l_api_version_number, p_header_rec => l_header_rec,
                              p_line_tbl => l_line_tbl,
                              p_action_request_tbl => l_action_request_tbl,
                              p_line_adj_tbl => l_line_adj_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);

    dbms_output.put_line('Completion of API');
    IF l_return_status = fnd_api.g_ret_sts_success THEN
        COMMIT;
        dbms_output.put_line('Booking of an Existing Order is Success ');
    ELSE
        dbms_output.put_line('Booking of an Existing Order failed:' || l_msg_data);
        ROLLBACK;
        FOR i IN 1..l_msg_count LOOP
            l_msg_data := oe_msg_pub.get(p_msg_index => i, p_encoded => 'F');
            dbms_output.put_line(i
                                 || ') '
                                 || l_msg_data);
        END LOOP;

    END IF;

END;
/

No comments:

Post a Comment