To develop above report, we have to use field catalog (because we have to display four fields only from MARA) and we have to pass field catalog parameter to Function Module
REUSE_ALV_GIRD_DISPLAY
.REPORT ZAVI_ALV_FCAT. TABLES : MARA. TYPE-POOLS SLIS . TYPES : BEGIN OF TY_MARA, "User defined internal table type MATNR TYPE MARA-MATNR, MTART TYPE MARA-MTART, MBRSH TYPE MARA-MBRSH, MEINS TYPE MARA-MEINS, END OF TY_MARA. DATA : IT_MARA TYPE TABLE OF TY_MARA . DATA : WA_MARA TYPE TY_MARA . DATA : IT_FCAT TYPE SLIS_T_FIELDCAT_ALV . DATA : WA_FCAT LIKE LINE OF IT_FCAT . SELECT-OPTIONS: S_MATNR FOR MARA-MATNR. START-OF-SELECTION . PERFORM GET_DATA . PERFORM CREATE_FCAT. END-OF-SELECTION . PERFORM DISP_ALV . *&---------------------------------------------------------------------* *& Form GET_DATA *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM GET_DATA . SELECT MATNR MTART MBRSH MEINS FROM MARA INTO TABLE IT_MARA WHERE MATNR IN S_MATNR. . ENDFORM. " GET_DATA *&---------------------------------------------------------------------* *& Form DISP_ALV *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM DISP_ALV . CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' EXPORTING I_CALLBACK_PROGRAM = SY-REPID IT_FIELDCAT = IT_FCAT "PASS FIELD CATALOG TO ALV TABLES T_OUTTAB = IT_MARA. ENDFORM. " DISP_ALV *&---------------------------------------------------------------------* *& Form CREATE_FCAT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM CREATE_FCAT . WA_FCAT-COL_POS = '1' . WA_FCAT-FIELDNAME = 'MATNR' . WA_FCAT-TABNAME = 'IT_MARA' . WA_FCAT-SELTEXT_M = 'MATERIALNO' . WA_FCAT-KEY = 'X' . APPEND WA_FCAT TO IT_FCAT . CLEAR WA_FCAT . WA_FCAT-COL_POS = '2' . WA_FCAT-FIELDNAME = 'MTART' . WA_FCAT-TABNAME = 'IT_MARA' . WA_FCAT-SELTEXT_M = 'MATERIALTYPE' . * WA_FCAT-NO_OUT = 'X' . WA_FCAT-HOTSPOT = 'X' . APPEND WA_FCAT TO IT_FCAT . CLEAR WA_FCAT . WA_FCAT-COL_POS = '3' . WA_FCAT-FIELDNAME = 'MBRSH' . WA_FCAT-REF_FIELDNAME = 'MBRSH' . WA_FCAT-REF_TABNAME = 'MARA' . * WA_FCAT-TABNAME = 'IT_MARA' . * WA_FCAT-SELTEXT_M = 'INDSECTOR' . * WA_FCAT-EDIT = 'X' . APPEND WA_FCAT TO IT_FCAT . CLEAR WA_FCAT . WA_FCAT-COL_POS = '4' . WA_FCAT-FIELDNAME = 'MEINS' . WA_FCAT-TABNAME = 'IT_MARA' . WA_FCAT-SELTEXT_M = 'MAT.UNITS' . WA_FCAT-EMPHASIZE = 'C610'. APPEND WA_FCAT TO IT_FCAT . CLEAR WA_FCAT . ENDFORM. " CREATE_FCAT
Serkan AKKAVAK Computer Engineer ABAP Developer & SAP S/4 HANA Logistics Team Lead Contact : serkurumsal@yandex.com
Social Plugin