SELECT FFV1.DESCRIPTION 机构名称,
GCC.SEGMENT3 "科目代码",
FFV3.DESCRIPTION 科目名称,
FU.USER_NAME 凭证录入人,
GJS.USER_JE_SOURCE_NAME 日记账来源,
GJC.USER_JE_CATEGORY_NAME 日记账类别,
GJH.PERIOD_NAME 会计期间,
GJH.POSTED_DATE 过账日期,
GJH.EXTERNAL_REFERENCE 凭证号码,
GJL.DESCRIPTION 摘要,
GJL.ENTERED_DR 借方,
GJL.ENTERED_CR 贷方,
'' 方向,
'' 余额,
'' 外币代码,
'' 外币借方,
'' 外币贷方
FROM GL_JE_HEADERS GJH,
GL_JE_LINES GJL,
GL_CODE_COMBINATIONS GCC,
GL_JE_CATEGORIES GJC,
GL_JE_SOURCES GJS,
FND_USER FU,
FND_FLEX_VALUE_SETS FFVS1,
FND_FLEX_VALUES_VL FFV1,
FND_FLEX_VALUE_SETS FFVS3,
FND_FLEX_VALUES_VL FFV3
WHERE GJH.JE_HEADER_ID = GJL.JE_HEADER_ID
AND GJS.JE_SOURCE_NAME = GJH.JE_SOURCE
AND GJC.JE_CATEGORY_NAME = GJH.JE_CATEGORY
AND GJL.CODE_COMBINATION_ID = GCC.CODE_COMBINATION_ID
AND GJH.CREATED_BY = FU.USER_ID(+)
AND GCC.SEGMENT1 = FFV1.FLEX_VALUE
AND FFVS1.FLEX_VALUE_SET_ID = FFV1.FLEX_VALUE_SET_ID
AND FFVS1.FLEX_VALUE_SET_NAME = 'XXXX_COMPANY' –第一段,根据自己环境确定
AND GCC.SEGMENT3 = FFV3.FLEX_VALUE
AND FFVS3.FLEX_VALUE_SET_ID = FFV3.FLEX_VALUE_SET_ID
AND FFVS3.FLEX_VALUE_SET_NAME = 'XXXX_ACCOUNT' –第三段,根据自己环境确定
AND GJH.STATUS = 'P'
AND GJH.ACTUAL_FLAG = 'A'
ORDER BY GCC.SEGMENT1, GJH.PERIOD_NAME;