SELECT B.business_unit , B.common_id , B.INVOICE_ID , B.item_nbr , d.language_cd , d.descr FROM PS_BI_BILLING_LINE B , ps_item_sf A , PS_ITEM_LINE_SF c , ps_item_type_lng d , ps_bus_unit_tbl_sf e , PS_SCC_INS_NAME_VW f , PS_BI_BILL_HEADER G WHERE B.BUSINESS_UNIT = C.BUSINESS_UNIT AND B.COMMON_ID = C.COMMON_ID AND B.SA_ID_TYPE = C.SA_ID_TYPE AND B.ITEM_NBR = C.ITEM_NBR AND B.ITEM_LINE = C.LINE_SEQ_NBR AND c.business_unit = a.business_unit AND c.common_id = a.common_id AND c.sa_id_type = a.sa_id_type AND c.item_nbr = a.item_nbr AND a.sa_id_type = 'P' AND d.item_type = a.item_type AND e.business_unit = a.business_unit AND a.common_id = f.emplid AND G.BUSINESS_UNIT = B.BUSINESS_UNIT AND G.INVOICE_ID = B.INVOICE_ID AND d.setid= ( SELECT setid FROM ps_set_cntrl_rec WHERE setcntrlvalue=e.institution AND recname='ITEM_TYPE_TBL') AND d.effdt = ( SELECT MAX(effdt) FROM ps_item_type_lng WHERE d.setid = setid AND d.item_type = item_type AND d.language_cd = language_cd AND effdt <= %CurrentDateIn)
|