Thursday, November 30, 2017

OData (Open Data Protocol)

OData (Open Data Protocol) is a standardized web protocol used to create and consume RESTful web services for exchanging data on the web. It is based on HTTP, AtomPub, and JSON standards and is widely used in SAP for building and consuming RESTful APIs for SAP systems.

In SAP, OData services are built on top of the SAP NetWeaver Gateway, which acts as a mediator between the SAP system and external systems. These services enable external systems, such as web and mobile applications, to access and modify data stored in SAP systems, such as SAP ERP or SAP S/4HANA, in a secure and controlled way.

One of the key benefits of OData is its simplicity and ease of use. It is based on widely accepted web standards, which makes it easy for developers to learn and use. OData services provide a consistent interface for accessing data, regardless of the underlying technology used to store the data.

Overall, OData is a powerful and flexible protocol for building and consuming RESTful APIs in SAP, enabling seamless integration with other systems and platforms, and unlocking new possibilities for data exchange and application development.


ODATA (Open Data Protocol) is a protocol used for building and consuming RESTful APIs in SAP systems. It provides several benefits, including:

Standardized protocol: ODATA is based on widely accepted web standards such as HTTP, AtomPub, and JSON, which make it easy for developers to learn and use.

Simplified data exchange: ODATA provides a consistent interface for accessing data, regardless of the underlying technology used to store the data. This simplifies data exchange between SAP and other systems, such as web and mobile applications.

Improved security: ODATA services are built on top of the SAP NetWeaver Gateway, which acts as a mediator between the SAP system and the external system. This ensures that data is accessed and modified in a secure and controlled manner.

Increased flexibility: ODATA allows for the creation of RESTful APIs that can be used across multiple platforms and programming languages, enabling developers to build applications using their preferred tools and frameworks.

Better user experience: ODATA enables the development of responsive, mobile-friendly applications that provide a seamless and consistent user experience across different devices.

Overall, ODATA is a powerful and flexible protocol that enables seamless integration with other systems and platforms, unlocking new possibilities for data exchange and application development in SAP systems.


Wednesday, August 23, 2017

Hierarchical sequential list ALV.

Hierarchical Sequential List ALV (ABAP List Viewer) is an interactive report that allows users to display and manipulate hierarchical data in a tree-like structure. This type of ALV report is useful when data has a parent-child relationship and requires a hierarchical format for better analysis. The data can be expanded or collapsed at each level to display the data in the next level, and users can drill down to the details of the data.

The Hierarchical Sequential List ALV report is highly customizable and can be modified using various events and options available in the ALV framework. This customization can help add custom functionality to the report, such as custom buttons or navigation. Additionally, the report is used in various applications such as organizational charts, bill of materials, and product structures.


This post shows how to display a hierarchical sequential list ALV.

TABLES: MARA,MAKT.
TYPE-POOLS: SLIS.
TYPES: BEGIN OF ST_MARA,
       EXPAND,
       MATNR TYPE MATNR,
       ERSDA TYPE ERSDA,
       ERNAM TYPE ERNAM,
       END OF ST_MARA.

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

DATA: IT_MARA TYPE TABLE OF ST_MARA,
      WA_MARA TYPE MARA,
      IT_MAKT TYPE TABLE OF ST_MAKT,
      WA_MAKT TYPE MAKT.

 DATA: IT_FCAT TYPE SLIS_T_FIELDCAT_ALV,
       WA_FCAT TYPE SLIS_FIELDCAT_ALV.

 DATA: WA_KEY TYPE SLIS_KEYINFO_ALV.
 DATA: WA_LAYOUT TYPE SLIS_LAYOUT_ALV.

 SELECT-OPTIONS:S_MATNR FOR MARA-MATNR.

 SELECT  MATNR
         ERSDA
         ERNAM
         FROM MARA INTO CORRESPONDING FIELDS OF TABLE IT_MARA WHERE MATNR IN S_MATNR.

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

     IF IT_MARA IS NOT INITIAL.
       SELECT MATNR
              SPRAS
              MAKTX
              FROM MAKT INTO TABLE IT_MAKT
              FOR ALL ENTRIES IN IT_MARA
              WHERE MATNR  = IT_MARA-MATNR.

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

WA_LAYOUT-EXPAND_FIELDNAME = 'EXPAND'.
WA_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.

WA_KEY-HEADER01 = 'MATNR'.
WA_KEY-ITEM01 = 'MATNR'.


WA_FCAT-COL_POS = '1'.
WA_FCAT-TABNAME = 'IT_MARA'.
WA_FCAT-FIELDNAME = 'MATNR'.
WA_FCAT-SELTEXT_M = 'MATERIAL NUMBER'.
WA_FCAT-KEY = 'X'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.

WA_FCAT-COL_POS = '2'.
WA_FCAT-TABNAME = 'IT_MARA'.
WA_FCAT-FIELDNAME = 'ERSDA'.
WA_FCAT-SELTEXT_M = 'CREATED ON'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.

