Saturday, August 19, 2017

Use of ALV To Calculate TOTAL of a particular field and setting the the total text by the layout property


REPORT  ZAVI_FEVER2.

TYPE-POOLSSLIS.

DATAIT_SPFLI TYPE TABLE OF SPFLI,
      WA_SPFLI TYPE SPFLI.
DATAIT_FCAT TYPE  SLIS_T_FIELDCAT_ALV,
      WA_FCAT TYPE  SLIS_FIELDCAT_ALV.

DATAWA_LAYOUT TYPE SLIS_LAYOUT_ALV.
SELECT FROM SPFLI INTO TABLE IT_SPFLI .



  CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
   EXPORTING
     I_PROGRAM_NAME               'SY-REPID'
*     I_INTERNAL_TABNAME           =
     I_STRUCTURE_NAME             'SPFLI'
*     I_CLIENT_NEVER_DISPLAY       = 'X'
*     I_INCLNAME                   =
*     I_BYPASSING_BUFFER           =
*     I_BUFFER_ACTIVE              =
    CHANGING
      ct_fieldcat                  IT_FCAT
   EXCEPTIONS
     INCONSISTENT_INTERFACE       1
     PROGRAM_ERROR                2
     OTHERS                       3
            .
  IF sy-subrc <> 0.
* Implement suitable error handling here
  ENDIF.


LOOP AT IT_FCAT INTO WA_FCAT.
  IF WA_FCAT-FIELDNAME 'DISTANCE'.
    WA_FCAT-DO_SUM 'X'.
    MODIFY IT_FCAT FROM WA_FCAT TRANSPORTING DO_SUM.
    ENDIF.
    ENDLOOP.

    WA_LAYOUT-TOTALS_TEXT 'TOTAL'.

 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        = ' '
    I_STRUCTURE_NAME               'SPFLI'
    IS_LAYOUT                      WA_LAYOUT
    IT_FIELDCAT                    IT_FCAT
*    IT_EXCLUDING                   =
*    IT_SPECIAL_GROUPS              =
*    IT_SORT                        =
*    IT_FILTER                      =
*    IS_SEL_HIDE                    =
*    I_DEFAULT                      = 'X'
*    I_SAVE                         = ' '
*    IS_VARIANT                     =
*    IT_EVENTS                      =
*    IT_EVENT_EXIT                  =
*    IS_PRINT                       =
*    IS_REPREP_ID                   =
*    I_SCREEN_START_COLUMN          = 0
*    I_SCREEN_START_LINE            = 0
*    I_SCREEN_END_COLUMN            = 0
*    I_SCREEN_END_LINE              = 0
*    IR_SALV_LIST_ADAPTER           =
*    IT_EXCEPT_QINFO                =
*    I_SUPPRESS_EMPTY_DATA          = ABAP_FALSE
*  IMPORTING
*    E_EXIT_CAUSED_BY_CALLER        =
*    ES_EXIT_CAUSED_BY_USER         =
   TABLES
     t_outtab                       IT_SPFLI
  EXCEPTIONS
    PROGRAM_ERROR                  1
    OTHERS                         2
           .
 IF sy-subrc <> 0.
* Implement suitable error handling here
 ENDIF.

Use of ALV LAYOUT- Displaying multiple ALV output by setting the layout property

This post shows how to displayed more than one list alv ( not blocked alv) in one program output by setting the ALV layout property.

REPORT  ZAVI_FEVER1.

TYPE-POOLSSLIS.
TYPESBEGIN OF ST_MAKT,
       MATNR TYPE MATNR,
       SPRAS  TYPE SPRAS,
       MAKTX  TYPE MAKTX,
       END OF ST_MAKT.

DATAIT_MAKT TYPE STANDARD TABLE OF ST_MAKT,
      WA_MAKT TYPE ST_MAKT.

TYPESBEGIN OF ST_FINAL,
        CHECK(1),
        MATNR TYPE MATNR,
        SPRAS  TYPE SPRAS,
        MAKTX  TYPE MAKTX,
        END OF ST_FINAL.

DATAIT_FINAL TYPE STANDARD TABLE OF ST_FINAL,
      WA_FINAL TYPE ST_FINAL.

DATAIT_FCAT TYPE SLIS_T_FIELDCAT_ALV,
      WA_FCAT TYPE SLIS_FIELDCAT_ALV.

DATAWA_LAYOUT TYPE SLIS_LAYOUT_ALV.


START-OF-SELECTION.

       SELECT MATNR
              SPRAS
              MAKTX
              FROM MAKT INTO TABLE IT_MAKT WHERE SPRAS 'SY-LANGU'.

       IF SY-SUBRC 0.
         SORT IT_MAKT BY MATNR.
       ENDIF.

END-OF-SELECTION.

       LOOP AT IT_MAKT INTO WA_MAKT.
         WA_FINAL-MATNR WA_MAKT-MATNR.
         WA_FINAL-SPRAS WA_MAKT-SPRAS.
         WA_FINAL-MAKTX WA_MAKT-MAKTX.
         APPEND WA_FINAL TO IT_FINAL.
         CLEARWA_FINAL,WA_MAKT.
         ENDLOOP.


