GL追溯子模块的视图

----应收1
/*1. 通过 gl_import_reference 表找到来源为应收的记录的 gl_sl_link_id
2. 通过 gl_sl_link_id 找到在 xla_ae_lines 表中对应行的 ae_header_id
3. 通过 ae_header_id 找到 xla_ae_headers 表中应应的 entity_id
4. 通过 entity_id 找到 xla.xla_transaction_entities 表中对应的记录
5. 找到 xla.xla_transaction_entities 表中的记录后需要按如下情况分开追溯:
  (1). entity_code 为 TRANSACTIONS 和 BILLS_RECEIVABLE 时,表中字段 source_id_int_1 对应的为 ra_customer_trx_all 表中的 customer_trx_id; 字段 security_id_int_1 对应的为 org_id
  (2). entity_code 为 ADJUSTMENTS 时,表中字段 source_id_int_1 对应的为 ar_adjustments_all 表中的 adjustment_id; 字段 security_id_int_1 对应的为 org_id
  (3). entity_code 为 RECEIPTS 时,表中字段 source_id_int_1 对应的为 ar_cash_receipts_all 表中的 cash_receipt_id; 字段 security_id_int_1 对应的为 org_id
  (4). entity_code 为 THIRD_PARTY_MERGE 的情况不会传送至总帐,所以没有追溯。*/
Select * From gl_import_references Where je_header_id=2235
Select * From xla_ae_lines xal Where xal.gl_sl_link_id=17150
Select * From xla_ae_headers  xah Where xah.ae_header_id=15151
Select * From xla.xla_transaction_entities  xte Where xte.entity_id=21074
Select * From ra_customer_trx_all rct Where rct.customer_trx_id=1415 And rct.org_id=81
 
----应付1
select aca.check_id,aca.check_number,aca.payment_id,gjh.*
from gl_je_headers gjh,
     gl_import_references gir,
     xla.xla_transaction_entities xte,
     xla.xla_ae_headers xah,
     ap_checks_all aca
where
      gjh.je_header_id = gir.je_header_id
      and xah.ae_header_id = gir.reference_7
      and xah.entity_id = gir.reference_5
      and xah.event_id = gir.reference_6
      and xah.je_category_name = 'Payments'     
      and xah.entity_id = xte.entity_id
      and gir.reference_10 is not null
      and xte.source_id_int_1 = aca.check_id
      and aca.check_number = 21
 
=============================================================
--资产
FROM XLA_FA_AEL_GL_V XLA_AEL_GL_V
WHERE application_id = 140
AND je_header_id = 276683
FROM XLA_FA_AEL_GL_V XLA_AEL_GL_V
WHERE application_id = 140
AND je_header_id = 276684
--应付
FROM XLA_AP_INV_AEL_GL_V XLA_AEL_GL_V
WHERE application_id = 200
AND je_header_id = 272724
FROM XLA_AP_PAY_AEL_GL_V XLA_AEL_GL_V
WHERE application_id = 200
AND je_header_id = 272181
FROM SQ_GL_JE_BATCHES_HEADERS_V
WHERE set_of_books_id = 1
and (JE_CATEGORY = 'Purchase Invoices')
and (JE_SOURCE = 'Payables')
--应收
发票
FROM XLA_AR_INV_AEL_GL_V XLA_AEL_GL_V
WHERE application_id = 222
AND je_header_id = 272056
核销
FROM XLA_AR_REC_AEL_GL_V XLA_AEL_GL_V
WHERE application_id = 222
AND je_header_id = 278535
AND je_line_num = 1
收款
FROM XLA_AR_REC_AEL_GL_V XLA_AEL_GL_V
WHERE application_id = 222
AND je_header_id = 277989

