Sunday 7 November 2021

Filtering by Short Material Product Hierarchy Dimension Keys with ABAP CDS Views

I previously explained how to Display Short Material Product Hierarchy Level Keys with ABAP CDS Views. But what if you want to use short Material Product Hierarchy dimensions instead of hierarchy levels? Displaying dimension is not an issue, but how to filter dimension by short key value? If this question challenges you, then my new blog is for you.

SAP ABAP CDS Views, SAP ABAP Exam Prep, SAP ABAP Tutorial and Materials, SAP ABAP Prep, SAP ABAP Career, SAP ABAP Guides, SAP ABAP Skills

SAP ABAP CDS Views, SAP ABAP Exam Prep, SAP ABAP Tutorial and Materials, SAP ABAP Prep, SAP ABAP Career, SAP ABAP Guides, SAP ABAP Skills

There is one line of code solution for this problem. It is often like that with SAP development. The biggest challenge is where to write that single line of code and what that line should be.

In our case the line of code is in ABAP CDS view dimension’s data element’s domain conversion route input function module. And the line of code is adding leading asterisk (*) before short dimension value key.

SAP ABAP CDS Views, SAP ABAP Exam Prep, SAP ABAP Tutorial and Materials, SAP ABAP Prep, SAP ABAP Career, SAP ABAP Guides, SAP ABAP Skills

SAP ABAP CDS Views, SAP ABAP Exam Prep, SAP ABAP Tutorial and Materials, SAP ABAP Prep, SAP ABAP Career, SAP ABAP Guides, SAP ABAP Skills

SAP ABAP CDS Views, SAP ABAP Exam Prep, SAP ABAP Tutorial and Materials, SAP ABAP Prep, SAP ABAP Career, SAP ABAP Guides, SAP ABAP Skills

The line of code does the trick converting dimension short key value into pattern selection

SAP ABAP CDS Views, SAP ABAP Exam Prep, SAP ABAP Tutorial and Materials, SAP ABAP Prep, SAP ABAP Career, SAP ABAP Guides, SAP ABAP Skills

SAP ABAP CDS Views, SAP ABAP Exam Prep, SAP ABAP Tutorial and Materials, SAP ABAP Prep, SAP ABAP Career, SAP ABAP Guides, SAP ABAP Skills

For the sake of completeness, here is conversion route output function module. It takes care of displaying short Material Product Hierarchy dimension keys

SAP ABAP CDS Views, SAP ABAP Exam Prep, SAP ABAP Tutorial and Materials, SAP ABAP Prep, SAP ABAP Career, SAP ABAP Guides, SAP ABAP Skills

SAP ABAP CDS Views, SAP ABAP Exam Prep, SAP ABAP Tutorial and Materials, SAP ABAP Prep, SAP ABAP Career, SAP ABAP Guides, SAP ABAP Skills

This is how Material Product Hierarchy dimensions are defined

SAP ABAP CDS Views, SAP ABAP Exam Prep, SAP ABAP Tutorial and Materials, SAP ABAP Prep, SAP ABAP Career, SAP ABAP Guides, SAP ABAP Skills

SAP ABAP CDS Views, SAP ABAP Exam Prep, SAP ABAP Tutorial and Materials, SAP ABAP Prep, SAP ABAP Career, SAP ABAP Guides, SAP ABAP Skills

For ease of Material Product Hierarchy dimensions use, I also recommend to extend I_Material dimension CDS view

SAP ABAP CDS Views, SAP ABAP Exam Prep, SAP ABAP Tutorial and Materials, SAP ABAP Prep, SAP ABAP Career, SAP ABAP Guides, SAP ABAP Skills

It is easy to define Material Product Hierarchy dimensions referring to I_Material attributes

SAP ABAP CDS Views, SAP ABAP Exam Prep, SAP ABAP Tutorial and Materials, SAP ABAP Prep, SAP ABAP Career, SAP ABAP Guides, SAP ABAP Skills

Source codes can be downloaded from GitHub:






P.S. In case Patterns/Wildcards in prompts are not enabled in your Analysis for Office installation, please add <OperatorContainsPattern value=”True” /> string to your Analysis for Office configuration file C:\Users\<user name>\AppData\Roaming\SAP\Cof\Ao_user_roaming.config

SAP ABAP CDS Views, SAP ABAP Exam Prep, SAP ABAP Tutorial and Materials, SAP ABAP Prep, SAP ABAP Career, SAP ABAP Guides, SAP ABAP Skills

Source: sap.com

No comments:

Post a Comment