R_CostElementGroupHierarchy

DDL: R_COSTELEMENTGROUPHIERARCHY SQL: RCOSTELMNTGRPH Type: view COMPOSITE

Cost Element Group Hierarchy

R_CostElementGroupHierarchy is a Composite CDS View that provides data about "Cost Element Group Hierarchy" in SAP S/4HANA. It reads from 7 data sources and exposes 60 fields with key fields SetClass, ChartOfAccounts, CostElementGroupHierarchyNode, HierarchyParentNode, ParentSetSubClass.

Data Sources (7)

SourceAliasJoin Type
I_CostElement _CostElement inner
I_SetHeader I_SetHeader from
I_Setleaf I_Setleaf union
I_Setleaf I_Setleaf union
I_Setleaf I_Setleaf union
I_Setleaf I_Setleaf union
I_Setnode I_Setnode union

Annotations (11)

NameValueLevelField
AbapCatalog.sqlViewName RCOSTELMNTGRPH view
AbapCatalog.compiler.compareFilter true view
AbapCatalog.preserveKey true view
ClientHandling.algorithm #SESSION_VARIABLE view
ObjectModel.usageType.dataClass #CUSTOMIZING view
ObjectModel.usageType.serviceQuality #C view
ObjectModel.usageType.sizeCategory #L view
AccessControl.authorizationCheck #CHECK view
VDM.lifecycle.contract.type #SAP_INTERNAL_API view
VDM.viewType #COMPOSITE view
EndUserText.label Cost Element Group Hierarchy view

Fields (60)

KeyFieldSource TableSource FieldDescription
KEY SetClass I_SetHeader SetClass
KEY ChartOfAccounts
KEY CostElementGroupHierarchyNode
KEY HierarchyParentNode
KEY ParentSetSubClass
KEY HierarchyLevel
KEY CostElement
KEY ControllingArea
char10asDrillState
CostElmntGrpHierNodeTypeFilter
CostElementGroupHierarchyNodekeySetClass
KEY ChartOfAccounts
KEY CostElementGroupHierarchyNode
KEY HierarchyParentNode
KEY ParentSetSubClass SetSubClass
KEY HierarchyLevel
KEY CostElement
KEY ControllingArea
char10asDrillState
CostElmntGrpHierNodeTypeFilter
KEY ChartOfAccounts
KEY CostElementGroupHierarchyNode
KEY HierarchyParentNode
KEY ParentSetSubClass SetSubClass
KEY HierarchyLevel
KEY CostElement
KEY ControllingArea
DrillState
CostElmntGrpHierNodeTypeFilter
CostElementkeySetClass
KEY ChartOfAccounts
KEY CostElementGroupHierarchyNode
KEY HierarchyParentNode
KEY ParentSetSubClass SetSubClass
KEY HierarchyLevel
KEY CostElement
KEY ControllingArea
char10asDrillState
CostElmntGrpHierNodeTypeFilter
SetClass
KEY ChartOfAccounts
KEY CostElementGroupHierarchyNode
KEY HierarchyParentNode
KEY ParentSetSubClass I_Setleaf SetSubClass
KEY HierarchyLevel
KEY CostElement I_CostElement CostElement
KEY ControllingArea I_CostElement ControllingArea
DrillState
CostElmntGrpHierNodeTypeFilter
SetClass
KEY ChartOfAccounts
KEY CostElementGroupHierarchyNode
KEY HierarchyParentNode
KEY ParentSetSubClass I_Setleaf SetSubClass
KEY HierarchyLevel
KEY CostElement I_CostElement CostElement
KEY ControllingArea I_CostElement ControllingArea
DrillState
CostElmntGrpHierNodeTypeFilter
CostElementName
@AbapCatalog.sqlViewName: 'RCOSTELMNTGRPH'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@ClientHandling.algorithm: #SESSION_VARIABLE

@ObjectModel.usageType: {
  dataClass: #CUSTOMIZING,
  serviceQuality: #C,
  sizeCategory: #L
}

@AccessControl.authorizationCheck: #CHECK

