Wednesday, 3 February 2016

Sales order through API oe_order_pub.process_order from backend in oracle apps(O2C)

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)                          := '204'; -- 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 := 117741;
   l_header_rec.price_list_id := 1000;
   l_header_rec.ordered_date := SYSDATE;
   l_header_rec.sold_from_org_id := 204;
   --l_header_rec.ship_from_org_id := 857545;
   l_header_rec.ship_to_org_id := 13854;
   l_header_rec.invoice_to_org_id := 13853;
   l_header_rec.salesrep_id := -3;
   --  l_header_rec.flow_status_code := 'ENTERED';
   l_header_rec.order_type_id := 1437;
   -- 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 := 8768;
   l_line_tbl (1).ordered_quantity := 1;
   l_line_tbl (1).ship_from_org_id := 204;
   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;

//////////////////////////////////////////////////////////////////
SELECT * FROM OE_ORDER_HEADERS_ALL WHERE ORDER_NUMBER=66473;


this 66473 existing  order number i took and i gave same details in this query means initialize environment section

SELECT * FROM mtl_system_items_b WHERE organization_id=204;

SELECT * FROM HR_OPERATING_UNITS WHERE organization_id=204;

SELECT INVENTORY_ITEM_ID FROM MTL_SYSTEM_ITEMS_B WHERE INTERNAL_ORDER_FLAG ='Y' AND ROWNUM < 2
AND ORGANIZATION_ID = 204

PASS THE ABOVE VALUE FOR INVENTORY_ITEM_ID PARAMETER


///////********************************/////////////************/////////
***************SALES ORDER BOOKING*****************
**************************************************************************

declare
v_api_version_number           NUMBER  := 1;
v_return_status                VARCHAR2 (2000);
v_msg_count                    NUMBER;
v_msg_data                     VARCHAR2 (2000);

-- 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;


BEGIN

DBMS_OUTPUT.PUT_LINE('Starting of script');

-- Setting the Enviroment --

mo_global.init('ONT');
fnd_global.apps_initialize ( user_id      => 1013455
                            ,resp_id      => 21623
                            ,resp_appl_id => 660);
mo_global.set_policy_context('S',204);

v_action_request_tbl (1)             := oe_order_pub.g_miss_request_rec;
v_action_request_tbl(1).request_type := OE_GLOBALS.G_BOOK_ORDER;
v_action_request_tbl(1).entity_code  := OE_GLOBALS.G_ENTITY_HEADER;
v_action_request_tbl(1).entity_id    := 198373;

DBMS_OUTPUT.PUT_LINE('Starting of API');

-- Calling the API to to Book an 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
);

DBMS_OUTPUT.PUT_LINE('Completion of API');


IF v_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:'||v_msg_data);
    ROLLBACK;
    FOR i IN 1 .. v_msg_count
    LOOP
      v_msg_data := oe_msg_pub.get( p_msg_index => i, p_encoded => 'F');
      dbms_output.put_line( i|| ') '|| v_msg_data);
    END LOOP;
END IF;

END;
/



-----------------------------------------------------------------------------------------
***************************PICK RELEASE SALES ORDER**************************************
*****************************************************************************************
DECLARE

x_return_status VARCHAR2 (2);
x_msg_count NUMBER;
x_msg_data VARCHAR2 (2000);
p_api_version_number NUMBER := 1.0;
init_msg_list VARCHAR2 (200);
x_msg_details VARCHAR2 (3000);
x_msg_summary VARCHAR2 (3000);
p_line_rows wsh_util_core.id_tab_type;
x_del_rows wsh_util_core.id_tab_type;
l_ship_method_code VARCHAR2 (100);
i NUMBER;
l_commit VARCHAR2 (30);
p_delivery_id NUMBER;
p_delivery_name VARCHAR2 (30);
x_trip_id VARCHAR2 (30);
x_trip_name VARCHAR2 (30);
exep_api EXCEPTION;
l_picked_flag VARCHAR2 (10);
l_return_status VARCHAR2 (1000);
l_msg_count NUMBER;
l_msg_data VARCHAR2 (1000);
l_user_id NUMBER :=1013455;
l_resp_id NUMBER :=21623;
l_appl_id NUMBER :=660;

