Ads

Simple ALV Report Example for SAP ABAP Freshers

Simple ALV Report  Example for SAP ABAP Freshers

This is simple and sample  ALV report example useful for SAP ABAP learning students or freshers


*&---------------------------------------------------------------------*
*& Report  ZALV_INTERACTIVE_REPORT
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  ZALV_INTERACTIVE_REPORT.

tYPE-POOLS:SLIS.

TYPESBEGIN OF TY_VBAK,
        VBELN TYPE VBAK-VBELN,
        ERDAT TYPE VBAK-ERDAT,
        ERZET TYPE VBAK-ERZET,
        ERNAM TYPE VBAK-ERNAM,
      END OF TY_VBAK.

types BEGIN OF TY_VBAP,
        VBELN TYPE VBAP-VBELN,
        POSNR TYPE VBAP-POSNR,
        MATNR TYPE VBAP-MATNR,
        END OF TY_VBAP.



data it_vbak type TABLE OF ty_vbak,
      it_vbap TYPE TABLE OF ty_vbap,
      wa_vbak type ty_vbak,
      wa_vbap TYPE ty_vbap,
IT_FCAT TYPE SLIS_T_FIELDCAT_ALV "field catalog table
WA_FCAT LIKE LINE OF IT_FCAT .


PARAMETERS P_VBELN TYPE VBAK-VBELN.

SELECT VBELN ERDAT ERZET ERNAM FROM VBAK INTO TABLE IT_VBAK WHERE VBELN P_VBELN.

  WA_FCAT-COL_POS '1' "column position
  WA_FCAT-FIELDNAME 'VBELN' "column name
  WA_FCAT-TABNAME 'IT_VBAK' "table
  WA_FCAT-SELTEXT_M 'SALES ORDER NO' "Column label
  WA_FCAT-KEY 'X' "is a key field
  WA_FCAT-HOTSPOT 'X' "Set hotspot for matnr
  APPEND WA_FCAT TO IT_FCAT "append to fcat
  CLEAR WA_FCAT .

  WA_FCAT-COL_POS '2' "column position
  WA_FCAT-FIELDNAME 'ERDAT' "column name
  WA_FCAT-TABNAME 'IT_VBAK' "table
  WA_FCAT-SELTEXT_M 'DATE' "Column label
  WA_FCAT-HOTSPOT 'X' "Set hotspot for matnr
  APPEND WA_FCAT TO IT_FCAT "append to fcat
  CLEAR WA_FCAT .

  WA_FCAT-COL_POS '3' "column position
  WA_FCAT-FIELDNAME 'ERZET' "column name
  WA_FCAT-TABNAME 'IT_VBAK' "table
  WA_FCAT-SELTEXT_M 'TIME' "Column label
  WA_FCAT-HOTSPOT 'X' "Set hotspot for matnr
  APPEND WA_FCAT TO IT_FCAT "append to fcat
  CLEAR WA_FCAT .



  WA_FCAT-COL_POS '4' "column position
  WA_FCAT-FIELDNAME 'ERZET' "column name
  WA_FCAT-TABNAME 'IT_VBAK' "table
  WA_FCAT-SELTEXT_M 'NAME' "Column label
  WA_FCAT-HOTSPOT 'X' "Set hotspot for matnr
  APPEND WA_FCAT TO IT_FCAT "append to 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                         =
         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_VBAK
*   EXCEPTIONS
*     PROGRAM_ERROR                     = 1
*     OTHERS                            = 2

 .Input screen:
Simple ALV Report  Example for SAP ABAP Freshers

Out put screen:
Simple ALV Report  Example for SAP ABAP Freshers


Comments

Popular posts from this blog

BADI Interview Questions in SAP ABAP

Sample SAP ABAP Programming Examples for Practice

Module Pool Programming Interview Questions and Answers in SAP ABAP

Step by Step tutorial on BDC Session Method Program in SAP ABAP

SAP ABAP Interview Questions and Answers for 10 Years Experienced