SAP List Viewer with Integrated Data Access (ALV with IDA)

In this blog, we will explain the work to be done to make it usable in business applications in the SAP ALV environment.

 SAP List Viewer with Integrated Data Access (ALV with IDA)

SAP offers a special version of the List Viewer, the SAP List Viewer with Integrated Data Access, to make it usable in business applications in the ALV environment. Using ALV with IDA makes it possible to display tables with huge amounts of data in the UI. Results of operations such as sorting, grouping or filtering are also delivered with very fast response time.

ALV with IDA gives application developers the option to use an in-memory database such as SAP HANA without having to migrate to a new programming environment. End users can continue to work on the familiar interface. The standard functions that have long been used in ALV to execute calculations are still available in ALV with IDA. From a user's perspective, it adjusts to the use of all ALV in-memory databases with well-known ALV functions. The new general programming model (CodingPushDown) is also best supported when using in-memory databases.

Isn't it exciting if I told you that you only need to write one line of code to view a database table from your system using ALV with IDA?

 cl_salv_gui_table_ida=>create( iv_table_name = 'SPFLI' )->fullscreen( )->display( ).

Let's see what we can do using ALV with IDA through an application.

First of all, we need to check system compatibility as it is not supported by all versions. Then we create the IDA object using the CL_SALV_GUI_TABLE_IDA class and determine the maximum number of rows to be displayed. This part is important since data display is limited to 2 billion cells.

 "Check DB capabilities CHECK cl_salv_gui_table_ida=>db_capabilities( )->is_table_supported( iv_ddic_table_name = 'SPFLI'). "Create IDA DATA(o_ida) = cl_salv_gui_table_ida=>create( iv_table_name = 'SPFLI' ). "Set maximum rows recommended IF cl_salv_gui_table_ida=>db_capabilities( )->is_max_rows_recommended( ).   o_ida->set_maximum_number_of_rows( iv_number_of_rows = 2000 ). ENDIF. 

Output of the program:

We will develop our application a little more by using the methods of the IF_SALV_GUI_TABLE_IDA interface.

IF_SALV_GUI_TABLE_IDA~SET_SELECT_OPTIONS

 "Define selection screen SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-001.   PARAMETERS p_carrid TYPE spfli-carrid.   SELECT-OPTIONS s_connid FOR spfli-connid. SELECTION-SCREEN END OF BLOCK b1.  DATA lr_carrid TYPE RANGE OF spfli-carrid.  IF p_carrid IS NOT INITIAL.   INSERT VALUE #( sign = 'I' option = 'EQ' low = p_carrid ) INTO TABLE lr_carrid. ENDIF.  "Range table collector DATA(o_sel) = NEW cl_salv_range_tab_collector( ). o_sel->add_ranges_for_name( iv_name = 'CARRID' it_ranges = lr_carrid[] ). o_sel->add_ranges_for_name( iv_name = 'CONNID' it_ranges = s_connid[] ).  "Get name and ranges o_sel->get_collected_ranges( IMPORTING et_named_ranges = DATA(lt_named_ranges) ).  "Set selected ranges to ALV o_ida->set_select_options( it_ranges = lt_named_ranges[] ). 

Selection screen and output of the program:

IF_SALV_GUI_TABLE_IDA~FIELD_CATALOG

DATA lt_field_names TYPE if_salv_gui_types_ida=>yts_field_name,   "Set avaible fields  lt_field_names = VALUE #(  ( CONV string('CARRID') )  ( CONV string('CONNID') )  ( CONV string('COUNTRYFR') )  ( CONV string('CITYFROM') )  ( CONV string('AIRPFROM') )  ( CONV string('COUNTRYTO') )  ( CONV string('CITYTO') )  ( CONV string('AIRPTO') )  ( CONV string('FLTIME') )  ( CONV string('DEPTIME') )  ( CONV string('ARRTIME') ) ).  o_ida->field_catalog( )->set_available_fields( its_field_names = lt_field_names ).

