Olá,
Dê uma olhada no seguinte
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 = 'UNIDADE DE MEDIDA'.
FLDCAT-COL_POS = 2.
APPEND FLDCAT TO FLDCAT.
CLEAR FLDCAT.
FLDCAT-FIELDNAME = 'GROES'.
FLDCAT-SELTEXT_M = 'TAMANHO'.
FLDCAT-COL_POS = 3.
FLDCAT-KEY = 'X'.
APPEND FLDCAT TO FLDCAT.
CLEAR FLDCAT.
FLDCAT-FIELDNAME = 'VOLUM'.
FLDCAT-SELTEXT_M = 'VOLUME'.
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 = 'EXIBIÇÃO DE GRADE'.
ENDFORM.
FORM DISPLAY_ALV_REPORT.
REPID = SY-REPID.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = REPID
I_CALLBACK_PF_STATUS_SET = 'PADRÃO'
I_CALLBACK_USER_COMMAND = 'COMANDO_DO_USUÁRIO'
I_CALLBACK_TOP_OF_PAGE = 'TOPO_DA_PÁGINA'
IS_LAYOUT = GD_LAYOUT
IT_FIELDCAT = FLDCAT[]
I_SAVE = 'X'
TABLES
T_OUTTAB = IT_MARA
-
EXCEÇÕES
-
ERRO_DE_PROGRAMA = 1
-
OUTROS = 2
.
SE SY-SUBRC <> 0.
-
MENSAGEM ID SY-MSGID TIPO SY-MSGTY NÚMERO SY-MSGNO
-
COM SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
FIMSE.
ENDFORM.
FORM DATA_RETRIEVAL.
SELECIONE MATNR MTART MEINS GROES VOLUM
INTO TABLE IT_MARA DE MARA