Thursday, September 11, 2014

Update Schedule Ship Date on OM Order Lines - OE_ORDER_PUB API

Dear Reader

Came across a requirement recently where customer wished to update the Scheduled Ship Date on some OM Order Lines via back-end

This can be achieved using OE_ORDER_PUB API call as below. Hope this helps

DECLARE
   l_user_id                      NUMBER;
   l_resp_id                      NUMBER;
   l_appl_id                      NUMBER;
   l_header_rec_in                oe_order_pub.header_rec_type;
   l_line_tbl_in                  oe_order_pub.line_tbl_type;
   l_action_request_tbl_in        oe_order_pub.request_tbl_type;
   l_header_rec_out               oe_order_pub.header_rec_type;
   l_line_tbl_out                 oe_order_pub.line_tbl_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_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_chr_program_unit_name        VARCHAR2 (100);
   l_chr_ret_status               VARCHAR2 (1000) := NULL;
   l_msg_count                    NUMBER := 0;
   l_msg_data                     VARCHAR2 (2000);
   l_num_api_version              NUMBER := 1.0;
   p_line_id                      NUMBER := 4810585;  --put your line ID here
   p_sched_ship_date              DATE := '28-JUL-2014'; --pass the schedule ship date which is desired to be updated
BEGIN
   SELECT user_id
     INTO l_user_id
     FROM fnd_user
    WHERE user_name = 'MYUSER';

   SELECT responsibility_id, application_id
     INTO l_resp_id, l_appl_id
     FROM fnd_responsibility_vl
    WHERE responsibility_name like 'Order Management Super User';

   fnd_global.apps_initialize (l_user_id, l_resp_id, l_appl_id);

   l_line_tbl_in (1) := oe_order_pub.g_miss_line_rec;
   l_line_tbl_in (1).line_id := p_line_id;
   l_line_tbl_in (1).schedule_ship_date := p_sched_ship_date;
   l_line_tbl_in (1).operation := oe_globals.g_opr_update;
   oe_msg_pub.delete_msg;

   oe_order_pub.process_order
                  (p_api_version_number         => l_num_api_version,
                  p_init_msg_list               => fnd_api.g_false,
                  p_return_values               => fnd_api.g_false,
                  p_action_commit               => fnd_api.g_false,
                  p_line_tbl                    => l_line_tbl_in,
                  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_chr_ret_status,
                  x_msg_count                   => l_msg_count,
                  x_msg_data                    => l_msg_data
                  );
   l_msg_data := NULL;

   IF l_chr_ret_status <> 'S'
   THEN
      FOR iindx IN 1 .. l_msg_count
      LOOP
         l_msg_data := l_msg_data || '  ' || oe_msg_pub.get (iindx);
      END LOOP;
   END IF;

   DBMS_OUTPUT.ENABLE (10000);
   DBMS_OUTPUT.put_line ('Return Status: ' || l_chr_ret_status);
   DBMS_OUTPUT.put_line ('Error Message: ' || l_msg_data);
END;

Cheers
A

3 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. Facing error while using this code...passed line id

    ReplyDelete
    Replies
    1. ORA-20001: SQL_PLSQL_ERROR: N, ROUTINE, MO_GLOBAL.VALID

      Delete