CREATE VIEW rlarp.sachdef AS 
WITH
sach_def AS (
SELECT
    s.BK7CODE plev,
    s.BK7DES1 d2,
    s.BK7DES2 d3,
    b.JBPLCD plcd,
    b.JBFDAT fdate,
    b.JBTDAT tdate,
    d.func,
    d.tier,
    d.currency,
    --d.des_currency,
    --d.fx,
    d.country,
    d.basis,
    d.parent
FROM
    lgdat.sach s
    INNER JOIN "CMS.CUSLG".IPRCBHC b ON
        b.JBPLVL = s.BK7CODE 
    INNER JOIN rlarp.plm d ON
        d.plcode = b.JBPLCD 
 )
SELECT * FROM sach_def 

