Optimizing SAP ALV with IDA: In-Memory Processing and Advanced Features

Mastering SAP ALV with IDA: Applying Record and Column Limits, Select Options, and Disabling Features 

In this blog, we will explore the ALV with IDA (Integrated Data Access) in SAP ABAP, which is designed to handle large datasets efficiently using SAP HANA’s in-memory capabilities. Unlike traditional ALV methods, which retrieve data into internal tables before displaying it, ALV with IDA processes data directly at the database level, reducing memory consumption and improving performance. 

We will cover: 

  • What is ALV with IDA, and how does it differ from classical ALV? 
  • When should you use ALV with IDA? 
  • How to apply record and column limits, filtering, and select-options? 
  • How to disable specific ALV features like sorting and filtering? 

Why Use ALV with IDA? 

Traditional ALV reports work well for small to medium datasets, but they retrieve all records into an internal table before displaying them. This can cause: 
High memory consumption when working with millions of records. 
Performance bottlenecks due to data transfer from DB to the application layer. 
Slow response times when filtering, sorting, or aggregating data. 

ALV with IDA solves these issues by: 
Processing data at the database level using SQL queries. 
Leveraging SAP HANA’s in-memory capabilities for faster execution. 
Automatically optimizing performance without manual tuning. 

When to Use ALV with IDA? 

Use ALV with IDA when: 

  • You are working with large datasets (millions of records). 
  • Your system runs on SAP HANA and supports in-memory processing. 
  • You need dynamic filtering, sorting, and aggregation at the database level. 
  • You want better performance without writing complex ABAP logic. 
     

🚫 When NOT to use ALV with IDA: 

  • If you are using a non-HANA database, as IDA is optimized for HANA. 
  • If you need custom processing logic on retrieved records before displaying them. 
  • If you are working with small datasets, where classical ALV is sufficient. 

In sap abap,we can display the data using write statement,using classical reports,using interactive report,using alv in list and grid format,using oalv containers,using salv  and          using alv  with ida(Integrated Data Access) . 

Alv with IDA: ALV with IDA (Integrated Data Access) is a modern approach to displaying data in SAP ABAP, leveraging the power of SAP HANA’s in-memory capabilities to improve performance and simplify data access. It enables the efficient display of large datasets by pushing down data-intensive operations to the HANA database layer, thereby reducing the data transferred to the application server. 

We can Display the data using the alv with IDA in sap gui  as well as ADT(Abap Development Tool). 

Some Features of Alv with IDA: 

In-Memory processing: 

ALV with IDA leverages SAP HANA’s in-memory computing, allowing data to be processed directly in the database instead of internal tables, ensuring faster execution. 

Code Push Down: 

Instead of handling operations like filtering and sorting in ABAP, these tasks are pushed to the database level, reducing load on the application server and improving performance. 

Direct Database Access: 

Data is fetched directly from the HANA database without being loaded into internal tables, minimizing memory consumption and enhancing speed. 

Automatic performance optimization: 

ALV with IDA automatically optimizes queries using HANA’s query optimizer, eliminating the need for manual performance tuning.  

Dynamic Data operations like filtering and Sorting: 

Filtering and sorting are executed at the database level, allowing instant, real-time operations even for large datasets. 

Database level aggregation and calculations: 

Aggregations such as SUM, COUNT, and AVERAGE are performed within the database, ensuring quick and efficient calculations. 

Disabling Sorting & Filtering: 

Certain fields can be restricted from sorting and filtering using ALV settings, ensuring data integrity and control over user actions. 

Prerequisites for using Alv with IDA: 

  • The SAP system must be running on an SAP HANA database. 
  • The SAP  Version should be higher than 7.4. 
  • It is recommended to use latest ADT(Abap Development Tool). 

Standard Classes used: 

cl_salv_gui_table_ida: cl_salv_gui_table_ida is a class in SAP ABAP (Object-Oriented ABAP) that is used to create and display ALV (ABAP List Viewer) grids. The ALV grid provides a powerful and flexible way to display data in a tabular format with various features such as sorting, filtering,restricting the fields and restricting the number of records. 