WA_LAYOUT-list_append 'X'.
WA_LAYOUT-f2code '&ETA'.
WA_FCAT-COL_POS '1'.
WA_FCAT-TABNAME 'IT_FINAL'.
WA_FCAT-FIELDNAME 'CHECK'.
WA_FCAT-CHECKBOX 'X'.
WA_FCAT-EDIT 'X'.
WA_FCAT-SELTEXT_M 'CHECKBOX'.
WA_FCAT-INPUT 'X'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.

*WA_LAYOUT-LIGHTS_FIELDNAME = 'LIGHT'.
WA_layout-window_titlebar 'ZAVI_TITLE CHANGE USING PROGRAM'.
WA_FCAT-COL_POS '2'.
WA_FCAT-TABNAME 'IT_FINAL'.
WA_FCAT-FIELDNAME 'MATNR'.
WA_FCAT-INPUT 'X'.
WA_FCAT-SELTEXT_M 'MATERIAL NUMBER'.
WA_LAYOUT-ZEBRA 'X'.
*WA_LAYOUT-NO_COLHEAD = 'X'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.

WA_LAYOUT-DETAIL_POPUP 'X'.
WA_FCAT-COL_POS '3'.
WA_FCAT-TABNAME 'IT_FINAL'.
WA_FCAT-FIELDNAME 'SPRAS'.
WA_FCAT-INPUT 'X'.
WA_FCAT-SELTEXT_M 'LANGUAGE'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.

WA_FCAT-COL_POS '4'.
WA_FCAT-TABNAME 'IT_FINAL'.
WA_FCAT-FIELDNAME 'MAKTX'.

WA_FCAT-SELTEXT_M 'MTERIAL DESCRIPTION'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.

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        = ' '
*   I_STRUCTURE_NAME               =
   IS_LAYOUT                      WA_LAYOUT
   IT_FIELDCAT                    IT_FCAT
*   IT_EXCLUDING                   =
*   IT_SPECIAL_GROUPS              =
*   IT_SORT                        =
*   IT_FILTER                      =
*   IS_SEL_HIDE                    =
*   I_DEFAULT                      = 'X'
*   I_SAVE                         = ' '
*   IS_VARIANT                     =
*   IT_EVENTS                      =
*   IT_EVENT_EXIT                  =
*   IS_PRINT                       =
*   IS_REPREP_ID                   =
*   I_SCREEN_START_COLUMN          = 0
*   I_SCREEN_START_LINE            = 0
*   I_SCREEN_END_COLUMN            = 0
*   I_SCREEN_END_LINE              = 0
*   IR_SALV_LIST_ADAPTER           =
*   IT_EXCEPT_QINFO                =
*   I_SUPPRESS_EMPTY_DATA          = ABAP_FALSE
* IMPORTING
*   E_EXIT_CAUSED_BY_CALLER        =
*   ES_EXIT_CAUSED_BY_USER         =
  TABLES
    t_outtab                       IT_FINAL
 EXCEPTIONS
   PROGRAM_ERROR                  1
   OTHERS                         2
          .
IF sy-subrc <> 0.
* Implement suitable error handling here
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        = ' '
*   I_STRUCTURE_NAME               =
   IS_LAYOUT                      WA_LAYOUT
   IT_FIELDCAT                    IT_FCAT
*   IT_EXCLUDING                   =
*   IT_SPECIAL_GROUPS              =
*   IT_SORT                        =
*   IT_FILTER                      =
*   IS_SEL_HIDE                    =
*   I_DEFAULT                      = 'X'
*   I_SAVE                         = ' '
*   IS_VARIANT                     =
*   IT_EVENTS                      =
*   IT_EVENT_EXIT                  =
*   IS_PRINT                       =
*   IS_REPREP_ID                   =
*   I_SCREEN_START_COLUMN          = 0
*   I_SCREEN_START_LINE            = 0
*   I_SCREEN_END_COLUMN            = 0
*   I_SCREEN_END_LINE              = 0
*   IR_SALV_LIST_ADAPTER           =
*   IT_EXCEPT_QINFO                =
*   I_SUPPRESS_EMPTY_DATA          = ABAP_FALSE
* IMPORTING
*   E_EXIT_CAUSED_BY_CALLER        =
*   ES_EXIT_CAUSED_BY_USER         =
  TABLES
    t_outtab                       IT_FINAL
 EXCEPTIONS
   PROGRAM_ERROR                  1
   OTHERS                         2
          .
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.

Use of ALV LAYOUT- Setting the program title using alv layout property

This post shows how to set the program title by the alv layout property set.

REPORT  ZAVI_FEVER1.

TYPE-POOLSSLIS.
TYPESBEGIN OF ST_MAKT,
       MATNR TYPE MATNR,
       SPRAS  TYPE SPRAS,
       MAKTX  TYPE MAKTX,
       END OF ST_MAKT.

DATAIT_MAKT TYPE STANDARD TABLE OF ST_MAKT,
      WA_MAKT TYPE ST_MAKT.

TYPESBEGIN OF ST_FINAL,
        CHECK(1),
        MATNR TYPE MATNR,
        SPRAS  TYPE SPRAS,
        MAKTX  TYPE MAKTX,
        END OF ST_FINAL.

DATAIT_FINAL TYPE STANDARD TABLE OF ST_FINAL,
      WA_FINAL TYPE ST_FINAL.

DATAIT_FCAT TYPE SLIS_T_FIELDCAT_ALV,
      WA_FCAT TYPE SLIS_FIELDCAT_ALV.

DATAWA_LAYOUT TYPE SLIS_LAYOUT_ALV.



