Skip to Content
avatar image
Former Member

ALV REPORT

Hi all,

1. can u tell me about ALV REPORT ? I need some samples also to understand it better.

My id : raaj_sap@rediffmail.com

Appreciate your information and will definitely reward points.

Regards

Rajarshi

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    avatar image
    Former Member
    Jul 13, 2007 at 09:46 AM

    Dear Rajarshi,

    ALV is Application List viewer.

    Sap provides a set of ALV (ABAP LIST VIEWER) function modules which can be put into use to embellish the output of a report. This set of ALV functions is used to enhance the readability and functionality of any report output. Cases arise in sap when the output of a report contains columns extending more than 255 characters in length.

    In such cases, this set of ALV functions can help choose selected columns and arrange the different columns from a report output and also save different variants for report display. This is a very efficient tool for dynamically sorting and arranging the columns from a report output.

    The report output can contain up to 90 columns in the display with the wide array of display options.

    The commonly used ALV functions used for this purpose are;

    1. REUSE_ALV_VARIANT_DEFAULT_GET

    2. REUSE_ALV_VARIANT_F4

    3. REUSE_ALV_VARIANT_EXISTENCE

    4. REUSE_ALV_EVENTS_GET

    5. REUSE_ALV_COMMENTARY_WRITE

    6. REUSE_ALV_FIELDCATALOG_MERGE

    7. REUSE_ALV_LIST_DISPLAY

    8. REUSE_ALV_GRID_DISPLAY

    9. REUSE_ALV_POPUP_TO_SELECT

    Purpose of the above Functions are differ not all the functions are required in all the ALV Report.

    But either no.7 or No.8 is there in the Program.

    How you call this function in your report?

    After completion of all the data fetching from the database and append this data into an Internal Table. say I_ITAB.

    Then use follwing function module.

    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' 
           EXPORTING 
                I_CALLBACK_PROGRAM       = 'Prog.name' 
                I_STRUCTURE_NAME         = 'I_ITAB' 
                I_DEFAULT                = 'X' 
                I_SAVE                   = 'A' 
           TABLES 
                T_OUTTAB                 = I_ITAB. 
      IF SY-SUBRC <> 0. 
        WRITE: 'SY-SUBRC: ', SY-SUBRC . 
      ENDIF. 
    ENDFORM.                    " GET_FINAL_DATA 

    Sample ALV1:

    REPORT Z_ALV_SIMPLE_EXAMPLE_WITH_ITAB .
    ************************************************************************
    *Simple example to use ALV and to define the ALV data in an internal
    *table
    ************************************************************************
    * Martin Schlegel, BearingPoint, December 2004
    *
    * Thanks to Madhusudhan Sonee and Rama Krishna Kommineni for testing
    * and feedback
    *
    ************************************************************************
    ************************************************************************
    *For a very long time, people gave me the feeling that ALV is a
    *complicated tool that is difficult to understand and to use.
    *Lately I had to use it and I discovered that ALV is easy to use and
    *saves a lot of work:
    *ALV will generate the column headings on its own, so one does not need
    *to work on headlines and transalation.
    *ALV allows the user to select the columns he wants to see, so the user
    *does not need to contact a developer for every change he likes to have.
    *ALV allows the user to create his own sums, so …
    *ALV has a simple way to work with internal tables.
    *If you really want to save time, use ALV instead of write!
    ************************************************************************
    *
    *Please take 30 minutes to explore the following example and see how
    *easy it is to use ALV!
    *
    ************************************************************************
    
    *data definition
    
    tables:
    marav. "Table MARA and table MAKT
    
    *---------------------------------------------------------------------*
    * Data to be displayed in ALV
    * Using the following syntax, REUSE_ALV_FIELDCATALOG_MERGE can auto-
    * matically determine the fieldstructure from this source program
    Data:
    begin of imat occurs 100,
    matnr like marav-matnr, "Material number
    maktx like marav-maktx, "Material short text
    matkl like marav-matkl, "Material group (so you can test to make
                            " intermediate sums)
    ntgew like marav-ntgew, "Net weight, numeric field (so you can test to
                            "make sums)
    gewei like marav-gewei, "weight unit (just to be complete)
    end of imat.
    
    *---------------------------------------------------------------------*
    * Other data needed
    * field to store report name
    data i_repid like sy-repid.
    * field to check table length
    data i_lines like sy-tabix.
    
    *---------------------------------------------------------------------*
    * Data for ALV display
    TYPE-POOLS: SLIS.
    data int_fcat type SLIS_T_FIELDCAT_ALV.
    
    *---------------------------------------------------------------------*
    select-options:
    s_matnr for marav-matnr matchcode object MAT1.
    
    *---------------------------------------------------------------------*
    start-of-selection.
    
    * read data into table imat
      select * from marav
      into corresponding fields of table imat
      where
      matnr in s_matnr.
    
    * Check if material was found
      clear i_lines.
      describe table imat lines i_lines.
      if i_lines lt 1.
    *   Using hardcoded write here for easy upload
        write: /
        'No materials found.'.
        exit.
      endif.
    
    end-of-selection.
    *---------------------------------------------------------------------*
    *
    * Now, we start with ALV
    *
    *---------------------------------------------------------------------*
    *
    *
    * To use ALV, we need a DDIC-structure or a thing called Fieldcatalogue.
    * The fieldcatalouge can be generated by FUNCTION
    * 'REUSE_ALV_FIELDCATALOG_MERGE' from an internal table from any
    * report source, including this report.
    * The only problem one might have is that the report and table names
    * need to be in capital letters. (I had it :-( )
    *
    *
    *---------------------------------------------------------------------*
    
    * Store report name
      i_repid = sy-repid.
    
    * Create Fieldcatalogue from internal table
      CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
           EXPORTING
                I_PROGRAM_NAME         = i_repid
                I_INTERNAL_TABNAME     = 'IMAT'  "capital letters!
                I_INCLNAME             = i_repid
           CHANGING
                CT_FIELDCAT            = int_fcat
           EXCEPTIONS
                INCONSISTENT_INTERFACE = 1
                PROGRAM_ERROR          = 2
                OTHERS                 = 3.
    *explanations:
    *    I_PROGRAM_NAME is the program which calls this function
    *
    *    I_INTERNAL_TABNAME is the name of the internal table which you want
    *                       to display in ALV
    *
    *    I_INCLNAME is the ABAP-source where the internal table is defined
    *               (DATA....)
    *      CT_FIELDCAT contains the Fieldcatalouge that we need later for
    *      ALV display
    
    
      IF SY-SUBRC <> 0.
        write: /
        'Returncode',
        sy-subrc,
        'from FUNCTION REUSE_ALV_FIELDCATALOG_MERGE'.
      ENDIF.
    
    *This was the fieldcatlogue
    *---------------------------------------------------------------------*
    *
    * And now, we are ready to display our list
    
    * Call for ALV list display
      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
           EXPORTING
    *            I_CALLBACK_PROGRAM = 'Z_ALV_SIMPLE_EXAMPLE_WITH_ITAB'
                I_CALLBACK_PROGRAM = i_repid
                IT_FIELDCAT        = int_fcat
                I_SAVE             = 'A'
           TABLES
                T_OUTTAB           = imat
           EXCEPTIONS
                PROGRAM_ERROR      = 1
                OTHERS             = 2.
    *
    *explanations:
    *    I_CALLBACK_PROGRAM is the program which calls this function
    *
    *    IT_FIELDCAT (just made by REUSE_ALV_FIELDCATALOG_MERGE) contains
    *                 now the data definition needed for display
    *
    *    I_SAVE allows the user to save his own layouts
    *
    *      T_OUTTAB contains the data to be displayed in ALV
    
    
      IF SY-SUBRC <> 0.
        write: /
        'Returncode',
        sy-subrc,
        'from FUNCTION REUSE_ALV_LIST_DISPLAY'.
      ENDIF.

    Samle ALV2:

    *&---------------------------------------------------------------------*
    *& Report  ZZ_22038_22098_002                                          *
    *&                                                                     *
    *&---------------------------------------------------------------------*
    *& This is an Interactive ALV report, where on line slection we can see
    *&  the secondry list
    *&
    *&                                                                     *
    *&---------------------------------------------------------------------*
    
    REPORT  ZZ_22038_22098_002 NO STANDARD PAGE HEADING LINE-SIZE 650
    MESSAGE-ID ZZ_9838                      .
    
    TYPE-POOLS: SLIS.
    *type declaration for values from ekko
    TYPES: BEGIN OF I_EKKO,
           EBELN LIKE EKKO-EBELN,
           AEDAT LIKE EKKO-AEDAT,
           BUKRS LIKE EKKO-BUKRS,
           BSART LIKE EKKO-BSART,
           LIFNR LIKE EKKO-LIFNR,
           END OF I_EKKO.
    
    DATA: IT_EKKO TYPE STANDARD TABLE OF I_EKKO INITIAL SIZE 0,
          WA_EKKO TYPE I_EKKO.
    
    *type declaration for values from ekpo
    TYPES: BEGIN OF I_EKPO,
           EBELN LIKE EKPO-EBELN,
           EBELP LIKE EKPO-EBELP,
           MATNR LIKE EKPO-MATNR,
           MENGE LIKE EKPO-MENGE,
           MEINS LIKE EKPO-MEINS,
           NETPR LIKE EKPO-NETPR,
           END OF I_EKPO.
    
    DATA: IT_EKPO TYPE STANDARD TABLE OF I_EKPO INITIAL SIZE 0,
          WA_EKPO TYPE I_EKPO .
    
    *variable for Report ID
    DATA: V_REPID LIKE SY-REPID .
    
    *declaration for fieldcatalog
    DATA: I_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
          WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
    
    
    DATA: IT_LISTHEADER TYPE SLIS_T_LISTHEADER.
    
    * declaration for events table where user comand or set PF status will
    * be defined
    DATA: V_EVENTS TYPE SLIS_T_EVENT,
          WA_EVENT TYPE SLIS_ALV_EVENT.
    
    * declartion for layout
    DATA: ALV_LAYOUT TYPE SLIS_LAYOUT_ALV.
    
    * declaration for variant(type of display we want)
    DATA: I_VARIANT TYPE DISVARIANT,
          I_VARIANT1 TYPE DISVARIANT,
          I_SAVE(1) TYPE C.
    
    *PARAMETERS : p_var TYPE disvariant-variant.
    
    *Title displayed when the alv list is displayed
    DATA:  I_TITLE_EKKO TYPE LVC_TITLE VALUE 'FIRST LIST DISPLAYED'.
    DATA:  I_TITLE_EKPO TYPE LVC_TITLE VALUE 'SECONDRY LIST DISPLAYED'.
    
    INITIALIZATION.
      V_REPID = SY-REPID.
      PERFORM BUILD_FIELDCATLOG.
      PERFORM EVENT_CALL.
      PERFORM POPULATE_EVENT.
    
    START-OF-SELECTION.
      PERFORM DATA_RETRIEVAL.
      PERFORM BUILD_LISTHEADER USING IT_LISTHEADER.
      PERFORM DISPLAY_ALV_REPORT.
    
    *&--------------------------------------------------------------------*
    *&      Form  BUILD_FIELDCATLOG
    *&--------------------------------------------------------------------*
    *       Fieldcatalog has all the field details from ekko
    *---------------------------------------------------------------------*
    FORM BUILD_FIELDCATLOG.
      WA_FIELDCAT-TABNAME = 'IT_EKKO'.
      WA_FIELDCAT-FIELDNAME = 'EBELN'.
      WA_FIELDCAT-SELTEXT_M = 'PO NO.'.
      APPEND WA_FIELDCAT TO I_FIELDCAT.
      CLEAR WA_FIELDCAT.
    
      WA_FIELDCAT-TABNAME = 'IT_EKKO'.
      WA_FIELDCAT-FIELDNAME = 'AEDAT'.
      WA_FIELDCAT-SELTEXT_M = 'DATE.'.
      APPEND WA_FIELDCAT TO I_FIELDCAT.
      CLEAR WA_FIELDCAT.
    
      WA_FIELDCAT-TABNAME = 'IT_EKKO'.
      WA_FIELDCAT-FIELDNAME = 'BUKRS'.
      WA_FIELDCAT-SELTEXT_M = 'COMPANY CODE'.
      APPEND WA_FIELDCAT TO I_FIELDCAT.
      CLEAR WA_FIELDCAT.
    
    WA_FIELDCAT-TABNAME = 'IT_EKKO'.
      WA_FIELDCAT-FIELDNAME = 'BUKRS'.
      WA_FIELDCAT-SELTEXT_M = 'DOCMENT TYPE'.
      APPEND WA_FIELDCAT TO I_FIELDCAT.
      CLEAR WA_FIELDCAT.
    
    WA_FIELDCAT-TABNAME = 'IT_EKKO'.
      WA_FIELDCAT-FIELDNAME = 'LIFNR'.
      WA_FIELDCAT-NO_OUT    = 'X'.
      WA_FIELDCAT-SELTEXT_M = 'VENDOR CODE'.
      APPEND WA_FIELDCAT TO I_FIELDCAT.
      CLEAR WA_FIELDCAT.
    
    
    ENDFORM.                    "BUILD_FIELDCATLOG
    
    *&--------------------------------------------------------------------*
    *&      Form  EVENT_CALL
    *&--------------------------------------------------------------------*
    *   we get all events - TOP OF PAGE or USER COMMAND in table v_events
    *---------------------------------------------------------------------*
    FORM EVENT_CALL.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
       EXPORTING
         I_LIST_TYPE           = 0
       IMPORTING
         ET_EVENTS             = V_EVENTS
    *  EXCEPTIONS
    *    LIST_TYPE_WRONG       = 1
    *    OTHERS                = 2
                .
      IF SY-SUBRC <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    "EVENT_CALL
    
    *&--------------------------------------------------------------------*
    *&      Form  POPULATE_EVENT
    *&--------------------------------------------------------------------*
    *      Events populated for TOP OF PAGE & USER COMAND
    *---------------------------------------------------------------------*
    FORM POPULATE_EVENT.
      READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'TOP_OF_PAGE'.
      IF SY-SUBRC EQ 0.
        WA_EVENT-FORM = 'TOP_OF_PAGE'.
        MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =
    WA_EVENT-FORM.
      ENDIF.
    
      READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'USER_COMMAND'.
      IF SY-SUBRC EQ 0.
        WA_EVENT-FORM = 'USER_COMMAND'.
        MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =
    WA_EVENT-NAME.
      ENDIF.
    ENDFORM.                    "POPULATE_EVENT
    
    
    *&--------------------------------------------------------------------*
    *&      Form  data_retrieval
    *&--------------------------------------------------------------------*
    *   retreiving values from the database table ekko
    *---------------------------------------------------------------------*
    FORM DATA_RETRIEVAL.
      SELECT EBELN AEDAT BUKRS BSART LIFNR FROM EKKO INTO TABLE IT_EKKO.
    
    ENDFORM.                    "data_retrieval
    *&--------------------------------------------------------------------*
    *&      Form  bUild_listheader
    *&--------------------------------------------------------------------*
    *       text
    *---------------------------------------------------------------------*
    *      -->I_LISTHEADEtext
    *---------------------------------------------------------------------*
    FORM BUILD_LISTHEADER USING I_LISTHEADER TYPE SLIS_T_LISTHEADER.
      DATA HLINE TYPE SLIS_LISTHEADER.
      HLINE-INFO = 'this is my first alv pgm'.
      HLINE-TYP = 'H'.
    ENDFORM.                    "build_listheader
    
    *&--------------------------------------------------------------------*
    *&      Form  display_alv_report
    *&--------------------------------------------------------------------*
    *       text
    *---------------------------------------------------------------------*
    FORM DISPLAY_ALV_REPORT.
      V_REPID = SY-REPID.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
         I_CALLBACK_PROGRAM                = V_REPID
    *   I_CALLBACK_PF_STATUS_SET          = ' '
         I_CALLBACK_USER_COMMAND           = 'USER_COMMAND'
         I_CALLBACK_TOP_OF_PAGE            = 'TOP_OF_PAGE'
         I_GRID_TITLE                      = I_TITLE_EKKO
    *   I_GRID_SETTINGS                   =
    *   IS_LAYOUT                         = ALV_LAYOUT
         IT_FIELDCAT                       = I_FIELDCAT[]
    *   IT_EXCLUDING                      =
    *   IT_SPECIAL_GROUPS                 =
    *   IT_SORT                           =
    *   IT_FILTER                         =
    *   IS_SEL_HIDE                       =
    *     i_default                         = 'ZLAY1'
         I_SAVE                            = 'A'
    *     is_variant                        = i_variant
         IT_EVENTS                         = V_EVENTS
        TABLES
          T_OUTTAB                          = IT_EKKO
    * EXCEPTIONS
    *   PROGRAM_ERROR                     = 1
    *   OTHERS                            = 2
                .
      IF SY-SUBRC <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    "display_alv_report
    
    
    
    
    *&--------------------------------------------------------------------*
    *&      Form  TOP_OF_PAGE
    *&--------------------------------------------------------------------*
    *       text
    *---------------------------------------------------------------------*
    FORM TOP_OF_PAGE.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          IT_LIST_COMMENTARY       = IT_LISTHEADER
    *    i_logo                   =
    *    I_END_OF_LIST_GRID       =
                .
    
    ENDFORM.                    "TOP_OF_PAGE
    
    *&--------------------------------------------------------------------*
    *&      Form  USER_COMMAND
    *&--------------------------------------------------------------------*
    *       text
    *---------------------------------------------------------------------*
    *      -->R_UCOMM    text
    *      -->,          text
    *      -->RS_SLEFIELDtext
    *---------------------------------------------------------------------*
    FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
    RS_SELFIELD TYPE SLIS_SELFIELD.
      CASE R_UCOMM.
        WHEN '&IC1'.
          READ TABLE IT_EKKO INTO WA_EKKO INDEX RS_SELFIELD-TABINDEX.
          PERFORM BUILD_FIELDCATLOG_EKPO.
          PERFORM EVENT_CALL_EKPO.
          PERFORM POPULATE_EVENT_EKPO.
          PERFORM DATA_RETRIEVAL_EKPO.
          PERFORM BUILD_LISTHEADER_EKPO USING IT_LISTHEADER.
          PERFORM DISPLAY_ALV_EKPO.
      ENDCASE.
    ENDFORM.                    "user_command
    *&--------------------------------------------------------------------*
    *&      Form  BUILD_FIELDCATLOG_EKPO
    *&--------------------------------------------------------------------*
    *       text
    *---------------------------------------------------------------------*
    FORM BUILD_FIELDCATLOG_EKPO.
    
      WA_FIELDCAT-TABNAME = 'IT_EKPO'.
      WA_FIELDCAT-FIELDNAME = 'EBELN'.
      WA_FIELDCAT-SELTEXT_M = 'PO NO.'.
      APPEND WA_FIELDCAT TO I_FIELDCAT.
      CLEAR WA_FIELDCAT.
      WA_FIELDCAT-TABNAME = 'IT_EKPO'.
      WA_FIELDCAT-FIELDNAME = 'EBELP'.
      WA_FIELDCAT-SELTEXT_M = 'LINE NO'.
      APPEND WA_FIELDCAT TO I_FIELDCAT.
      CLEAR WA_FIELDCAT.
      WA_FIELDCAT-TABNAME = 'I_EKPO'.
      WA_FIELDCAT-FIELDNAME = 'MATNR'.
      WA_FIELDCAT-SELTEXT_M = 'MATERIAL NO.'.
      APPEND WA_FIELDCAT TO I_FIELDCAT.
      CLEAR WA_FIELDCAT.
    WA_FIELDCAT-TABNAME = 'I_EKPO'.
      WA_FIELDCAT-FIELDNAME = 'MENGE'.
      WA_FIELDCAT-SELTEXT_M = 'QUANTITY'.
      APPEND WA_FIELDCAT TO I_FIELDCAT.
      CLEAR WA_FIELDCAT.
    
    WA_FIELDCAT-TABNAME = 'I_EKPO'.
      WA_FIELDCAT-FIELDNAME = 'MEINS'.
      WA_FIELDCAT-SELTEXT_M = 'UOM'.
      APPEND WA_FIELDCAT TO I_FIELDCAT.
      CLEAR WA_FIELDCAT.
    
    WA_FIELDCAT-TABNAME = 'I_EKPO'.
      WA_FIELDCAT-FIELDNAME = 'NETPR'.
      WA_FIELDCAT-SELTEXT_M = 'PRICE'.
      APPEND WA_FIELDCAT TO I_FIELDCAT.
      CLEAR WA_FIELDCAT.
    
    
    ENDFORM.                    "BUILD_FIELDCATLOG_EKPO
    
    *&--------------------------------------------------------------------*
    *&      Form  event_call_ekpo
    *&--------------------------------------------------------------------*
    *   we get all events - TOP OF PAGE or USER COMMAND in table v_events
    *---------------------------------------------------------------------*
    FORM EVENT_CALL_EKPO.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
       EXPORTING
         I_LIST_TYPE           = 0
       IMPORTING
         ET_EVENTS             = V_EVENTS
    * EXCEPTIONS
    *   LIST_TYPE_WRONG       = 1
    *   OTHERS                = 2
                .
      IF SY-SUBRC <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    "event_call_ekpo
    
    
    *&--------------------------------------------------------------------*
    *&      Form  POPULATE_EVENT
    *&--------------------------------------------------------------------*
    *        Events populated for TOP OF PAGE & USER COMAND
    *---------------------------------------------------------------------*
    FORM POPULATE_EVENT_EKPO.
      READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'TOP_OF_PAGE'.
      IF SY-SUBRC EQ 0.
        WA_EVENT-FORM = 'TOP_OF_PAGE'.
        MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =
    WA_EVENT-FORM.
      ENDIF.
    
      ENDFORM.                    "POPULATE_EVENT
    
    *&--------------------------------------------------------------------*
    *&      Form  TOP_OF_PAGE
    *&--------------------------------------------------------------------*
    *       text
    *---------------------------------------------------------------------*
    FORM F_TOP_OF_PAGE.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          IT_LIST_COMMENTARY       = IT_LISTHEADER
    *    i_logo                   =
    *    I_END_OF_LIST_GRID       =
                .
    
    ENDFORM.                    "TOP_OF_PAGE
    
    *&--------------------------------------------------------------------*
    *&      Form  USER_COMMAND
    *&--------------------------------------------------------------------*
    *       text
    *---------------------------------------------------------------------*
    *      -->R_UCOMM    text
    *      -->,          text
    *      -->RS_SLEFIELDtext
    *---------------------------------------------------------------------*
    
    *retreiving values from the database table ekko
    FORM DATA_RETRIEVAL_EKPO.
    SELECT EBELN EBELP MATNR MENGE MEINS NETPR FROM EKPO INTO TABLE IT_EKPO.
    ENDFORM.
    
    FORM BUILD_LISTHEADER_EKPO USING I_LISTHEADER TYPE SLIS_T_LISTHEADER.
    DATA: HLINE1 TYPE SLIS_LISTHEADER.
    HLINE1-TYP = 'H'.
    HLINE1-INFO = 'CHECKING PGM'.
    ENDFORM.
    
    
    FORM DISPLAY_ALV_EKPO.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
     EXPORTING
    *   I_INTERFACE_CHECK                 = ' '
    *   I_BYPASSING_BUFFER                = ' '
    *   I_BUFFER_ACTIVE                   = ' '
       I_CALLBACK_PROGRAM                = V_REPID
    *   I_CALLBACK_PF_STATUS_SET          = ' '
    *   I_CALLBACK_USER_COMMAND           = 'F_USER_COMMAND'
       I_CALLBACK_TOP_OF_PAGE            = '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_TITLE_EKPO
    *   I_GRID_SETTINGS                   =
    *   IS_LAYOUT                         =
       IT_FIELDCAT                       = I_FIELDCAT[]
    *   IT_EXCLUDING                      =
    *   IT_SPECIAL_GROUPS                 =
    *   IT_SORT                           =
    *   IT_FILTER                         =
    *   IS_SEL_HIDE                       =
    *   I_DEFAULT                         =
       I_SAVE                            = 'A'
    *   IS_VARIANT                        =
       IT_EVENTS                         = V_EVENTS
      TABLES
        T_OUTTAB                          = IT_EKPO
     EXCEPTIONS
       PROGRAM_ERROR                     = 1
       OTHERS                            = 2
              .
    IF SY-SUBRC <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    ENDFORM.

    Regards,

    Naveen.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Naveen,

      I have seen the answer u gave for the ALV with example using step by step explanation.

      Can you please provide such a material for Module pool Programming.

      It will be very very helpful

      Thanks fo rthe ALV u given n for the future helps.

      Bye,

      Nitin

  • avatar image
    Former Member
    Jul 13, 2007 at 09:30 AM

    Hi Rajarsi,

    Programming with the ABAP List Viewer:

    &#61548; 50% of the time spent on finding the right tables and

    table relationships (selection process)

    &#61548; 1% of the time spent on preparing field catalog and sort sequence information for the list viewer

    &#61548; 9% of the time spent on ‘fancy features’

    for interactive list events

    &#61548; no time spent on ‘looks’ and ‘feel’

    (column headings, sorting, etc.)

    &#61548; time savings >= 40% easily possible

    List Viewer Basics:

    &#61548; Implementation via function modules

    &#61550; REUSE_ALV_LIST_DISPLAY

    &#61559; ‘simple’ single level list

    &#61550; REUSE_ALV_HIERSEQ_LIST_DISPLAY

    &#61559; two level list with header and item data

    &#61550; REUSE_ALV_GRID_DISPLAY

    &#61559; Spreadsheet look and feel

    &#61550; REUSE_ALV*

    &#61559; utilities for list viewer

    Programming steps:

    &#61548; Declare data areas for list viewer

    &#61548; Declare internal table to store selected data

    &#61548; Select data into internal table

    &#61548; Build field catalog

    &#61548; Build sort catalog

    &#61548; Build event catalog

    &#61548; Start list viewer

    &#61548; Process call back events

    Declare data areas for list viewer:

    &#61548; 4.6

    &#61550; TYPE-POOLS: SLIS

    &#61550; DATA: DISVARIANT LIKE DISVARIANT,

    EVENTCAT TYPE SLIS_T_EVENT,

    EVENTCAT_LN LIKE LINE OF EVENTCAT,

    FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,

    FIELDCAT_LN LIKE LINE OF FIELDCAT,

    SORTCAT TYPE SLIS_T_SORTINFO_ALV,

    SORTCAT_LN LIKE LINE OF SORTCAT.

    &#61548; Use the standard include RPR_ALV_DATA

    &#61550; This include contains the above data declarations as well as the subroutines:

    &#61550; F4_DISPLAY_VARIANT (show F4 help for ALV variants)

    &#61559; Calls function REUSE_ALV_VARIANT_F4

    &#61550; CHECK_VARIANT_EXISTENCE (validate variant existence)

    Declare internal table to store selected data:

    &#61548; DATA: BEGIN OF IVBAP OCCURS 0,

    VBELN LIKE VBAP-VBELN,

    POSNR LIKE VBAP-POSNR,

    MATNR LIKE VBAP-MATNR,

    MATKL LIKE VBAP-MATKL,

    CHARG LIKE VBAP-CHARG,

    KWMENG LIKE VBAP-KWMENG,

    VRKME LIKE VBAP-VRKME,

    ARKTX LIKE VBAP-ARKTX,

    END OF IVBAP.

    &#61548; Best practice is to create structure instead of declaring fields individually

    Select data into internal table:

    &#61548; SELECT VBELN POSNR MATNR …

    INTO CORRESPONDING FIELDS OF TABLE IVBAP

    FROM VBAP

    WHERE VBELN IN …

    AND MATNR IN ...

    Start list viewer:

    FORM START_LIST_VIEWER.

    DATA: PGM LIKE SY-REPID.

    PGM = SY-REPID.

    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

    EXPORTING

    I_CALLBACK_PROGRAM = PGM

    I_STRUCTURE_NAME = ’STRUCTURE_NAME'

    IT_FIELDCAT = FIELDCAT

    IT_SORT = SORTCAT

    I_SAVE = ’U’

    I_CALLBACK_USER_COMMAND = 'USER_COMMAND'

    TABLES

    T_OUTTAB = IVBAP

    EXCEPTIONS

    PROGRAM_ERROR = 1

    OTHERS = 2.

    ENDFORM.

    Reward points if u helpful

    Cheers,

    Govind.

    Add comment
    10|10000 characters needed characters exceeded