EBS R12中SLA子分类帐与子模块的关联关系

EBS R12中SLA子分类帐与子模块的关联关系

一、应付帐款

发票分录

简易SQL:

select ai.INVOICE_NUM, xal.*
  from AP_INVOICES_ALL          ai,
       XLA_TRANSACTION_ENTITIES xte,
       xla_events               xe,
       XLA_AE_HEADERS           xah,
       XLA_AE_LINES             xal
 where ai.SET_OF_BOOKS_ID = 2027
   and ai.SET_OF_BOOKS_ID = xte.LEDGER_ID
   and ai.INVOICE_ID = xte.SOURCE_ID_INT_1
   and ai.INVOICE_NUM = '4600060381@2012_1500000511_2'
   and xte.ENTITY_ID = xe.ENTITY_ID
   and xe.EVENT_ID = xah.EVENT_ID
   and xal.AE_HEADER_ID = xah.AE_HEADER_ID

详细SQL

SELECT gjh.ATTRIBUTE10,
       gjh.DESCRIPTION,
       gjh.NAME,
       gjl.PERIOD_NAME,
       gjl.ENTERED_DR,
       gjl.ENTERED_CR,
       gjl.DESCRIPTION,
       xte.transaction_number,
       aia.INVOICE_NUM,
       aia.ATTRIBUTE6
  FROM apps.GL_JE_LINES                  GJL, --日记账行
       apps.GL_JE_HEADERS                GJH, --日记账头
       apps.GL_JE_SOURCES_TL             GJST, --日记账来源
       apps.GL_JE_CATEGORIES_TL          GJCT, --日记账类别
       apps.GL_CODE_COMBINATIONS_KFV     GCC, --账户组合
       apps.GL_IMPORT_REFERENCES         GIR, --总账导入参考信息(GL和XLA之间的关联)
       XLA.XLA_AE_LINES             XAL, --子分类账行
       XLA.XLA_AE_HEADERS           XAH, --子分类账头
       XLA.XLA_TRANSACTION_ENTITIES XTE, --子分类账事务处理实体信息
       apps.ap_invoices_all aia
 WHERE GJL.JE_HEADER_ID = GJH.JE_HEADER_ID
   AND GJL.CODE_COMBINATION_ID = GCC.CODE_COMBINATION_ID
   AND GJL.JE_HEADER_ID = GIR.JE_HEADER_ID
   AND GJH.JE_SOURCE = GJST.JE_SOURCE_NAME
   AND GJH.JE_CATEGORY = GJCT.JE_CATEGORY_NAME
   AND GJL.JE_LINE_NUM = GIR.JE_LINE_NUM
   AND XAL.GL_SL_LINK_TABLE = GIR.GL_SL_LINK_TABLE
   AND XAL.GL_SL_LINK_ID = GIR.GL_SL_LINK_ID
   AND XAH.AE_HEADER_ID = XAL.AE_HEADER_ID
   AND XAH.ENTITY_ID = XTE.ENTITY_ID
   AND XAH.LEDGER_ID = XTE.LEDGER_ID
   AND XAH.APPLICATION_ID = XTE.APPLICATION_ID
   AND GJST.LANGUAGE = 'ZHS'
   AND GJCT.LANGUAGE = 'ZHS'
   and xte.transaction_number=aia.INVOICE_NUM
   and xte.ledger_id=aia.SET_OF_BOOKS_ID
   and nvl(xte.source_id_int_1,-99)=aia.INVOICE_ID
   --parameter
   and gjl.PERIOD_NAME ='2021-06'
   and GJST.USER_JE_SOURCE_NAME='应付账款'
   and GJCT.user_je_category_name='采购发票'
   and xte.ledger_id=2021
      --and gcc.segment3 ='1405010501'
      -- and gcc.segment1='102'
      -- AND XTE.SOURCE_ID_INT_1 ='297522110'---事务处理id
  -- and gjh.JE_BATCH_ID = '1605197'
--  AND XTE.ENTITY_CODE = :2

付款分录

简易SQL:

