R12 SLA 子分类帐和GL总帐关联查询

-- R12 SLA 子分类帐和GL总帐关联查询
select
       xte.application_id "应用",
       xte.entity_id,
       xte.ledger_id "分类帐SOB",
       xte.entity_code,
       xett.name "事务实体类型",
       le.name "法人主体",
       le.legal_entity_identifier "人主体所得税纳税登记" 
-- legal_entity_tax
        -- ----------------------------
        -- AP_INVOICES  AP发票     INVOICE_ID
        -- AP_PAYMENTS  AP付款     CHECK_ID
        -- RECEIPTS     收款       CASH_RECEIPT_ID
        -- TRANSACTIONS 事务处理  销售发票 CUSTOMER_TRX_ID
       ,
       xte.source_id_int_1 "事务源对应ID"
       
-- ----------------------------
        /* --下面两个字段折旧的时候会有值
                                                        ,xte.source_id_int_2
                                                        ,xte.source_id_int_3
*/ ,
       xte.security_id_int_1     "ORG_ID",
       xte.source_application_id "源对应应用"
       
-- ======xla_event=========--------
       ,
       xe.event_type_code 
-- Event type code
       ,
       xent.name "事件类型"
       
--  ,xe.event_status_code --Event status code
        --  ,xe.process_status_code --Processing status code
        /* This flag indicates whether the event is on hold or not.
                                                 possible values: (Y)--yes, (N)--No
*/
       
--  ,xe.on_hold_flag
        -- ==============xla_ae_headers=======-----
       ,
       xah.ledger_id "SOB",
       xah.je_category_name 
-- General Ledger category name
       ,
       xah.accounting_date,
       xah.period_name "期间"
       
/*  ,xah.balance_type_code --Balance type (Actual, Budget, or Encumbrance)
                                          ,xah.gl_transfer_date
                                          ,xah.accounting_entry_status_code
                                          ,xah.accounting_entry_type_code
                                          ,xah.zero_amount_flag
*/
       
-- ==============xla_ae_line=======-----
       ,
       xal.ae_line_num         "行号",
       xal.code_combination_id "账户ID",
       gjl.code_combination_id "日记帐gcc"
       
/*  ,xal.gl_transfer_mode_code
                                          ,xal.accounting_class_code "会计分类"
*/ ,
       xlp.meaning       "会计分类",
       xal.accounted_dr  "入账借项(本位币)",
       xal.accounted_cr  "入账贷项(本位币)",
       xal.currency_code "币种",
       xal.entered_dr    "账户原币借项",
       xal.entered_cr    "账户原币贷项"
       ,
       gir.je_line_num "日记帐行号",
       xdl.source_distribution_id_num_1 "源账户关联ID",
       xdl.tax_line_ref_id,
       xdl.unrounded_entered_dr,
       xdl.unrounded_entered_cr,
       xdl.applied_to_source_id_num_1
       ,
       xte.entity_id,
       xte.application_id,
       xe.event_id,
       xah.ae_header_id,
       xal.ae_line_num
  
from  xla_transaction_entities xte,
       xla_entity_types_tl      xett,
       xle_entity_profiles      le,
       xla_events               xe,
       xla_event_types_tl       xent,
       xla_ae_headers           xah,
       xla_ae_lines             xal,
       xla_lookups              xlp,
       xla_distribution_links   xdl,
       gl_import_references     gir,
       gl_je_lines              gjl
 
where   1   =   1
   
and  xte.entity_id  =  xe.entity_id
   
and  xte.application_id  =  xe.application_id
   
and  xte.legal_entity_id  =  le.legal_entity_id( + )    and  xah.event_id  =  xe.event_id
   
and  xah.application_id  =  xe.application_id
   
and  xent.event_type_code  =  xe.event_type_code
   
and  xent.application_id  =  xe.application_id
   
and  xent.language  =   ' ZHS '
   
and  xah.ae_header_id  =  xal.ae_header_id
   
and  xah.application_id  =  xal.application_id
   
and  xlp.lookup_type( + =   ' XLA_ACCOUNTING_CLASS '
   
and  xlp.lookup_code( + =  xal.accounting_class_code
   
and  xal.ae_header_id  =  xdl.ae_header_id( + )
   
and  xal.ae_line_num  =  xdl.ae_line_num( + )
   
and  xal.application_id  =  xdl.application_id( + )
   
and  gir.gl_sl_link_id  =  xal.gl_sl_link_id
   
and  gir.gl_sl_link_table  =  xal.gl_sl_link_table
   
and  gjl.je_header_id  =  gir.je_header_id
   
and  gjl.je_line_num  =  gir.je_line_num
   
and  xett.entity_code  =  xte.entity_code
   
and  xett.application_id  =  xte.application_id
   
and  xett.language  =   ' ZHS ' ;


你可能感兴趣的:(关联查询)