Example of a Simple Conversion

This section contains an example of converting a simple report from the SAP List Viewer variant to the ALV with IDA variant.

Before: SAP List Viewer Variant

"a. Selection Screen
	DATA  ls_sflight TYPE  sflight.
	SELECT-OPTIONS  carrid FOR  ls_sflight- carrid.
	SELECT-OPTIONS  connid FOR  ls_sflight- connid.

START-OF-SELECTION.
"b. Data Selection [ALL ROWS –  ALL COLUMNS]  from  database  into [ITAB]
"   on the ABAP server using values of Selection Screen
	DATA  lt_sflight TYPE STANDARD TABLE OF  sflight.
	SELECT  * FROM  sflight INTO  CORRESPONDING FIELDS OF TABLE  lt_sflight
		WHERE  carrid IN  carrid
		AND  connid IN  connid.

"c. Show selected data  of [ITAB]  in ALV : here object model  in Fullscreen  Mode
	CALL METHOD  cl_salv_table=> factory( IMPORTING  r_salv_table = DATA( lo_alv_display)
		CHANGING   t_table      =  lt_sflight ).
		lo_alv_display-> display( ).

A selection screen is displayed on which the values (a) entered by the user are applied to the WHERE condition of the SQL SELECT statement (b) of the application. The data is transferred to an in internal ABAP table and passed to the ALV in the full screen version (c).

See also, example report SALV_IDA_V01_DATA_DISPLAY_GUI.

After: ALV with IDA Variant

In accordance with the comparison table (see Evaluation of the Concepts of the ALV Flavors) section (b) has to be replaced with the transfer of the input on the selection screen, and instead of the SAP List Viewer the ALV with IDA has to be used, which is waiting for the transfer of the table name (c). The following source code is used for this:
"a. Selection Screen
	DATA  ls_sflight TYPE  sflight.
	SELECT-OPTIONS  carrid FOR  ls_sflight- carrid.
	SELECT-OPTIONS  connid FOR  ls_sflight- connid.

START-OF-SELECTION.
"b. Data Selection using values of Selection Screen
"b.1. create an 'ALV with IDA' instance
	data( lo_alv_display) =  cl_salv_gui_table_ida=>create(  iv_table_name    = 'SFLIGHT' ).

"b.2. collect select options and hand over values to #ALV with IDA'
	data( lo_collector) = NEW  cl_salv_range_tab_collector( ).
	lo_collector-> add_ranges_for_name(  iv_name = 'CARRID'      it_ranges =  carrid[] ).
	lo_collector-> add_ranges_for_name(  iv_name = 'CONNID'      it_ranges =  connid[] ).
	lo_collector-> get_collected_ranges( IMPORTING  et_named_ranges = data( lt_name_range_pairs) ).
	lo_alv_display-> set_select_options(  it_ranges =  lt_name_range_pairs ).

"c. Show data in 'ALV with IDA' :
	lo_alv_display-> fullscreen( ) ->display( ).

See also, example report SALV_IDA_V01_DATA_DISPLAY_IDA.