select ac.CHECK_NUMBER, xal.*
  from AP_INVOICES_ALL          ai,
       AP_INVOICE_PAYMENTS_ALL aip,
       AP_CHECKS_ALL ac,
       XLA_TRANSACTION_ENTITIES xte,
       xla_events               xe,
       XLA_AE_HEADERS           xah,
       XLA_AE_LINES             xal
 where ai.SET_OF_BOOKS_ID =’&sob_id’
   and ai.SET_OF_BOOKS_ID = xte.LEDGER_ID
   and ac.check_id = xte.SOURCE_ID_INT_1
   and ai.INVOICE_NUM = '&INVOICE_NUM '
   and xte.ENTITY_ID = xe.ENTITY_ID
   and xe.EVENT_ID = xah.EVENT_ID
   and xal.AE_HEADER_ID = xah.AE_HEADER_ID
   and ai.INVOICE_ID=aip.INVOICE_ID
   and aip.CHECK_ID=ac.CHECK_ID

详细SQL

SELECT '付款' Trx_Type,
To_Char(Ac.Check_Number) Doc_Num, --发票编号,
Xah.Period_Name, --期间
Ac.Vendor_Id,
Ac.Org_Id,
Ac.Vendor_Site_Id,
pvs.VENDOR_SITE_CODE,
Decode('Y',
'N',
Ac.Currency_Code,
Cux_Ap_Vendor_Balance_Detai.Get_Base_Currency_Code(Ac.Org_Id)) Currency_Code, --币种
Gcc.Segment3, --科目,
Gl_Flexfields_Pkg.Get_Description_Sql(Gcc.Chart_Of_Accounts_Id, 3, Gcc.Segment3) Segment3_Desc, --科目描述
Decode(Ac.Attribute1, Null, Ac.Description, Ac.Attribute1 || '|' || Ac.Description) Docnum_Desc, --发票摘要
Decode('Y', 'N', Xal.Entered_Dr, Xal.Accounted_Dr) Accounted_Dr, --借方
Decode('Y', 'N', Xal.Entered_Cr, Xal.Accounted_Cr) Accounted_Cr, --贷方
Null Attribute1
From Xla.Xla_Transaction_Entities Xte,
Ap_Checks_All Ac,
Xla_Ae_Headers Xah,
Xla_Ae_Lines Xal,
Gl_Code_Combinations Gcc,
po_vendor_sites_all pvs
Where 1 = 1
And Xte.Entity_Id = Xah.Entity_Id
And Xte.Application_Id = Xah.Application_Id
And Xte.Source_Id_Int_1 = Ac.Check_Id
And Xah.Ae_Header_Id = Xal.Ae_Header_Id
And Xah.Application_Id = Xal.Application_Id
And Xal.Accounting_Class_Code In ('LIABILITY', --负债
'PREPAID_EXPENSE' --预付费用
)
And Xte.Application_Id = 200
And Xte.Entity_Code = 'AP_PAYMENTS'
And Ac.Status_Lookup_Code <> 'VOIDED' --已撤销
And Xah.Accounting_Entry_Status_Code = 'F' --最终
And Xal.Code_Combination_Id = Gcc.Code_Combination_Id
And Mo_Global.Check_Access(Ac.Org_Id) = 'Y'
and ac.VENDOR_SITE_ID = pvs.VENDOR_SITE_ID
--参数
And Xah.Ledger_Id = 2021
And (101 = Ac.Org_Id)
And (3911 = Ac.Vendor_Id)
And Xah.Accounting_Date Between to_date('2018/11/29','YYYY-MM-DD HH24:MI:SS')
And to_date('2018/12/28 23:59:59','YYYY-MM-DD HH24:MI:SS');

二、应收帐款