CURSOR c_ord_details
IS

SELECT oha.order_number sales_order, oha.org_id, ola.line_number,
ola.shipment_number, ola.flow_status_code,
wdd.delivery_detail_id, wdd.inv_interfaced_flag,
wdd.oe_interfaced_flag, wdd.released_status
FROM apps.oe_order_headers_all oha,
apps.oe_order_lines_all ola,
apps.wsh_delivery_details wdd
WHERE oha.header_id = ola.header_id
AND oha.org_id = ola.org_id
AND oha.header_id = wdd.source_header_id
AND ola.line_id = wdd.source_line_id
AND oha.booked_flag = 'Y'
AND NVL (ola.cancelled_flag, 'N') <> 'Y'
AND wdd.released_status in ('R','B')
AND ola.flow_status_code = 'AWAITING_SHIPPING'
AND oha.order_number =66502
AND oha.org_id = 204;

BEGIN

-- Initializing the Applications


fnd_global.apps_initialize (l_user_id, l_resp_id, l_appl_id);

x_return_status := wsh_util_core.g_ret_sts_success;
i := 0;

FOR i IN c_ord_details

LOOP

-- Mandatory initialization for R12
mo_global.set_policy_context ('S', i.org_id);
mo_global.init ('ONT');

p_line_rows (1) := i.delivery_detail_id;

-- API Call for Auto Create Deliveries

DBMS_OUTPUT.put_line
('Calling WSH_DELIVERY_DETAILS_PUB to Perform AutoCreate Delivery');
DBMS_OUTPUT.put_line
('====================================================');

wsh_delivery_details_pub.autocreate_deliveries
(p_api_version_number => 1.0,
p_init_msg_list => apps.fnd_api.g_true,
p_commit => l_commit,
x_return_status => x_return_status,
x_msg_count => x_msg_count,
x_msg_data => x_msg_data,
p_line_rows => p_line_rows,
x_del_rows => x_del_rows
);

DBMS_OUTPUT.put_line (x_return_status);
DBMS_OUTPUT.put_line (x_msg_count);
DBMS_OUTPUT.put_line (x_msg_data);

IF (x_return_status <> wsh_util_core.g_ret_sts_success) THEN

DBMS_OUTPUT.put_line
('Failed to Auto create delivery for Sales Order');
RAISE exep_api;

ELSE

DBMS_OUTPUT.put_line
('Auto Create Delivery Action has successfully completed for SO');
DBMS_OUTPUT.put_line ('=============================================');
END IF;

-- Pick release.
p_delivery_id := x_del_rows (1);
p_delivery_name := TO_CHAR (x_del_rows (1));

DBMS_OUTPUT.put_line
('Calling WSH_DELIVERIS_PUB to Perform Pick Release of SO');
DBMS_OUTPUT.put_line ('=============================================');
-- API Call for Pick Release

wsh_deliveries_pub.delivery_action (p_api_version_number => 1.0,
p_init_msg_list => NULL,
x_return_status => x_return_status,
x_msg_count => x_msg_count,
x_msg_data => x_msg_data,
p_action_code => 'PICK-RELEASE',
p_delivery_id => p_delivery_id,
p_delivery_name => p_delivery_name,
p_asg_trip_id => NULL,
p_asg_trip_name => NULL,
p_asg_pickup_stop_id => NULL,
p_asg_pickup_loc_id => NULL,
p_asg_pickup_stop_seq => NULL,
p_asg_pickup_loc_code => NULL,
p_asg_pickup_arr_date => NULL,
p_asg_pickup_dep_date => NULL,
p_asg_dropoff_stop_id => NULL,
p_asg_dropoff_loc_id => NULL,
p_asg_dropoff_stop_seq => NULL,
p_asg_dropoff_loc_code => NULL,
p_asg_dropoff_arr_date => NULL,
p_asg_dropoff_dep_date => NULL,
p_sc_action_flag => 'S',
p_sc_intransit_flag => 'N',
p_sc_close_trip_flag => 'N',
p_sc_create_bol_flag => 'N',
p_sc_stage_del_flag => 'Y',
p_sc_trip_ship_method => NULL,
p_sc_actual_dep_date => NULL,
p_sc_report_set_id => NULL,
p_sc_report_set_name => NULL,
p_sc_defer_interface_flag => 'Y',
p_sc_send_945_flag => NULL,
p_sc_rule_id => NULL,
p_sc_rule_name => NULL,
p_wv_override_flag => 'N',
x_trip_id => x_trip_id,
x_trip_name => x_trip_name
);

