Friday, October 30, 2009

Performing Pick Release Using WSH_DELIVERY_PUB API

Performing Pick Release Using WSH_DELIVERY_PUB API
************************************************************

Creating Deliveries:
===============
• A Delivery is required to perform Ship Confirm. It represent all the goods that were shipped from the same warehouse, going to the same Customer location.
• A Delivery can be created automatically or manually from the Shipping Transaction form at any time after the order lines have become “Awaiting Shipment” or can be automatically created during the Release Sales Order process.

• The delivery can also be created Programatically using shipping API “WSH_DELIVERIES_PUB.Create_update_delivery” by passing the required and optional parameter values.

Specific parameters:

• p_api_version_number => 1.0
• p_action_code => CREATE

-- for creating new delivery
• p_delivery_info => Attributes of the delivery entity of type Delivery_Pub_Rec_Type

Performing Pick Release:
===================

What Happens during Pick Release:
**************************************
• A pre-approved Move Order is automatically created in Inventory.
• A Move order is a request for a subinventory transfer from the source subinventory to the destination (staging) subinventory.
• A Move order is created for every Sales Order Line that has the status of “Awaiting Shipping” and passes the picking criteria.
• The Destination subinventory is the Staging subinventory entered on the Release Sales Orders form or defaulted from the Shipping Parameters. Only one staging subinventory is allowed per Picking Batch.

Allocate Inventory to the move order:
***************************************
• Allocating can be done automatically after the move order is created by setting “Auto Allocate” to yes on the Release Sales Order form or postponed until later, then manually allocated from the Transaction Move Orders form.
• The Release Sequence Rule, that was entered on the Release Sales Orders form, or defaulted from the Shipping Parameters, will be used to determine in what sequence to fill the move orders.
• Move orders use inventory’s picking rules to suggest the material that should be allocated. The sourcing values for subinventory, locators, revisions, and lots are defaulted on to the move order.
• The source defaults can be manually updated from the Transaction Move Orders form.
• A high level reservation is placed for the Move Order’s material requirements.
• Allocating inventory is a prerequisite for printing Pick Slips. The Pick Slip Grouping Rule entered on the Release Sales Orders form or defaulted from the Shipping Parameters is used while printing pick slips.

Pick Confirm the move order
******************************
• Pick Confirm can be done automatically during the picking process by setting “Pick Confirm” to yes on the Release Sales Orders form or by unchecking the Pick Confirm Required checkbox in the Organization Parameters form. If it is not done automatically during pick release it can be done manually from the Transaction Move Orders form by selecting the Transact button.
• The Pick Confirm transaction executes the subinventory transfer, moving the material from it’s source location to it’s destination staging location. Only 1 staging subinventory is supported per picking batch.
• The high level reservations are replaced with detail reservations.
• If you transact less than the requested quantity, the Move Order will stay open until the total quantity is transacted, or the order is closed or cancelled.
• The status of the Sales Order Line, which is linked to the Move Order, is changed to “Picked” making it eligible for Ship Confirm.
• If not all of the Move order quantity was transacted the status of the Sales Order Line, is changed to “Picked Partial”. During Ship Confirm the order line will split into 2 shipment schedules (e.g. 1.1 and 1.2). The status of the unfilled line will be changed to “Awaiting Shipping”.

For performing Pick Release Programatically we can use the shipping public API "WSH_DELIVERIES_PUB.Delivery_Action”, which enables pick release of the sales order line. The relevant pick release parameters are retrieved from the Shipping and Organization Parameter setup.

Specific Parameters:

p_action_code = > PICK_RELEASE
p_delivery_id/p_delivery_name => Id/name of delivery


-- R12 - OM - Sample Script to Perform Pick using WSH_DELIVERY_PUB API --
-- ======================================================== --


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;
l_resp_id NUMBER;
l_appl_id NUMBER;

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 = 10001059
AND oha.org_id = 308;