SELECT
       gjh.DOC_SEQUENCE_VALUE,--总账单据编号
       gjh.DESCRIPTION,--日记账说明
       gjh.NAME,--日记账名称
       gjl.PERIOD_NAME,--期间
       gjl.ENTERED_DR,--借方
       gjl.ENTERED_CR,--贷方
       gjl.DESCRIPTION,--日记账行描述
       xte.transaction_number,--子分类账编号
       rct.TRX_NUMBER,--应收事务处理编号
       rct.TRX_DATE,--日期
       rct.BATCH_ID,--批号
       hca.ACCOUNT_NUMBER,--客户编码
       hca.ACCOUNT_NAME,--客户名称
       rct.INTERFACE_HEADER_ATTRIBUTE1,--订单号
       rct.INTERFACE_HEADER_ATTRIBUTE2,--订单类型
       rct.ATTRIBUTE14--业务单据编号
  FROM apps.GL_JE_LINES                  GJL, --日记账行
       apps.GL_JE_HEADERS                GJH, --日记账头
       apps.GL_JE_SOURCES_TL             GJST, --日记账来源
       apps.GL_JE_CATEGORIES_TL          GJCT, --日记账类别
       apps.GL_CODE_COMBINATIONS_KFV     GCC, --账户组合
       apps.GL_IMPORT_REFERENCES         GIR, --总账导入参考信息(GL和XLA之间的关联)
       XLA.XLA_AE_LINES             XAL, --子分类账行
       XLA.XLA_AE_HEADERS           XAH, --子分类账头
       XLA.XLA_TRANSACTION_ENTITIES XTE, --子分类账事务处理实体信息
       ra_customer_trx_all rct,
       HZ_CUST_ACCOUNTS hca
 WHERE GJL.JE_HEADER_ID = GJH.JE_HEADER_ID
   AND GJL.CODE_COMBINATION_ID = GCC.CODE_COMBINATION_ID
   AND GJL.JE_HEADER_ID = GIR.JE_HEADER_ID
   AND GJH.JE_SOURCE = GJST.JE_SOURCE_NAME
   AND GJH.JE_CATEGORY = GJCT.JE_CATEGORY_NAME
   AND GJL.JE_LINE_NUM = GIR.JE_LINE_NUM
   AND XAL.GL_SL_LINK_TABLE = GIR.GL_SL_LINK_TABLE
   AND XAL.GL_SL_LINK_ID = GIR.GL_SL_LINK_ID
   AND XAH.AE_HEADER_ID = XAL.AE_HEADER_ID
   AND XAH.ENTITY_ID = XTE.ENTITY_ID
   AND XAH.LEDGER_ID = XTE.LEDGER_ID
   AND XAH.APPLICATION_ID = XTE.APPLICATION_ID
   AND GJST.LANGUAGE = 'ZHS'
   AND GJCT.LANGUAGE = 'ZHS'
   and xte.transaction_number=rct.TRX_NUMBER
   and xte.ledger_id=rct.SET_OF_BOOKS_ID
   and nvl(xte.source_id_int_1,-99)=rct.CUSTOMER_TRX_ID
   AND rct.SOLD_TO_CUSTOMER_ID = hca.CUST_ACCOUNT_ID
   --parameter
   and gjl.PERIOD_NAME ='2022-04'
   and GJST.USER_JE_SOURCE_NAME='应收账款'
   and GJCT.user_je_category_name='销售发票'
   and xte.ledger_id=2021
   AND gjh.NAME = '102AR发票220400023'

三、资产

FA_DEPRN_DETAIL_H 折旧回滚表
FA_DEPRN_EVENTS 折旧事件表
注:R12回滚是基于资产卡片,R11I回滚是基于资产帐簿

资产折旧

简易SQL

select fa.TAG_NUMBER, fdp.PERIOD_NAME, xal.*
  from FA_ADDITIONS_B           fa,
       FA_DEPRN_DETAIL          fdd,
       FA_DEPRN_PERIODS         fdp,
       XLA_TRANSACTION_ENTITIES xte,
       xla_events               xe,
       XLA_AE_HEADERS           xah,
       XLA_AE_LINES             xal
 where fa.TAG_NUMBER = '&TAG_NUMBER '
   and fa.ASSET_ID = fdd.ASSET_ID
   and xte.SOURCE_ID_INT_1 = fdd.ASSET_ID
   and xte.SOURCE_ID_CHAR_1 = fdd.BOOK_TYPE_CODE
   and xte.SOURCE_ID_INT_2 = fdd.PERIOD_COUNTER
   and xte.SOURCE_ID_INT_3 = fdd.DEPRN_RUN_ID
   and fdp.BOOK_TYPE_CODE = fdd.BOOK_TYPE_CODE
   and fdp.PERIOD_COUNTER = fdd.PERIOD_COUNTER
   and xte.ENTITY_ID = xe.ENTITY_ID
   and xah.EVENT_ID = xe.EVENT_ID
and xah.AE_HEADER_ID = xal.AE_HEADER_ID

详细SQL