@VDM.lifecycle.contract.type: #SAP_INTERNAL_API
@VDM.viewType:#COMPOSITE
@EndUserText.label: 'Cost Element Group Hierarchy'
define view R_CostElementGroupHierarchy 
  as select from I_SetHeader
    left outer to many join I_Setnode as _SetNode on    I_SetHeader.SetClass = _SetNode.ChildSetClass and
                                                I_SetHeader.SetSubClass = _SetNode.ChildSetSubClass and
                                                I_SetHeader.SetID = _SetNode.ChildSetID 
    association[0..1] to R_CostElementGroupEndNode  as _CostElementGroupEndNode     on  I_SetHeader.SetClass = _CostElementGroupEndNode.SetClass 
                                                                                    and I_SetHeader.SetSubClass = _CostElementGroupEndNode.ChartOfAccounts
                                                                                    and I_SetHeader.SetID = _CostElementGroupEndNode.CostElementGroupHierarchyNode                                     
{
  key I_SetHeader.SetClass,
  key cast (I_SetHeader.SetSubClass as fis_ktopl) as ChartOfAccounts,
  key cast (I_SetHeader.SetID   as costelementgrouphierarchynode) as CostElementGroupHierarchyNode,
  key cast('' as costelementgrouphierarchynode) as HierarchyParentNode,
  key cast( '' as setsubcls)  as ParentSetSubClass,      
  key cast( 1 as abap.int4) as HierarchyLevel,    
  key cast('' as kstar) as CostElement,
  
  key cast('' as kokrs) as ControllingArea,
      
      cast(case
            when _CostElementGroupEndNode.CostElementGroupHierarchyNode is null
              then 'expanded'
          else 'leaf'
      end as abap.char( 10 )) as DrillState,
            
      cast('R' as costelmntgrphiernodetypefilter) as CostElmntGrpHierNodeTypeFilter,    
      cast('' as ktext) as CostElementName                

}
where
      I_SetHeader.SetClass = '0102' and
      _SetNode.SetID is null
  
union 
  
  select from I_Setnode 
  
  association[0..1] to R_CostElementGroupEndNode  as _CostElementGroupEndNode     on  I_Setnode.SetClass = _CostElementGroupEndNode.SetClass 
                                                                                  and I_Setnode.SetSubClass = _CostElementGroupEndNode.ChartOfAccounts
                                                                                  and I_Setnode.ChildSetID = _CostElementGroupEndNode.CostElementGroupHierarchyNode              
    
{  
  key SetClass,
  key cast (SetSubClass as fis_ktopl) as ChartOfAccounts,
  key cast (ChildSetID as costelementgrouphierarchynode) as CostElementGroupHierarchyNode,
  key cast(SetID  as costelementgrouphierarchynode) as HierarchyParentNode,
  key SetSubClass as ParentSetSubClass,
  key cast( 1 as abap.int4 ) as HierarchyLevel,          
  key cast('' as kstar) as CostElement,
  
  key cast('' as kokrs) as ControllingArea,
      
      cast(case
            when _CostElementGroupEndNode.CostElementGroupHierarchyNode is null
              then 'expanded'
          else 'leaf'
      end as abap.char( 10 )) as DrillState,
      
      cast('A' as costelmntgrphiernodetypefilter) as CostElmntGrpHierNodeTypeFilter,
      cast('' as ktext) as CostElementName         
      
}
where
  SetClass = '0102'
  
union 

select from I_Setleaf                                                          
                                              
                                                                     
{
  key SetClass,
  key cast (SetSubClass as fis_ktopl) as ChartOfAccounts,
  key cast (SetRangeFromValue as costelementgrouphierarchynode) as CostElementGroupHierarchyNode,
  key cast(SetID  as costelementgrouphierarchynode) as HierarchyParentNode,
  key SetSubClass as ParentSetSubClass,
  key cast(2 as abap.int4 ) as HierarchyLevel,
  key cast('' as kstar) as CostElement,
      
  key cast('' as kokrs) as ControllingArea,
      cast('expanded' as abap.char( 10 )) as DrillState,
      cast('A' as costelmntgrphiernodetypefilter) as CostElmntGrpHierNodeTypeFilter,        
      cast('' as ktext) as CostElementName    
}
where
  SetClass = '0102'
  and SetRangeFromValue = '*'
  
union 