BEGIN

-- Initializing the Applications

SELECT user_id
INTO l_user_id
FROM fnd_user
WHERE user_name = 'A42485';

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

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 x_msg_details;
DBMS_OUTPUT.put_line (x_msg_data);

ELSE

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

END IF;

END;

12 comments:

  1. Hi Jyoti,

    These are pretty useful articles. But there is one scenario which I did not see here. I was wondering if you have a solution for partial ship confirms. The delivery has been picked fully but shipped partially. I know this straight forward but how do I ship confirm the remaining quantity programmatically? I am not running pick release again as the line is picked. How can I ship the remaining quantity using the first delivery_id? Any help in this regard would be greatly appreciated. I can be reached on gvk2512@gmail.com

    Thanks,
    Goutham

    ReplyDelete
  2. Thanks Goutham,
    Yes, the partial shipment can be done by passing the shipping quantity into the API. I will test the same & update the blog.

    Rgds,
    Jyoti

    ReplyDelete
  3. Hi Jyoti
    Following your article I was able to do the picking (ie, the SO lines are now showing "Picked") however, I am lost after that. I tried to use your script for partial shipping of a SO, and the script fails whenever I try to CONFIRM the shipment by passing 'S'.
    Any suggestions? I cross checked the quantities and made sure that there was enough quantity to confirm the shipping.

    ReplyDelete
  4. Hi Jyoti,
    I am performing shipping using all APIs and I am having issues getting past launch pick release and to allocate inventory. I did some research and saw that there are concurrent programs that get kicked off in the backround after pick release is performed. Is this true? If I do create trip, launch pick release and allocate inventory all sequentially, I get the following error:
    Pick Release launched successfully for selected lines. The request ID is 436228079.|Number of concurrent requests launched successfully: 1. Number of requests that failed: 0.ORA-01400: cannot insert NULL into ("INV"."MTL_MATERIAL_TRANSACTIONS_TEMP"."LAST_UPDATED_BY")
    When I add a commit after the launch pick release it seems to work at times and not at other times. Any idea why this is happening?

    ReplyDelete
  5. you will be required to use update_shipping_attribute to partially ship it.

    ReplyDelete
  6. for lot controlled items,even when i set auto allocate to "no" and auto pick confirm to "no", the system seems to print the earliest lot on the pick list and also populates the move order with the same lot. Of course I can override the lot on the move order. is there a way to just show all the possible lots on the pick list and not populate the move order with lot numbers -- just let the user pick the lots.. Thanks

    ReplyDelete
  7. Dear Jyoti,

    I have run your script and it's works. Thank you so much. But, the delivery id created per line order. How to create delivery id per order number?

    ReplyDelete
  8. Hi Jyoti,

    I am getting following error from the API while pick release :-

    Error: Number of concurrent requests launched successfully: 0. Number of requests that failed: 1.Error: Launching Pick Release failed for Delivery

    will appreciate your reply.

    Thanks,
    Ankit

    ReplyDelete
  9. Hi Jyoti,
    Your article is very useful, above code is upto launch pick release, please provide further code for desired lot reservation and pick confirm through API.

    Thanks a lot

    ReplyDelete
  10. Hi Jyothi

    wsh_deliveries_pub.delivery_action pick-release picks full ordered quantity.

    How to pick only the reserved quantity through wsh_deliveries_pub.delivery_action api.

    Pls help me in this regards.

    Thanks in advance.


    ReplyDelete
  11. Very nice. I am seeing your post related to training in all blogs.
    Keep posting..

    ReplyDelete
  12. Hi Jyothi,

    I have a scenario where I send in a batch of data for Pick Release and Pick Confirm. I have a custom program which performs both the operation in one shot sequentially. But when the batch of data contains two orders with same part numbers, the program performs only pick release but does not perform pick confirm. Could there be any standard reason for this? Thanks

    ReplyDelete