START-OF-SELECTION.

       SELECT MATNR
              SPRAS
              MAKTX
              FROM MAKT INTO TABLE IT_MAKT WHERE SPRAS 'SY-LANGU'.

       IF SY-SUBRC 0.
         SORT IT_MAKT BY MATNR.
       ENDIF.

END-OF-SELECTION.

       LOOP AT IT_MAKT INTO WA_MAKT.
         WA_FINAL-MATNR WA_MAKT-MATNR.
         WA_FINAL-SPRAS WA_MAKT-SPRAS.
         WA_FINAL-MAKTX WA_MAKT-MAKTX.
         APPEND WA_FINAL TO IT_FINAL.
         CLEARWA_FINAL,WA_MAKT.
         ENDLOOP.


WA_LAYOUT-f2code '&ETA'.
WA_FCAT-COL_POS '1'.
WA_FCAT-TABNAME 'IT_FINAL'.
WA_FCAT-FIELDNAME 'CHECK'.
WA_FCAT-CHECKBOX 'X'.
WA_FCAT-EDIT 'X'.
WA_FCAT-SELTEXT_M 'CHECKBOX'.
WA_FCAT-INPUT 'X'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.

*WA_LAYOUT-LIGHTS_FIELDNAME = 'LIGHT'.
WA_layout-window_titlebar 'ZAVI_TITLE CHANGE USING PROGRAM'.
WA_FCAT-COL_POS '2'.
WA_FCAT-TABNAME 'IT_FINAL'.
WA_FCAT-FIELDNAME 'MATNR'.
WA_FCAT-INPUT 'X'.
WA_FCAT-SELTEXT_M 'MATERIAL NUMBER'.
WA_LAYOUT-ZEBRA 'X'.
*WA_LAYOUT-NO_COLHEAD = 'X'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.

WA_LAYOUT-DETAIL_POPUP 'X'.
WA_FCAT-COL_POS '3'.
WA_FCAT-TABNAME 'IT_FINAL'.
WA_FCAT-FIELDNAME 'SPRAS'.
WA_FCAT-INPUT 'X'.
WA_FCAT-SELTEXT_M 'LANGUAGE'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.

WA_FCAT-COL_POS '4'.
WA_FCAT-TABNAME 'IT_FINAL'.
WA_FCAT-FIELDNAME 'MAKTX'.

WA_FCAT-SELTEXT_M 'MTERIAL DESCRIPTION'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.

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        = ' '
*   I_STRUCTURE_NAME               =
   IS_LAYOUT                      WA_LAYOUT
   IT_FIELDCAT                    IT_FCAT
*   IT_EXCLUDING                   =
*   IT_SPECIAL_GROUPS              =
*   IT_SORT                        =
*   IT_FILTER                      =
*   IS_SEL_HIDE                    =
*   I_DEFAULT                      = 'X'
*   I_SAVE                         = ' '
*   IS_VARIANT                     =
*   IT_EVENTS                      =
*   IT_EVENT_EXIT                  =
*   IS_PRINT                       =
*   IS_REPREP_ID                   =
*   I_SCREEN_START_COLUMN          = 0
*   I_SCREEN_START_LINE            = 0
*   I_SCREEN_END_COLUMN            = 0
*   I_SCREEN_END_LINE              = 0
*   IR_SALV_LIST_ADAPTER           =
*   IT_EXCEPT_QINFO                =
*   I_SUPPRESS_EMPTY_DATA          = ABAP_FALSE
* IMPORTING
*   E_EXIT_CAUSED_BY_CALLER        =
*   ES_EXIT_CAUSED_BY_USER         =
  TABLES
    t_outtab                       IT_FINAL
 EXCEPTIONS
   PROGRAM_ERROR                  1
   OTHERS                         2
          .
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.

Use of ALV Layout- Displaying detailed information in a pop up screen

The ALV layout feature in SAP ABAP is used to personalize the appearance of ALV reports. It offers various functions that can be incorporated to enhance the functionality of the reports. One such function is displaying detailed information in a pop-up screen.

To use this function, the pop-up screen must be defined in the ABAP Dictionary by creating a screen with relevant fields and screen elements. A custom field can then be added to the ALV layout using the 'Edit' function, and set to trigger the pop-up screen when clicked. This custom field can be labeled, such as 'Details', to indicate that it is intended to display additional information.

Once the 'Details' field is clicked, the pop-up screen is displayed with the required detailed information. The data displayed in the pop-up screen depends on the program logic and varies based on the data being presented in the ALV report.


Sample Program for Reference - 

REPORT  ZAVI_FEVER1.

TYPE-POOLS: SLIS.
TYPES: BEGIN OF ST_MAKT,
       MATNR TYPE MATNR,
       SPRAS  TYPE SPRAS,
       MAKTX  TYPE MAKTX,
       END OF ST_MAKT.

DATA: IT_MAKT TYPE STANDARD TABLE OF ST_MAKT,
      WA_MAKT TYPE ST_MAKT.

TYPES: BEGIN OF ST_FINAL,
        LIGHT(1),
        CHECK(1),
        MATNR TYPE MATNR,
        SPRAS  TYPE SPRAS,
        MAKTX  TYPE MAKTX,
        END OF ST_FINAL.

DATA: IT_FINAL TYPE STANDARD TABLE OF ST_FINAL,
      WA_FINAL TYPE ST_FINAL.