WA_FCAT-COL_POS = '3'.
WA_FCAT-TABNAME = 'IT_MARA'.
WA_FCAT-FIELDNAME = 'ERNAM'.
WA_FCAT-SELTEXT_M = 'CREATED BY'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.

WA_FCAT-COL_POS = '4'.
WA_FCAT-TABNAME = 'IT_MAKT'.
WA_FCAT-FIELDNAME = 'SPRAS'.
WA_FCAT-SELTEXT_M = 'LANGUAGE'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.

WA_FCAT-COL_POS = '4'.
WA_FCAT-TABNAME = 'IT_MAKT'.
WA_FCAT-FIELDNAME = 'MAKTX'.
WA_FCAT-SELTEXT_M = 'DESCRIPTION'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.

CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
  EXPORTING
*   I_INTERFACE_CHECK              = ' '
   I_CALLBACK_PROGRAM             = SY-REPID
*   I_CALLBACK_PF_STATUS_SET       = ' '
*   I_CALLBACK_USER_COMMAND        = ' '
   IS_LAYOUT                      = WA_LAYOUT
   IT_FIELDCAT                    = IT_FCAT
*   IT_EXCLUDING                   =
*   IT_SPECIAL_GROUPS              =
*   IT_SORT                        =
*   IT_FILTER                      =
*   IS_SEL_HIDE                    =
*   I_SCREEN_START_COLUMN          = 0
*   I_SCREEN_START_LINE            = 0
*   I_SCREEN_END_COLUMN            = 0
*   I_SCREEN_END_LINE              = 0
*   I_DEFAULT                      = 'X'
*   I_SAVE                         = ' '
*   IS_VARIANT                     =
*   IT_EVENTS                      =
*   IT_EVENT_EXIT                  =
    i_tabname_header               = 'IT_MARA'
    i_tabname_item                 = 'IT_MAKT'
*   I_STRUCTURE_NAME_HEADER        =
*   I_STRUCTURE_NAME_ITEM          =
    is_keyinfo                     = WA_KEY
*   IS_PRINT                       =
*   IS_REPREP_ID                   =
*   I_BYPASSING_BUFFER             =
*   I_BUFFER_ACTIVE                =
*   IR_SALV_HIERSEQ_ADAPTER        =
*   IT_EXCEPT_QINFO                =
*   I_SUPPRESS_EMPTY_DATA          = ABAP_FALSE
* IMPORTING
*   E_EXIT_CAUSED_BY_CALLER        =
*   ES_EXIT_CAUSED_BY_USER         =
  TABLES
    t_outtab_header                = IT_MARA
    t_outtab_item                  = IT_MAKT
 EXCEPTIONS
   PROGRAM_ERROR                  = 1
   OTHERS                         = 2
          .
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.





In summary, the Hierarchical Sequential List ALV is a powerful tool in SAP ABAP that helps users display and analyze hierarchical data in a tree-like structure. It can be customized using different events and options to suit specific needs and is useful for various applications that require the display of data with a parent-child relationship.

Sunday, August 20, 2017

Use of ALV To Calculate TOTAL and SORT Table for Sub Total Calculation

The ALV Field Catalog is a critical feature in SAP ABAP that enables users to define and personalize the fields and columns in their ALV reports. One of the useful functions that can be included in the field catalog is the capability to calculate subtotals and totals for specific columns or groups of columns.

To add this function, users need to create the field catalog in the ABAP Dictionary. This involves defining a structure with the necessary fields and screen elements to present the ALV report. Within this structure, the user can determine which columns will be included in the report and how they will be calculated.

After creating the field catalog, users can set up the table for subtotal calculation. This requires defining a structure to store the subtotals and totals and specifying any grouping criteria for the subtotals.

To compute the subtotals and totals, the user must then define the applicable fields in the field catalog as SUM fields, which will conduct the necessary calculations. The user can also configure the sorting logic for the subtotals, which will determine how the subtotals are grouped and displayed in the report.

Overall, the ALV Field Catalog is an essential tool for personalizing and customizing ALV reports in SAP ABAP. By integrating subtotals and totals into the report, users can provide additional context and insight into the data being presented, leading to a more efficient and effective user experience.

Sample Report for Reference - 

REPORT  ZAVI_FEVER2.

TYPE-POOLS: SLIS.

DATA: IT_SPFLI TYPE TABLE OF SPFLI,
      WA_SPFLI TYPE SPFLI.
DATA: IT_FCAT TYPE  SLIS_T_FIELDCAT_ALV,
      WA_FCAT TYPE  SLIS_FIELDCAT_ALV.
DATA: IT_sort TYPE slis_t_sortinfo_alv.
DATA: WA_LAYOUT TYPE SLIS_LAYOUT_ALV.
DATA: WA_sort TYPE slis_SORTinfo_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.

WA_SORT-FIELDNAME = 'CARRID'.
WA_SORT-SPOS = '1'.
WA_SORT-UP = 'X'.
WA_SORT-SUBTOT = 'X'.
APPEND WA_SORT TO IT_SORT.


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_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

.

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.