Tuesday, 6 April 2021

API to apply hold on already created sales order

 DECLARE

  v_api_version_number NUMBER := 1;

  v_return_status      VARCHAR2 (2000);

  v_msg_count          NUMBER;

  v_msg_data           VARCHAR2 (2000);

  -- p_return_status

  -- IN Variables --

  v_header_rec oe_order_pub.header_rec_type;

  v_line_tbl oe_order_pub.line_tbl_type;

  v_action_request_tbl oe_order_pub.request_tbl_type;

  v_line_adj_tbl oe_order_pub.line_adj_tbl_type;

  -- OUT Variables --

  v_header_rec_out oe_order_pub.header_rec_type;

  v_header_val_rec_out oe_order_pub.header_val_rec_type;

  v_header_adj_tbl_out oe_order_pub.header_adj_tbl_type;

  v_header_adj_val_tbl_out oe_order_pub.header_adj_val_tbl_type;

  v_header_price_att_tbl_out oe_order_pub.header_price_att_tbl_type;

  v_header_adj_att_tbl_out oe_order_pub.header_adj_att_tbl_type;

  v_header_adj_assoc_tbl_out oe_order_pub.header_adj_assoc_tbl_type;

  v_header_scredit_tbl_out oe_order_pub.header_scredit_tbl_type;

  v_header_scredit_val_tbl_out oe_order_pub.header_scredit_val_tbl_type;

  v_line_tbl_out oe_order_pub.line_tbl_type;

  v_line_val_tbl_out oe_order_pub.line_val_tbl_type;

  v_line_adj_tbl_out oe_order_pub.line_adj_tbl_type;

  v_line_adj_val_tbl_out oe_order_pub.line_adj_val_tbl_type;

  v_line_price_att_tbl_out oe_order_pub.line_price_att_tbl_type;

  v_line_adj_att_tbl_out oe_order_pub.line_adj_att_tbl_type;

  v_line_adj_assoc_tbl_out oe_order_pub.line_adj_assoc_tbl_type;

  v_line_scredit_tbl_out oe_order_pub.line_scredit_tbl_type;

  v_line_scredit_val_tbl_out oe_order_pub.line_scredit_val_tbl_type;

  v_lot_serial_tbl_out oe_order_pub.lot_serial_tbl_type;

  v_lot_serial_val_tbl_out oe_order_pub.lot_serial_val_tbl_type;

  v_action_request_tbl_out oe_order_pub.request_tbl_type;

  ----other parameter---

  l_user_id          NUMBER := 4927312;--fnd_global.user_id;

  l_resp_id          NUMBER := 51234;   --fnd_global.resp_id;

  l_application_id   NUMBER := 660;     --fnd_global.resp_appl_id;

  l_entity_id        NUMBER;

  lv_lookup_code     VARCHAR2(200);

  lv_description     VARCHAR2(1000);

  lv_meaning         VARCHAR2(300);

  l_entity_code      VARCHAR2(100);

  l_request_type     VARCHAR2(150);

  l_api_error        VARCHAR2(1000);

  l_all_api_error    VARCHAR2(4000);

  value_not_found    EXCEPTION;

  action_value_error EXCEPTION;

