SELECT A.BUSINESS_UNIT , B.DOC_TYPE_CLOSE FROM PS_BUS_UNIT_TBL_GL A , PS_BU_AP_GL_OPT B , PS_DOC_TYPE_TBL C WHERE A.DOC_SEQ = 'Y' AND B.BUSINESS_UNIT = A.BUSINESS_UNIT AND B.DOC_TYPE_CLOSE <> ' ' AND C.SETID = ( SELECT I.SETID FROM PS_SET_CNTRL_REC I WHERE I.SETCNTRLVALUE = B.BUSINESS_UNIT AND I.REC_GROUP_ID = 'FS_42' AND I.RECNAME = 'DOC_TYPE_TBL') AND C.DOC_TYPE = B.DOC_TYPE_CLOSE AND ( (C.SEQ_TYPE = 'A' AND EXISTS ( SELECT 'X' FROM PS_JRNL_TYPE_TBL J WHERE J.SETID = C.SETID AND J.JRNL_TYPE = C.JRNL_TYPE AND J.SEQ_BY = 'D')) OR EXISTS ( SELECT 'X' FROM PS_JRNL_TYPE_TBL K , PS_JRNL_CODE_TBL L WHERE K.SETID = C.SETID AND K.JRNL_TYPE = C.JRNL_TYPE AND K.SEQ_BY <> 'D' AND L.SETID = C.SETID AND L.JRNL_CODE = C.JRNL_CODE AND L.SEQ_TYPE = 'A'))
|