cancel line
DESCRIPTION
scriptTRANSCRIPT
-
5/19/2018 Cancel Line
1/5
REM $Header: ontd0008.sql 115.1 2004/05/21 22:26:56 tbharti ship $REM +=======================================================================+REM | Copyright (c) 2003 Oracle Corporation, Redwood Shores, CA, USA |REM | All rights reserved. |REM +=======================================================================+REM | FILENAME |REM | ontd0008.sql |REM | |REM | DESCRIPTION |REM | This script has been created to allow cancelling those lines |REM | which are stuck due to some data corruption and can neither |
REM | be progressed nor cancelled from the application.This script |REM | will do the following: |REM | |REM | 1. Update Lines to show as if Cancelled. |REM | 2. Cancel Delivery Details(if any) associated to order lines. |REM | 3. Progress flow(if exists) to CLOSE. |REM | |REM | Note that this script DOES NOT: |REM | |REM | 1. Delink the Configured Items that may exist on an order. |REM | 2. Update the history tables with cancellation information. |REM | 3. Unschedule the Lines. Inventory patch # 1807561 should be |REM | applied after running this script to relieve the demand. |
REM | 4. Update Move Order Lines, log a clean bug against inventory |REM | 5. Update Supply. |REM | |REM | DISCLAIMER |REM | Do not use this script as a replacement for OM Cancellation |REM | functionality as it's strictly meant for those stuck order |REM | lines which can neither be progressed nor cancelled from the |REM | application. |REM | |REM | Use this script at your own risk. The script has been tested |REM | and appears to works as intended. However, you should always |REM | test any script before relying on it. |REM | |
REM | Proofread the script prior to running it. Due to differences |REM | in the way text editors,email packages and operating systems |REM | handle text formatting (spaces, tabs and carriage returns), |REM | this script may not be in an executable state when you first |REM | receive it. Check over the script to ensure that errors of |REM | this type are corrected. |REM | |REM | Do not remove disclaimer paragraph. |REM | |REM | INPUT/OUTPUT |REM | Inputs : Line Id(Required) |REM | |REM | Output : Report is printed to an O/S file named line_id.lst |
REM | |REM | NOTE |REM | This script should be tested in TEST Instance first. |REM | If results are satisfactory in TEST, then only use in |REM | PRODUCTION Instance. |REM | |REM | HISTORY |REM | 14-MAR-2002 Tarun Bharti Created |REM +=======================================================================+
-
5/19/2018 Cancel Line
2/5
REM dbdrv:noneSET VERIFY OFF;WHENEVER OSERROR EXIT FAILURE ROLLBACK;WHENEVER SQLERROR EXIT FAILURE ROLLBACK;
clear buffer;set serveroutput on size 500000set feed offset pagesize 1000set linesize 120set underline '='
Promptaccept order_line_id num prompt 'Enter LINE_ID of the line to Cancel: 'Prompt
spool &order_line_id
declare
l_lin_id number := &order_line_id; l_lin_key varchar2(30) := to_char(l_lin_id);
l_ordered_qty number;
l_flow_exists varchar2(1); l_user_id number; l_resp_id number; l_resp_appl_id number; l_heading varchar2(1) := 'N';
cursor wsh_ifaced is select
substr(wdd.source_line_number, 1, 15) line_num , substr(wdd.item_description, 1, 30) item_name , wdd.shipped_quantity , wdd.source_line_id line_id
from wsh_delivery_details wdd, oe_order_lines_all oel where wdd.inv_interfaced_flag = 'Y' and nvl(wdd.shipped_quantity,0) > 0 and oel.line_id = wdd.source_line_id and oel.open_flag = 'N' and oel.ordered_quantity = 0 and wdd.source_code = 'OE' and oel.line_id = l_lin_id and exists
( select 'x'from mtl_material_transactions mmt
where wdd.delivery_detail_id = mmt.picking_line_id and mmt.trx_source_line_id = wdd.source_line_id
and mmt.transaction_source_type_id in ( 2,8 ));
begin
dbms_output.put_line('Updating Line ID: '||l_lin_id);
l_flow_exists := 'Y';
update oe_order_lines_all set flow_status_code = 'CANCELLED'
-
5/19/2018 Cancel Line
3/5
, open_flag = 'N' , cancelled_flag = 'Y' , ordered_quantity = 0 , cancelled_quantity = ordered_quantity + nvl(cancelled_quantity, 0) , last_updated_by = -9999999 , last_update_date = sysdate where line_id = l_lin_id;
Begin select number_value into l_user_id
from wf_item_attribute_values where item_type = 'OEOL' and item_key = l_lin_key and name = 'USER_ID';
select number_value into l_resp_id from wf_item_attribute_values where item_type = 'OEOL' and item_key = l_lin_key and name = 'RESPONSIBILITY_ID';
select number_value
into l_resp_appl_id from wf_item_attribute_values where item_type = 'OEOL' and item_key = l_lin_key and name = 'APPLICATION_ID';
Exception When No_Data_Found Then l_flow_exists := 'N'; End;
if l_flow_exists = 'Y' then
fnd_global.apps_initialize(l_user_id, l_resp_id, l_resp_appl_id);
wf_engine.handleerror( OE_Globals.G_WFI_LIN , l_lin_key , 'CLOSE_LINE' , 'RETRY' , 'CANCEL' ); end if;
for wsh_ifaced_rec in wsh_ifaced loop if l_heading = 'N' then dbms_output.put_line(' ');
dbms_output.put_line('Following Cancelled Lines have already been Interfaced to Inventory.'); dbms_output.put_line('Onhand Qty must be manually adjusted for these Itemsand Quantities.'); dbms_output.put_line(' '); dbms_output.put_line('+---------------+------------------------------+---------------+---------------+'); dbms_output.put_line('|Line No. |Item Name |Shipped Qty| Line Id|'); dbms_output.put_line('+---------------+------------------------------+----
-
5/19/2018 Cancel Line
4/5
-----------+---------------+'); l_heading := 'Y'; end if; dbms_output.put_line('|'||rpad(wsh_ifaced_rec.line_num, 15)|| '|'||rpad(wsh_ifaced_rec.item_name, 30)|| '|'||lpad(to_char(wsh_ifaced_rec.shipped_quantity), 15)|| '|'||lpad(to_char(wsh_ifaced_rec.line_id), 15)||'|'); end loop;
update wsh_delivery_assignments
set delivery_id = null , parent_delivery_detail_id = null , last_updated_by = -9999999 , last_update_date = sysdate where delivery_detail_id in
(select wdd.delivery_detail_id from wsh_delivery_details wdd, oe_order_lines_all oel where wdd.source_line_id = oel.line_id and wdd.source_code = 'OE' and oel.cancelled_flag = 'Y' and oel.line_id = l_lin_id and released_status 'D');
update wsh_delivery_details set released_status = 'D' , src_requested_quantity = 0 , requested_quantity = 0 , shipped_quantity = 0 , cycle_count_quantity = 0 , cancelled_quantity = decode(requested_quantity,0,cancelled_quantity,requested_quantity) , subinventory = null , locator_id = null , lot_number = null , serial_number = null , revision = null
, ship_set_id = null , inv_interfaced_flag = 'X' , oe_interfaced_flag = 'X' , last_updated_by = -9999999 , last_update_date = sysdate where source_line_id = l_lin_id and source_code = 'OE' and released_status 'D' and exists
(select 'x' from oe_order_lines_all oel where source_line_id = oel.line_id and oel.cancelled_flag = 'Y');
Exception when others then rollback; dbms_output.put_line(substr(sqlerrm, 1, 240));end;/
PromptPrompt You must enter Commit to Save the Changes and Rollback to Revert.
-
5/19/2018 Cancel Line
5/5
Prompt
spool off