The real tables (they're infact views) which store this infoRMAtion are :
Oracle Payables :
-----------------
XLA_AP_INV_AEL_GL_V - Payable invoice entries (Gen. Ledger)
XLA_AP_INV_AEL_SL_V - Payable invoice entries (Subledger)
XLA_AP_PAY_AEL_GL_V - Payment voucher entries (Gen.Ledger)
XLA_AP_PAY_AEL_SL_V - Payment voucher entries (Subledger)
Oracle Receivables :
--------------------
XLA_AR_ADJ_AEL_SL_V - AR adjustment entries (Subledger)
XLA_AR_INV_AEL_SL_V - AR invoices (Sugledger)
XLA_AR_REC_AEL_SL_V - AR receipts (Subledger)
XLA_AR_ADJ_AEL_GL_V - AR adjustment entries (Gen.Ledger)
XLA_AR_INV_AEL_GL_V - AR invoices (Gen.Ledger)
XLA_AR_REC_AEL_GL_V - AR receipts (Gen.Ledger)
For the rest of the modules, you can check out the XLA% views or synonyms in APPS schema.
The form. displays information from these views/synonyms and in the Record History, shows it as XLA_AEL_GL_V.

How to drilldown to the following Source/Categories via SQL:
1. Payables/Payments
2. Purchasing/Receiving
3. Inventory/MTL
Solution
1. Payables/Payments:
SELECT *
FROM apps.gl_je_lines gje,
apps.gl_je_headers gjh,
apps.ap_invoice_distributions_all apid,
ap_invoices_all apa,
ap_ae_lines_all apae
WHERE
apae.GL_SL_LINK_ID = gje.GL_SL_LINK_ID -- this provides drill back to AP
and gje.je_header_id = gjh.je_header_id
and gjh.NAME = 'Purchase Invoices USD DD-MMM-YY' -- <--Journal name
AND apae.REFERENCE5 = 'XX 100506' -- invoice number
and apae.REFERENCE2 = apid.INVOICE_ID
AND apid.invoice_id = apa.invoice_id
and apae.SOURCE_ID = apid.INVOICE_DISTRIBUTION_ID -- ties distrib table to GL
AND gjh.actual_flag = 'A'
ORDER BY gje.je_line_num
2. Purchasing/Receiving:
select *
from apps.gl_je_lines gje, apps.gl_je_headers gjh, po_headers_all poh, po_distributions_all pod,
po_lines_all poll, apps.rcv_transactions rcvt
where gje.reference_2 = to_char(poh.PO_HEADER_ID)
and gje.REFERENCE_3 = to_char(pod.PO_DISTRIBUTION_ID)
and pod.PO_LINE_ID = poll.PO_LINE_ID
and gje.REFERENCE_5 = to_char(rcvt.TRANSACTION_ID)
and gje.JE_HEADER_ID = gjh.JE_HEADER_ID
and gjH.ACTUAL_FLAG = 'A'
and gjh.PERIOD_NAME = 'MMM-YY'
-- and gjh.NAME = 'Receiving USD DD-MMM-YY' -- header id is 120597
order by gje.JE_LINE_NUM
3. Inventory/MTL:
select *
from apps.gl_je_lines gje, apps.gl_je_headers gjh, apps.mtl_material_transactions mmt
where gje.REFERENCE_3 = to_char(mmt.TRANSACTION_ID) and
gje.JE_HEADER_ID = gjh.JE_HEADER_ID and
gjH.ACTUAL_FLAG = 'A' and
gjh.NAME = 'MTL USD DD-MMM-YY' -- je_header_id = 116944 ; ref 3 = 6092631
order by gje.JE_LINE_NUM

用表查吧,主要这几个表就可以了,xla.xla_ae_headers,xla.xla_ae_lines,xla.xla_transaction_entities,xla_events (用的少)
参考追溯AP付款的例子,注意修改子模块的表和xte.entity_code 值就可以了。 (这里值为'AP_PAYMENTS')
select ac.check_id,
ac.check_date,
ac.check_number,
gcc.segment1,
gcc.segment3,
ac.amount,
xl.accounted_dr,
xl.accounted_cr,
xte.entity_code,
gir.je_header_id,
gjh.period_name,
xh.event_type_code
from xla.xla_ae_headers xh,
xla.xla_ae_lines xl,
xla.xla_transaction_entities xte,
gl.gl_code_combinations gcc,
ap.ap_checks_all ac,
gl.gl_import_references gir,
gl.gl_je_headers gjh,
gl.gl_je_batches gjb,
xla.xla_events xea
where xh.ae_header_id = xl.ae_header_id
and xte.entity_id = xh.entity_id
and ac.check_id = xte.Source_Id_Int_1(+)
and gir.gl_sl_link_id(+) = xl.gl_sl_link_id
and gir.je_header_id = gjh.je_header_id(+)
and xl.code_combination_id = gcc.code_combination_id
and gjh.je_batch_id = gjb.je_batch_id
and xea.event_id = xte.entity_id
and xte.entity_code = 'AP_PAYMENTS'

你可能感兴趣的:(header,Security,application,import,transactions,combinations)