SELECT A.BUSINESS_UNIT ,A.COMMON_ID ,A.ITEM_NBR ,D.LINE_SEQ_NBR ,x.LANGUAGE_CD ,x.DESCR FROM PS_ITEM_SF A ,PS_ITEM_TYPE_TBL B ,PS_BUS_UNIT_TBL_SF C ,PS_ITEM_LINE_SF D ,PSTREENODE O ,PSTREELEAF Q , PS_ITEM_TYPE_LNG x WHERE A.BUSINESS_UNIT = C.BUSINESS_UNIT AND A.ITEM_TYPE=B.ITEM_TYPE AND A.BUSINESS_UNIT = D.BUSINESS_UNIT AND A.COMMON_ID = D.COMMON_ID AND A.SA_ID_TYPE = D.SA_ID_TYPE AND A.ITEM_NBR = D.ITEM_NBR AND A.SA_ID_TYPE = 'P' AND B.ITEM_TYPE_CD = 'C' AND A.ITEM_AMT - A.APPLIED_AMT > 0 AND B.SETID= ( SELECT F.SETID FROM PS_SET_CNTRL_REC F WHERE F.RECNAME='ITEM_TYPE_TBL' AND F.SETCNTRLVALUE=C.INSTITUTION) AND B.EFFDT= ( SELECT MAX(Y.EFFDT) FROM PS_ITEM_TYPE_TBL Y WHERE Y.SETID=B.SETID AND Y.ITEM_TYPE=B.ITEM_TYPE AND Y.EFFDT <= %CurrentDateIn AND Y.EFF_STATUS = 'A' ) AND O.SETID = B.SETID AND O.TREE_NAME = C.TREE_NAME2 AND O.EFFDT = ( SELECT MAX(P.EFFDT) FROM PSTREENODE P WHERE P.SETID = O.SETID AND P.TREE_NAME = O.TREE_NAME AND P.EFFDT <= %CurrentDateIn) AND Q.SETID = O.SETID AND Q.TREE_NAME = O.TREE_NAME AND Q.TREE_BRANCH =O.TREE_BRANCH AND Q.TREE_NODE_NUM = O.TREE_NODE_NUM AND Q.EFFDT = O.EFFDT AND B.ITEM_TYPE >= Q.RANGE_FROM AND B.ITEM_TYPE <= Q.RANGE_TO AND b.setid = x.setid AND b.item_type=x.item_type AND b.effdt = x.effdt
|