ALV with IDA

Estimated read time 20 min read

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

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 Code Push Down Direct Database Access Automatic performance optimization Dynamic Data operations like filtering and Sorting Database level aggregation and calculations Disabling features like sorting and filtering. 

 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 

Output:

 Example2: Displaying the specific number of records using Alv with Ida. 
In this Example we are displaying 10records using Alv with Ida.


Output:

 Example3: Displaying specific fields data only using Alv with Ida. 
In this Example we are displaying specific fields Data using Alv with Ida.
We are deleting the data of fields MBRSH, MTART, ERDAT, ERNAM, ERSDA, Created_at_time

*&———————————————————————*
*& Report ztk_alv_restricting_fields
*&———————————————————————*
*&
*&———————————————————————*
REPORT ztk_alv_restricting_fields.

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’
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
).
CATCH cx_salv_param_out_of_bounds.
ENDTRY.

* Display alv

lr_salv->fullscreen( )->display( ).
*CATCH cx_salv_ida_contract_violation.

Output

 Example: Displaying the data based on parameter using Alv with Ida.

In This Example we are Displaying the Data based on Parameter using Alv with Ida.

*&———————————————————————*
*& Report ztk_alv_parameter
*&———————————————————————*
*&
*&———————————————————————*
REPORT ztk_alv_parameter.

PARAMETERS: p_MTART TYPE MARA-MTART.
DATA: lr_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.

CL_SALV_GUI_TABLE_IDA=>create(
EXPORTING
iv_table_name = ‘MARA’
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.

LR_COND_FACT = LR_sALV->condition_factory( ).
LR_COND = LR_COND_FACT->equals(
name = ‘MTART’
value = P_MTART ).
* CATCH cx_salv_ida_unknown_name.
LR_sALV->set_select_options(
EXPORTING
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.

LR_sALV->fullscreen( )->display( ).

*CATCH cx_salv_ida_contract_violation.

Output

Example: Displaying the data based on select-options using Alv with Ida .

*&———————————————————————*
*& Report ztk_alv_selectopt
*&———————————————————————*
*&
*&———————————————————————*
REPORT ztk_alv_selectopt.

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

 

Example 6: Displaying the data in zebra pattern and providing title using Alv with Ida.

*&———————————————————————*
*& Report ztk_alv_title_zebrapattern
*&———————————————————————*
*&
*&———————————————————————*
REPORT ztk_alv_title_zebrapattern.

DATA: lr_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 = lr_salv ).

* Get display option reference
lr_disp = lr_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
lr_salv->fullscreen( )->display( ).

Output:

Example: Displaying the data using ALV with Ida and disabling features like sorting, filtering for a particular field   

*&———————————————————————*
*& Report ztk_alv_disable_arithmatic
*&———————————————————————*
*&
*&———————————————————————*
REPORT ztk_alv_disable_arithmatic.

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’
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’ ).

* CATCH cx_salv_ida_unknown_name.
* CATCH cx_salv_call_after_1st_display.
* CATCH cx_salv_ida_unknown_name.
* CATCH cx_salv_call_after_1st_display.

lr_salv->fullscreen( )->display( ).
* CATCH cx_salv_ida_contract_violation.

Output

Here i have disabled sorting and filtering for material type (MTART).

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

Conclusion:

In this Blog, we  explored how to display the data using ALV with IDA (Integrated Data Access) 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 explored how to disable filtering and sorting for a particular field in ALV,
how to display data using ALV with IDA in zebra pattern, Displayed Data with parameters and select options, displaying specific number of records, Displaying specific fields Data.

Thanks.

 

​ Mastering SAP ALV with IDA: Applying Record and Column Limits, Select Options, and Disabling Features 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 Code Push Down Direct Database Access Automatic performance optimization Dynamic Data operations like filtering and Sorting Database level aggregation and calculations Disabling features like sorting and filtering.  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 Output: Example2: Displaying the specific number of records using Alv with Ida. In this Example we are displaying 10records using Alv with Ida.Output: Example3: Displaying specific fields data only using Alv with Ida. In this Example we are displaying specific fields Data using Alv with Ida.We are deleting the data of fields MBRSH, MTART, ERDAT, ERNAM, ERSDA, Created_at_time*&———————————————————————*
*& Report ztk_alv_restricting_fields
*&———————————————————————*
*&
*&———————————————————————*
REPORT ztk_alv_restricting_fields.

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’
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
).
CATCH cx_salv_param_out_of_bounds.
ENDTRY.

* Display alv

lr_salv->fullscreen( )->display( ).
*CATCH cx_salv_ida_contract_violation. Output Example: Displaying the data based on parameter using Alv with Ida.In This Example we are Displaying the Data based on Parameter using Alv with Ida.*&———————————————————————*
*& Report ztk_alv_parameter
*&———————————————————————*
*&
*&———————————————————————*
REPORT ztk_alv_parameter.

PARAMETERS: p_MTART TYPE MARA-MTART.
DATA: lr_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.

CL_SALV_GUI_TABLE_IDA=>create(
EXPORTING
iv_table_name = ‘MARA’
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.

LR_COND_FACT = LR_sALV->condition_factory( ).
LR_COND = LR_COND_FACT->equals(
name = ‘MTART’
value = P_MTART ).
* CATCH cx_salv_ida_unknown_name.
LR_sALV->set_select_options(
EXPORTING
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.

LR_sALV->fullscreen( )->display( ).

*CATCH cx_salv_ida_contract_violation. OutputExample: Displaying the data based on select-options using Alv with Ida .*&———————————————————————*
*& Report ztk_alv_selectopt
*&———————————————————————*
*&
*&———————————————————————*
REPORT ztk_alv_selectopt.

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 Example 6: Displaying the data in zebra pattern and providing title using Alv with Ida.*&———————————————————————*
*& Report ztk_alv_title_zebrapattern
*&———————————————————————*
*&
*&———————————————————————*
REPORT ztk_alv_title_zebrapattern.

DATA: lr_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 = lr_salv ).

* Get display option reference
lr_disp = lr_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
lr_salv->fullscreen( )->display( ). Output:Example: Displaying the data using ALV with Ida and disabling features like sorting, filtering for a particular field   *&———————————————————————*
*& Report ztk_alv_disable_arithmatic
*&———————————————————————*
*&
*&———————————————————————*
REPORT ztk_alv_disable_arithmatic.

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’
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’ ).

* CATCH cx_salv_ida_unknown_name.
* CATCH cx_salv_call_after_1st_display.
* CATCH cx_salv_ida_unknown_name.
* CATCH cx_salv_call_after_1st_display.

lr_salv->fullscreen( )->display( ).
* CATCH cx_salv_ida_contract_violation. OutputHere i have disabled sorting and filtering for material type (MTART).For remaining fields,the features like sorting and filtering are enabled Conclusion:In this Blog, we  explored how to display the data using ALV with IDA (Integrated Data Access) 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 explored how to disable filtering and sorting for a particular field in ALV,how to display data using ALV with IDA in zebra pattern, Displayed Data with parameters and select options, displaying specific number of records, Displaying specific fields Data.Thanks.   Read More Technology Blog Posts by Members articles 

#SAP

#SAPTechnologyblog

You May Also Like

More From Author