SELECT gh.je_header_id,
gh.period_name,
gh.default_effective_date,
gh.je_source,
gs.user_je_source_name,
gh.je_category,
gc.user_je_category_name,
gb.name batch_name,
gh.name je_name,
gl.je_line_num,
gh.doc_sequence_value,
gl.description,
gcc.concatenated_segments,
gcc.segment1, --公司
gcc.segment2, --核算主体
gcc.segment3, --部门
gcc.segment4, --科目
gcc.segment5, --子目
gcc.segment6, --项目
gcc.segment7, --往来
gh.currency_code,
gl.entered_dr,
gl.entered_cr,
gl.accounted_dr,
gl.accounted_cr,
gb.approval_status_code,
glook1.meaning approval_status,
glook2.meaning batch_status,
gb.status,
gb.CREATION_DATE,
gh.created_by,
gb.approver_employee_id,
gl.attribute6,
gl.attribute7,
gl.attribute8,
gl.attribute9,
gl.attribute10,
gl.attribute11,
gl.attribute12,
gl.attribute13,
gl.attribute14,
gl.attribute15,
gl.attribute16,
gl.attribute17,
gl.attribute18,
gl.attribute19,
gl.attribute20 FROM gl_je_batches gb,
gl_je_headers gh,
gl_je_lines gl,
gl_code_combinations_kfv gcc,
gl_je_sources gs,
gl_je_categories gc,
gl_lookups glook1,
gl_lookups glook2
WHERE gb.je_batch_id = gh.je_batch_id
AND gh.je_header_id = gl.je_header_id
AND gs.je_source_name = gh.je_source
AND gc.je_category_name = gh.je_category
AND gb.approval_status_code = glook1.lookup_code
AND gb.status = glook2.lookup_code
AND glook1.lookup_type = 'JE_BATCH_APPROVAL_STATUS'
AND glook2.lookup_type = 'BATCH_STATUS' AND gl.code_combination_id = gcc.code_combination_id
AND gh.ledger_id = g_ledger_id
AND gh.currency_code <> 'STAT'