You are on page 1of 4

SELECT je_lines.

ae_header_id,
je_lines.ae_line_num,
NVL(je_lines.accounted_dr, 0) AS amount_dr,
NVL(je_lines.accounted_cr, 0) as amount_cr,
NVL(je_lines.entered_dr, 0) entered_dr,
NVL(je_lines.entered_cr, 0) entered_cr,
je_lines.description,
je_lines.currency_code,
je_headers.PERIOD_NAME,
gl_periods.PERIOD_YEAR,
gl_periods.PERIOD_NUM,
gl_periods.QUARTER_NUM,
-- je_headers.ACCOUNTING_DATE,
je_headers.GL_TRANSFER_DATE,
je_lines.code_combination_id,

cc.segment1 AS company,
gl_flexfields_pkg.get_description_sql(cc.chart_of_accounts_id,
1,
cc.segment1) AS company_desc,
cc.segment2 AS cost_center,
gl_flexfields_pkg.get_description_sql(cc.chart_of_accounts_id,
2,
cc.segment2) AS cost_center_desc,
cc.segment3 AS account,
gl_flexfields_pkg.get_description_sql(cc.chart_of_accounts_id,
3,
cc.segment3) AS account_desc,
-- parent_account.ancestor_pk1_value AS parent_acc,
cc.segment4 AS Branch,
gl_flexfields_pkg.get_description_sql(cc.chart_of_accounts_id,
4,
cc.segment4) AS Branch_desc,
cc.segment5 AS Channel,
gl_flexfields_pkg.get_description_sql(cc.chart_of_accounts_id,
5,
cc.segment5) AS Channel_desc,

cc.segment6 AS LOB,
gl_flexfields_pkg.get_description_sql(cc.chart_of_accounts_id,
6,
cc.segment6) AS LOB_desc,

cc.segment7 AS Product,
gl_flexfields_pkg.get_description_sql(cc.chart_of_accounts_id,
7,
cc.segment7) AS Product_desc,

cc.segment8 AS Intercompany,
gl_flexfields_pkg.get_description_sql(cc.chart_of_accounts_id,
8,
cc.segment8) AS Intercompany_desc,

cc.segment9 AS future_1,
cc.segment10 AS future_2,

je_headers.application_id,
ent.entity_id,
ent.entity_code,
ent.source_id_int_1,
NULL AS trx_id, --adj.adjustment_id,
NULL AS trx_number,
NULL AS cust_id, --trx.bill_to_customer_id,
NULL AS cust_name, --prt.party_name AS customer_name,
NULL AS cust_number, --cust_acc.account_number AS customer_account_number,
app.product_code,
je_headers.je_category_name,
je_headers.description AS je_header_description,
je_headers.accounting_date,
je_lines.created_by,
(SELECT distinct gjh.POSTED_DATE
FROM gl_je_batches GLB,
gl_je_headers gjh,
gl_je_lines gjl,
gl_import_references gir,
xla_ae_lines xlal,
xla_ae_headers xlah,
xla_events xlae,
xla_transaction_entities xlate
WHERE GLB.je_batch_id = gjh.je_batch_id
AND gjh.je_header_id = gjl.je_header_id
AND gjl.je_header_id = gir.je_header_id
AND gjl.je_line_num = gir.je_line_num
AND gir.gl_sl_link_table = xlal.gl_sl_link_table
AND gir.gl_sl_link_id = xlal.gl_sl_link_id
AND xlal.ae_header_id = xlah.ae_header_id
AND xlah.event_id = xlae.event_id
AND xlae.entity_id = xlate.entity_id
AND xlae.application_id = xlate.application_id
and xlal.ae_header_id = je_lines.ae_header_id
and xlal.gl_sl_link_id = je_lines.gl_sl_link_id
and xlal.gl_sl_link_table = je_lines.gl_sl_link_table) POSTED_DATE,

