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 ...
随机推荐
- 从PHP官网被攻击,到熟悉SSL(安全链路层)
近日,php官网php.net网站受到恶意攻击,攻击者至少破坏了2个服务器.PHP工作组不得不重置用户密码. PHP工作组在随后的调查发现,攻击者成功的对网站注入了恶意的JavaScript代码,这个 ...
- cocos2d-x的TestCpp分析
最近,我刚开始学coco2d-x 我会写我的学习经验来 首先TestCppproject有许多例子文件夹,而在这些文件夹以外的其他文件 .我首先研究这些文件: controller.h/cpp:管理方 ...
- ios中mvc的FormsAuthentication.SetAuthCookie(cookieUserName, false)失败
如果楼主使用.net开发,要注意FormsAuthentication.SetAuthCookie 方法的使用会导致ios出现该问题.因为这个方法在ios设备上是把票据加入到url中,导致url和你的 ...
- awk学习点滴
1,常量 ARGC:命令行参数个数 包括awk本身命令,但awk的自带option不算在内. ARGV:命令行参数数组 ARGV[0]是awk本身,其他依次提取就好. $ awk -F ' ' 'BE ...
- 依赖注入和IOC
http://www.bbsmvc.com/archiver/csharp/thread-831-1.html 本来想使用一下Ninject的,然后搜索了很久,都没找到比较详细的关于Ninject的使 ...
- boost------ref的使用(Boost程序库完全开发指南)读书笔记
STL和Boost中的算法和函数大量使用了函数对象作为判断式或谓词参数,而这些参数都是传值语义,算法或函数在内部保修函数对象的拷贝并使用,例如: #include "stdafx.h&quo ...
- SZU:L89 Frog Encoding
Judge Info Memory Limit: 65536KB Case Time Limit: 3000MS Time Limit: 3000MS Judger: Normal Descripti ...
- iOS基础 - 内存分析
一.内存的重要性 程序是否可用的最根本的制约因素. 十分影响用户体验. 程序的crash有很多情况都是内存的原因. 二.iOS平台内存警告机制 iOS系统不支持虚拟内存,一旦出现内存不足的情况,iOS ...
- GDB-Darwin-Extentions
- 【javascript】判断浏览设备是手机还是电脑
判断页面浏览设备是手机还是电脑,代码如下: function browserRedirect() { var sUserAgent = navigator.userAgent.toLowerCase( ...