前面的都是业务方面的,现在进行技术简析,更多的内容还在整理中。
在SLA中技术方面最常用的就是日记帐来源追溯,在追溯的过程中从GL到SLA和11i差别不大,
使通过gl_import_references表来进行,该表的je_batch_id,je_header_id,je_line_num
是和GL关联,该表字段gl_sl_link_id是和SLA中的行表(XLA_AE_LINES)关联,
在SLA中重要的几张表如下:
xla_transaction_entities:The table XLA_ENTITIES contains information about
sub-ledger document or transactions.
XLA_EVENTS:The XLA_EVENTS table record all information related to a specific
event. This table is created as a type XLA_ARRAY_EVENT_TYPE.
XLA_AE_HEADERS:The XLA_AE_HEADERS table stores subledger journal entries.
There is a one-to-many relationship between accounting events and journal entry headers.
XLA_AE_LINES:The XLA_AE_LINES table stores the subledger journal entry lines.
There is a one-to-many relationship between subledger journal entry headers and subledger
journal entry lines
XLA_DISTRIBUTION_LINKS:The XLA_DISTRIBUTION_LINKS table stores the link between
transactions and subledger journal entry lines.
在一个系统PKG中有如下结构的插值语句,从而可以清楚的得出几个表之间的联系:
上面提到的 gl_import_references.gl_sl_link_id 字段就是和 xla_ae_lines.gl_sl_link_id 字段关联, 在这些表中和子模块关联的字段在 xla_transaction_entities 中,该表中有如下形式的字段
insert
all
when(line_id = 1) then
into
xla_transaction_entities
(upg_batch_id
,entity_id
, ……)
values
(……)
into
xla_events
(upg_batch_id
,entity_id
,event_id
,……)
values
(……)
into
xla_ae_headers
(upg_batch_id
,entity_id
,event_id
,ae_header_id
, ……)
values
(……)
when
(1 = 1) then
into
xla_ae_lines
(upg_batch_id
,ae_header_id
,ae_line_num
, ……)
values
(……)
into
xla_distribution_links
(upg_batch_id
,event_id
,ae_header_id
,ae_line_num
, ……)
values
(……)
select …… from ……;
源表关联字段
source_id_int_num
source_id_char_num
这两个字段是用来和源模块关联,该字段的设置是在各个子模块 :
路径是: 设置>>会计科目设置>>子分类帐会计设置>>会计方法生成器>>事件>>事件模型
界面如下 : 该界面的实体代码就是对应 xla_transaction_entities 表中的 ENTITY_CODE 字段,每个来源就标示了该子分类帐是哪个模块产生的。
点击 [ 标示 ] 进入如下界面 : 该界面中的实体表列字段时子模块相关源表的字段,标示列就是SLA中
xla_transaction_entities表的列 , SLA 和字模块的联系就是通过该界面的设置来完成的。
安全性控制字段
security_id_char_num
security_id_int_num
这两个字段是用来进行安全验证,数据屏蔽使用
xla_transaction_entities是有VDP验证的表,各个模块使用的策略函数是
通过设置>>会计科目设置>>子分类帐会计设置>>子分类帐应用产品 来设置的,
如AP模块使用的是:XLA_SECURITY_POLICY_PKG.MO_POLICY,在该方法中有一句很重要
FUNCTION MO_Policy
(p_obj_schema
IN
VARCHAR2
,p_obj_name
IN
VARCHAR2)
RETURN
VARCHAR2
IS
l_mo_policy
VARCHAR2(4000);
l_log_module
VARCHAR2(240);
BEGIN
IF g_log_enabled THEN
l_log_module := C_DEFAULT_MODULE||'.MO_Policy';
END
IF;
IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
trace('MO_Policy.Begin',C_LEVEL_PROCEDURE,l_log_module);
END
IF;
l_mo_policy := mo_global.org_security
( obj_schema => null
,obj_name
=> null
);
IF (C_LEVEL_STATEMENT >= g_log_level) THEN
trace('l_mo_policy after calling
mo_global.org_security = ' || l_mo_policy,C_LEVEL_STATEMENT,l_log_module);
END
IF;
l_mo_policy := REGEXP_REPLACE(l_mo_policy, 'org_id', 'security_id_int_1',1,1);
-- Security identifiers are not populated. In case of, manual journal entires
-- or third party merge events.
-- bug 4717192, add the if condition
IF(l_mo_policy is
not
null) THEN
l_mo_policy := l_mo_policy || ' OR security_id_int_1 IS NULL ';
END
IF;
xla_utility_pkg.print_logfile
('l_mo_policy after replace = ' || l_mo_policy);
IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
trace('MO_Policy.End',C_LEVEL_PROCEDURE,l_log_module);
END
IF;
RETURN(l_mo_policy);
END MO_Policy;
一般的MOAC
VPD 使用的字段时ORG_ID 该处是将ORG_ID 替换为 security_id_int_1 ,很明显了
现在分析了GL和SLA以及 SLA和字模块之间联系,在加上上面的那段插值代码中对应的表关系,就很容易整理
出常见的追溯关系了,可能也有特殊情况没有涉及到。
下面是一个实例 :
首先看**这边的分配,该分配是对应于SLA中的表xla_distribution_links
在该情况下可以查询出每个会计帐户的明细来历,这是AP**的分配
select aid.invoice_distribution_id "分配ID"
,aid.invoice_line_number "**行号"
,distribution_line_number 分配行号
,aid.rcv_transaction_id 接收事务id
,aid.amount "金额"
from ap_invoice_distributions aid
,ap_invoices
api
where api.invoice_id = aid.invoice_id
and aid.invoice_id = 10140
order
by aid.invoice_line_number
,distribution_line_number;
分配ID
**行号
分配行号
接收事务ID
金额
15000
1
1
4
5000
15003
1
2
4
-5000
15001
2
1
0
15002
2
2
0
15004
2
3
0
15005
2
4
0
15007
2
5
0
15008
2
6
0
15010
2
7
0
15011
2
8
0
15006
3
1
4
1500
15009
3
2
4
-1500
该分配在SLA中每行会生成两行数据
select xte.source_id_int_1
"**ID"
,xdl.source_distribution_id_num_1
"源分配ID"
,xdl.ae_line_num
"SLA行号"
,xdl.unrounded_entered_dr
"借"
,xdl.unrounded_entered_cr
"贷"
,xdl.applied_to_source_id_num_1
"没清楚"
,gjl.code_combination_id
"GL帐户"
from xla_ae_lines
xal
,xla_distribution_links
xdl
,xla_transaction_entities xte
,xla_events
xe
,gl_import_references
gir
,gl_je_lines
gjl
where xal.ae_header_id = xdl.ae_header_id(+)
and xal.ae_line_num = xdl.ae_line_num(+)
and xte.application_id = xdl.application_id
and xte.entity_id = xe.entity_id
and xe.event_id = xdl.event_id
and xe.application_id = xdl.application_id
and gir.gl_sl_link_id = xal.gl_sl_link_id
and gjl.je_header_id = gir.je_header_id
and gjl.je_line_num = gir.je_line_num
and xal.ae_header_id = 14012
and xdl.application_id = 200
order
by xdl.source_distribution_id_num_1;
**ID
源分配ID
SLA行号
借
贷
没清楚
GL帐户
10140
15000
1
5000
61
1004
10140
15000
3
5000
10140
1009
10140
15001
2
0
10140
1009
10140
15001
5
0
10140
1028
10140
15002
4
0
10140
1004
10140
15002
2
0
10140
1009
10140
15003
1
5000
61
1004
10140
15003
3
5000
10140
1009
10140
15004
5
0
10140
1028
10140
15004
2
0
10140
1009
10140
15005
4
0
10140
1004
10140
15005
2
0
10140
1009
10140
15006
1
1500
61
1004
10140
15006
3
1500
10140
1009
10140
15007
2
0
10140
1009
10140
15007
5
0
10140
1028
10140
15008
4
0
10140
1004
10140
15008
2
0
10140
1009
10140
15009
1
1500
61
1004
10140
15009
3
1500
10140
1009
10140
15010
2
0
10140
1009
10140
15010
5
0
10140
1028
10140
15011
2
0
10140
1009
10140
15011
4
0
10140
1004
分析:应付分配中的账户,在SLA中会产生两行数据,并且这两行数据借贷相反 金额相同。
从GL查行数据,在GL的一个header下的行有可能是经过合并后的行,因此GL的行并不能准确的表示出帐户源的帐户信息,在GL的同一个帐户行可能对应着AP这边很多张**的帐户信息,但会计行中的子分类帐日记帐分录行的每一行则一定对应着同一张**。
如下代码是整理的追溯一般代码
select
'_^_' "KEY"
--======xla_transaction_entities=========--------
,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 "日记帐行号"
,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
,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 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'
and gir.je_batch_id = 3008;
xte_id
inc_ID
event_id
SLA hd_id
SLA行
GL行
SLA_gccID
GL_gccID
edr ecr
17024
10180
47028
14013
1
1
1004
1004
3000
17024
10180
47028
14013
2
3
1009
1009
510
17024
10180
47028
14013
3
3
1009
1009
3000
17024
10180
47028
14013
4
1
1004
1004
0
17024
10180
47028
14013
5
5
1028
1028
510
17024
10180
47035
14018
1
2
1009
1009
2000
17024
10180
47035
14018
2
4
1010
1010
2000
17013
10140
47017
14012
1
1
1004
1004
0
17013
10140
47017
14012
2
3
1009
1009
0
17013
10140
47017
14012
3
2
1009
1009
0
17013
10140
47017
14012
4
1
1004
1004
0
17013
10140
47017
14012
5
5
1028
1028
0
17004
10120
47008
14011
1
6
6000
6000
2000
17004
10120
47008
14011
2
3
1009
1009
0
17004
10120
47008
14011
3
3
1009
1009
2000
17004
10120
47008
14011
4
6
6000
6000
0
17004
10120
47008
14011
5
5
1028
1028
0
17015
10160
47019
14003
1
6
6000
6000
2000
17015
10160
47019
14003
2
3
1009
1009
0
17015
10160
47019
14003
3
3
1009
1009
2000
17015
10160
47019
14003
4
6
6000
6000
0
17015
10160
47019
14003
5
5
1028
1028
0
对上面的分析:对同一来源的会计科目,可以多次创建event。一个GL日记帐头对应的源,可以是多个相同来源会计科目的合并,合并原则推测-------来源,类型,会计期相同(同一个头的条件),gccID相同,借贷方向相同。
但愿上面的草草分析应该能满足一般的需要