--基礎事件關係圖
Select * From xla_entity_types_vl; --事件實體
Select * From xla_entity_id_mappings;--實體ID對應表
Select * From xla_event_classes_vl;--事件分類
Select * From xla_event_types_vl; --事件類型
===================================
--子分類賬關係圖
Select * From xla_transaction_entities;--會計事物處理實體
Select * From xla_events ; --會計事件
Select * From xla_ae_headers;--子賬頭
Select * From xla_ae_lines;--子賬行
Select * From xla_distribution_links;--關聯事物處理信息
===================================
--子模塊和GL關係圖
Select * From gl_import_references;---(總賬參考)
總賬關聯(gl_sl_link_id,gl_sl_link_table)
子分類帳的xla_ae_lines(子賬行)
說明:GL和子模塊之間的關聯是經過gl_import_reference實現的,關鍵字段是gl_sl_link_id,gl_sl_link_table。
GL->子模塊追溯
------------------------------------------------
Select Xal.Ae_Header_Id, Xal.Ae_Line_Num, Jh.Je_Source
From Gl_Je_Lines Jl,
Gl_Je_Headers Jh,
Gl_Import_References Gir,
Xla_Ae_Lines Xal
Where Jl.Je_Header_Id = Gir.Je_Header_Id
And Jh.Je_Header_Id = Jl.Je_Header_Id
And Jl.Je_Line_Num = Gir.Je_Line_Num
And Gir.Gl_Sl_Link_Id = Xal.Gl_Sl_Link_Id
And Gir.Gl_Sl_Link_Table = Xal.Gl_Sl_Link_Table
And Jl.Je_Header_Id = :1
And Jl.Je_Line_Num = :2
--根據je_header_id找到相應的會計實體,主要是須要實體代碼和幾個source_id
--經過source_id…和entity_code的組合判斷,能夠準確的追溯到具體的事物處理
Select Xte.Entity_Code,
Xte.Source_Id_Int_1,
Xte.Source_Id_Int_2,
Xte.Source_Id_Int_3,
Xte.Source_Id_Int_4,
Xte.Source_Id_Char_1,
Xte.Source_Id_Char_2,
Xte.Source_Id_Char_3,
Xte.Source_Id_Char_4,
Xte.Security_Id_Int_1,
Xte.Security_Id_Int_2,
Xte.Security_Id_Int_3
From Xla.Xla_Transaction_Entities Xte, Xla_Ae_Headers Xah
Where 1 = 1
And Xah.Ae_Header_Id = :1
And Xte.Entity_Id = Xah.Entity_Id
And Xte.Application_Id = Xah.Application_Id
===================================
--根據日記賬來源查詢xla_subledgers表得到drilldown的程序
--因爲這部分是寫死的,所以,對程序員來講,只能作參考
--至於怎麼寫的靈活和通用,還須要參考琢磨寫成一個通用的動態SQL
Select Xs.Drilldown_Procedure_Name, Xs.Application_Id
From Xla.Xla_Subledgers Xs
Where Xs.Je_Source_Name = :Je_Source_Name
And Xs.Application_Id = :Application_Id
--上面的信息查詢出來後,組合成一個動態SQL,返回一個準確的結果集
--固然,一般狀況下,咱們都沒有考慮寫成通用程序,所以能夠寫死是
--哪些會計事件,會計實體代碼
---==========================================
Select Cr.Cash_Receipt_Id Cash_Receipt_Id,
Cr.Document_Number Gather_Num,
Jh.Doc_Sequence_Value Doc_Sequence_Value,
Cr.Customer_Name Customer_Name,
Cr.Remit_Bank_Branch Bank_Name,
Cr.Remit_Bank_Account Bank_Account,
Cr.Receipt_Number Receipt_Number,
Cr.Amount Amount,
Cr.State_Dsp State_Dsp,
Trunc(h.Accounting_Date) ,
h.Event_Type_Code Event_Type_Code
From Xla_Ae_Lines l,
Xla_Ae_Headers h,
Xla.Xla_Transaction_Entities Te,
Gl_Import_References Ir,
Gl_Je_Headers Jh,
Ar_Cash_Receipts_v Cr
Where Cr.Cash_Receipt_Id = Te.Source_Id_Int_1(+)
And Cr.Currency_Code = &p_Currency
And Te.Entity_Code(+) = 'RECEIPTS'
And Te.Entity_Id = h.Entity_Id(+)
And Te.Application_Id = h.Application_Id(+)
And h.Ae_Header_Id = l.Ae_Header_Id(+)
And h.Application_Id = l.Application_Id(+)
And l.Gl_Sl_Link_Table = Ir.Gl_Sl_Link_Table(+)
And l.Gl_Sl_Link_Id = Ir.Gl_Sl_Link_Id(+)
And Ir.Je_Header_Id = Jh.Je_Header_Id(+)
And l.Ae_Line_Num(+) = 1
And h.Accounting_Entry_Status_Code(+) = 'F'
And h.Accounting_Date Between Trunc(&p_Start_Date) And
(trunc(&p_End_Date) + 86399 / 8640);
Select * From Ar_Cash_Receipts_v;
Begin
mo_global.init('M');
End;
Select * From xla_ae_headers xal Where xal.ae_header_id=32263;
Select * From xla_ae_lines xa Where xa.ae_header_id=32263;
Select * From ap_invoices_all ai Where ai.invoice_id=36293 And ai.org_id=114程序員