DBMS_OUTPUT.put_line (x_return_status);
DBMS_OUTPUT.put_line (x_msg_count);
DBMS_OUTPUT.put_line (x_msg_data);

IF (x_return_status <> wsh_util_core.g_ret_sts_success) THEN

DBMS_OUTPUT.put_line ('Failed to Pick Release the sales order');
RAISE exep_api;

ELSE

DBMS_OUTPUT.put_line ('Sales Order has successfully Pick Released');
DBMS_OUTPUT.put_line ('==============================');

END IF;

--for pick confirm
COMMIT;

END LOOP;

EXCEPTION

WHEN exep_api THEN

DBMS_OUTPUT.put_line ('==============');
DBMS_OUTPUT.put_line ('Error Details If Any');
DBMS_OUTPUT.put_line ('==============');

wsh_util_core.get_messages ('Y',
x_msg_summary,
x_msg_details,
x_msg_count
);

IF x_msg_count > 1 THEN

x_msg_data := x_msg_summary ;
DBMS_OUTPUT.put_line (x_msg_data);

ELSE

x_msg_data := x_msg_summary;
DBMS_OUTPUT.put_line (x_msg_data);

END IF;

END;

/
COMMIT;


----------------------------------------------------------------------------------------------------------------
*****************************ship confirm from backend ****************************************
***********************************************************************************************
DECLARE
    --Standard Parameters.
    p_api_version                NUMBER;
    p_init_msg_list              VARCHAR2(30);
    p_commit                     VARCHAR2(30);

    --Parameters for WSH_DELIVERIES_PUB.Delivery_Action.  
    p_action_code                VARCHAR2(15);
    p_delivery_id                NUMBER;
    p_delivery_name              VARCHAR2(30);
    p_asg_trip_id                NUMBER;
    p_asg_trip_name              VARCHAR2(30);
    p_asg_pickup_stop_id         NUMBER;
    p_asg_pickup_loc_id          NUMBER;
    p_asg_pickup_loc_code        VARCHAR2(30);
    p_asg_pickup_arr_date        DATE;
    p_asg_pickup_dep_date        DATE;
    p_asg_dropoff_stop_id        NUMBER;
    p_asg_dropoff_loc_id         NUMBER;
    p_asg_dropoff_loc_code       VARCHAR2(30);
    p_asg_dropoff_arr_date       DATE;
    p_asg_dropoff_dep_date       DATE;
    p_sc_action_flag             VARCHAR2(10);
    p_sc_close_trip_flag         VARCHAR2(10);
    p_sc_create_bol_flag         VARCHAR2(10);
    p_sc_stage_del_flag          VARCHAR2(10);
    p_sc_trip_ship_method        VARCHAR2(30);
    p_sc_actual_dep_date         VARCHAR2(30);
    p_sc_report_set_id           NUMBER;
    p_sc_report_set_name         VARCHAR2(60);
    p_wv_override_flag           VARCHAR2(10);
    p_sc_defer_interface_flag    VARCHAR2(1);
    x_trip_id                    VARCHAR2(30);
    x_trip_name                  VARCHAR2(30);

    --out parameters  
    x_return_status              VARCHAR2(10);
    x_msg_count                  NUMBER;
    x_msg_data                   VARCHAR2(2000);
    x_msg_details                VARCHAR2(3000);
    x_msg_summary                VARCHAR2(3000);

    -- Handle exceptions  
    vApiErrorException           EXCEPTION;