DATA: IT_FCAT TYPE SLIS_T_FIELDCAT_ALV,
      WA_FCAT TYPE SLIS_FIELDCAT_ALV.

DATA: WA_LAYOUT TYPE SLIS_LAYOUT_ALV.

START-OF-SELECTION.
       SELECT MATNR
              SPRAS
              MAKTX
              FROM MAKT INTO TABLE IT_MAKT WHERE SPRAS = SY-LANGU.

       IF SY-SUBRC = 0.
         SORT IT_MAKT BY MATNR.
       ENDIF.

END-OF-SELECTION.

       LOOP AT IT_MAKT INTO WA_MAKT.
         WA_FINAL-MATNR = WA_MAKT-MATNR.
         WA_FINAL-SPRAS = WA_MAKT-SPRAS.
         WA_FINAL-MAKTX = WA_MAKT-MAKTX.
         APPEND WA_FINAL TO IT_FINAL.
         CLEAR: WA_FINAL,WA_MAKT.
         ENDLOOP.


WA_FCAT-COL_POS = '1'.
WA_FCAT-TABNAME = 'IT_FINAL'.
WA_FCAT-FIELDNAME = 'CHECK'.
WA_FCAT-CHECKBOX = 'X'.
WA_FCAT-EDIT = 'X'.
WA_FCAT-SELTEXT_M = 'CHECKBOX'.
WA_FCAT-INPUT = 'X'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.

*WA_LAYOUT-LIGHTS_FIELDNAME = 'LIGHT'.
WA_FCAT-COL_POS = '2'.
WA_FCAT-TABNAME = 'IT_FINAL'.
WA_FCAT-FIELDNAME = 'MATNR'.
WA_FCAT-INPUT = 'X'.
WA_FCAT-SELTEXT_M = 'MATERIAL NUMBER'.
WA_LAYOUT-ZEBRA = 'X'.
*WA_LAYOUT-NO_COLHEAD = 'X'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.

WA_LAYOUT-DETAIL_POPUP = 'X'.
WA_FCAT-COL_POS = '3'.
WA_FCAT-TABNAME = 'IT_FINAL'.
WA_FCAT-FIELDNAME = 'SPRAS'.
WA_FCAT-INPUT = 'X'.
WA_FCAT-SELTEXT_M = 'LANGUAGE'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.

WA_FCAT-COL_POS = '4'.
WA_FCAT-TABNAME = 'IT_FINAL'.
WA_FCAT-FIELDNAME = 'MAKTX'.

WA_FCAT-SELTEXT_M = 'MTERIAL DESCRIPTION'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.

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        = ' '
*   I_STRUCTURE_NAME               =
   IS_LAYOUT                      = WA_LAYOUT
   IT_FIELDCAT                    = IT_FCAT
*   IT_EXCLUDING                   =
*   IT_SPECIAL_GROUPS              =
*   IT_SORT                        =
*   IT_FILTER                      =
*   IS_SEL_HIDE                    =
*   I_DEFAULT                      = 'X'
*   I_SAVE                         = ' '
*   IS_VARIANT                     =
*   IT_EVENTS                      =
*   IT_EVENT_EXIT                  =
*   IS_PRINT                       =
*   IS_REPREP_ID                   =
*   I_SCREEN_START_COLUMN          = 0
*   I_SCREEN_START_LINE            = 0
*   I_SCREEN_END_COLUMN            = 0
*   I_SCREEN_END_LINE              = 0
*   IR_SALV_LIST_ADAPTER           =
*   IT_EXCEPT_QINFO                =
*   I_SUPPRESS_EMPTY_DATA          = ABAP_FALSE
* IMPORTING
*   E_EXIT_CAUSED_BY_CALLER        =
*   ES_EXIT_CAUSED_BY_USER         =
  TABLES
    t_outtab                       = IT_FINAL
 EXCEPTIONS
   PROGRAM_ERROR                  = 1
   OTHERS                         = 2
          .
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.




In conclusion, the ALV layout function in SAP ABAP is an effective tool for personalizing and customizing ALV reports. By incorporating a pop-up screen to display detailed information, users can improve the functionality and user experience of their reports, leading to more efficient operations.


Use of ALV Layout- Displaying Traffic Light


The ALV layout is a feature of SAP ABAP that enables users to personalize the appearance of their ALV reports. One of the functions that can be included in an ALV layout is the display of traffic lights.

The traffic light display can be used to indicate the state of information in a report. For instance, if a report contains information on a manufacturing process, the traffic light display can be utilized to show whether the process is progressing smoothly or has encountered issues.

To add the traffic light display to an ALV layout, users must first specify the traffic light icons in the ABAP Dictionary. This entails defining a new data element and setting the traffic light icons to be used for each status. Afterward, the traffic light display can be incorporated into the ALV layout by setting the corresponding field in the layout to use the traffic light icons.

Apart from the traffic light display, the ALV layout also allows users to customize other aspects of the report, such as column headers, column widths, and color schemes. This customization can be accomplished through various ALV events and options that are available in the ALV framework.

In summary, the utilization of the ALV layout in displaying traffic lights is an effective way to visualize data in an ALV report and can provide a quick overview of the status of the information being presented.

Sample Program for Reference - 

REPORT  ZAVI_FEVER1.

