Displaying
data via ALV is very
popular among ABAP programmers. ALV or so called SAP List Viewer (in fact it
shouldn’t it be called SLV? funny though) is a user interface element for
displaying tabular data in applications. It has a format data very familiar to
SAP users. By default it offers a lot of functions like sorting, filtering, summing
data in tables etc. Moreover it can be relatively easy enhanced by custom or
application specific functions (custom button in ALV’s toolbar etc.). The ALV
is sometimes called ALV grid control as the data is displayed in the table or
grid.
There
are few of Function Modules and classes/methods that can be used by ABAP programmer
to leverage power of the ALV. In my case I was wondering what can be minimal
ABAP code that could display data from internal table of ABAP program.
I
came up with below to example program demonstrating minimal ABAP code for the ALV
grid:
REPORT zmm_minimal_alv_01.
SELECT * FROM usr02 INTO TABLE @DATA(lt_users).
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_structure_name = 'USR02'
i_grid_title = 'Title of the ALV grid:'
TABLES
t_outtab = lt_users.
In
the example a I’m passing an information about data to be displayed by a
structure with general layout specifications for list layout. In this case the
structure (USR02) is present in ABAP Dictionary. In case it would be a custom
one no persistently present in the ABAP Dictionary I would need to either pass
it via internal table (IMPORT param IS_LAYOUT) with the set of information to
be outputted or to pass it via a field catalog (IMPORT param IT_FIELDCAT) in
the form of an internal table.
By
adding import param i_grid_title a
title of the grid can be added:
REPORT zmm_minimal_alv_02.
SELECT * FROM usr02 INTO TABLE @DATA(lt_users).
CALL FUNCTION
'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_structure_name = 'USR02'
i_grid_title = 'Title
of the ALV grid:'
TABLES
t_outtab = lt_users.
By
adding below import param it is possible to display the grid in new popup
window and params can control position of that popup:
REPORT zmm_minimal_alv_03.
SELECT * FROM usr02 INTO TABLE @DATA(lt_users).
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_structure_name = 'USR02'
i_grid_title = 'Title of the ALV grid:'
i_screen_start_column = 10
i_screen_start_line = 20
i_screen_end_column = 200
i_screen_end_line = 50
TABLES
t_outtab = lt_users.
Just
to add also FM POPUP_WITH_TABLE_DISPLAY could be used to display data from the
internal table in simple way however it is not the ALV.
Source
code of the example can be found here: github.com/softy12/MINIMAL_ALV
8 comments:
Try Fucntion Module: HR_IT_SHOW_ANY_TABLE_ON_ALV
Hi Antelio,
thanks for a hint. However as I;m specializing on BW there is no such a FM in the BW systems. It looks like it is available in ECC systems as part of HR (HCM) module.
cheers
Hey Martin, i am getting an error called RAISE EXCEPTION and the Internet didnt help me find a solution. maybe you just should write a tutorial with a custom/own database table. i have Problems EVERYTIME when im trying to set up ANYTHING with ANY of these SAP delivered tables like mara etc..
im going to explode soon because of chaotic SAP
Increment: my System dont even know what @DATA means. is this Keyword necessary?
Hi abaphater, what is a precise error you getting when calling FM REUSE_ALV_GRID_DISPLAY? I believe the code must work also for custom tables...
Hi abaphater, statement @DATA is part of inline declaration (see here: https://blog.maruskin.eu/2017/01/abap-inline-declarations.html) available in NetWaever system of version 74 and higher. You can write ABAP statements more freely and easily with the inline declarations.
cheers
thanks for Reply, but i dont have the opportunity to upgrade to the newest Version, because many of our Clients are using old versions
well; I understand, you can still stick to old format of ABAP statement.
Post a Comment