Oracle EBS中分类账和法人实体 的关系(有sql语句实例)
Oracle数据库技术(6) 
版权声明:本文为博主原创文章,未经博主允许不得转载。
首先,对于EBS中的法人实体和分类账以及OU之间的一个层次关系如下图:
其中,对于分类账和法人实体,并不简单是一对多的关系,按照理论上来讲:由于分类账存在辅助分类账,所以一个法人实体除了对应一个主分类账(Primary Ledger)外,还可能存在辅助分类账,但是一个法人实体肯定只对应一个唯一的主分类账,而对于分类账之间是否存在有“主从关系”还不太清楚,有待进一步考证。
而在R12中,要找出他们之间的关系就需要通过一下sql来看了:
- SELECT lg.ledger_id,
- lg.NAME ledger_name,
- lg.short_name ledger_short_name,
- cfgdet.object_id legal_entity_id,
- le.NAME legal_entity_name,
- reg.location_id location_id,
- hrloctl.location_code location_code,
- hrloctl.description location_description,
- lg.ledger_category_code,
- lg.currency_code,
- lg.chart_of_accounts_id,
- lg.period_set_name,
- lg.accounted_period_type,
- lg.sla_accounting_method_code,
- lg.sla_accounting_method_type,
- lg.bal_seg_value_option_code,
- lg.bal_seg_column_name,
- lg.bal_seg_value_set_id,
- cfg.acctg_environment_code,
- cfg.configuration_id,
- rs.primary_ledger_id,
- rs.relationship_enabled_flag
- FROM gl_ledger_config_details primdet,
- gl_ledgers lg,
- gl_ledger_relationships rs,
- gl_ledger_configurations cfg,
- gl_ledger_config_details cfgdet,
- xle_entity_profiles le,
- xle_registrations reg,
- hr_locations_all_tl hrloctl
- WHERE rs.application_id = 101
- AND ((rs.target_ledger_category_code = 'SECONDARY' AND
- rs.relationship_type_code <> 'NONE') OR
- (rs.target_ledger_category_code = 'PRIMARY' AND
- rs.relationship_type_code = 'NONE') OR
- (rs.target_ledger_category_code = 'ALC' AND
- rs.relationship_type_code IN ('JOURNAL', 'SUBLEDGER')))
- AND lg.ledger_id = rs.target_ledger_id
- AND lg.ledger_category_code = rs.target_ledger_category_code
- AND nvl(lg.complete_flag, 'Y') = 'Y'
- AND primdet.object_id = rs.primary_ledger_id
- AND primdet.object_type_code = 'PRIMARY'
- AND primdet.setup_step_code = 'NONE'
- AND cfg.configuration_id = primdet.configuration_id
- AND cfgdet.configuration_id(+) = cfg.configuration_id
- AND cfgdet.object_type_code(+) = 'LEGAL_ENTITY'
- AND le.legal_entity_id(+) = cfgdet.object_id
- AND reg.source_id(+) = cfgdet.object_id
- AND reg.source_table(+) = 'XLE_ENTITY_PROFILES'
- AND reg.identifying_flag(+) = 'Y'
- AND hrloctl.location_id(+) = reg.location_id
- AND hrloctl.LANGUAGE(+) = userenv('LANG');
- SELECT lg.ledger_id,
- lg.NAME ledger_name,
- lg.short_name ledger_short_name,
- cfgdet.object_id legal_entity_id,
- le.NAME legal_entity_name,
- reg.location_id location_id,
- hrloctl.location_code location_code,
- hrloctl.description location_description,
- lg.ledger_category_code,
- lg.currency_code,
- lg.chart_of_accounts_id,
- lg.period_set_name,
- lg.accounted_period_type,
- lg.sla_accounting_method_code,
- lg.sla_accounting_method_type,
- lg.bal_seg_value_option_code,
- lg.bal_seg_column_name,
- lg.bal_seg_value_set_id,
- cfg.acctg_environment_code,
- cfg.configuration_id,
- rs.primary_ledger_id,
- rs.relationship_enabled_flag
- FROM gl_ledger_config_details primdet,
- gl_ledgers lg,
- gl_ledger_relationships rs,
- gl_ledger_configurations cfg,
- gl_ledger_config_details cfgdet,
- xle_entity_profiles le,
- xle_registrations reg,
- hr_locations_all_tl hrloctl
- WHERE rs.application_id = 101
- AND ((rs.target_ledger_category_code = 'SECONDARY' AND
- rs.relationship_type_code <> 'NONE') OR
- (rs.target_ledger_category_code = 'PRIMARY' AND
- rs.relationship_type_code = 'NONE') OR
- (rs.target_ledger_category_code = 'ALC' AND
- rs.relationship_type_code IN ('JOURNAL', 'SUBLEDGER')))
- AND lg.ledger_id = rs.target_ledger_id
- AND lg.ledger_category_code = rs.target_ledger_category_code
- AND nvl(lg.complete_flag, 'Y') = 'Y'
- AND primdet.object_id = rs.primary_ledger_id
- AND primdet.object_type_code = 'PRIMARY'
- AND primdet.setup_step_code = 'NONE'
- AND cfg.configuration_id = primdet.configuration_id
- AND cfgdet.configuration_id(+) = cfg.configuration_id
- AND cfgdet.object_type_code(+) = 'LEGAL_ENTITY'
- AND le.legal_entity_id(+) = cfgdet.object_id
- AND reg.source_id(+) = cfgdet.object_id
- AND reg.source_table(+) = 'XLE_ENTITY_PROFILES'
- AND reg.identifying_flag(+) = 'Y'
- AND hrloctl.location_id(+) = reg.location_id
- AND hrloctl.LANGUAGE(+) = userenv('LANG');
从数据结果中可以看出,系统中有7个分类账(LEDGER)和5个法人实体(LEGAL_ENTITY),对于TCL_YSP这个法人实体来说,拥有两个分类账,其LEDGER_CATEGORY_CODE分别为PRIMARY和SECONDARY,说明了一个法人实体有一个主分类账,并且可以有辅助分类账,而2041这个分类账,则没有对应的法人实体,但是其LEDGER_CATEGORY_CODE依然为PRIMARY,这说明一个分类账的category_code有可能是事前定义好的,而不是在与法人实体关联的时候才决定的,所以不能确定分类账之间到底有层次关系……
对以上的sql进行精简,也可以得出相应的关系来:
- select lg.ledger_id, --分类帐
- cfgdet.object_id legal_entity_id, --法人实体
- lg.currency_code,
- lg.chart_of_accounts_id,
- rs.primary_ledger_id
- from gl_ledger_config_details primdet,
- gl_ledgers lg,
- gl_ledger_relationships rs,
- gl_ledger_configurations cfg,
- gl_ledger_config_details cfgdet
- where rs.application_id = 101 --101为总账GL应用
- and ((rs.target_ledger_category_code = 'SECONDARY' and
- rs.relationship_type_code <> 'NONE') or
- (rs.target_ledger_category_code = 'PRIMARY' and
- rs.relationship_type_code = 'NONE') or
- (rs.target_ledger_category_code = 'ALC' and
- rs.relationship_type_code in ('JOURNAL', 'SUBLEDGER')))
- and lg.ledger_id = rs.target_ledger_id
- and lg.ledger_category_code = rs.target_ledger_category_code
- and nvl(lg.complete_flag, 'Y') = 'Y'
- and primdet.object_id = rs.primary_ledger_id
- and primdet.object_type_code = 'PRIMARY'
- and primdet.setup_step_code = 'NONE'
- and cfg.configuration_id = primdet.configuration_id
- and cfgdet.configuration_id(+) = cfg.configuration_id
- and cfgdet.object_type_code(+) = 'LEGAL_ENTITY';
- select lg.ledger_id, --分类帐
- cfgdet.object_id legal_entity_id, --法人实体
- lg.currency_code,
- lg.chart_of_accounts_id,
- rs.primary_ledger_id
- from gl_ledger_config_details primdet,
- gl_ledgers lg,
- gl_ledger_relationships rs,
- gl_ledger_configurations cfg,
- gl_ledger_config_details cfgdet
- where rs.application_id = 101 --101为总账GL应用
- and ((rs.target_ledger_category_code = 'SECONDARY' and
- rs.relationship_type_code <> 'NONE') or
- (rs.target_ledger_category_code = 'PRIMARY' and
- rs.relationship_type_code = 'NONE') or
- (rs.target_ledger_category_code = 'ALC' and
- rs.relationship_type_code in ('JOURNAL', 'SUBLEDGER')))
- and lg.ledger_id = rs.target_ledger_id
- and lg.ledger_category_code = rs.target_ledger_category_code
- and nvl(lg.complete_flag, 'Y') = 'Y'
- and primdet.object_id = rs.primary_ledger_id
- and primdet.object_type_code = 'PRIMARY'
- and primdet.setup_step_code = 'NONE'
- and cfg.configuration_id = primdet.configuration_id
- and cfgdet.configuration_id(+) = cfg.configuration_id
- and cfgdet.object_type_code(+) = 'LEGAL_ENTITY';
Oracle EBS中分类账和法人实体 的关系(有sql语句实例)的更多相关文章
- oracle 数据库中,应用程序里的连接探測语句的正确使用
oracle 数据库中,应用程序里的连接探測语句的正确使用 本文为原创文章.转载请注明出处:http://blog.csdn.net/msdnchina/article/details/3851376 ...
- oracle查看执行最慢与查询次数最多的sql语句及其执行速度很慢的问题分析
oracle查看执行最慢与查询次数最多的sql语句 注:本文来源 于<oracle查看执行最慢与查询次数最多的sql语句> 前言 在ORACLE数据库应用调优中,一个SQL的执行次数/频率 ...
- 从数据库中查询所有表及所有字段的SQL语句
从数据库中查询所有表及所有字段的SQL语句 由于一个小项目的需要,近日完成一个从数据库中查询所有表及所有字段的方法,其实用两条SQL语句就可以完成. Sql Server版:列出当前DB中所有表:se ...
- (转载)总结一下SQL语句中引号(')、quotedstr()、('')、format()在SQL语句中的用法
总结一下SQL语句中引号(').quotedstr().('').format()在SQL语句中的用法 总结一下SQL语句中引号(').quotedstr().('').format()在SQL语句中 ...
- 总结一下SQL语句中引号(')、quotedstr()、('')、format()在SQL语句中的用法
总结一下SQL语句中引号(').quotedstr().('').format()在SQL语句中的用法 日期:2005年6月1日 作者:seasky212 总结一下SQL语句中引号(').quoted ...
- (转载)总结一下SQL语句中引号(')、quotedstr()、('')、format()在SQL语句中的用法
总结一下SQL语句中引号(').quotedstr().('').format()在SQL语句中的用法以及SQL语句中日期格式的表示(#).('')在Delphi中进行字符变量连接相加时单引号用('' ...
- log4j向oracle中插入一条系统当前时间的sql语句
配置log4j,要向oracle插入一条系统当前时间的sql语句,按网上查找的总是出现各种各样的报错,最后总结出的写法是: ### shezhi### log4j.rootLogger = debug ...
- Oracle 行转列pivot 、列转行unpivot 的Sql语句总结
这个比较简单,用||或concat函数可以实现 select concat(id,username) str from app_user select id||username str from ap ...
- Oracle、DB2、SQLSERVER、Mysql、Access分页SQL语句梳理
最近把平时在项目中常用到的数据库分页sql总结了下.大家可以贴出分页更高效的sql语句.sqlserver分页 第一种分页方法 需用到的参数: pageSize 每页显示多少条数据 pageNumbe ...
随机推荐
- 关于Java String对象创建的几点疑问
我们通过JDK源码会知道String实质是字符数组,而且是不可被继承(final)和具有不可变性(immutable).可以如果想要了解String的创建我们需要先了解下JVM的内存结构. 1.JVM ...
- 使用vsnprintf后链接错误及解决方法
/home/merlin/swinstall/MentorGraphics/Sourcery_CodeBench_Lite_for_ARM_EABI/bin/../lib//../../../../a ...
- Android项目---listview的那些属性,常用却不常见
一.在xml中,常用到的属性有 android:cacheColorHint="#00000000" //设置拖动背景色为透明 android:dividerHeight=&quo ...
- Oracle笔试题库之问答题篇-总共60道
1.把表A从表空间TSP1更改成表空间TSP2的方法 解答:alter table A move tablespace TSP2 2.删除表的列: 解答:alert table 表名 drop 列名 ...
- using和yield return
C#中的using和yield return混合使用 最近写代码为了为了省事儿用了几个yield return,因为我不想New一个List<T>或者T[]对象再往里放元素,就直接返回IE ...
- 解决C# WinForm 中 VSHOST.EXE 程序不关闭的问题
右击“解决方案”--属性-调试栏-启用调试器部分-“启用Visual studio宿主进程”不勾选
- 获得WCF Client端的本地端口
获得WCF Client端的本地端口 最近需要做个小功能,当WCF调用远程服务时,显示该调用的网速或流量.其中比较关键的一步就是需要获得WCF Client端的本地端口,原来以为是个简单的事情,结果 ...
- c++class 内存布局
#include <iostream> using namespace std; class base1 { int a; double b; char c; }; int main() ...
- 替换__thread的一种方式,实现TLS功能
TLS是由于多线程编程带来的产物,主要是为了解决线程资源局部化,具体内容网上有很多介绍.有很多地方已经支持了该功能,但有些地方没有,下面是GCC的一些介绍,反正具体看实际使用情况: 5.51 Thre ...
- Event处理
Event处理 今天抽时间写了一部分Event处理方面的函数愈发的觉得jQuery的优秀,自己前期的想法太粗糙,造成后面这些函数参数很多,操作很很不直观,看样子是要重构的节奏,还好小伙儿伴们安慰,架构 ...