TYPE-POOLS: SLIS.
TYPES: BEGIN OF ST_MAKT,
       MATNR TYPE MATNR,
       SPRAS  TYPE SPRAS,
       MAKTX  TYPE MAKTX,
       END OF ST_MAKT.

DATA: IT_MAKT TYPE STANDARD TABLE OF ST_MAKT,
      WA_MAKT TYPE ST_MAKT.

TYPES: BEGIN OF ST_FINAL,
        LIGHT(1),
        CHECK(1),
        MATNR TYPE MATNR,
        SPRAS  TYPE SPRAS,
        MAKTX  TYPE MAKTX,
        END OF ST_FINAL.

DATA: IT_FINAL TYPE STANDARD TABLE OF ST_FINAL,
      WA_FINAL TYPE ST_FINAL.

DATA: IT_FCAT TYPE SLIS_T_FIELDCAT_ALV,
      WA_FCAT TYPE SLIS_FIELDCAT_ALV.

DATA: WA_LAYOUT TYPE SLIS_LAYOUT_ALV.



START-OF-SELECTION.

       SELECT MATNR
              SPRAS
              MAKTX
              FROM MAKT INTO TABLE IT_MAKT WHERE SPRAS = 'SY-LANGU'.

       IF SY-SUBRC = 0.
         SORT IT_MAKT BY MATNR.
       ENDIF.

END-OF-SELECTION.

       LOOP AT IT_MAKT INTO WA_MAKT.
         WA_FINAL-MATNR = WA_MAKT-MATNR.
         WA_FINAL-SPRAS = WA_MAKT-SPRAS.
         WA_FINAL-MAKTX = WA_MAKT-MAKTX.
         APPEND WA_FINAL TO IT_FINAL.
         CLEAR: WA_FINAL,WA_MAKT.
         ENDLOOP.


         LOOP AT IT_FINAL INTO WA_FINAL.
           IF SY-TABIX < 5.
WA_FINAL-light = 1.
ELSEIF sy-tabix > 5 AND sy-tabix LE 15.
WA_FINAL-light = 2. 
ELSE.
WA_FINAL-light = 3. 
ENDIF.
MODIFY IT_FINAL FROM WA_FINAL TRANSPORTING light.
ENDLOOP.


IF R1 = 'X'.

WA_FCAT-COL_POS = '1'.
WA_FCAT-TABNAME = 'IT_FINAL'.
WA_FCAT-FIELDNAME = 'CHECK'.
WA_FCAT-CHECKBOX = 'X'.
WA_FCAT-EDIT = 'X'.
WA_FCAT-SELTEXT_M = 'CHECKBOX'.
WA_FCAT-INPUT = 'X'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.

WA_LAYOUT-LIGHTS_FIELDNAME = 'LIGHT'.
WA_FCAT-COL_POS = '2'.
WA_FCAT-TABNAME = 'IT_FINAL'.
WA_FCAT-FIELDNAME = 'MATNR'.
WA_FCAT-INPUT = 'X'.
WA_FCAT-SELTEXT_M = 'MATERIAL NUMBER'.
WA_LAYOUT-ZEBRA = 'X'.
*WA_LAYOUT-NO_COLHEAD = 'X'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.

WA_FCAT-COL_POS = '3'.
WA_FCAT-TABNAME = 'IT_FINAL'.
WA_FCAT-FIELDNAME = 'SPRAS'.
WA_FCAT-INPUT = 'X'.
WA_FCAT-SELTEXT_M = 'LANGUAGE'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.

WA_FCAT-COL_POS = '4'.
WA_FCAT-TABNAME = 'IT_FINAL'.
WA_FCAT-FIELDNAME = 'MAKTX'.

WA_FCAT-SELTEXT_M = 'MTERIAL DESCRIPTION'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.

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        = ' '
*   I_STRUCTURE_NAME               =
   IS_LAYOUT                      = WA_LAYOUT
   IT_FIELDCAT                    = IT_FCAT
*   IT_EXCLUDING                   =
*   IT_SPECIAL_GROUPS              =
*   IT_SORT                        =
*   IT_FILTER                      =
*   IS_SEL_HIDE                    =
*   I_DEFAULT                      = 'X'
*   I_SAVE                         = ' '
*   IS_VARIANT                     =
*   IT_EVENTS                      =
*   IT_EVENT_EXIT                  =
*   IS_PRINT                       =
*   IS_REPREP_ID                   =
*   I_SCREEN_START_COLUMN          = 0
*   I_SCREEN_START_LINE            = 0
*   I_SCREEN_END_COLUMN            = 0
*   I_SCREEN_END_LINE              = 0
*   IR_SALV_LIST_ADAPTER           =
*   IT_EXCEPT_QINFO                =
*   I_SUPPRESS_EMPTY_DATA          = ABAP_FALSE
* IMPORTING
*   E_EXIT_CAUSED_BY_CALLER        =
*   ES_EXIT_CAUSED_BY_USER         =
  TABLES
    t_outtab                       = IT_FINAL
 EXCEPTIONS
   PROGRAM_ERROR                  = 1
   OTHERS                         = 2
          .
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.


Use of ALV Layout-> Hiding column header text

The ALV Layout feature in SAP ABAP enables users to customize the appearance of their ALV reports. One of the helpful functions that can be included in an ALV layout is the ability to hide column header text for specific columns.

To incorporate this function, users must first define the ALV layout in the ABAP Dictionary by creating a layout object with the required fields and screen elements to display the ALV report. Within this layout object, users can define which columns will be included in the report and how they will be displayed.

