Hola,
Echa un vistazo a lo siguiente
TYPE-POOLS: SLIS.
TYPES: BEGIN OF I_MARA,
MATNR LIKE MARA-MATNR,
MTART LIKE MARA-MTART,
MEINS LIKE MARA-MEINS,
GROES LIKE MARA-GROES,
VOLUM LIKE MARA-VOLUM,
END OF I_MARA.
DATA: IT_MARA TYPE STANDARD TABLE OF I_MARA INITIAL SIZE 0.
DATA: FLDCAT TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE,
REPID TYPE SY-REPID,
GD_LAYOUT TYPE SLIS_LAYOUT_ALV.
START-OF-SELECTION.
PERFORM DATA_RETRIEVAL.
PERFORM BLD_FLDCAT.
PERFORM BLD_LAYOUT.
PERFORM DISPLAY_ALV_REPORT.
FORM BLD_FLDCAT.
FLDCAT-FIELDNAME = 'MATNR'.
FLDCAT-SELTEXT_M = 'NÚMERO DE MATERIAL'.
FLDCAT-COL_POS = 0.
FLDCAT-KEY = 'X'.
APPEND FLDCAT TO FLDCAT.
CLEAR FLDCAT.
FLDCAT-FIELDNAME = 'MTART'.
FLDCAT-SELTEXT_M = 'TIPO DE MATERIAL'.
FLDCAT-COL_POS = 1.
FLDCAT-KEY = 'X'.
APPEND FLDCAT TO FLDCAT.
CLEAR FLDCAT.
FLDCAT-FIELDNAME = 'MEINS'.
FLDCAT-SELTEXT_M = 'UNIDAD DE MEDIDA'.
FLDCAT-COL_POS = 2.
APPEND FLDCAT TO FLDCAT.
CLEAR FLDCAT.
FLDCAT-FIELDNAME = 'GROES'.
FLDCAT-SELTEXT_M = 'TAMAÑO'.
FLDCAT-COL_POS = 3.
FLDCAT-KEY = 'X'.
APPEND FLDCAT TO FLDCAT.
CLEAR FLDCAT.
FLDCAT-FIELDNAME = 'VOLUM'.
FLDCAT-SELTEXT_M = 'VOLUMEN'.
FLDCAT-COL_POS = 4.
APPEND FLDCAT TO FLDCAT.
CLEAR FLDCAT.
ENDFORM.
FORM BLD_LAYOUT.
GD_LAYOUT-NO_INPUT = 'X'.
GD_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
GD_LAYOUT-ZEBRA = 'X'.
GD_LAYOUT-WINDOW_TITLEBAR = 'GRID DISPLAY'.
ENDFORM.
FORM DISPLAY_ALV_REPORT.
REPID = SY-REPID.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = REPID
I_CALLBACK_PF_STATUS_SET = 'STANDARD'
I_CALLBACK_USER_COMMAND = 'USER-COMMAND'
I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'
IS_LAYOUT = GD_LAYOUT
IT_FIELDCAT = FLDCAT[]
I_SAVE = 'X'
TABLES
T_OUTTAB = IT_MARA
-
EXCEPTIONS
-
PROGRAM_ERROR = 1
-
OTHERS = 2
.
IF SY-SUBRC <> 0.
-
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
-
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM.
FORM DATA_RETRIEVAL.
SELECT MATNR MTART MEINS GROES VOLUM
INTO TABLE IT_MARA FROM MARA