/*===============================================================
*name:
* ERP 子分类账、总账和资产关系查询SQL
*description:
* ERP 子分类账、总账和资产关系查询SQL
*create by:
* 
*
=================================================================*/
SELECT gjh.ATTRIBUTE10,
       gjh.DESCRIPTION,
       gjh.NAME,
       gjl.PERIOD_NAME,
       gjl.ENTERED_DR,
       gjl.ENTERED_CR,
       gjl.DESCRIPTION,
       xte.transaction_number,
       fa.ASSET_NUMBER,
       fa.MODEL_NUMBER,
       fa.MANUFACTURER_NAME,
       xla_oa_functions_pkg.get_ccid_description(gcc.chart_of_accounts_id,gcc.code_combination_id) concatenated_desc
  FROM apps.GL_JE_LINES                  GJL, --日记账行
       apps.GL_JE_HEADERS                GJH, --日记账头
       apps.GL_JE_SOURCES_TL             GJST, --日记账来源
       apps.GL_JE_CATEGORIES_TL          GJCT, --日记账类别
       apps.GL_CODE_COMBINATIONS_KFV     GCC, --账户组合
       apps.GL_IMPORT_REFERENCES         GIR, --总账导入参考信息(GL和XLA之间的关联)
       XLA.XLA_AE_LINES             XAL, --子分类账行
       XLA.XLA_AE_HEADERS           XAH, --子分类账头
       XLA.XLA_TRANSACTION_ENTITIES XTE, --子分类账事务处理实体信息
       FA_ADDITIONS_B           fa,
       FA_DEPRN_DETAIL          fdd
 WHERE GJL.JE_HEADER_ID = GJH.JE_HEADER_ID
   AND GJL.CODE_COMBINATION_ID = GCC.CODE_COMBINATION_ID
   AND GJL.JE_HEADER_ID = GIR.JE_HEADER_ID
   AND GJH.JE_SOURCE = GJST.JE_SOURCE_NAME
   AND GJH.JE_CATEGORY = GJCT.JE_CATEGORY_NAME
   AND GJL.JE_LINE_NUM = GIR.JE_LINE_NUM
   AND XAL.GL_SL_LINK_TABLE = GIR.GL_SL_LINK_TABLE
   AND XAL.GL_SL_LINK_ID = GIR.GL_SL_LINK_ID
   AND XAH.AE_HEADER_ID = XAL.AE_HEADER_ID
   AND XAH.ENTITY_ID = XTE.ENTITY_ID
   AND XAH.LEDGER_ID = XTE.LEDGER_ID
   AND XAH.APPLICATION_ID = XTE.APPLICATION_ID
   AND fa.ASSET_ID = fdd.ASSET_ID
   and xte.SOURCE_ID_INT_1 = fdd.ASSET_ID
   and xte.SOURCE_ID_CHAR_1 = fdd.BOOK_TYPE_CODE
   and xte.SOURCE_ID_INT_2 = fdd.PERIOD_COUNTER
   and xte.SOURCE_ID_INT_3 = fdd.DEPRN_RUN_ID
   AND GJST.LANGUAGE = 'ZHS'
   AND GJCT.LANGUAGE = 'ZHS'
   --parameter
   --AND gjl.PERIOD_NAME ='2021-06'
   AND GJST.USER_JE_SOURCE_NAME='资产'
   AND GJCT.user_je_category_name='折旧'
   AND xte.ledger_id=2021
   AND fa.ASSET_NUMBER ='H929-179'
