0% found this document useful (0 votes)
64 views3 pages

SQL For RMA Receipt Data Fix

The document describes steps to process return merchandise authorizations (RMAs) by: 1. Loading RMA data into a temporary table 2. Identifying RMA lines where the returned asset is not in the system 3. Identifying RMA lines where the returned asset exists but receipt is blank 4. Identifying incorrectly received assets that were returned on another order 5. Updating the status of assets in the system to match the RMA data

Uploaded by

Rishabh Goyal
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
Download as txt, pdf, or txt
0% found this document useful (0 votes)
64 views3 pages

SQL For RMA Receipt Data Fix

The document describes steps to process return merchandise authorizations (RMAs) by: 1. Loading RMA data into a temporary table 2. Identifying RMA lines where the returned asset is not in the system 3. Identifying RMA lines where the returned asset exists but receipt is blank 4. Identifying incorrectly received assets that were returned on another order 5. Updating the status of assets in the system to match the RMA data

Uploaded by

Rishabh Goyal
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1/ 3

--Step 1

--Create temp Table


create table tmp_rma(
ORDER_NO VARCHAR2(100),
LINE_NO Number,
ACTION_TYPE VARCHAR2(100),
STATUS VARCHAR2(100),
RETURN_ITEM VARCHAR2(100),
RETURN_SERIAL_NUMBER VARCHAR2(100),
RECEIVED_QUANTITY number,
RETURN_RECEIPT_DATE date
);

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

If (I.RA_PAR_ID IS NOT NULL AND I.STATUS_CD = 'Uninstalled') THEN


UPDATE S_ASSET SET STATUS_CD = 'Installed', x_replacement_id = '' WHERE ROW_ID
= I.ROW_ID;
DBMS_OUTPUT.PUT_LINE('Record is component: and rownum = ' || I.RNUM || '----'
||I.ROW_ID);
IF (I.R_SERIAL_NUM = I.SERIAL_NUM AND I.PAR_STAT = 'Uninstalled') THEN
UPDATE S_ASSET SET STATUS_CD = 'Installed', x_replacement_id = '' WHERE
ROW_ID = I.RA_PAR_ID;
DBMS_OUTPUT.PUT_LINE('Record is parent and rownum = ' || I.RNUM || '----' ||
I.RA_PAR_ID);
END IF;

ELSIF(I.STATUS_CD = 'Uninstalled' AND I.RA_PAR_ID IS NULL) THEN


UPDATE S_ASSET SET STATUS_CD = 'Installed', x_replacement_id = '' WHERE ROW_ID
= I.ROW_ID;
DBMS_OUTPUT.PUT_LINE('Record is individual and rownum = ' || I.RNUM || '----'
||I.ROW_ID);
ELSE NULL;
END IF;
END LOOP;

update s_order_item set status_cd = '', X_REC_SBL_AST_ID = '' where row_id in (


select oi.row_id from s_order o, s_order_item oi where o.row_id = oi.order_id and
(o.order_num||oi.ln_num) in (
select order_no||line_no from tmp_rma));

update s_order_item set status_cd = 'Submitted', X_REC_SBL_AST_ID = '' where row_id


in (
select oi.row_id from s_order o, s_order_item oi where o.row_id = oi.order_id and
(o.order_num||oi.ln_num) in (
select order_no||line_no from tmp_rma tmp where not exists (
select 1
from tmp_rma t, s_order o, s_order_item oi, s_asset da, s_org_ext oe
where t.order_no = o.order_num and o.row_id = oi.order_id and t.line_no = oi.LN_NUM
and t.return_serial_number = da.serial_num and t.return_receipt_date < da.ship_dt
and da.OWNER_ACCNT_ID = oe.row_id(+)
and t.order_no = tmp.order_no and t.line_no = tmp.line_no)));

COMMIT;

EXCEPTION
WHEN OTHERS THEN DBMS_OUTPUT.PUT_LINE('ERROR');
END;

===================================================================================
==========================================================================

You might also like