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. Ora创建job定时执行某存储过程

    --创建job任务,每天晚上8点执行存储过程:por_postrecords-- declare job number; begin sys.dbms_job.submit(job =>job, ...

  2. leetcode第八题--String to Integer (atoi)

    Problem: Implement atoi to convert a string to an integer. Hint: Carefully consider all possible inp ...

  3. ylb:SQLServer常用系统函数-字符串函数、配置函数、系统统计函数

    原文:ylb:SQLServer常用系统函数-字符串函数.配置函数.系统统计函数 ylbtech-SQL Server:SQL Server-SQLServer常用系统函数 -- ========== ...

  4. HDU 4812 D Tree 树分区+逆+hash新位置

    意甲冠军: 特定n点树 K 以下n号码是正确的点 以下n-1行给出了树的侧. 问: 所以,如果有在正确的道路点图的路径 % mod  = K 如果输出路径的两端存在. 多条路径则输出字典序最小的一条. ...

  5. BackgroundWorker组件使用总结

    首先在窗体拖入一个BackgroundWorker组件,根据功能需要设置BackgroundWorker的属性 WorkerSupportsCancellation = true; 允许取消后台正在执 ...

  6. 喜大本\\ u0026普,微软的开源

    词汇表--喜大本\\ u0026普:爱过.有趣的游戏,庆祝.奔走相告.简而言之<reload=1">微软宣布.NET开发环境开源>是个好消息. 前言及历史回想 就我个人来说 ...

  7. 解决设置redmineblacklog的按钮无效问题

    安装了redemin+backlog后,想要设置backlog, 先用管理员登录,然后访问网页: http://localhost/settings/plugin/redmine_backlogs 发 ...

  8. iOS基础 - 单元测试

    单元测试(unit testing):对软件中最小可测试单元进行检查和验证.一般面向过程的语言中,基本单元为函数,面向对象的语言中,基本单元通常是类,其实对于一个手机上的app来说基本单元也可以是一个 ...

  9. 关于C#时间格式化中的“f”

    示例: DateTime.Now.ToString("yyyyMMddHHmmssfff") 上面的示例就是将日期格式化到毫秒级.那么问题来了,格式化到微秒级.纳秒级怎么整?f又是 ...

  10. oracle数据库对date字段类型存在空值进行排序的处理方法

    oracle数据库对date字段类型存在空值进行排序的处理方法      oracle 数据库,如果表中有一个字段类型为date,且该字段类型存在空值,并且需要排序,     解决方法为使用oracl ...