snap quota rep
This commit is contained in:
parent
c0c0a98e1f
commit
c6df2774cb
44
build/snap_cust_osmfs.sql
Normal file
44
build/snap_cust_osmfs.sql
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
UPDATE
|
||||||
|
RLARP.OSMFS_DEV S
|
||||||
|
SET
|
||||||
|
DSM = CR.QUOTA_REP
|
||||||
|
FROM
|
||||||
|
(
|
||||||
|
SELECT DISTINCT
|
||||||
|
VERSION,
|
||||||
|
COALESCE(GLEC,'') GLEC,
|
||||||
|
COALESCE(MING,'') MING,
|
||||||
|
BILL_CUST,
|
||||||
|
SHIP_CUST,
|
||||||
|
------------quota rep column--------------
|
||||||
|
CASE WHEN COALESCE(ming,'') = 'B52' THEN 'PW' ELSE
|
||||||
|
--if the gl expense code is 1RE use the retail rep assigned to the bill-to customer if available
|
||||||
|
CASE WHEN COALESCE(glec,'') = '1RE' AND COALESCE(cu.currep,'') <> '' THEN
|
||||||
|
cu.currep
|
||||||
|
--default logic
|
||||||
|
ELSE
|
||||||
|
CASE SUBSTR(bill_class,2,3)
|
||||||
|
WHEN 'DIS' THEN
|
||||||
|
ship_rep
|
||||||
|
ELSE
|
||||||
|
bill_rep
|
||||||
|
END
|
||||||
|
END
|
||||||
|
END QUOTA_REP
|
||||||
|
FROM
|
||||||
|
RLARP.OSMFS_DEV S
|
||||||
|
LEFT OUTER JOIN LGDAT.CUST ON
|
||||||
|
BVCUST = BILL_CUST
|
||||||
|
LEFT OUTER JOIN lgpgm.usrcust cu ON
|
||||||
|
cu.cucust = s.bill_cust
|
||||||
|
--WHERE
|
||||||
|
-- COALESCE(GLEC,'') IS NOT NULL
|
||||||
|
) CR
|
||||||
|
WHERE
|
||||||
|
CR.VERSION = S.VERSION
|
||||||
|
AND CR.GLEC = COALESCE(S.GLEC,'')
|
||||||
|
AND CR.MING = COALESCE(S.MING,'')
|
||||||
|
AND CR.BILL_CUST = S.BILL_CUST
|
||||||
|
AND CR.SHIP_CUST = S.SHIP_CUST
|
||||||
|
AND COALESCE(S.DSM,'') <> CR.QUOTA_REP;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user