${if(p_all='true',
" SELECT *
FROM gl_je_headers gjh
,gl_je_sources_tl gjs
,gl_je_categories_tl gjc
,gl_je_batches gjb
,gl_je_lines gjl
,fnd_user fnd
,hr_employees p
,apps.cux_gl_code_combinations_v gcc
WHERE gjh.je_source = gjs.je_sour
ce_name
AND gjc.je_category_name = gjh.je_category
AND gjh.je_batch_id = gjb.je_batch_id
AND gjh.je_header_id = gjl.je_header_id
AND gjs.language = 'ZHS'
AND gjc.language = 'ZHS'
/*AND trunc(SYSDATE) BETWEEN
nvl(p.effective_start_date, SYSDATE - 1) AND
nvl(p.effective_end_date, SYSDATE)*/
AND fnd.user_id = gjh.created_by
AND p.employee_id = fnd.employee_id
AND gjl.code_combination_id = gcc.code_combination_id
AND (gjh.je_source IN ('Manual'
,'Manual (Copied)'
,'Encumbrance'
,'Encumbrance (Copied)'
,'Recurring'
,'Revaluation') OR
(gjh.je_source IN ('Payables', 'Receivables') AND
NOT EXISTS
(SELECT 1
FROM gl_import_references gir
WHERE gir.je_header_id = gjh.je_header_id
AND gir.je_line_num = gjl.je_line_num)))
and (gjb.name || '+' || gjh.name
) in(SELECT document_number FROM tempmain )
"+ " AND gjh.ledger_id ="+ {p_ledger_id}+
" AND gcc.segment1 IN (" +{p_company_code} +")"
+" AND gjh.default_effective_date BETWEEN
to_date('"+{P
_GL_DATE_FROM}+" 00:00:00'
,'yyyy-mm-dd hh24:mi:ss') AND
to_date('"+{P_GL_DATE_TO}+" 23:59:59', 'yyyy-mm-dd hh24:mi:ss')"
${if(p_description <> ""," and (gjl.description like '%"+p_description+"%' )" ,"") }