专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > SQL

Oracle EBS中分类账跟法人实体 的关系(有sql语句实例)

发布时间:2010-05-20 14:01:29 文章来源:www.iduyao.cn 采编人员:星星草
Oracle EBS中分类账和法人实体 的关系(有sql语句实例)

 

 

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

 分类:
 

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

 

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

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

 

[c-sharp] view plaincopy
 
  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');  
[c-sharp] view plain copy
 
  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进行精简,也可以得出相应的关系来:

 

[c-sharp] view plaincopy
 
  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';  
[c-sharp] view plain copy
 
  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';  

 

 

 

 
 
友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: