SAP ABAP BASIC ALV REPORT
REPORT ZVA_MAST_ALV_REP.
TYPE-POOLS: SLIS.
TABLES: MAST.
TYPES: BEGIN OF ST_MAST,
MATNR TYPE MATNR,
WERKS TYPE WERKS_D,
STLAN TYPE STLAN,
STLNR TYPE STNUM,
END OF ST_MAST.
DATA: IT_MAST TYPE STANDARD TABLE OF ST_MAST,
WA_MAST TYPE ST_MAST,
IT_FCAT TYPE SLIS_T_FIELDCAT_ALV,
WA_FCAT TYPE SLIS_FIELDCAT_ALV.
SELECT-OPTIONS : S_MATNR FOR MAST-MATNR.
SELECT MATNR
WERKS
STLAN
STLNR FROM MAST INTO TABLE IT_MAST
WHERE MATNR IN S_MATNR.
WA_FCAT-COL_POS = '1'.
WA_FCAT-FIELDNAME = 'MATNR'.
WA_FCAT-SELTEXT_M = 'Material Number'.
APPEND WA_FCAT TO IT_FCAT.
WA_FCAT-COL_POS = '2'.
WA_FCAT-FIELDNAME = 'WERKS'.
WA_FCAT-SELTEXT_M = 'Plant'.
APPEND WA_FCAT TO IT_FCAT.
WA_FCAT-COL_POS = '3'.
WA_FCAT-FIELDNAME = 'STLAN'.
WA_FCAT-SELTEXT_M = 'BOM Usage'.
APPEND WA_FCAT TO IT_FCAT.
WA_FCAT-COL_POS = '4'.
WA_FCAT-FIELDNAME = 'STLNR'.
WA_FCAT-SELTEXT_M = 'Bill of Material'.
APPEND WA_FCAT TO IT_FCAT.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
IT_FIELDCAT = it_fcat
TABLES
t_outtab = it_mast
* EXCEPTIONS
* PROGRAM_ERROR = 1
* OTHERS = 2
.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
Serkan AKKAVAK
Computer Engineer
ABAP Developer & SAP S/4 HANA Logistics Team Lead
Contact : serkurumsal@yandex.com
Social Plugin