cl_salv_range_tab_collector: cl_salv_range_tab_collector is a class in SAP ABAP(Object-Oriented ABAP) that is used to provide select options while displaying the data using alv with IDA.  

Standard Interfaces used: 

if_salv_gui_table_ida In SAP, the IF_SALV_GUI_TABLE_IDA interface is used for creating and handling ALV (ABAP List Viewer) grids with Integrated Data Access (IDA). 

if_salv_ida_condition_factory – The IF_SALV_IDA_CONDITION_FACTORY interface is used in the context of SAP HANA Integrated Data Access (IDA) for creating conditions and filters on the data being retrieved and displayed in ALV (ABAP List Viewer) grids. 

if_salv_ida_condition It provides a way to define and manage conditions for filtering, sorting, and aggregating data when working with large datasets in an ALV grid. This interface is particularly useful for specifying conditions to be applied to the data set to retrieve and display relevant data efficiently. 

if_salv_gui_field_catalog_ida – The IF_SALV_GUI_FIELD_CATALOG_IDA interface is used in the context of ALV (ABAP List Viewer) with Integrated Data Access (IDA) to define and manage the field catalog for an ALV grid. The field catalog specifies the properties of the fields (columns) to be displayed in the ALV grid, such as field names, data types, visibility. 

 

Standard Exceptions used: 

cx_salv_ida_contract_violation This exception is raised when there is a violation of a contract or condition defined by the ALV with IDA framework. 

cx_salv_db_connection – The CX_SALV_DB_CONNECTION class is an exception class used to handle database connection errors within the context of the ALV (ABAP List Viewer) with Integrated Data Access (IDA) framework. This exception is specifically designed to manage issues related to the database connection when working with ALV with IDA. 

cx_salv_db_table_not_supported – The CX_SALV_DB_TABLE_NOT_SUPPORTED exception class is used to handle cases where a database table is not supported by the ALV (ABAP List Viewer) with Integrated Data Access (IDA) framework. This exception is particularly relevant when attempting to use a table that does not meet the requirements or constraints defined by the ALV with IDA framework. 

cx_salv_ida_contract_violation – The CX_SALV_IDA_CONTRACT_VIOLATION class represents an exception that is used within the ALV (ABAP List Viewer) with Integrated Data Access (IDA) framework to indicate that a contract or condition defined by the framework has been violated. This exception is crucial for maintaining the integrity and expected behavior of the ALV with IDA framework by ensuring that all predefined rules and conditions are met. 

cx_salv_ida_unknown_name– The CX_SALV_IDA_UNKNOWN_NAME exception class is used within the ALV (ABAP List Viewer) with Integrated Data Access (IDA) framework to indicate that an unknown or invalid name was encountered. This typically refers to situations where a field name, table name, or view name specified in the ALV with IDA framework does not exist or is not recognized. 

cx_salv_ida_associate_invalid – The CX_SALV_IDA_ASSOCIATE_INVALID exception class is used within the ALV (ABAP List Viewer) with Integrated Data Access (IDA) framework to indicate that an association or relationship between tables or views is invalid. This exception typically arises when there are issues with the definition or use of associations, which are crucial for retrieving and displaying related data in ALV grids.  

What is the Main purpose of this Blog: 

Scenario: I want to display the Material master data using alv with Ida and restricting the number of records ,restring the number of fields ,disabling features like sorting,filtering,providing select options and parameters for the alv. 

I have displayed the data in ADT tool. 

Example1: Displaying Material master data using alv with ida 

REPORT zss_rp_alv_with_ida_simple.

TRY.

cl_salv_gui_table_ida=>create(
EXPORTING
iv_table_name = ‘MARA’
* io_gui_container =
* io_calc_field_handler =
* RECEIVING
* ro_alv_gui_table_ida =
)->fullscreen( )->display( ).

CATCH cx_salv_db_connection.
CATCH cx_salv_db_table_not_supported.
CATCH cx_salv_ida_contract_violation.

