Search code examples
abapalv

ALV Grid for In-Line Declaration


How do you display an in-line declared data type in an ALV grid?

eg:

SELECT *
INTO TABLE @DATA(lt_result)
FROM table.

How can the lt_result be displayed in an ALV grid?


Solution

  • Here is a basic example:

    DATA: alv TYPE REF TO cl_salv_table.   
    
    SELECT *
    INTO TABLE @DATA(lt_result)
    FROM table.
    
    cl_salv_table=>factory( IMPORTING r_salv_table = alv
                            CHANGING  t_table      = lt_result ).
    
    alv->display( ).
    

    You can find other examples using the SALV Object Model in package SALV_OM_OBJECTS.

    This is a more modern approach than using 'REUSE_ALV_GRID_DISPLAY' and you will not need to define a field catalog.