BEGIN

    -- Initialize return status

    x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;

    -- Call this procedure to initialize applications parameters

    FND_GLOBAL.APPS_INITIALIZE(
       user_id      => 1013455
    ,  resp_id      => 21623
    ,  resp_appl_id => 660);

    -- Values for Ship Confirming the delivery

    p_action_code                 := 'CONFIRM'; -- The action code for ship confirm
    p_delivery_id                 := 3783377;   -- The delivery that needs to be confirmed
    p_sc_action_flag              := 'S';       -- Ship entered quantity.
    p_sc_close_trip_flag          := 'Y';       -- Close the trip after ship confirm
    p_sc_trip_ship_method         := 'DHL';     -- The ship method code
    p_sc_defer_interface_flag     := 'N';

    -- Call to WSH_DELIVERIES_PUB.Delivery_Action.
    WSH_DELIVERIES_PUB.Delivery_Action(
        p_api_version_number         => 1.0,
        p_init_msg_list              => p_init_msg_list,
        x_return_status              => x_return_status,
        x_msg_count                  => x_msg_count,
        x_msg_data                   => x_msg_data,
        p_action_code                => p_action_code,
        p_delivery_id                => p_delivery_id,
        p_delivery_name              => p_delivery_name,
        p_asg_trip_id                => p_asg_trip_id,
        p_asg_trip_name              => p_asg_trip_name,
        p_asg_pickup_stop_id         => p_asg_pickup_stop_id,
        p_asg_pickup_loc_id          => p_asg_pickup_loc_id,
        p_asg_pickup_loc_code        => p_asg_pickup_loc_code,
        p_asg_pickup_arr_date        => p_asg_pickup_arr_date,
        p_asg_pickup_dep_date        => p_asg_pickup_dep_date,
        p_asg_dropoff_stop_id        => p_asg_dropoff_stop_id,
        p_asg_dropoff_loc_id         => p_asg_dropoff_loc_id,
        p_asg_dropoff_loc_code       => p_asg_dropoff_loc_code,
        p_asg_dropoff_arr_date       => p_asg_dropoff_arr_date,
        p_asg_dropoff_dep_date       => p_asg_dropoff_dep_date,
        p_sc_action_flag             => p_sc_action_flag,
        p_sc_close_trip_flag         => p_sc_close_trip_flag,
        p_sc_create_bol_flag         => p_sc_create_bol_flag,
        p_sc_stage_del_flag          => p_sc_stage_del_flag,
        p_sc_trip_ship_method        => p_sc_trip_ship_method,
        p_sc_actual_dep_date         => p_sc_actual_dep_date,
        p_sc_report_set_id           => p_sc_report_set_id,
        p_sc_report_set_name         => p_sc_report_set_name,
        p_wv_override_flag           => p_wv_override_flag,
        p_sc_defer_interface_flag    => p_sc_defer_interface_flag  ,        
        x_trip_id                    => x_trip_id,
        x_trip_name                  => x_trip_name);

    IF (x_return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS)
THEN
        RAISE vApiErrorException;
    ELSE
        dbms_output.put_line('The confirm action on the delivery '||p_delivery_id||' is successful');
    END IF;
EXCEPTION
    WHEN vApiErrorException
THEN
        WSH_UTIL_CORE.get_messages('Y', x_msg_summary, x_msg_details,x_msg_count);
        IF x_msg_count > 1
THEN
            x_msg_data := x_msg_summary || x_msg_details;
            DBMS_OUTPUT.PUT_LINE('Message Data : '||x_msg_data);
        ELSE
            x_msg_data := x_msg_summary;
            DBMS_OUTPUT.PUT_LINE('Message Data : '||x_msg_data);
        END IF;
    WHEN OTHERS
    THEN
DBMS_OUTPUT.PUT_LINE('Unexpected Error: '||SQLERRM);
END;
/

1 comment:

  1. We would like to acknowledge the exceptional service that we received during the entire refinancing process. Mr Lee professionalism and knowledge of the loan company was impressive and truly appreciated. Mr Lee is a reliable loan officer.In the past, we have had experience with several others banks and have found the process frustrating and tedious. Mr Lee went above and beyond to ensure that all of our needs were met and that everything was handled thoroughly and efficiently. We have and will continue to recommend him in the future.”Mr Lee Contact Email /Whatsapp 247officedept@gmail.com+1-989-394-3740


    ReplyDelete