(SELECT distinct b.name je_batch_name


FROM gl_je_batches b,
gl_je_headers h,
gl_je_lines l,
gl_import_references gir,
xla_ae_lines xlal,
xla_ae_headers xlah,
xla_events xlae
WHERE b.je_batch_id = h.je_batch_id
AND h.je_header_id = l.je_header_id
AND l.je_header_id = gir.je_header_id
AND l.je_line_num = gir.je_line_num
AND gir.gl_sl_link_table = xlal.gl_sl_link_table
AND gir.gl_sl_link_id = xlal.gl_sl_link_id
AND xlal.application_id = xlah.application_id
AND xlal.ae_header_id = xlah.ae_header_id
AND xlah.application_id = xlae.application_id
AND xlah.event_id = xlae.event_id
and xlal.ae_header_id = je_lines.ae_header_id
and xlal.gl_sl_link_id = je_lines.gl_sl_link_id
and xlal.gl_sl_link_table = je_lines.gl_sl_link_table) Journal_Batch,

(SELECT distinct h.POSTING_ACCT_SEQ_VALUE


FROM gl_je_batches b,
gl_je_headers h,
gl_je_lines l,
gl_import_references gir,
xla_ae_lines xlal,
xla_ae_headers xlah,
xla_events xlae
WHERE b.je_batch_id = h.je_batch_id
AND h.je_header_id = l.je_header_id
AND l.je_header_id = gir.je_header_id
AND l.je_line_num = gir.je_line_num
AND gir.gl_sl_link_table = xlal.gl_sl_link_table
AND gir.gl_sl_link_id = xlal.gl_sl_link_id
AND xlal.application_id = xlah.application_id
AND xlal.ae_header_id = xlah.ae_header_id
AND xlah.application_id = xlae.application_id
AND xlah.event_id = xlae.event_id
and xlal.ae_header_id = je_lines.ae_header_id
and xlal.gl_sl_link_id = je_lines.gl_sl_link_id
and xlal.gl_sl_link_table = je_lines.gl_sl_link_table) Journal_Number,
rct.PO_DISTRIBUTION_ID,
RECEIVING_DATA.po_number,
RECEIVING_DATA.receipt_num,
RECEIVING_DATA.receipt_date,
rct.quantity,
rct.transaction_type,
rct.transaction_id

FROM xla_ae_lines je_lines,


xla_ae_headers je_headers,
fnd_application app,
gl_code_combinations cc,
xla_transaction_entities ent,
gl_import_references gl_link,
gl_periods,
rcv_transactions rct,
(SELECT poh.po_header_id,
rct.transaction_id,
poh.segment1 po_number,
rsh.receipt_num,
rct.transaction_date receipt_date

FROM rcv_shipment_headers rsh,


rcv_transactions rct,
po_headers_all poh
WHERE rsh.shipment_header_id = rct.shipment_header_id
AND rct.po_header_id = poh.po_header_id) RECEIVING_DATA

WHERE je_lines.ae_header_id = je_headers.ae_header_id


AND je_headers.gl_transfer_status_code = 'Y'
AND je_headers.PERIOD_NAME = gl_periods.PERIOD_NAME
and gl_periods.PERIOD_SET_NAME = 'Macro Calendar'
AND gl_periods.PERIOD_YEAR = :P_PERIOD_YEAR
AND gl_periods.PERIOD_NUM between :P_STAR_PERIOD_NUM AND
:P_END_PERIOD_NUM
AND je_headers.application_id = app.application_id
AND je_lines.code_combination_id = cc.code_combination_id
AND je_headers.entity_id = ent.entity_id
AND ent.entity_code = 'RECEIVING'
AND je_lines.gl_sl_link_id = gl_link.gl_sl_link_id
AND je_lines.gl_sl_link_table = gl_link.gl_sl_link_table
and ent.source_id_int_1 = rct.transaction_id
and RECEIVING_DATA.transaction_id = ent.source_id_int_1

-- AND rct.transaction_type IN ('RECEIVE', 'MATCH')


-- and cc.segment3 = 901010206

You might also like