Once the ALV layout is defined, users can set the 'no_text' property for specific columns to hide the header text. This can be done using the 'set_column_optimize' method of the ALV object. By setting the 'no_text' parameter to 'X', the column header text will be hidden from the report.

This function can be particularly useful when dealing with large or complex reports, as it allows users to focus on the data within the columns without distraction from the header text. Additionally, it can be used to save space and reduce clutter in the report, leading to a more efficient and effective user experience.

Sample Report for Reference -

REPORT  ZAVI_FEVER1.

TYPE-POOLS: SLIS.
TYPES: BEGIN OF ST_MAKT,
       MATNR TYPE MATNR,
       SPRAS  TYPE SPRAS,
       MAKTX  TYPE MAKTX,
       END OF ST_MAKT.

DATA: IT_MAKT TYPE STANDARD TABLE OF ST_MAKT,
      WA_MAKT TYPE ST_MAKT.

TYPES: BEGIN OF ST_FINAL,
       CHECK(1),
        MATNR TYPE MATNR,
        SPRAS  TYPE SPRAS,
        MAKTX  TYPE MAKTX,
        END OF ST_FINAL.

DATA: IT_FINAL TYPE STANDARD TABLE OF ST_FINAL,
      WA_FINAL TYPE ST_FINAL.

DATA: IT_FCAT TYPE SLIS_T_FIELDCAT_ALV,
      WA_FCAT TYPE SLIS_FIELDCAT_ALV.

DATA: WA_LAYOUT TYPE SLIS_LAYOUT_ALV.

START-OF-SELECTION.

       SELECT MATNR
              SPRAS
              MAKTX
              FROM MAKT INTO TABLE IT_MAKT WHERE SPRAS = SY-LANGU.

       IF SY-SUBRC = 0.
         SORT IT_MAKT BY MATNR.
       ENDIF.
END-OF-SELECTION.
       LOOP AT IT_MAKT INTO WA_MAKT.
         WA_FINAL-MATNR = WA_MAKT-MATNR.
         WA_FINAL-SPRAS = WA_MAKT-SPRAS.
         WA_FINAL-MAKTX = WA_MAKT-MAKTX.
         APPEND WA_FINAL TO IT_FINAL.
         CLEAR: WA_FINAL,WA_MAKT.
         ENDLOOP.

IF R1 = 'X'.

WA_FCAT-COL_POS = '1'.
WA_FCAT-TABNAME = 'IT_FINAL'.
WA_FCAT-FIELDNAME = 'CHECK'.
WA_FCAT-CHECKBOX = 'X'.
WA_FCAT-EDIT = 'X'.
WA_FCAT-SELTEXT_M = 'CHECKBOX'.
WA_FCAT-INPUT = 'X'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.

WA_FCAT-COL_POS = '2'.
WA_FCAT-TABNAME = 'IT_FINAL'.
WA_FCAT-FIELDNAME = 'MATNR'.
WA_FCAT-INPUT = 'X'.
WA_FCAT-SELTEXT_M = 'MATERIAL NUMBER'.
WA_LAYOUT-ZEBRA = 'X'.
WA_LAYOUT-NO_COLHEAD = 'X'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.

WA_FCAT-COL_POS = '3'.
WA_FCAT-TABNAME = 'IT_FINAL'.
WA_FCAT-FIELDNAME = 'SPRAS'.
WA_FCAT-INPUT = 'X'.
WA_FCAT-SELTEXT_M = 'LANGUAGE'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.

WA_FCAT-COL_POS = '4'.
WA_FCAT-TABNAME = 'IT_FINAL'.
WA_FCAT-FIELDNAME = 'MAKTX'.

WA_FCAT-SELTEXT_M = 'MTERIAL DESCRIPTION'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.

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        = ' '
*   I_STRUCTURE_NAME               =
   IS_LAYOUT                      = WA_LAYOUT
   IT_FIELDCAT                    = IT_FCAT
*   IT_EXCLUDING                   =
*   IT_SPECIAL_GROUPS              =
*   IT_SORT                        =
*   IT_FILTER                      =
*   IS_SEL_HIDE                    =
*   I_DEFAULT                      = 'X'
*   I_SAVE                         = ' '
*   IS_VARIANT                     =
*   IT_EVENTS                      =
*   IT_EVENT_EXIT                  =
*   IS_PRINT                       =
*   IS_REPREP_ID                   =
*   I_SCREEN_START_COLUMN          = 0
*   I_SCREEN_START_LINE            = 0
*   I_SCREEN_END_COLUMN            = 0
*   I_SCREEN_END_LINE              = 0
*   IR_SALV_LIST_ADAPTER           =
*   IT_EXCEPT_QINFO                =
*   I_SUPPRESS_EMPTY_DATA          = ABAP_FALSE
* IMPORTING
*   E_EXIT_CAUSED_BY_CALLER        =
*   ES_EXIT_CAUSED_BY_USER         =
  TABLES
    t_outtab                       = IT_FINAL
 EXCEPTIONS
   PROGRAM_ERROR                  = 1
   OTHERS                         = 2
          .
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.



TO CALL ONE ALV REPORT FROM ANOTHER ALV REPORT USING ''SUBMIT"


To call one ALV report from another ALV report using "SUBMIT" in SAP ABAP, you can follow these steps:

