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?
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?
You have to do the same thing regardless of how you created lt_result. A
select *
as in your example will result in lt_result being equal to if you didDATA lt_result type table of tablename
In this case you can send in the name of the structure. But this only works if the structure type is defined in SE11, i.e. if you do a
select *
without any joins or aliases.Otherwise you have to create and send in a field catalog with all the fields in lt_result you wish to display.
Example:
The same thing applies if you use cl_gui_alv_grid.
Edit: You can fill the field-catalog dynamically like this:
Use the range table to get field-descriptions from table dd04t.
Then loop at
lo_struct->components
again, and fill the field catalog with fieldname and description. Here you can also add special logic for any given fields.Here is a basic example:
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.