Skip to Content
Technical Articles
Author's profile photo Sinela Anwar

Display logo in ALV Report.

I am happy to share my very first blog post on SAP ABAP Programming using ALV. 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.

Step 3: Click on Execute.

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

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.

 

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

By following the steps you will be able to create logo in ALV Report. I hope this blog post helped you as beginner.

As we continue to learn more, I will use this first blog post to link all the parts of this series.

Follow my profile to be notified of the next blog post. Please feel free to ask any questions you have in the comments section below.

Join the conversation about the ABAP programming by following the tag  ABAP Development

Post questions and answer related to tag by following the tag Questions & Answers

Read other blog post on topic ABAP Development

Assigned Tags

      7 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Rodrigo Giner de la Vega
      Rodrigo Giner de la Vega

      Really ???  2022 and still using FM REUSE_ALV_GRID_DISPLAY ? Sorry, but this is totally outdated, almost prehistoric.

      check this post to see how to do the same with SALV

      https://answers.sap.com/questions/1892782/how-to-display-logo-on-alv-grid-report.html

      Regards

       

      Author's profile photo Sinela Anwar
      Sinela Anwar
      Blog Post Author

      Actually when I started learning ALV first I worked using these methods then moved to the classes that's why I have used basic methods for them to understand and this blog is not for people like you it is for the beginners so you can't expect them to know everything and this blog will help them understand ALV from scratch.

      Thanks for your feedback.

      Author's profile photo Sandra Rossi
      Sandra Rossi

      I understand your point but if you know SALV, you'd better explain to all people who recently attended training based on twenty-years old material that it's time to switch to classic ABAP programming based on ABAP Objects. By the way, even SALV is very old but not as old as REUSE stuff, subroutines, and so on.

      The good point is that there was no such post before yours (at least I couldn't find easily one). Maybe attaching a screenshot would help people understand what your code is producing.

      Author's profile photo Sinela Anwar
      Sinela Anwar
      Blog Post Author

      Thanks for your feedback Sandra will sure do the changes.

      Author's profile photo Shai Sinai
      Shai Sinai

      I would still advise to use CL_GUI_ALV_GRID over CL_SALV_TABLE (maybe by creating your own "SALV-like" class, like FALV).

      The CL_SALV_TABLE has many restrictions (The most known is the editable ALV, but there also others), and once you run into one, you must refactor your whole code.

      Author's profile photo Tharun k
      Tharun k

      Thank you for sharing useful information madam.

      Author's profile photo Praphull Shingade
      Praphull Shingade

      Hi,

      For me it is really helpful, this question had asked me in interview that time I was unable to answer this question.

      but now I got it, code is not having any error which is really nice.

       

      thanks for sharing this information.