logo

Are you need IT Support Engineer? Free Consultant

Displaying CDS Views in ALV using SALV IDA

  • By sujay
  • 06/06/2026
  • 6 Views

Displaying CDS Views in ALV using SALV IDA

Traditional ALV reports require fetching data into internal tables before displaying it. With SALV IDA (Integrated Data Access), data is read directly from the database, leveraging the power of SAP HANA for optimized performance.

In this example, we consume the CDS View ZI_SO_DETAILS and display it in a full-screen ALV without creating any internal table. This approach is ideal for large datasets and modern SAP S/4HANA developments.

 

 

*&———————————————————————*
*& Report : ZCDS_DISPLAY_IN_ALVFORM
*& Author : Prabhat Mishra
*& Purpose :
*& This report demonstrates how to display a CDS View using
*& ALV with Integrated Data Access (IDA).
*&
*& Key Features:
*& – Direct consumption of CDS Views in ALV
*& – HANA-optimized data retrieval
*& – No internal table required
*& – Built-in sorting, filtering, and aggregation
*& – Full-screen ALV display using SALV IDA framework
*&
*& CDS View Used : ZI_SO_DETAILS
*&———————————————————————*

REPORT zcds_display_in_alvform.

DATA : lo_alv TYPE REF TO if_salv_gui_table_ida,
lo_display TYPE REF TO if_salv_gui_table_display_opt,
lo_screen TYPE REF TO if_salv_gui_fullscreen_ida.

*———————————————————————*
* Create ALV IDA instance for CDS View
*———————————————————————*
TRY.
CALL METHOD cl_salv_gui_table_ida=>create_for_cds_view
EXPORTING
iv_cds_view_name=”ZI_SO_DETAILS”
RECEIVING
ro_alv_gui_table_ida = lo_alv.

CATCH cx_salv_db_connection.
CATCH cx_salv_db_table_not_supported.
CATCH cx_salv_ida_contract_violation.
CATCH cx_salv_function_not_supported.
ENDTRY.

*———————————————————————*
* Configure ALV display settings
*———————————————————————*
lo_alv->display_options(
RECEIVING ro_display_options = lo_display ).

* Set report title
lo_display->set_title(
iv_title=”Manage Sales Order” ).

* Enable zebra pattern for better readability
lo_display->enable_alternating_row_pattern( ).

* Set focus on ALV output
lo_display->set_focus( ).

*———————————————————————*
* Display CDS data in Full-Screen ALV
*———————————————————————*
lo_alv->fullscreen(
RECEIVING ro_fullscreen = lo_screen ).

lo_screen->display( ).

Source link

Leave a Reply

Your email address will not be published. Required fields are marked *