SQL For RMA Receipt Data Fix
SQL For RMA Receipt Data Fix
--Step 2
Load data into Temp Table via command or using Master from EBS.xlsx using SQL
developer Client
--Step 3
--Identify correct return assets not exists in Siebel, there will be no action on
these RMA lines as correct receipts are not in Siebel
select * from tmp_rma t
where not exists (select 1 from s_asset a, s_prod_int p where a.prod_id = p.row_id
and a.serial_num = t.return_serial_number and p.part_num = t.return_item);
--203
--Step 4
--Identify RMAs having blank return receipts and correct receipt assets exists in
Siebel DB
These need to be shared with EBS along with Order No, Line No, Correct Return
Serial # and Return Item to trigger RMA Receipt interface
select oi.row_id, t.order_no, t.line_no, t.return_item, t.return_serial_number,
o.X_RMA_TYPE, da.serial_num D_SERIAL_NUM, ra.serial_num R_SERIAL_NUM,
ra.par_asset_id RA_PAR_ID, sa.serial_num S_SERIAL_NUM, sa.par_asset_id SA_PAR_ID
from tmp_rma t, s_order o, s_order_item oi, s_asset ra, s_asset sa, s_asset da,
s_prod_int p--, s_asset ca, s_prod_int cp
where t.order_no = o.order_num and o.row_id = oi.order_id and t.line_no = oi.ln_num
and oi.X_REC_SBL_AST_ID = ra.row_id(+) and oi.X_SHIP_ASSET_ID = sa.row_id(+) and
oi.asset_id = da.row_id(+) and ra.prod_id = p.row_id(+) and ra.serial_num is null
and exists (select 1 from s_asset a, s_prod_int p where a.prod_id = p.row_id and
a.serial_num = t.return_serial_number and p.part_num = t.return_item)
order by x_rma_type, da.serial_num;
--26
--Step 5
--Incorrect Receipts are RMA'd on another Order and should remain Uninstalled
select t.order_no, t.line_no, t.return_item, t.return_serial_number, o.X_RMA_TYPE,
da.serial_num D_SERIAL_NUM, ra.serial_num R_SERIAL_NUM, ra.par_asset_id RA_PAR_ID,
sa.serial_num S_SERIAL_NUM, sa.par_asset_id SA_PAR_ID--, ca.serial_num
Correct_SERIAL_NUM
from tmp_rma t, s_order o, s_order_item oi, s_asset ra, s_asset sa, s_asset da,
s_prod_int p--, s_asset ca, s_prod_int cp
where t.order_no = o.order_num and o.row_id = oi.order_id and t.line_no = oi.ln_num
and oi.X_REC_SBL_AST_ID = ra.row_id(+) and oi.X_SHIP_ASSET_ID = sa.row_id(+) and
oi.asset_id = da.row_id(+) and ra.prod_id = p.row_id(+) and ra.serial_num is not
null
and exists (select 1 from s_order_item aoi, s_order ao where aoi.order_id =
ao.row_id and asset_id = oi.X_REC_SBL_AST_ID and ao.order_num <> o.order_num);
--74
--Step 6
--Install incorrect returns and update correct Returns on RMA Lines
select t.order_no, t.line_no, t.return_item, t.return_serial_number, o.X_RMA_TYPE,
da.serial_num D_SERIAL_NUM, ra.serial_num R_SERIAL_NUM,
ra.status_cd, ra.par_asset_id RA_PAR_ID, pra.status_cd, sa.serial_num S_SERIAL_NUM,
sa.par_asset_id SA_PAR_ID--, ca.serial_num Correct_SERIAL_NUM
from tmp_rma t, s_order o, s_order_item oi, s_asset ra, s_asset sa, s_asset da,
s_prod_int p, s_asset pra--, s_prod_int cp
where t.order_no = o.order_num and o.row_id = oi.order_id and t.line_no = oi.ln_num
and ra.par_asset_id = pra.row_id(+)
and oi.X_REC_SBL_AST_ID = ra.row_id(+) and oi.X_SHIP_ASSET_ID = sa.row_id(+) and
oi.asset_id = da.row_id(+) and ra.prod_id = p.row_id(+) and ra.serial_num is not
null
and not exists (select 1 from s_order_item aoi, s_order ao where aoi.order_id =
ao.row_id and asset_id = oi.X_REC_SBL_AST_ID and ao.order_num <> o.order_num);
--232
===================================================================================
==========================================================================
DECLARE
CURSOR UPD_ASSET IS
select ROWNUM RNUM, t.order_no, t.line_no, t.return_item, t.return_serial_number,
o.X_RMA_TYPE, ra.serial_num R_SERIAL_NUM, ra.row_id,
ra.status_cd, ra.par_asset_id RA_PAR_ID, pra.serial_num, pra.status_cd PAR_STAT
from tmp_rma t, s_order o, s_order_item oi, s_asset ra, s_asset pra--, s_prod_int
cp
where t.order_no = o.order_num and o.row_id = oi.order_id and t.line_no = oi.ln_num
and ra.par_asset_id = pra.row_id(+)
and oi.X_REC_SBL_AST_ID = ra.row_id --AND I.STATUS_CD = 'Uninstalled' --and
ra.serial_num = '8215334438D9PV'
and not exists (select 1 from s_order_item aoi, s_order ao where aoi.order_id =
ao.row_id and asset_id = oi.X_REC_SBL_AST_ID and ao.order_num <> o.order_num);
--232
BEGIN
FOR I IN UPD_ASSET
LOOP
COMMIT;
EXCEPTION
WHEN OTHERS THEN DBMS_OUTPUT.PUT_LINE('ERROR');
END;
===================================================================================
==========================================================================