/*===============================================================
*name:
* erp 固定资产相关信息查询sql-历史折旧
*description:
* erp 固定资产相关信息查询sql-历史折旧
*create by:
* 
*
=================================================================*/
select
fa.asset_id,
fb.book_type_code,
fdp.period_counter,
fdp.period_name,
fa.asset_number,--资产编号
fa.tag_number,--标签号
fa.serial_number,--序列号
fa.description,--资产名称
fa.attribute_category_code,--资产类别编码
csha.description fa_major_category,--资产大类
cshi.description fa_minor_category,--资产小类
fak.segment4||'.'||fak.segment5 asset_key,--资产关键字
decode(fa.asset_type,'CAPITALIZED','资本化',fa.asset_type) asset_type,--资产类型
fa.manufacturer_name,--制造商
fa.model_number,--型号
fa.current_units,--数量
cshd.description depreciation_department,--折旧部门
gcc.concatenated_segments,--费用账户
cshav.description account_description,--账户(科目)说明
cshd.flex_value,--地点编号
cshd.description use_address,--使用地址
fdh.units_assigned,--分配数量
fb.date_placed_in_service,--启用日期
fb.original_cost,--原始成本
fb.cost,--当前成本
fb.salvage_value residual_value,--残值
nvl(fb.percent_salvage_value,0) * 100||'%' percent_salvage_value,--残值率
fds.deprn_amount month_deprn_amount,--当月折旧金额,
fds.ytd_deprn,--ytd折旧
fds.ytd_deprn year_ytd_deprn,--当年折旧金额
fds.deprn_reserve,--累计折旧金额,
'' impairment_of_assets,--资产减值
fb.recoverable_cost,--可回收成本
fb.cost-fds.deprn_reserve nbv_retired,--账面净值(当前成本-累计折旧)
cshft.description fa_state,--使用状况
cshfs.description fa_source,--资产来源
'' project_num,--项目编号
fb.life_in_months service_life,--使用寿命
'' residual_life,--剩余寿命
fb.deprn_method_code,--折旧方法
fb.depreciate_flag,--是否折旧
(select trunc(min(fddd.deprn_run_date))
from fa_deprn_detail fddd
where 1=1
and fddd.asset_id = fb.asset_id
and fddd.book_type_code = fb.book_type_code) deprn_run_date,--入账日期
fb.prorate_date,--折旧日期
'' provision_for_impairment,--减值准备
'' impairment_date,--计提减值日期
frs.retirement_type_code,--报废类型
frs.date_retired,--报废日期
frs.cost_retired,--报废成本
frs.units,--报废数量
'' cost_of_sales,--销售成本
'' demolition_cost,--拆迁成本
'' profit_and_loss,--损益
decode(frs.date_retired,null,'N','Y') scrap_flag,--完全报废标记
'' multi_source_flag,--多来源行标记
'' multi_distribution_flag,--多行分配标记
fin.vendor_number,--供应商编号
fin.vendor_name,--供应商名称
fin.invoice_number,--发票编号
fin.invoice_line_number,--ap发票分配行号
fin.description invoice_description,--ap发票说明
fin.fixed_assets_cost,--行金额
fe.employee_number,--录入人员
fb.bonus_rule,--附加规则
fb.global_attribute1,--附加规则起算日期
fds.deprn_amount total_deprn_amount,--折旧总额
fds.deprn_amount - (nvl(fds.deprn_adjustment_amount,
0) - nvl(fds.bonus_deprn_adjustment_amount,
0)) - nvl(fds.bonus_deprn_amount,
0) deprn_amount,--折旧额
nvl(fds.deprn_adjustment_amount,
0) - nvl(fds.bonus_deprn_adjustment_amount,
0) deprn_adjustment_amount--调整额
from fa_books fb,
fa_additions fa,
gl_je_headers                gjh, --日记账头
gl_je_lines                  gjl, --日记账行
gl_je_sources_tl             gjst, --日记账来源
gl_je_categories_tl          gjct, --日记账类别
gl_import_references         gir, --总账导入参考信息(gl和xla之间的关联)
xla_transaction_entities xte,
xla_events               xe,
xla_ae_headers           xah,
xla_ae_lines             xal,
fa_categories_b fcb,
fa_retirements frs,
fa_invoice_details_v fin,
fa_asset_keywords fak,
fa_deprn_summary fds,
fa_deprn_periods fdp,
cux_sys_hd_fa_major_category_v csha,
cux_sys_hd_fa_minor_category_v cshi,
fa_distribution_history fdh,
gl_code_combinations_kfv gcc,
cux_sys_hd_department_v cshd,
cux_sys_hd_account_v cshav,
cux_sys_hd_fa_source_v cshfs,
cux_sys_hd_fa_state_v cshft,
fnd_user fu,
fa_employees fe
where 1=1
and fb.asset_id = fa.asset_id
and gjl.je_header_id = gjh.je_header_id
and gjl.je_header_id = gir.je_header_id
and gjl.je_line_num = gir.je_line_num
and gjh.je_source = gjst.je_source_name
and gjh.je_category = gjct.je_category_name
and xte.entity_id = xe.entity_id
and xah.event_id = xe.event_id
and xah.ae_header_id = xal.ae_header_id
and xal.gl_sl_link_table = gir.gl_sl_link_table
and xal.gl_sl_link_id = gir.gl_sl_link_id
and xte.source_id_int_1(+) = fb.asset_id
and xte.source_id_char_1(+) = fb.book_type_code
and xte.source_id_int_2(+) = fdp.period_counter
and xte.source_id_int_3(+) = fds.deprn_run_id
and fa.asset_category_id = fcb.category_id
and fb.asset_id = frs.asset_id(+)
and fb.book_type_code = frs.book_type_code(+)
and fb.asset_id = fin.asset_id(+)
and fin.created_by = fu.user_id(+)
and fu.employee_id = fe.employee_id(+)
and fa.asset_key_ccid = fak.code_combination_id
and fak.segment4 = cshft.flex_value
and fak.segment5 = cshfs.flex_value
and fb.asset_id = fds.asset_id
and fb.book_type_code = fds.book_type_code
and fds.period_counter = fdp.period_counter
and fds.book_type_code = fdp.book_type_code
and fcb.segment1 = csha.flex_value
and fcb.segment2 = cshi.flex_value
and csha.flex_value = cshi.parent_flex_value_low
and fa.asset_id = fdh.asset_id
and fb.book_type_code = fdh.book_type_code
and gjl.code_combination_id = gcc.code_combination_id
and gcc.segment2 = cshd.flex_value(+)
and gcc.segment3 = cshav.flex_value
and fdh.date_ineffective is null
and fb.date_ineffective is null
and gjst.language = 'ZHS'
and gjct.language = 'ZHS'
and gjst.user_je_source_name='资产'
and gjct.user_je_category_name='折旧'
AND gcc.segment2 <> '0'
--参数
--and fb.book_type_code = p_book_type_code
--and fdp.period_name = p_period_name
--and fa.asset_number = 'H929-179'

