ABAP for SAP HANA. Part XX. ALV Report On SAP HANA – Opportunities And Challenges

The HANA Storm has been sweeping everyone away. As of September 2017, SAP report claimed there were more than 1000 Clients already live on S/4HANA. So tomorrow if not today, all Practitioners working on SAP would have to swim through the HANA waters. Narrowing down the SAP Practitioners to ABAPer, who program ALV Reports every other week. Have you wondered how good or bad it can be to design an ALV Report in SAP with HANA as Suite as well as Database? In this article, we would try to present stories from both eras, prior to HANA and in HANA.

ALV REPORTS ARE THE COCKROACHES OF SAP WORLD, WHICH WOULD SURVIVE EVERY EVOLUTION.

Roots or Foundation or the Start point in ALV is same in HANA World as it was before in traditional database, i.e. SELECTION-SCREEN. Sadly, we tend to draw some conclusions as soon as we see this. The screen needs to have checkboxes, radio buttons, selection screen blocks etc. This is sad because at one end we see Fiori Launchpads have dynamic and colorful screens with applications enhancing User Experience (UX) using SAP UI5 and at the other end the traditional ALV.

Rather cribbing about it, we need to remember that clients (still) demand ALV reports similar to standard T-Code output e.g. ME2N (quoting because that is what was the requirement I got). Afterall everything is not about user experience. Complex business needs also get some weight.

No matter, whether you are trying to learn Fiori or SAPUI5, ALV reports cannot be replaced. So, also start looking into the new way you can create the ALVs.

How can we make our (ABAPers) lives cheerful and interesting? Add HANA into the mix and what you get is easier to code (well not so much) and more importantly greater improvement in the performance.

The improvement in performance is solely attributed to one thing that is the concept called “Code Push Down” or “Code to Data (Database) Paradigm”. Heard it anywhere? Do not say No. We are at the 20th part in our HANA ABAP Series.

Here we have a tipping point. One can go for the method of using CDS View along with AMDP (if necessary) or go with IDA. Using IDA is a lot easier than AMDP, but either one cannot be a replacement for the other. They have their own roles to play. In the next article, I will cover the differences and advantages of IDA against CDS.

Before scrolling down it would be a good idea to know a little more about AMDP (ABAP Managed Database Procedure) and IDA (Integrated Data Access).

So for ALV in HANA, we have the following:.

1. Selection Screen

2. Data is ready in CDS +/- AMDP

What next? Just connect them.

3. Applying selection screen criteria into CDS view entries.

The third step is a bit tricky. We again have multiple opportunities here.

3.1 Either pass all the selection screen filters into AMDP ( NOT CDS View because of the fact that CDS Views are parameterized and cannot take more than one value for a single field and selection screen of the ALV report has select options which are in range tables)

OR

3.2 Get all the entries from CDS View into your Application Layer and then proceed with usual coding practice.

By this time, experienced ABAPers would say that first approach (AMDP) would do all the good in terms of performance.

Now we have narrowed down to:

  1. Selection Screen
  2. Data is ready in CDS +/- AMDP
  3. Applying selection screen criteria into CDS view entries using AMDP and importing only required entries into AS layer and proceeding with usual SALV factory class using OOPs.

Technical Points:

1. Conversion of SELECT-OPTIONS into Dynamic “WHERE CLAUSE”: Once the usual selection screen is built, the first hurdle would be to integrate the select options into AMDP. To achieve that we have the following code snippet:

DATA(lv_where) = cl_shdb_seltab=>combine_seltabs(
it_named_seltabs = VALUE #(
( name = 'MATNR' dref = REF #( so_matnr[] ) )
( name = 'EBELN' dref = REF #( so_ebeln[] ) )
) ).

Hope you are able to understand the above code. Else, the below alternative for the same operation can help you better.

cl_shdb_seltab=>combine_seltabs(
EXPORTING
it_named_seltabs = VALUE #(
( name = 'MATNR' dref = REF #( so_matnr[] ) )
( name = 'EBELN' dref = REF #( so_ebeln[] ) )
)
RECEIVING
rv_where = DATA(lv_where) ).

2. Using Dynamic where clause in AMDP: The next challenge is to use the where clause. There is a feature in SAP AS 7.40 and higher of “APPLY FILTER”. The lv_where clause built above is passed to AMDP method parameter ip_filters.