How to use BW Infoobject hierarchy in ABAP CDS views
Hi, in this post I would like to consider a case where you need to use in ABAP CDS Analytical Reporting hierarchies from BW Infoobject master data.
In previous posts I have considered creation of custom hierarchy based tables similar SAP HR and annotations used in query to consume it:
https://blogs.sap.com/2017/02/22/how-to-build-a-custom-hierarchy-in-abap-cds-views/
https://blogs.sap.com/2017/02/21/how-to-consume-a-hierarchy-in-cds-view-analytical-query/
Introduction
- Hierarchies could be loaded or maintained manually in BW embedded in S/4HANA system.
- Considered approach is particularly relevant in case in S/4HANA there is embedded planning solution and you need to reuse existing hierarchy in analytical reports based on ABAP CDS views.
- Considered example will work correctly in case of simple parent-child hierarchies based on one characteristic, without text nodes or linked nodes.
Step-by-step
- Consider infoobject MFICOCP04 “Reporting Section” and existing hierarchy in RSH1 t-code:
2. Create ABAP CDS views Dimension, Text, Hierarchy:
3. Analyse dimension VDM in RSRTS_ODP_DIS t-code and notice that hierarchy metadata is presented here.
4. Test of hierarchy display in RSRT:
5. Use annotations in analytics query to display hierarchy:
Below ABAP CDS view is needed to derive hierarchy name based on reporting year parameter, in example we had several hierarchies maintained for characteristic.
Analytical query code:
Note that derivation of hierarchy guid based on a hierarchy name may be not required in your case, just simplify solution (if needed)
Result
We considered creation of hierarchy ABAP CDS view based on BW Infoobject master data tables.
I would like to thank Former Member for her help with BW part of this example! Thank you!
Thank you for attention!
Hi Maksim,
I think you're challenging yourself to integrate the BW hierarchy directly in CDS, but that looks very complicated and inflexible for me.
It's should be still plausible to do it this way, right?
CDS view >> Open ODS View >> assign the field with the InfoObject >> Set the hierarchy in Query Designer
Cheers
Hi, Donnie!
Yes, you approach is of course fair.
But lead to loss of CDS semantics. Also instead of CDS you could use HANA Calculation views and assign it to Composite Provider.
BR, Maksim
Hi Maksim,
Could you tell me which CDS semantics would be lost?
As for Calculation Views, other than the different script language, I don't understand what is the direction SAP planning with it.
SAP clearly against using attribute and analytical views in a thread some time ago.
But now I see in CDS the attribute/dimension and analytical view concept is back and nothing have been said anything against it (yet).
By Semantins I mean assosiations to master data at cube level. In your approach one need to make master data for needed characteristics availible. For CDS approach it is easier and faster as for BW.
Calculation views as I understand problem: now SAP recommends to use CV, earllier there were also AT, AN views. Different HANA engines are used for making operations with AT, AN and CV. For minimazing data tranfer between engines, it is recommend to use only CVs. For internal ligic of HANA views working for performance di not struggle. This thing has no connection to ABAP CDS. Only by words attribute or dimention, they are used in any analitical tool.
BR, Maksim
Hello,
I am following your guide and at the end in the analytic query I am getting an error that "annotation of my_field use hierarchies, but my_field does not have any [Analytics]". Can you explain how exactly the field is linked to the IO hierarchy. How the system knows that this field is needed IO? In the analytic query there is no association to dimension created in the first step.
Thank you in advanced.
Emilia
Hi Maksim,
If I have text nodes in my hierarchy can you tell me how I would need to change the cds view you have created ?
Thanks and regards
Paul