3

Display Short Material Product Hierarchy Level Keys with ABAP CDS Views

 2 years ago
source link: https://blogs.sap.com/2021/10/07/display-short-material-product-hierarchy-level-keys-with-abap-cds-views/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
October 7, 2021 2 minute read

Display Short Material Product Hierarchy Level Keys with ABAP CDS Views

Previously I explained how to Add Multiple T179 Material Product Hierarchies to S/4HANA Embedded Analytics Content. Material Product Hierarchy displays long levels key based on T179 table, but users accustomed to see individual level short keys the ways they maintained in MM02 transaction. Take Material Product Hierarchy to a next level addressing user requirements.

Below is how users assign hierarchy levels are maintained in MM02 transaction

Display-Short-Product-Hierarchy-Level-Keys-with-ABAP-CDS-Views-1-2.png

Users expect to see the same short Material Product Hierarchy level keys in ABAP CDS view queries. Unfortunately, it is not the case. Hierarchy level keys are displayed the way they are stored in T179 table

Display-Short-Product-Hierarchy-Level-Keys-with-ABAP-CDS-Views-2-3.png

Display-Short-Product-Hierarchy-Level-Keys-with-ABAP-CDS-Views-4.png

This blog explains how to display short Material Product Hierarchy level keys as shown below

Display-Short-Product-Hierarchy-Level-Keys-with-ABAP-CDS-Views-3-2.png

All it takes is to make some minor changes to I_ProductHierarchyNode CDS view casting Product Hierarchy Node using custom ZPRODH data element

Display-Short-Product-Hierarchy-Level-Keys-with-ABAP-CDS-Views-5.png

ZPRODH data element created on top of ZPRODH domain which is using ZPH conversion routine.

Display-Short-Product-Hierarchy-Level-Keys-with-ABAP-CDS-Views-6.png

Display-Short-Product-Hierarchy-Level-Keys-with-ABAP-CDS-Views-8.png

The trick is in ZPH conversion routine. What conversion routine is doing is removing preceding hierarchy levels during output.

Display-Short-Product-Hierarchy-Level-Keys-with-ABAP-CDS-Views-9.png

ZPH conversion routine is defined with using two function modules CONVERSION_EXIT_ZPH_INPUT and CONVERSION_EXIT_ZPH_OUTPUT. Output routing is doing the trick

Display-Short-Product-Hierarchy-Level-Keys-with-ABAP-CDS-Views-10.png

Input routing is not doing much

Display-Short-Product-Hierarchy-Level-Keys-with-ABAP-CDS-Views-11.png

CONVERSION_EXIT_ZPH_OUTPUT can be downloaded from GitHub


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK