Wednesday, 13 July 2022

Display logo in ALV Report.

In this blog post you will learn how to display logo in your ALV Report.

How to Create a Logo

Once you login to system enter T-code OAER.

Follow the below steps to create a logo.

Step 1: Enter OAER transaction code in command field and press Enter.

Step 2: Enter the following fields for your logo.

SAP ABAP , SAP ABAP Exam, SAP ABAP Exam Prep, SAP ABAP Career, SAP ABAP Skills, SAP ABAP Jobs, SAP ABAP Tutorial and Material, SAP ABAP Preparation

Step 3: Click on Execute.

Step 4: Below screen will displayed, double click on Standard Doc Types.

SAP ABAP , SAP ABAP Exam, SAP ABAP Exam Prep, SAP ABAP Career, SAP ABAP Skills, SAP ABAP Jobs, SAP ABAP Tutorial and Material, SAP ABAP Preparation

Step 5: Select the picture from your files you want make logo.

Step 6: Then open your ALV report and make changes in TOP_OF_PAGE event.

SAP ABAP , SAP ABAP Exam, SAP ABAP Exam Prep, SAP ABAP Career, SAP ABAP Skills, SAP ABAP Jobs, SAP ABAP Tutorial and Material, SAP ABAP Preparation

Refer to the code below for the whole program.

*&---------------------------------------------------------------------*
*& Report Z1015035_ALV_LOGO
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT Z1015035_ALV_LOGO.
INCLUDE Z1015035_INC_ALV_MARA.

START-OF-SELECTION .
  PERFORM GET_DATA .
  PERFORM CREATE_FCAT.
  PERFORM GET_EVENT.
  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.
*&---------------------------------------------------------------------*
*& 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-HOTSPOT = 'X' .
  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' .
  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-TABNAME = 'IT_MARA' .
  WA_FCAT-SELTEXT_M = 'IND.SECTOR' .
  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' .
  APPEND WA_FCAT TO IT_FCAT .
  CLEAR WA_FCAT .
ENDFORM.
*&---------------------------------------------------------------------*
*& Form DISP_ALV
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& -->  p1        text
*& <--  p2        text
*&---------------------------------------------------------------------*
FORM DISP_ALV .
  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           = '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                         =
     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_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        =
*     O_PREVIOUS_SRAL_HANDLER           =
*   IMPORTING
*     E_EXIT_CAUSED_BY_CALLER           =
*     ES_EXIT_CAUSED_BY_USER            =
    TABLES
      T_OUTTAB                          = IT_MARA
*   EXCEPTIONS
*     PROGRAM_ERROR                     = 1
*     OTHERS                            = 2
            .
*  IF SY-SUBRC <> 0.
** Implement suitable error handling here
*  ENDIF.

ENDFORM.

FORM TOP_OF_PAGE .
  WA_HEADING-TYP = 'H' .
  WA_HEADING-INFO = 'MATERIAL MASTER REPORT' .
  APPEND WA_HEADING TO IT_HEADING .

  WA_HEADING-TYP = 'S' .
  WA_HEADING-KEY = 'USERNAME' .
  WA_HEADING-INFO = SY-UNAME .
  APPEND WA_HEADING TO IT_HEADING .

  WA_HEADING-TYP = 'A' .
  WA_HEADING-KEY = 'DATE' .
  WA_HEADING-INFO = SY-DATUM .
  APPEND WA_HEADING TO IT_HEADING .

  CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
      IT_LIST_COMMENTARY       = IT_HEADING
     I_LOGO                   = 'LOGO1'
*     I_END_OF_LIST_GRID       = 'X'
*     I_ALV_FORM               =
            .
ENDFORM .
*&---------------------------------------------------------------------*
*& Form GET_EVENT
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& -->  p1        text
*& <--  p2        text
*&---------------------------------------------------------------------*
FORM GET_EVENT .

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
*   EXPORTING
*     I_LIST_TYPE           = 0
   IMPORTING
     ET_EVENTS             =  IT_EVENTS
*   EXCEPTIONS
*     LIST_TYPE_WRONG       = 1
*     OTHERS                = 2
            .
*  IF SY-SUBRC <> 0.
** Implement suitable error handling here
*  ENDIF.

"TOP-OF-PAGE EVENT
  READ TABLE IT_EVENTS INTO WA_EVENTS WITH KEY NAME = 'TOP_OF_PAGE' .
  WA_EVENTS-FORM = 'TOP_OF_PAGE' .
  MODIFY  IT_EVENTS FROM WA_EVENTS INDEX SY-TABIX .
  "END-OF-LIST EVENT
  READ TABLE IT_EVENTS INTO WA_EVENTS WITH KEY NAME = 'END_OF_LIST' .
  WA_EVENTS-FORM = 'END_OF_LIST' .
  MODIFY  IT_EVENTS FROM WA_EVENTS INDEX SY-TABIX .
ENDFORM.

FORM END_OF_LIST .
  REFRESH IT_HEADING .
  CLEAR WA_HEADING .

  WA_HEADING-TYP = 'S' .
  WA_HEADING-INFO = '---ALV_REPORT---' .
  APPEND WA_HEADING TO IT_HEADING .

  CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
   EXPORTING
     IT_LIST_COMMENTARY       = IT_HEADING
    I_END_OF_LIST_GRID       = 'X'
           .
ENDFORM . 

INCLUDE

*&---------------------------------------------------------------------*
*& Include Z1015035_INC_ALV_MARA
*&---------------------------------------------------------------------*
TABLES : MARA, T134.
TYPE-POOLS SLIS .

TYPES : BEGIN OF TY_MARA,
        MATNR TYPE MARA-MATNR,
        MTART TYPE MARA-MTART,
        MBRSH TYPE MARA-MBRSH,
        MEINS TYPE MARA-MEINS,
      END OF TY_MARA,
      BEGIN OF TY_T134,
        MTART TYPE T134-MTART,
        MTREF TYPE T134-MTREF,
        MBREF TYPE T134-MBREF,
        END OF TY_T134,
         BEGIN OF TY_VBAP,
    VBELN TYPE VBAP-VBELN,
    POSNR TYPE VBAP-POSNR,
    MATNR TYPE VBAP-MATNR,
    END OF TY_VBAP.

DATA : IT_MARA TYPE TABLE OF TY_MARA, WA_MARA TYPE TY_MARA, IT_VBAP TYPE TABLE OF TY_VBAP, WA_VBAP TYPE TY_VBAP,
        IT_T134 TYPE TABLE OF TY_T134, WA_T134 TYPE TY_T134,
       IT_FCAT TYPE SLIS_T_FIELDCAT_ALV, WA_FCAT LIKE LINE OF IT_FCAT,
       IT_EVENTS TYPE SLIS_T_EVENT, WA_EVENTS LIKE LINE OF IT_EVENTS,
       IT_HEADING TYPE SLIS_T_LISTHEADER, WA_HEADING LIKE LINE OF IT_HEADING .

SELECT-OPTIONS: S_MATNR FOR MARA-MATNR. 

Output


SAP ABAP , SAP ABAP Exam, SAP ABAP Exam Prep, SAP ABAP Career, SAP ABAP Skills, SAP ABAP Jobs, SAP ABAP Tutorial and Material, SAP ABAP Preparation

By following the steps you will be able to create logo in ALV Report.

No comments:

Post a Comment