BEGIN

 DBMS_OUTPUT.PUT_LINE('Starting of script');

  fnd_global.apps_initialize(

  fnd_profile.value('USER_ID'),

  fnd_profile.value('RESPONSIBILITY_ID'),

  fnd_profile.value('APPLICATION_ID')

  );*/

  oe_msg_pub.initialize;

  MO_GLOBAL.INIT('ONT');

  l_request_type := OE_GLOBALS.G_APPLY_HOLD;

  --Assign Value to request_tbl_type for APPLY HOLD--

  v_action_request_tbl (1)              := oe_order_pub.g_miss_request_rec;

  v_action_request_tbl (1).entity_id    := 19963952;                   -- Header ID/line ID of the order

  v_action_request_tbl (1).entity_code  := OE_GLOBALS.G_ENTITY_HEADER; --OE_GLOBALS.G_ENTITY_HEADER/OE_GLOBALS.G_ENTITY_LINE;;

  v_action_request_tbl (1).request_type := OE_GLOBALS.G_APPLY_HOLD;    --OE_GLOBALS.G_APPLY_HOLD/OE_GLOBALS.G_RELEASE_HOLD;

  v_action_request_tbl (1).param1       := 1008;                       -- hold_id

  v_action_request_tbl (1).param2       := 'O';                        -- indicator that it is an order hold

  v_action_request_tbl (1).param3       := 1997869;                   -- Header ID/line ID of the order

  v_action_request_tbl (1).param4       := 'Hold applied using API';

  --('Starting of API');

  -- CALLING THE API TO APPLY HOLD ON EXISTING ORDER --

  OE_ORDER_PUB.PROCESS_ORDER ( p_api_version_number => v_api_version_number , 

                              p_header_rec => v_header_rec , 

                              p_line_tbl => v_line_tbl , 

                              p_action_request_tbl => v_action_request_tbl , 

                              p_line_adj_tbl => v_line_adj_tbl

  -- OUT variables

                              , x_header_rec => v_header_rec_out , 

                              x_header_val_rec => v_header_val_rec_out , 

                              x_header_adj_tbl => v_header_adj_tbl_out , 

                              x_header_adj_val_tbl => v_header_adj_val_tbl_out , 

                              x_header_price_att_tbl => v_header_price_att_tbl_out , 

                              x_header_adj_att_tbl => v_header_adj_att_tbl_out , 

                              x_header_adj_assoc_tbl => v_header_adj_assoc_tbl_out , 

                              x_header_scredit_tbl => v_header_scredit_tbl_out , 

                              x_header_scredit_val_tbl => v_header_scredit_val_tbl_out , 

                              x_line_tbl => v_line_tbl_out , 

                              x_line_val_tbl => v_line_val_tbl_out , 

                              x_line_adj_tbl => v_line_adj_tbl_out , 

                              x_line_adj_val_tbl => v_line_adj_val_tbl_out , 

                              x_line_price_att_tbl => v_line_price_att_tbl_out , 

                              x_line_adj_att_tbl => v_line_adj_att_tbl_out , 

                              x_line_adj_assoc_tbl => v_line_adj_assoc_tbl_out , 

                              x_line_scredit_tbl => v_line_scredit_tbl_out , 

                              x_line_scredit_val_tbl => v_line_scredit_val_tbl_out , 

                              x_lot_serial_tbl => v_lot_serial_tbl_out , 

                              x_lot_serial_val_tbl => v_lot_serial_val_tbl_out , 

                              x_action_request_tbl => v_action_request_tbl_out ,

                              x_return_status => v_return_status , 

                              x_msg_count => v_msg_count , 

                              x_msg_data => v_msg_data);

  COMMIT;

  --('Completion of API');

  IF v_return_status = fnd_api.g_ret_sts_success THEN

    COMMIT;

  ELSE

    ROLLBACK;

    FOR i IN 1 .. v_msg_count

    LOOP

      v_msg_data  := oe_msg_pub.get( p_msg_index => i, p_encoded => 'F');

      l_api_error := v_msg_data;

      SELECT DECODE(l_all_api_error,NULL,l_api_error,l_all_api_error

        ||'|'

        ||l_api_error)

      INTO l_all_api_error

      FROM DUAL;

    END LOOP;

  END IF;

  FOR i IN 1 .. v_msg_count

  LOOP

    v_msg_data  := oe_msg_pub.get( p_msg_index => i, p_encoded => 'F');

    l_api_error := v_msg_data;

    SELECT DECODE(l_all_api_error,NULL,l_api_error,l_all_api_error

      ||'|'

      ||l_api_error)

    INTO l_all_api_error

    FROM DUAL;

  END LOOP;

  -- p_return_status := v_return_status;

  --p_error_msg := l_all_api_error;

  dbms_output.put_line('v_return_status: '||v_return_status ||'l_all_api_error :'||l_all_api_error);

END;

No comments:

Post a Comment

AP Invoice Notes related Table details in Oracle Fusion

 What is the table that stores the AP Invoice notes? AP notes are stored in ZMM_NOTES table with SOURCE_OBJECT_CODE = 'AP_STANDARD_INVOI...