2012-12-06 16:05 2822人阅读 评论(0) 收藏 举报
 分类:
Oracle EBS(12)  Oracle数据库技术(6) 

版权声明:本文为博主原创文章,未经博主允许不得转载。

首先,对于EBS中的法人实体和分类账以及OU之间的一个层次关系如下图:

其中,对于分类账和法人实体,并不简单是一对多的关系,按照理论上来讲:由于分类账存在辅助分类账,所以一个法人实体除了对应一个主分类账(Primary Ledger)外,还可能存在辅助分类账,但是一个法人实体肯定只对应一个唯一的主分类账,而对于分类账之间是否存在有“主从关系”还不太清楚,有待进一步考证。

而在R12中,要找出他们之间的关系就需要通过一下sql来看了:

  1. SELECT lg.ledger_id,
  2. lg.NAME ledger_name,
  3. lg.short_name ledger_short_name,
  4. cfgdet.object_id legal_entity_id,
  5. le.NAME legal_entity_name,
  6. reg.location_id location_id,
  7. hrloctl.location_code location_code,
  8. hrloctl.description location_description,
  9. lg.ledger_category_code,
  10. lg.currency_code,
  11. lg.chart_of_accounts_id,
  12. lg.period_set_name,
  13. lg.accounted_period_type,
  14. lg.sla_accounting_method_code,
  15. lg.sla_accounting_method_type,
  16. lg.bal_seg_value_option_code,
  17. lg.bal_seg_column_name,
  18. lg.bal_seg_value_set_id,
  19. cfg.acctg_environment_code,
  20. cfg.configuration_id,
  21. rs.primary_ledger_id,
  22. rs.relationship_enabled_flag
  23. FROM gl_ledger_config_details primdet,
  24. gl_ledgers               lg,
  25. gl_ledger_relationships  rs,
  26. gl_ledger_configurations cfg,
  27. gl_ledger_config_details cfgdet,
  28. xle_entity_profiles      le,
  29. xle_registrations        reg,
  30. hr_locations_all_tl      hrloctl
  31. WHERE rs.application_id = 101
  32. AND ((rs.target_ledger_category_code = 'SECONDARY' AND
  33. rs.relationship_type_code <> 'NONE') OR
  34. (rs.target_ledger_category_code = 'PRIMARY' AND
  35. rs.relationship_type_code = 'NONE') OR
  36. (rs.target_ledger_category_code = 'ALC' AND
  37. rs.relationship_type_code IN ('JOURNAL', 'SUBLEDGER')))
  38. AND lg.ledger_id = rs.target_ledger_id
  39. AND lg.ledger_category_code = rs.target_ledger_category_code
  40. AND nvl(lg.complete_flag, 'Y') = 'Y'
  41. AND primdet.object_id = rs.primary_ledger_id
  42. AND primdet.object_type_code = 'PRIMARY'
  43. AND primdet.setup_step_code = 'NONE'
  44. AND cfg.configuration_id = primdet.configuration_id
  45. AND cfgdet.configuration_id(+) = cfg.configuration_id
  46. AND cfgdet.object_type_code(+) = 'LEGAL_ENTITY'
  47. AND le.legal_entity_id(+) = cfgdet.object_id
  48. AND reg.source_id(+) = cfgdet.object_id
  49. AND reg.source_table(+) = 'XLE_ENTITY_PROFILES'
  50. AND reg.identifying_flag(+) = 'Y'
  51. AND hrloctl.location_id(+) = reg.location_id
  52. AND hrloctl.LANGUAGE(+) = userenv('LANG');
  1. SELECT lg.ledger_id,
  2. lg.NAME ledger_name,
  3. lg.short_name ledger_short_name,
  4. cfgdet.object_id legal_entity_id,
  5. le.NAME legal_entity_name,
  6. reg.location_id location_id,
  7. hrloctl.location_code location_code,
  8. hrloctl.description location_description,
  9. lg.ledger_category_code,
  10. lg.currency_code,
  11. lg.chart_of_accounts_id,
  12. lg.period_set_name,
  13. lg.accounted_period_type,
  14. lg.sla_accounting_method_code,
  15. lg.sla_accounting_method_type,
  16. lg.bal_seg_value_option_code,
  17. lg.bal_seg_column_name,
  18. lg.bal_seg_value_set_id,
  19. cfg.acctg_environment_code,
  20. cfg.configuration_id,
  21. rs.primary_ledger_id,
  22. rs.relationship_enabled_flag
  23. FROM gl_ledger_config_details primdet,
  24. gl_ledgers               lg,
  25. gl_ledger_relationships  rs,
  26. gl_ledger_configurations cfg,
  27. gl_ledger_config_details cfgdet,
  28. xle_entity_profiles      le,
  29. xle_registrations        reg,
  30. hr_locations_all_tl      hrloctl
  31. WHERE rs.application_id = 101
  32. AND ((rs.target_ledger_category_code = 'SECONDARY' AND
  33. rs.relationship_type_code <> 'NONE') OR
  34. (rs.target_ledger_category_code = 'PRIMARY' AND
  35. rs.relationship_type_code = 'NONE') OR
  36. (rs.target_ledger_category_code = 'ALC' AND
  37. rs.relationship_type_code IN ('JOURNAL', 'SUBLEDGER')))
  38. AND lg.ledger_id = rs.target_ledger_id
  39. AND lg.ledger_category_code = rs.target_ledger_category_code
  40. AND nvl(lg.complete_flag, 'Y') = 'Y'
  41. AND primdet.object_id = rs.primary_ledger_id
  42. AND primdet.object_type_code = 'PRIMARY'
  43. AND primdet.setup_step_code = 'NONE'
  44. AND cfg.configuration_id = primdet.configuration_id
  45. AND cfgdet.configuration_id(+) = cfg.configuration_id
  46. AND cfgdet.object_type_code(+) = 'LEGAL_ENTITY'
  47. AND le.legal_entity_id(+) = cfgdet.object_id
  48. AND reg.source_id(+) = cfgdet.object_id
  49. AND reg.source_table(+) = 'XLE_ENTITY_PROFILES'
  50. AND reg.identifying_flag(+) = 'Y'
  51. AND hrloctl.location_id(+) = reg.location_id
  52. 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进行精简,也可以得出相应的关系来:

  1. select lg.ledger_id, --分类帐
  2. cfgdet.object_id legal_entity_id, --法人实体
  3. lg.currency_code,
  4. lg.chart_of_accounts_id,
  5. rs.primary_ledger_id
  6. from gl_ledger_config_details primdet,
  7. gl_ledgers               lg,
  8. gl_ledger_relationships  rs,
  9. gl_ledger_configurations cfg,
  10. gl_ledger_config_details cfgdet
  11. where rs.application_id = 101  --101为总账GL应用
  12. and ((rs.target_ledger_category_code = 'SECONDARY' and
  13. rs.relationship_type_code <> 'NONE') or
  14. (rs.target_ledger_category_code = 'PRIMARY' and
  15. rs.relationship_type_code = 'NONE') or
  16. (rs.target_ledger_category_code = 'ALC' and
  17. rs.relationship_type_code in ('JOURNAL', 'SUBLEDGER')))
  18. and lg.ledger_id = rs.target_ledger_id
  19. and lg.ledger_category_code = rs.target_ledger_category_code
  20. and nvl(lg.complete_flag, 'Y') = 'Y'
  21. and primdet.object_id = rs.primary_ledger_id
  22. and primdet.object_type_code = 'PRIMARY'
  23. and primdet.setup_step_code = 'NONE'
  24. and cfg.configuration_id = primdet.configuration_id
  25. and cfgdet.configuration_id(+) = cfg.configuration_id
  26. and cfgdet.object_type_code(+) = 'LEGAL_ENTITY';
  1. select lg.ledger_id, --分类帐
  2. cfgdet.object_id legal_entity_id, --法人实体
  3. lg.currency_code,
  4. lg.chart_of_accounts_id,
  5. rs.primary_ledger_id
  6. from gl_ledger_config_details primdet,
  7. gl_ledgers               lg,
  8. gl_ledger_relationships  rs,
  9. gl_ledger_configurations cfg,
  10. gl_ledger_config_details cfgdet
  11. where rs.application_id = 101  --101为总账GL应用
  12. and ((rs.target_ledger_category_code = 'SECONDARY' and
  13. rs.relationship_type_code <> 'NONE') or
  14. (rs.target_ledger_category_code = 'PRIMARY' and
  15. rs.relationship_type_code = 'NONE') or
  16. (rs.target_ledger_category_code = 'ALC' and
  17. rs.relationship_type_code in ('JOURNAL', 'SUBLEDGER')))
  18. and lg.ledger_id = rs.target_ledger_id
  19. and lg.ledger_category_code = rs.target_ledger_category_code
  20. and nvl(lg.complete_flag, 'Y') = 'Y'
  21. and primdet.object_id = rs.primary_ledger_id
  22. and primdet.object_type_code = 'PRIMARY'
  23. and primdet.setup_step_code = 'NONE'
  24. and cfg.configuration_id = primdet.configuration_id
  25. and cfgdet.configuration_id(+) = cfg.configuration_id
  26. and cfgdet.object_type_code(+) = 'LEGAL_ENTITY';
 
 