Define the target report: First, you need to define the target report that you want to call from your source report. This report should have a program name and selection-screen parameters, which will be used to pass data from the source report.

Set up the SUBMIT statement: In the source report, you need to use the SUBMIT statement to call the target report. The SUBMIT statement should include the program name of the target report, any selection-screen parameters, and any other relevant options.

Pass data to the target report: If the target report requires input data from the source report, you can use the EXPORT TO MEMORY statement to pass the data to the memory. Then, in the target report, you can use the IMPORT FROM MEMORY statement to retrieve the data.

Display the target report: Once you have set up the SUBMIT statement and passed any necessary data, you can use the ALV function module 'REUSE_ALV_GRID_DISPLAY' to display the target report. This function module should be called in the target report, and any necessary ALV parameters should be passed as input.

Overall, calling one ALV report from another ALV report using "SUBMIT" is a straightforward process that involves defining the target report, setting up the SUBMIT statement, passing data to the target report, and displaying the target report using the ALV function module.

Sample Program for Reference - 

REPORT  ZAVI_11.

TYPE-POOLSSLIS.
TYPESBEGIN OF ST_MAKT,
       MATNR TYPE MATNR,
       SPRAS  TYPE SPRAS,
       MAKTX  TYPE MAKTX,
       END OF ST_MAKT.

DATAIT_MAKT TYPE STANDARD TABLE OF ST_MAKT,
      WA_MAKT TYPE ST_MAKT.

TYPESBEGIN OF ST_FINAL,
       CHECK(1),
        MATNR TYPE MATNR,
        SPRAS  TYPE SPRAS,
        MAKTX  TYPE MAKTX,
        END OF ST_FINAL.

DATAIT_FINAL TYPE STANDARD TABLE OF ST_FINAL,
      WA_FINAL TYPE ST_FINAL.

DATAIT_FCAT TYPE SLIS_T_FIELDCAT_ALV,
      WA_FCAT TYPE SLIS_FIELDCAT_ALV.

DATAWA_LAYOUT TYPE SLIS_LAYOUT_ALV.


START-OF-SELECTION.

       SELECT MATNR
              SPRAS
              MAKTX
              FROM MAKT INTO TABLE IT_MAKT WHERE SPRAS SY-LANGU.

       IF SY-SUBRC 0.
         SORT IT_MAKT BY MATNR.
       ENDIF.
END-OF-SELECTION.
       LOOP AT IT_MAKT INTO WA_MAKT.
         WA_FINAL-MATNR WA_MAKT-MATNR.
         WA_FINAL-SPRAS WA_MAKT-SPRAS.
         WA_FINAL-MAKTX WA_MAKT-MAKTX.
         APPEND WA_FINAL TO IT_FINAL.
         CLEARWA_FINAL,WA_MAKT.
         ENDLOOP.

WA_FCAT-COL_POS '1'.
WA_FCAT-TABNAME 'IT_FINAL'.
WA_FCAT-FIELDNAME 'CHECK'.
WA_FCAT-CHECKBOX 'X'.
WA_FCAT-EDIT 'X'.
WA_FCAT-SELTEXT_M 'CHECKBOX'.
WA_FCAT-INPUT 'X'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.

WA_FCAT-COL_POS '2'.
WA_FCAT-TABNAME 'IT_FINAL'.
WA_FCAT-FIELDNAME 'MATNR'.
WA_FCAT-INPUT 'X'.
WA_FCAT-SELTEXT_M 'MATERIAL NUMBER'.
WA_LAYOUT-ZEBRA 'X'.

APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.

WA_FCAT-COL_POS '3'.
WA_FCAT-TABNAME 'IT_FINAL'.
WA_FCAT-FIELDNAME 'SPRAS'.
WA_FCAT-INPUT 'X'.
WA_FCAT-SELTEXT_M 'LANGUAGE'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.

WA_FCAT-COL_POS '4'.
WA_FCAT-TABNAME 'IT_FINAL'.
WA_FCAT-FIELDNAME 'MAKTX'.
WA_FCAT-EDIT 'X'.
WA_FCAT-SELTEXT_M 'MTERIAL DESCRIPTION'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.

SUBMIT ZAVI_22 AND RETURN. "***SUBMIT WILL CALL AND EXECUTE ZAVI_22 REPORT AND THEN WILL GET RETURN TO THE CURRENT SESSION"

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        = ' '
*   I_STRUCTURE_NAME               =
   IS_LAYOUT                      WA_LAYOUT
   IT_FIELDCAT                    IT_FCAT
*   IT_EXCLUDING                   =
*   IT_SPECIAL_GROUPS              =
*   IT_SORT                        =
*   IT_FILTER                      =
*   IS_SEL_HIDE                    =
*   I_DEFAULT                      = 'X'
*   I_SAVE                         = ' '
*   IS_VARIANT                     =
*   IT_EVENTS                      =
*   IT_EVENT_EXIT                  =
*   IS_PRINT                       =
*   IS_REPREP_ID                   =
*   I_SCREEN_START_COLUMN          = 0
*   I_SCREEN_START_LINE            = 0
*   I_SCREEN_END_COLUMN            = 0
*   I_SCREEN_END_LINE              = 0
*   IR_SALV_LIST_ADAPTER           =
*   IT_EXCEPT_QINFO                =
*   I_SUPPRESS_EMPTY_DATA          = ABAP_FALSE
* IMPORTING
*   E_EXIT_CAUSED_BY_CALLER        =
*   ES_EXIT_CAUSED_BY_USER         =
  TABLES
    t_outtab                       IT_FINAL
 EXCEPTIONS
   PROGRAM_ERROR                  1
   OTHERS                         2
          .
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.