ENDTRY.

Siva_sankar_225_0-1742496935602.png

 

Example 2:Displaying the specific number of records using alv with ida 

REPORT zss_rp_alv_with_ida_restrecs.

DATA: lo_salv TYPE REF TO if_salv_gui_table_ida.

TRY.

cl_salv_gui_table_ida=>create(
EXPORTING
iv_table_name = ‘MARA’
* io_gui_container =
* io_calc_field_handler =
RECEIVING
ro_alv_gui_table_ida = lo_salv
).

CATCH cx_salv_db_connection.
CATCH cx_salv_db_table_not_supported.
CATCH cx_salv_ida_contract_violation.

ENDTRY.

TRY.

lo_salv->set_maximum_number_of_rows(
EXPORTING
iv_number_of_rows = 10
* iv_unrestricted =
).

CATCH cx_salv_param_out_of_bounds.

ENDTRY.

lo_salv->fullscreen( )->display( ).

  

Siva_sankar_225_1-1742496935605.png

Example 3:Displaying specific fields data only using alv with ida. 

REPORT zss_rp_alv_with_ida_restfields.

DATA:lr_salv TYPE REF TO if_salv_gui_table_ida,
lr_fcat TYPE REF TO if_salv_gui_field_catalog_ida.

TRY.

cl_salv_gui_table_ida=>create(
EXPORTING
iv_table_name = ‘MARA’
* io_gui_container =
* io_calc_field_handler =
RECEIVING
ro_alv_gui_table_ida = lr_salv
).

CATCH cx_salv_db_connection.
CATCH cx_salv_db_table_not_supported.
CATCH cx_salv_ida_contract_violation.

ENDTRY.

* get the field catalog reference

lr_fcat = lr_salv->field_catalog( ).

* get all the fields

lr_fcat->get_available_fields(
IMPORTING
ets_field_names = DATA(lt_field)
).

* Delete few fields as needed

LOOP AT lt_field INTO DATA(ls_Wa).

IF ls_wa = ‘MBRSH’ OR ls_wa = ‘MTART’ OR LS_wA = ‘ERDAT’ OR LS_wA = ‘ERNAM’
OR LS_wA = ‘CREATED_AT_TIME’ OR LS_wA = ‘ERSDA’ .

DELETE lt_field INDEX sy-tabix.

ENDIF.

ENDLOOP.

*SET back the fields to be displayed

TRY.

lr_fcat->set_available_fields( its_field_names = lt_field ).
CATCH cx_salv_ida_unknown_name.

ENDTRY.

* set maximum rows to display

TRY.

lr_salv->set_maximum_number_of_rows(
EXPORTING
iv_number_of_rows = 10
* iv_unrestricted =
).

CATCH cx_salv_param_out_of_bounds.

ENDTRY.

* Display alv

TRY.

lr_salv->fullscreen( )->display( ).

CATCH cx_salv_ida_contract_violation.

ENDTRY.

Output: 

You can see the deleted field of the above mentioned like, created on, created time etc.., 

Siva_sankar_225_2-1742496935607.png

Example 4 : Displaying the data based on parameter using alv with ida 

REPORT zss_rp_alv_with_ida_params.

PARAMETERS: p_MTART TYPE mara-mtart.
DATA: lo_salv TYPE REF TO if_salv_gui_table_ida,
lr_cond_fact TYPE REF TO if_salv_ida_condition_factory,
lr_cond TYPE REF TO if_salv_ida_condition.

TRY.

cl_salv_gui_table_ida=>create(
EXPORTING
iv_table_name = ‘MARA’
* io_gui_container =
* io_calc_field_handler =
RECEIVING
ro_alv_gui_table_ida = lo_salv
).

CATCH cx_salv_db_connection.
CATCH cx_salv_db_table_not_supported.
CATCH cx_salv_ida_contract_violation.

ENDTRY.

TRY.

lr_cond_fact = lo_salv->condition_factory( ).
lr_cond = lr_cond_fact->equals(
name = ‘MTART’
value = p_mtart
).

