Olá,
Veja este código.
REPORT ZBHALV_LIST1.
TABLES:MARA.
SELECT-OPTIONS: MATNR FOR MARA-MATNR.
DATA:BEGIN OF ITAB OCCURS 0,
MATNR LIKE MARA-MATNR,
ERSDA LIKE MARA-ERSDA,
MTART LIKE MARA-MTART,
MBRSH LIKE MARA-MBRSH,
END OF ITAB.
SELECT * FROM MARA INTO CORRESPONDING FIELDS OF TABLE ITAB WHERE MATNR
IN MATNR.
TYPE-POOLS SLIS.
DATA:FCAT TYPE slis_t_fieldcat_alv.
DATA:LAYOUT TYPE slis_layout_alv.
DATA:EVE TYPE slis_t_event WITH HEADER LINE.
DATA:HEAD TYPE slis_t_listheader WITH HEADER LINE.
DATA:SORT TYPE slis_t_sortinfo_alv WITH HEADER LINE.
SORT-UP = 'X'.
SORT-SPOS = 1.
SORT-FIELDNAME = 'ERSDA'.
SORT-tabname = 'MARA'.
APPEND SORT.
SORT-SPOS = 2.
SORT-FIELDNAME = 'MTART'.
SORT-tabname = 'MARA'.
APPEND SORT.
EVE-NAME = 'TOP_OF_PAGE'.
EVE-FORM = 'TOPOFPAGE'.
APPEND EVE.
EVE-NAME = 'TOP_OF_LIST'.
EVE-FORM = 'TOPOFLIST'.
APPEND EVE.
EVE-NAME = 'END_OF_LIST'.
EVE-FORM = 'ENDOFLIST'.
APPEND EVE.
LAYOUT-ZEBRA = 'X'.
LAYOUT-no_hline = 'X'.
LAYOUT-NO_VLINE = 'X'.
LAYOUT-window_titlebar = 'DETALHES DO MATERIAL'.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = SY-REPID
I_INTERNAL_TABNAME = 'ITAB'
-
I_STRUCTURE_NAME =
-
I_CLIENT_NEVER_DISPLAY = 'X'
I_INCLNAME = SY-REPID
-
I_BYPASSING_BUFFER =
-
I_BUFFER_ACTIVE =
CHANGING
CT_FIELDCAT = FCAT
-
EXCEPTIONS
-
INCONSISTENT_INTERFACE = 1
-
PROGRAM_ERROR = 2
-
OTHERS = 3
.
IF SY-SUBRC <> 0.
-
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
-
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
-
I_INTERFACE_CHECK = ' '
-
I_BYPASSING_BUFFER =
-
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = SY-REPID
-
I_CALLBACK_PF_STATUS_SET =
-
I_CALLBACK_USER_COMMAND =
-