select from I_Setleaf                                                          
                                              
  association[0..*] to I_CostElement as _CostElement on I_Setleaf.SetRangeFromValue <= _CostElement.CostElement
                                                      and I_Setleaf.SetRangeToValue >= _CostElement.CostElement                                                                   
{
  key SetClass,
  key cast (SetSubClass as fis_ktopl) as ChartOfAccounts,
  key cast (concat( concat(SetRangeFromValue, '-'), SetRangeToValue) as costelementgrouphierarchynode) as CostElementGroupHierarchyNode,
  key cast(SetID  as costelementgrouphierarchynode) as HierarchyParentNode,
  key SetSubClass as ParentSetSubClass,
  key cast(2 as abap.int4 ) as HierarchyLevel,
  key cast('' as kstar) as CostElement,
      
  key cast('' as kokrs) as ControllingArea,
      cast(case
            when _CostElement.CostElement is null
              then 'leaf'
          else 'expanded'
      end as abap.char( 10 )) as DrillState,
      
      cast('A' as costelmntgrphiernodetypefilter) as CostElmntGrpHierNodeTypeFilter,        
      cast('' as ktext) as CostElementName    
}
where
  SetClass = '0102'  
  and SetRangeFromValue <> '*' 
  
union

select from I_Setleaf
                                                           
  association[1..*] to I_CostElement as _CostElement on I_Setleaf.SetRangeFromValue <= _CostElement.CostElement
                                                      and I_Setleaf.SetRangeToValue >= _CostElement.CostElement
                                                      

{
  key I_Setleaf.SetClass,
  key cast (I_Setleaf.SetSubClass as fis_ktopl) as ChartOfAccounts,
  key cast ('' as costelementgrouphierarchynode) as CostElementGroupHierarchyNode,
  key cast(concat( concat(I_Setleaf.SetRangeFromValue, '-'), I_Setleaf.SetRangeToValue)  as costelementgrouphierarchynode) as HierarchyParentNode,
  key I_Setleaf.SetSubClass as ParentSetSubClass,
  key cast( 3 as abap.int4 ) as HierarchyLevel,
  key _CostElement.CostElement,
  
  key _CostElement.ControllingArea,
      cast('leaf' as abap.char( 10 )) as DrillState,
      cast('A' as costelmntgrphiernodetypefilter) as CostElmntGrpHierNodeTypeFilter,          
      _CostElement._Text[ Language = $session.system_language ].CostElementName as CostElementName
}
where
  I_Setleaf.SetClass = '0102'
  and SetRangeFromValue <> '*'
  
union

select from I_Setleaf
                                                           
  inner join I_CostElement as _CostElement on I_Setleaf.SetSubClass = _CostElement.ChartOfAccounts
                                                      

{
  key I_Setleaf.SetClass,
  key cast (I_Setleaf.SetSubClass as fis_ktopl) as ChartOfAccounts,
  key cast ('' as costelementgrouphierarchynode) as CostElementGroupHierarchyNode,
  key cast(I_Setleaf.SetRangeFromValue as costelementgrouphierarchynode) as HierarchyParentNode,
  key I_Setleaf.SetSubClass as ParentSetSubClass,
  key cast( 3 as abap.int4 ) as HierarchyLevel,
  key _CostElement.CostElement,
  
  key _CostElement.ControllingArea,
      cast('leaf' as abap.char( 10 )) as DrillState,
      cast('A' as costelmntgrphiernodetypefilter) as CostElmntGrpHierNodeTypeFilter,          
      _CostElement._Text[ Language = $session.system_language ].CostElementName as CostElementName
}
where
  I_Setleaf.SetClass = '0102'   
  and I_Setleaf.SetRangeFromValue = '*' 

/*+[internal] {
"BASEINFO":
{
"FROM":
[
"I_COSTELEMENT",
"I_COSTELEMENTTEXT",
"I_SETHEADER",
"I_SETLEAF",
"I_SETNODE",
"R_COSTELEMENTGROUPENDNODE"
],
"ASSOCIATED":
[
"R_COSTELEMENTGROUPENDNODE"
],
"BASE":
[],
"ANNO_REF":
[],
"SCALAR_FUNCTION":
[],
"VERSION":0,
"ANNOREF_EVALUATION_ERROR":""
}
}*/