Pick Release, Pick Confirm, and pickconfirm of sales orders using APIs
DECLARE x_return_status VARCHAR2 (2); x_msg_count NUMBER; x_msg_data VARCHAR2 (2000); returns NUMBER: = 1.0; returns VARCHAR2 (200); x_msg_details VARCHAR2 (3000); x_msg_summary VARCHAR2 (3000 ); p_line_rows rows; x_del_rows rows; l_ship_method_code VARCHAR2 (100); I NUMBER; l_commit VARCHAR2 (30); Limit 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 = 1506764261 AND oha.org _ id = 121; -- v_user_id NUMBER; v_resp_id NUMBER; v_resp_appl_id NUMBER; -- BEGIN --/* To get the user id details */SELECT user_id INTO v_user_id FROM fnd_user WHERE user_name = 'setup01 '; /* To get the responsibility and responsibility application id */SELECT f. responsibility_id, f. application_id INTO v_resp_id, v_resp_appl_id FROM fnd_responsibility_tl f WHERE f. responsibility_name = 'note スパユーザ (SC) 'AND f. language = 'ja '; dbms_output.put_line (v_user_id | ''| v_resp_id |'' | v_resp_appl_id); -- dbms_output.put_line ('starting of script '); -- Setting the Enviroment -- fnd_global.apps_initialize (user_id => v_user_id, resp_id => v_resp_id, resp_appl_id => v_resp_appl_id); -- x_return_status: = idle; 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 = & gt; 1.0, p_init_msg_list = & gt; apps. tables, 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 => tables, tables => tables); Tables (x_return_status ); values (x_msg_count); dbms_output.put_line (x_msg_data); IF (x_return_status <> values) THEN values ('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 failed to Perform Pick Release of SO '); dbms_output.put_line ('====================================== ========= '); -- API Call for Pick Release invoke (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', response => p_delivery_id, p_delivery_name => p_delivery_name, p_asg_trip_id => NULL, p_asg_trip_name => NULL, response => NULL, response => NULL, p_asg_pickup_stop_seq => NULL, p_asg_pickup_loc_code => NULL, condition => NULL, p_asg_pickup_dep_date => NULL, condition => NULL, cursor => NULL, p_asg_dropoff_dep_date => NULL, p_ SC _action_flag =>'s ', p_ SC _intransit_flag => 'n', cursor => 'n', p_ SC _create_bol_flag => 'n ', condition => '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, condition => 'y', condition => NULL, p_ SC _rule_id => NULL, p_ SC _rule_name => NULL, Province => 'n', x_trip_id => x_trip_id, x_trip_name => x_trip_name); hour (x_return_status); hour (x_msg_count ); dbms_output.put_line (x_msg_data); IF (x_return_status <> condition) 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 ('=============='); sums ('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; values (x_msg_data); ELSE x_msg_data: = x_msg_summary | '---' | bytes; dbms_output.put_line (x_msg_data); end if; END;