"***"

REPORT  ZAVI_22.

TYPE-POOLSSLIS.
TYPESBEGIN OF ST_MAKT,
       MATNR TYPE MATNR,
       SPRAS  TYPE SPRAS,
       MAKTX  TYPE MAKTX,
       END OF ST_MAKT.

DATAIT_MAKT TYPE STANDARD TABLE OF ST_MAKT,
      WA_MAKT TYPE ST_MAKT.

TYPESBEGIN OF ST_FINAL,
       CHECK(1),
        MATNR TYPE MATNR,
        SPRAS  TYPE SPRAS,
        MAKTX  TYPE MAKTX,
        END OF ST_FINAL.

DATAIT_FINAL TYPE STANDARD TABLE OF ST_FINAL,
      WA_FINAL TYPE ST_FINAL.

DATAIT_FCAT TYPE SLIS_T_FIELDCAT_ALV,
      WA_FCAT TYPE SLIS_FIELDCAT_ALV.

DATAWA_LAYOUT TYPE SLIS_LAYOUT_ALV.


START-OF-SELECTION.

       SELECT MATNR
              SPRAS
              MAKTX
              FROM MAKT INTO TABLE IT_MAKT WHERE SPRAS SY-LANGU.

       IF SY-SUBRC 0.
         SORT IT_MAKT BY MATNR.
       ENDIF.
END-OF-SELECTION.
       LOOP AT IT_MAKT INTO WA_MAKT.
         WA_FINAL-MATNR WA_MAKT-MATNR.
         WA_FINAL-SPRAS WA_MAKT-SPRAS.
         WA_FINAL-MAKTX WA_MAKT-MAKTX.
         APPEND WA_FINAL TO IT_FINAL.
         CLEARWA_FINAL,WA_MAKT.
         ENDLOOP.


WA_LAYOUT-BOX_FIELDNAME 'CHECK'.
WA_FCAT-COL_POS '1'.
WA_FCAT-TABNAME 'IT_FINAL'.
WA_FCAT-FIELDNAME 'CHECK'.
WA_FCAT-CHECKBOX 'X'.
WA_FCAT-EDIT 'X'.
WA_FCAT-SELTEXT_M 'CHECKBOX'.
WA_FCAT-INPUT 'X'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.

WA_FCAT-COL_POS '2'.
WA_FCAT-TABNAME 'IT_FINAL'.
WA_FCAT-FIELDNAME 'MATNR'.
WA_FCAT-INPUT 'X'.
WA_FCAT-EDIT 'X'.
WA_FCAT-SELTEXT_M 'MATERIAL NUMBER'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.

WA_FCAT-COL_POS '3'.
WA_FCAT-TABNAME 'IT_FINAL'.
WA_FCAT-FIELDNAME 'SPRAS'.
WA_FCAT-EDIT 'X'.
WA_FCAT-SELTEXT_M 'LANGUAGE'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.

WA_FCAT-COL_POS '4'.
WA_FCAT-TABNAME 'IT_FINAL'.
WA_FCAT-FIELDNAME 'MAKTX'.
WA_FCAT-EDIT 'X'.
WA_FCAT-SELTEXT_M 'MTERIAL DESCRIPTION'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.

CALL FUNCTION 'REUSE_ALV_GRID_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           = ' '
*   I_CALLBACK_TOP_OF_PAGE            = ' '
*   I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
*   I_CALLBACK_HTML_END_OF_LIST       = ' '
*   I_STRUCTURE_NAME                  =
*   I_BACKGROUND_ID                   = ' '
*   I_GRID_TITLE                      =
*   I_GRID_SETTINGS                   =
   IS_LAYOUT                         WA_LAYOUT
   IT_FIELDCAT                       IT_FCAT
*   IT_EXCLUDING                      =
*   IT_SPECIAL_GROUPS                 =
*   IT_SORT                           =
*   IT_FILTER                         =
*   IS_SEL_HIDE                       =
*   I_DEFAULT                         = 'X'
*   I_SAVE                            = ' '
*   IS_VARIANT                        =
*   IT_EVENTS                         =
*   IT_EVENT_EXIT                     =
*   IS_PRINT                          =
*   IS_REPREP_ID                      =
*   I_SCREEN_START_COLUMN             = 0
*   I_SCREEN_START_LINE               = 0
*   I_SCREEN_END_COLUMN               = 0
*   I_SCREEN_END_LINE                 = 0
*   I_HTML_HEIGHT_TOP                 = 0
*   I_HTML_HEIGHT_END                 = 0
*   IT_ALV_GRAPHICS                   =
*   IT_HYPERLINK                      =
*   IT_ADD_FIELDCAT                   =
*   IT_EXCEPT_QINFO                   =
*   IR_SALV_FULLSCREEN_ADAPTER        =
* IMPORTING
*   E_EXIT_CAUSED_BY_CALLER           =
*   ES_EXIT_CAUSED_BY_USER            =
  TABLES
    t_outtab                          IT_FINAL
 EXCEPTIONS
   PROGRAM_ERROR                     1
   OTHERS                            2
          .
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.