Using the field_catalog method, we have hidden the last four fields. Output of the program:

IF_SALV_GUI_TABLE_IDA~DEFAULT_LAYOUT

 DATA lt_sort_order  TYPE if_salv_gui_types_ida=>yt_sort_rule.  "Build sort order fields INSERT VALUE #( field_name = 'CITYFROM'                 descending = abap_true                 is_grouped = abap_true ) INTO TABLE lt_sort_order.  "Set Sort Order o_ida->default_layout( )->set_sort_order( EXPORTING it_sort_order = lt_sort_order ). 

By using the default_layout method, we have sorted and grouped the data according to the departure city area. Output of the program:

IF_SALV_GUI_TABLE_IDA~TOOLBAR

 "Toolbar   o_ida->toolbar( )-> add_button( EXPORTING iv_fcode = 'DISP' iv_icon = '@16@' iv_text = 'Detay göster' ). 

We added a "Show detail" button using the toolbar method. Output of the program:

IF_SALV_GUI_TABLE_IDA~SELECTION

 "Set selection node o_ida->selection( )->set_selection_mode( EXPORTING iv_mode = 'SINGLE' ). 

We have activated the ability to select a single row with the selection method, and finally we will show the detail information of the selected row via the event handler. Of course, again using an ALV with IDA.

 CLASS lcl_handle_action DEFINITION.   PUBLIC SECTION.     METHODS:       constructor IMPORTING io_ida TYPE REF TO if_salv_gui_table_ida,        handle_action FOR EVENT function_selected OF if_salv_gui_toolbar_ida.     DATA:       o_ida TYPE REF TO if_salv_gui_table_ida. ENDCLASS.  CLASS lcl_handle_action IMPLEMENTATION.    METHOD constructor.     o_ida = io_ida.   ENDMETHOD.   METHOD handle_action.     DATA:       ls_spfli        TYPE spfli,       lt_named_ranges TYPE if_salv_service_types=>yt_named_ranges.      IF o_ida IS BOUND.       IF o_ida->selection( )->is_row_selected( ).         "get selected row         o_ida->selection( )->get_selected_row( IMPORTING es_row = ls_spfli ).          "Check DB capabilities         CHECK cl_salv_gui_table_ida=>db_capabilities( )->is_table_supported( iv_ddic_table_name = 'SFLIGHT').          DATA(o_ida_item) = cl_salv_gui_table_ida=>create( iv_table_name = 'SFLIGHT' ).          "Set maximum rows recommended         IF cl_salv_gui_table_ida=>db_capabilities( )->is_max_rows_recommended( ).           o_ida_item->set_maximum_number_of_rows( iv_number_of_rows = 2000 ).         ENDIF.          IF o_ida_item IS BOUND.            INSERT VALUE #( name = 'CARRID'                           sign = 'I'                           option = 'EQ'                           low = ls_spfli-carrid                           ) INTO TABLE lt_named_ranges.            INSERT VALUE #( name = 'CONNID'                           sign = 'I'                           option = 'EQ'                           low = ls_spfli-connid                           ) INTO TABLE lt_named_ranges.            o_ida_item->set_select_options( it_ranges = lt_named_ranges ).           o_ida_item->fullscreen( )->display( ).          ENDIF.       ELSE.         MESSAGE 'Satır seçilmedi' TYPE 'I'.       ENDIF.     ENDIF.   ENDMETHOD.  ENDCLASS. 

DEFINITION, IMPLEMENTATION and handle_action methods belonging to the local handler class are defined and set.

 DATA(o_handler) = NEW lcl_handle_action( io_ida = o_ida ).  SET HANDLER o_handler->handle_action FOR o_ida->toolbar( ). 

When the row is selected and the show detail button is pressed, the SFLIGHT records of the airline company and connection number in the row are displayed with a new ALV.