With ABAP 740, we have a new way using Integrated Data Access to generate the ALV and this is very prominent when using SAP HANA.
Table of Content for all SALV IDA articles:
- SALV IDA (Integrated Data Access) – Introduction
- SALV IDA – Selection Conditions
- SALV IDA – New Calculated Fields
- SALV IDA – Column Settings
- SALV IDA – Add and Handle Hotspot (Hyperlink)
The existing ALV is has more functionality on the application layer. That makes it very very slow. The full data is being selected and sent to the ALV framework, which translates that into display on the GUI container.
Since the entire data is being selected beforehand, the framework has to parse the data as required. Assume you have set a filter which only displays a single record in ALV output but the huge dataset was selected. Furthermore, you have a many records which you are sorting – again this is happening on the application layer.
With HANA database aka HDB aka in-memory DB, many of the operation which can be executed on the front-end can be send to the database – the code pushdown.
With introduction of IDA ALV, many of this problems can be solved. Question is how?
What is SALV IDA?
The new SALV IDA (Integrated Data Access) works more on code push-down concept. Means, you don’t select the data and send that to the ALV, instead you generate the ALV for the DB table, DB view or a CDS views. CDS views are new concept in 740 which I will cover in future articles.
The IDA framework then analyze the required columns, analyze the filters to get the required where condition and execute the select query. Additionally it also analyze the view port — the only visible section of the ALV — the visible rows and columns. Using this info, the framework would trigger a new query on the DB to get only those required data. Sweet!
One thing to note, IDA ALV would work on any database but you many not get all the great performance benefits if you not using the HDB.
This is the simplest possible call to generate the SALV using IDA.
SALV IDA Simple Call
TRY. cl_salv_gui_table_ida=>create( iv_table_name = 'T100' )->fullscreen( )->display( ). CATCH cx_salv_db_connection cx_salv_db_table_not_supported cx_salv_ida_contract_violation cx_root INTO DATA(lo_exc). MESSAGE lo_exc TYPE 'I'. ENDTRY.
Output of this Simple call:
I don’t take SAP’s word by itself, but I try to verify the claim So, to check if what SAP has suggested that only few data is selected, I ran a trace on the program.
When running this sample code on HDB, I got this trace:
Where as not on HDB, it triggered the select with all the rows of the table:
See how HDB is only using 1000 records to start with generating the output, where as the non HDB is selecting all the records.
This template demo class is used for all the subsequent articles on SALV IDA. If you just got a method which needs to be plugged in, this would be the template you are looking for. If you are with me for a long time, you would see the familiar pattern which was used in SALV tutorials
CLASS lcl_alv DEFINITION. PUBLIC SECTION. METHODS: generate_alv. PRIVATE SECTION. DATA: o_salv_ida TYPE REF TO if_salv_gui_table_ida. "CL_SALV_GUI_GRID_MODEL_IDA. *$*$1 *$*$1 ENDCLASS. START-OF-SELECTION. NEW lcl_alv( )->generate_alv( ). * CLASS lcl_alv IMPLEMENTATION. METHOD generate_alv. TRY. o_salv_ida = cl_salv_gui_table_ida=>create( iv_table_name = 'T100' ). *$*$2 *$*$2 o_salv_ida->fullscreen( )->display( ). CATCH cx_salv_db_connection cx_salv_db_table_not_supported cx_salv_ida_contract_violation cx_root INTO DATA(lo_exc). MESSAGE lo_exc TYPE 'I'. ENDTRY. ENDMETHOD. *$*$3 *$*$3 ENDCLASS.