@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":""
}
}*/