CATCH cx_salv_ida_unknown_name.

ENDTRY.

TRY.

lo_salv->set_select_options(
EXPORTING
* it_ranges =
io_condition = lr_cond
).

CATCH cx_salv_ida_associate_invalid.
CATCH cx_salv_db_connection.
CATCH cx_salv_ida_condition_invalid.
CATCH cx_salv_ida_unknown_name.

ENDTRY.

lo_salv->fullscreen( )->display( ).

 

Output: 

Siva_sankar_225_3-1742496935608.png

Siva_sankar_225_4-1742496935609.png

Siva_sankar_225_5-1742496935609.png

Example 5 : Displaying the data based on select-options  using alv with ida 

REPORT zss_rp_alv_with_ida_selopt.

DATA: lv_MATNR TYPE MARA-MATNR.
SELECT-OPTIONS: s_MATNR FOR lv_MATNR.
DATA: lr_salv TYPE REF TO if_salv_gui_table_ida,
lr_range TYPE REF TO cl_salv_range_tab_collector.

cl_salv_gui_table_ida=>create(
EXPORTING
iv_table_name = ‘MARA’
RECEIVING
ro_alv_gui_table_ida = lr_salv ).

CREATE OBJECT lr_range.

*Set the range

lr_range->add_ranges_for_name( iv_name = ‘MATNR’ it_ranges = s_MATNR[] ).
lr_range->get_collected_ranges( IMPORTING et_named_ranges = DATA(lt_ranges) ).

lr_salv->set_select_options(
EXPORTING
it_ranges = lt_ranges ).
* Display ALV

lr_salv->fullscreen( )->display( ).

Output: 

Siva_sankar_225_6-1742496935611.png

 

Siva_sankar_225_7-1742496935612.png

 

Siva_sankar_225_8-1742496935613.png

Example 6: Displaying the data in zebra pattern and providing title using alv with ida 

REPORT zss_rp_alv_with_ida_zebra.

DATA: lo_salv TYPE REF TO if_salv_gui_table_ida,
lr_disp TYPE REF TO if_salv_gui_table_display_opt.

cl_salv_gui_table_ida=>create(
EXPORTING
iv_table_name = ‘MARA’
RECEIVING
ro_alv_gui_table_ida = lo_salv ).

* Get display option reference

lr_disp = lo_salv->display_options( ).

* Set the title

lr_disp->set_title( iv_title = ‘Material Master’ ).

* Set zebra pattern

lr_disp->enable_alternating_row_pattern( ).

* Display ALV

lo_salv->fullscreen( )->display( ).

 

Output: 

Siva_sankar_225_9-1742496935615.png

Example 7:Displaying the data using ALVwith ida and disabling features like sorting,filtering for a particular field  

REPORT zss_rp_alv_with_ida_sortdis.

DATA:lr_salv TYPE REF TO if_Salv_gui_table_ida,
lt_fcat TYPE REF TO if_salv_gui_field_catalog_ida.

TRY.

cl_salv_gui_table_ida=>create(
EXPORTING
iv_table_name = ‘MARA’
* io_gui_container =
* io_calc_field_handler =
RECEIVING
ro_alv_gui_table_ida = lr_salv
).
CATCH cx_salv_db_connection.
CATCH cx_salv_db_table_not_supported.
CATCH cx_salv_ida_contract_violation.

ENDTRY.

lt_fcat = lr_Salv->field_catalog( ).
lt_fcat->disable_filter( iv_field_name = ‘MTART’ ).
lt_fcat->disable_sort( iv_field_name = ‘MTART’ ).
lr_salv->fullscreen( )->display( ).

 

Output: 

Siva_sankar_225_10-1742496935616.png

 

 

As you can see below, disable the functionalities of sorting and filtering for MTART (Material Type) 

Siva_sankar_225_11-1742496935618.png

 

Siva_sankar_225_12-1742496935619.png 

For remaining fields,the features like sorting and filtering are enabled 

Siva_sankar_225_13-1742496935620.png

 

Scroll to Top