Oracle EBS中分类账和法人实体 的关系(有sql语句实例)的更多相关文章

  1. oracle 数据库中,应用程序里的连接探測语句的正确使用

    oracle 数据库中,应用程序里的连接探測语句的正确使用 本文为原创文章.转载请注明出处:http://blog.csdn.net/msdnchina/article/details/3851376 ...

  2. oracle查看执行最慢与查询次数最多的sql语句及其执行速度很慢的问题分析

    oracle查看执行最慢与查询次数最多的sql语句 注:本文来源 于<oracle查看执行最慢与查询次数最多的sql语句> 前言 在ORACLE数据库应用调优中,一个SQL的执行次数/频率 ...

  3. 从数据库中查询所有表及所有字段的SQL语句

    从数据库中查询所有表及所有字段的SQL语句 由于一个小项目的需要,近日完成一个从数据库中查询所有表及所有字段的方法,其实用两条SQL语句就可以完成. Sql Server版:列出当前DB中所有表:se ...

  4. (转载)总结一下SQL语句中引号(')、quotedstr()、('')、format()在SQL语句中的用法

    总结一下SQL语句中引号(').quotedstr().('').format()在SQL语句中的用法 总结一下SQL语句中引号(').quotedstr().('').format()在SQL语句中 ...

  5. 总结一下SQL语句中引号(')、quotedstr()、('')、format()在SQL语句中的用法

    总结一下SQL语句中引号(').quotedstr().('').format()在SQL语句中的用法 日期:2005年6月1日 作者:seasky212 总结一下SQL语句中引号(').quoted ...

  6. (转载)总结一下SQL语句中引号(')、quotedstr()、('')、format()在SQL语句中的用法

    总结一下SQL语句中引号(').quotedstr().('').format()在SQL语句中的用法以及SQL语句中日期格式的表示(#).('')在Delphi中进行字符变量连接相加时单引号用('' ...

  7. log4j向oracle中插入一条系统当前时间的sql语句

    配置log4j,要向oracle插入一条系统当前时间的sql语句,按网上查找的总是出现各种各样的报错,最后总结出的写法是: ### shezhi### log4j.rootLogger = debug ...

  8. Oracle 行转列pivot 、列转行unpivot 的Sql语句总结

    这个比较简单,用||或concat函数可以实现 select concat(id,username) str from app_user select id||username str from ap ...

  9. Oracle、DB2、SQLSERVER、Mysql、Access分页SQL语句梳理

    最近把平时在项目中常用到的数据库分页sql总结了下.大家可以贴出分页更高效的sql语句.sqlserver分页 第一种分页方法 需用到的参数: pageSize 每页显示多少条数据 pageNumbe ...

随机推荐

  1. 关于Java String对象创建的几点疑问

    我们通过JDK源码会知道String实质是字符数组,而且是不可被继承(final)和具有不可变性(immutable).可以如果想要了解String的创建我们需要先了解下JVM的内存结构. 1.JVM ...

  2. 使用vsnprintf后链接错误及解决方法

    /home/merlin/swinstall/MentorGraphics/Sourcery_CodeBench_Lite_for_ARM_EABI/bin/../lib//../../../../a ...

  3. Android项目---listview的那些属性,常用却不常见

    一.在xml中,常用到的属性有 android:cacheColorHint="#00000000" //设置拖动背景色为透明 android:dividerHeight=&quo ...

  4. Oracle笔试题库之问答题篇-总共60道

    1.把表A从表空间TSP1更改成表空间TSP2的方法 解答:alter table A move tablespace TSP2 2.删除表的列: 解答:alert table 表名 drop 列名 ...

  5. using和yield return

    C#中的using和yield return混合使用 最近写代码为了为了省事儿用了几个yield return,因为我不想New一个List<T>或者T[]对象再往里放元素,就直接返回IE ...

  6. 解决C# WinForm 中 VSHOST.EXE 程序不关闭的问题

    右击“解决方案”--属性-调试栏-启用调试器部分-“启用Visual studio宿主进程”不勾选

  7. 获得WCF Client端的本地端口

    获得WCF Client端的本地端口 最近需要做个小功能,当WCF调用远程服务时,显示该调用的网速或流量.其中比较关键的一步就是需要获得WCF  Client端的本地端口,原来以为是个简单的事情,结果 ...

  8. c++class 内存布局

    #include <iostream> using namespace std; class base1 { int a; double b; char c; }; int main() ...

  9. 替换__thread的一种方式,实现TLS功能

    TLS是由于多线程编程带来的产物,主要是为了解决线程资源局部化,具体内容网上有很多介绍.有很多地方已经支持了该功能,但有些地方没有,下面是GCC的一些介绍,反正具体看实际使用情况: 5.51 Thre ...

  10. Event处理

    Event处理 今天抽时间写了一部分Event处理方面的函数愈发的觉得jQuery的优秀,自己前期的想法太粗糙,造成后面这些函数参数很多,操作很很不直观,看样子是要重构的节奏,还好小伙儿伴们安慰,架构 ...