资产事务

select xe.EVENT_TYPE_CODE,xah.EVENT_TYPE_CODE,xal.*
  from FA_TRANSACTION_HEADERS fth,
       XLA_TRANSACTION_ENTITIES xte,
       xla_events               xe,
       XLA_AE_HEADERS           xah,
       XLA_AE_LINES             xal
 where fth.TRANSACTION_HEADER_ID=xte.SOURCE_ID_INT_1
   and xte.ENTITY_ID = xe.ENTITY_ID
   and xah.EVENT_ID = xe.EVENT_ID
   and xah.AE_HEADER_ID = xal.AE_HEADER_ID
   and fth.ASSET_ID=15008335

四、成本管理

库存

select xe.EVENT_TYPE_CODE, xah.EVENT_TYPE_CODE, xal.*
  from MTL_TRANSACTION_ACCOUNTS mta,
       XLA_TRANSACTION_ENTITIES xte,
       xla_events               xe,
       XLA_AE_HEADERS           xah,
       xla_ae_lines             xal
 where mta.ORGANIZATION_ID = 277
   and mta.TRANSACTION_ID = xte.SOURCE_ID_INT_1
   and mta.ORGANIZATION_ID = xte.SOURCE_ID_INT_2
   and mta.TRANSACTION_SOURCE_TYPE_ID = xte.SOURCE_ID_INT_3
   and mta.TRANSACTION_ID = 9871318
   and xte.ENTITY_ID = xe.ENTITY_ID
   and xe.EVENT_ID = xah.EVENT_ID
   and xah.AE_HEADER_ID = xal.AE_HEADER_ID

接收

select xte.ENTITY_CODE, xah.EVENT_TYPE_CODE, rae.EVENT_SOURCE, xal.*
  from RCV_TRANSACTIONS         rt,
       RCV_ACCOUNTING_EVENTS    rae,
       XLA_TRANSACTION_ENTITIES xte,
       xla_events               xe,
       XLA_AE_HEADERS           xah,
       xla_ae_lines             xal
 where rae.RCV_TRANSACTION_ID = xte.SOURCE_ID_INT_1
   and rae.ACCOUNTING_EVENT_ID = xte.SOURCE_ID_INT_2
   and rt.ORGANIZATION_ID = xte.SOURCE_ID_INT_3
   and rt.TRANSACTION_ID = 498557

猜你喜欢

转载自blog.csdn.net/qq_38696286/article/details/126768948