Skip to Content
author's profile photo Former Member
Former Member

ALV Interactive

Hi Friends.....

Iam Gopi give me some examples to work on ALV interactive. I worked on ALV and i dnt knw how to generate a alv interactive report......

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jul 27, 2008 at 02:46 AM
    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 27, 2008 at 08:08 AM

    go to Tcode se80 in it go to slis package and see all the program there you will get all example programs of alv programs

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jul 27, 2008 at 02:19 AM

    Interactive ALV Check the Below sample code..

    Observe the usercommand code.

    When i click on Ordernumber and i am taking the value from SELFIELD-VALUE.

    or else you can read the table with selfield-tabindex and get the value and pass it to set parameter id.

    REPORT  ztest_alv.
     
    TYPE-POOLS:slis.
    DATA:it_fieldcat  TYPE  slis_t_fieldcat_alv,
         wa_field LIKE LINE OF it_fieldcat.
    DATA: BEGIN OF it_likp OCCURS 0,
           vbeln TYPE likp-vbeln,
          END OF it_likp.
     
    wa_field-fieldname = 'VBELN'.
    wa_field-tabname = 'IT_LIKP'.
    wa_field-hotspot = 'X'.
    APPEND wa_field TO it_fieldcat.
     
    SELECT vbeln FROM likp
    UP TO 10 ROWS
    INTO TABLE it_likp.
     
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
      EXPORTING
        i_callback_program      = sy-repid
        i_callback_user_command = 'USER_COMMAND'
        it_fieldcat             = it_fieldcat
      TABLES
        t_outtab                = it_likp
      EXCEPTIONS
        program_error           = 1.
     
    *&---------------------------------------------------------------------*
    *&      Form  user_Command
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *      -->UCOMM      text
    *      -->SELFIELD   text
    *----------------------------------------------------------------------*
    FORM user_command USING ucomm TYPE sy-ucomm
                        selfield TYPE slis_selfield.
      CASE ucomm.
     
        WHEN '&IC1'.
         IF selfield-fieldname = 'VBELN'.
          SET PARAMETER ID 'VL'  FIELD selfield-value.
          CALL TRANSACTION 'VL03N' AND SKIP FIRST SCREEN.
        ENDIF.
      ENDCASE.
     
    ENDFORM. "user_Command

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 27, 2008 at 08:17 AM

    go throught the following code

    *&---------------------------------------------------------------------*
    *& Report  ZHAI_SD_CUSTOMER_DETAILS_ALV
    *&
    *&---------------------------------------------------------------------*
    *&
    *&
    *&---------------------------------------------------------------------*
    
    REPORT  ZHAI_SD_CUSTOMER_DETAILS_ALV.
    
    TYPE-POOLS: SLIS.
    
    *--------------------------------
    *     TYPES DECLARATIONS
    *---------------------------------
    
    TABLES : KNA1.
    
    DATA : BEGIN OF IT_CUST OCCURS 0,
      KUNNR LIKE KNA1-KUNNR,
      NAME1 LIKE KNA1-NAME1,
      LAND1 LIKE KNA1-LAND1,
      ORT01 LIKE KNA1-ORT01,
      STRAS LIKE KNA1-STRAS,
      PSTLZ LIKE KNA1-PSTLZ,
           END OF IT_CUST.
    
    DATA:BEGIN OF IT_SALE OCCURS 0,
     VBELN LIKE VBAK-VBELN,"SALES DOC NO
     AUDAT LIKE VBAK-AUDAT,"DATE RECIEVED AND SENT
     AUART LIKE VBAK-AUART,"SALES DOC LIKE
     NETWR LIKE VBAK-NETWR,"NET VALUE IN DOC CURRENCY
     KUNNR LIKE VBAK-KUNNR,
          END OF IT_sale.
    
    TYPES: BEGIN OF TY_ITEM,
     VBELN TYPE VBAP-VBELN,
     POSNR TYPE VBAP-POSNR,"ITEM NO
     MATNR TYPE VBAP-MATNR,"MATERIAL NO
     CHARG TYPE VBAP-CHARG,"BATCH
     MATKL TYPE VBAP-MATKL,"MATERIAL GROUP
     MEINS TYPE VBAP-MEINS,"BASE UNIT OF MEASURE
    END OF TY_ITEM.
    
    SELECT-OPTIONS : S_KUNNR FOR KNA1-KUNNR.
    
    *-----------------------------------------
    *----------------
    *      INTERNAL TABLES
    *-----------------------------------------
    *----------------
    
    DATA:
    *      IT_CUST  TYPE TABLE OF TY_CUST,
    *      IT_SALE  TYPE TABLE OF TY_SALE,
          IT_ITEM  TYPE TABLE OF TY_ITEM.
    
    *------------------------------------------------
    *---------------
    *                    INTERNAL TABLES FOR ALV
    *------------------------------------------------
    *---------------
    
    DATA: IT_FCAT   TYPE  SLIS_T_FIELDCAT_ALV,
          IT_FCAT1  TYPE  SLIS_T_FIELDCAT_ALV,
          IT_FCAT3  TYPE SLIS_T_FIELDCAT_ALV.
    
    DATA: IT_EVENTS TYPE TABLE OF   slis_alv_event,
          IT_EVENTS1 TYPE TABLE OF SLIS_ALV_EVENT,
          IT_EVENTS2 TYPE TABLE OF SLIS_ALV_EVENT.
    
    DATA: IT_LISTHEADER1 TYPE SLIS_T_LISTHEADER,
          IT_LISTHEADER TYPE TABLE OF slis_listheader,
          IT_LISTHEADER3 TYPE TABLE OF SLIS_LISTHEADER,
          IT_FOOTER TYPE TABLE OF SLIS_LISTHEADER.
    
    DATA: IT_SORT TYPE SLIS_T_SORTINFO_ALV,
          WA_SORT LIKE LINE OF IT_SORT.
    
    
    *------------------------------------------------
    *--------------
    *                    WORK AREAS FOR ALV
    *-------------------------------------------------
    *--------------
    
    DATA: WA_LAYOUT  TYPE SLIS_LAYOUT_ALV,
          WA_LAYOUT1 TYPE SLIS_LAYOUT_ALV,
          WA_FCAT    LIKE LINE OF IT_FCAT,
          WA_FCAT1   LIKE LINE OF IT_FCAT1,
          WA_FCAT3   LIKE LINE OF IT_FCAT3,
          WA_EVENTS  LIKE LINE OF IT_EVENTS,
          WA_EVENTS1 LIKE LINE OF IT_EVENTS,
          WA_EVENTS2 LIKE LINE OF IT_EVENTS.
    *---------------------------------------------
    *-------------
    *         WORK VARIABLES
    *-------------------------------------------------
    *-------------
    
    DATA: W_REPID TYPE SY-REPID,
          W_KUNNR TYPE KNA1-KUNNR.
    
    *$*$**-----------------------------
    *--------------------
    *    WORK  AREAS
    *----------------------------------
    *---------------
    
    
    *------------------------------
    *     MACROS
    *------------------------------
    
    DEFINE ADD_FCAT1..
    WA_FCAT1-COL_POS = &1.
    WA_FCAT1-FIELDNAME = &2.
    WA_FCAT1-TABNAME = &3.
    WA_FCAT1-REF_TABNAME = &4.
    WA_FCAT1-KEY = &5.
    WA_FCAT1-DO_SUM = &6.
    WA_FCAT1-HOTSPOT = &7.
    WA_FCAT1-EMPHASIZE = &8.
    APPEND WA_FCAT1 TO IT_FCAT1.
    
    END-OF-DEFINITION.
    
    START-OF-SELECTION.
    
      PERFORM F_GET_DATA.
    
      PERFORM F_BUILD_FCAT.
    
      PERFORM F_GET_EVENTS.
    
      PERFORM F_BUILD_LAYOUT USING WA_LAYOUT.
    
      PERFORM F_GET_DISPLAY.
    *&-------------------------
    *&      Form  F_GET_DATA
    *&-----------------------
    FORM F_GET_DATA .
    
     SELECT   KUNNR
              NAME1
              LAND1
              ORT01
              STRAS
              PSTLZ FROM KNA1
              INTO TABLE
     IT_CUST WHERE KUNNR IN S_KUNNR.
    
    ENDFORM.                    " F_GET_DATA
    *&----------------------------------
    *&      Form  F_GET_DISPLAY
    *&----------------------------------
    *       text
    *-----------------------------------
    *  -->  p1        text
    *  <--  p2        text
    *-----------------------------------
    FORM F_GET_DISPLAY .
    CLEAR W_REPID.
     MOVE SY-REPID TO W_REPID.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
         I_CALLBACK_PROGRAM                = w_repid
    *   I_CALLBACK_PF_STATUS_SET          = ' '
    *   I_CALLBACK_USER_COMMAND           = ' '
         I_CALLBACK_TOP_OF_PAGE            = 'F_TOP_OF_PAGE'
    *   I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
    *   I_CALLBACK_HTML_END_OF_LIST       = ' '
    *   I_STRUCTURE_NAME                  =
    *   I_BACKGROUND_ID                   = 'DUCK'
    *   I_GRID_TITLE                      =
    *   I_GRID_SETTINGS                   =
       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_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_CUST
    * 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.                    " F_GET_DISPLAY
    *&----------------------------
    *&      Form  F_GET_EVENTS
    *&----------------------------
    *       text
    *-----------------------------
    *  -->  p1        text
    *  <--  p2        text
    *-----------------------------
    FORM F_GET_EVENTS .
      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.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    
      SORT IT_EVENTS.
    READ TABLE IT_EVENTS INTO WA_EVENTS
     WITH KEY NAME = 'TOP_OF_PAGE' BINARY SEARCH.
    
     IF SY-SUBRC EQ 0.
    
    WA_EVENTS-FORM = 'F_TOP_OF_PAGE'.
    
     MODIFY  IT_EVENTS  INDEX SY-TABIX FROM
    
     WA_EVENTS TRANSPORTING FORM.
    
      ENDIF.
    
    READ TABLE IT_EVENTS INTO WA_EVENTS
    WITH KEY NAME = 'USER_COMMAND' BINARY SEARCH.
    
    IF SY-SUBRC EQ 0.
    
    WA_EVENTS-FORM = 'F_USER_COMMAND'.
    
    MODIFY IT_EVENTS FROM WA_EVENTS INDEX
    SY-TABIX TRANSPORTING FORM.
    
    READ TABLE IT_EVENTS INTO WA_EVENTS
    
     WITH KEY NAME = 'USER_COMMAND' BINARY SEARCH.
    
     ENDIF.
    READ TABLE IT_EVENTS INTO WA_EVENTS WITH
     KEY NAME = 'END_OF_PAGE' BINARY SEARCH.
    
    IF SY-SUBRC EQ 0.
    
    WA_EVENTS-FORM = 'F_END_OF_PAGE'.
    
    MODIFY IT_EVENTS FROM WA_EVENTS
    INDEX SY-TABIX TRANSPORTING FORM.
    ENDIF.
    
    ENDFORM.                    "F_GET_EVENTS
    
    *&---------------------------------------
    *&      Form  F_BUILD_LAYOUT
    *&---------------------------------------
    FORM F_BUILD_LAYOUT  USING P_WA_LAYOUT LIKE WA_LAYOUT .
    CLEAR P_WA_LAYOUT.
    P_WA_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
    *P_WA_LAYOUT-F2CODE = '&ETA'.
    *p_wa_layout-detail_popup = 'X'.
    P_WA_LAYOUT-DETAIL_TITLEBAR = 'ALV REPORT'.
    *P_WA_LAYOUT-CONFIRMATION_PROMPT  = 'X'.
    ENDFORM.                    " F_BUILD_LAYOUT
    *&-----------------------------
    *&      Form  F_TOP_OF_PAGE
    *&-----------------------------
    FORM F_TOP_OF_PAGE .
    refresh it_listheader.
    
      DATA: LS_LIST TYPE SLIS_LISTHEADER.
    
      LS_LIST-TYP = 'H'.
    
      LS_LIST-INFO = TEXT-004.
    
      APPEND LS_LIST TO IT_LISTHEADER.
    
    
      LS_LIST-typ = 'S'.
      LS_LIST-key = 'Date: '.
      CONCATENATE sy-datum+6(2) '.'
      sy-datum+4(2) '.'
      sy-datum(4) INTO LS_LIST-info. "todays date
      append LS_LIST to IT_LISTHEADER.
      clear: LS_LIST.
    
      LS_LIST-TYP = 'S'.
      LS_LIST-KEY = 'DEVELOPED:'.
      LS_LIST-INFO = SY-UNAME.
      APPEND LS_LIST TO IT_LISTHEADER.
      CLEAR LS_LIST.
    
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          IT_LIST_COMMENTARY = IT_LISTHEADER
          I_LOGO             = 'GLOBAL'.
    
    ENDFORM.                    " F_TOP_OF_PAGE
    *&------------------------------
    *&      Form  F_BUILD_FCAT
    *&------------------------------
    FORM F_BUILD_FCAT .
    CLEAR: W_REPID,
           IT_FCAT.
      MOVE SY-REPID TO W_REPID.
    
      CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
       EXPORTING
         I_PROGRAM_NAME               = W_REPID
         I_INTERNAL_TABNAME           = 'IT_CUST'
         I_INCLNAME                   = W_REPID
        CHANGING
          CT_FIELDCAT                  = IT_FCAT
     EXCEPTIONS
       INCONSISTENT_INTERFACE       = 1
       PROGRAM_ERROR                = 2
       OTHERS                       = 3
                .
      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.                    " F_BUILD_FCAT
    *&---------------------------
    *&      Form  F_USER_COMMAND
    *&---------------------------
    FORM F_USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
                              RS_SELFIELD TYPE SLIS_SELFIELD.
    
    
    CASE  R_UCOMM.
    
     WHEN '&IC1'.
    
    IF RS_SELFIELD-FIELDNAME = 'KUNNR'.
    
    READ TABLE IT_CUST
    
     INDEX RS_SELFIELD-TABINDEX.
    
     MOVE rs_selfield-value TO W_KUNNR.
    
     IF IT_CUST IS NOT INITIAL.
    
       PERFORM F_GET_SECONDARY_DATA.
    
       PERFORM F_BUILD_FCAT1.
    
       PERFORM F_BUILD_EVENTS.
    
       PERFORM F_GET_SORT.
    
    
    
       PERFORM F_BUILD_LAYOUT1.
    
      PERFORM F_GET_DISPLAY1.
    
    
     ENDIF.
    
      ENDIF.
    
      ENDCASE.
    
    ENDFORM.                    " F_USER_COMMAND
    *&------------------------------------
    *&      Form  F_GET_SECONDARY_DATA
    *&------------------------------------
    FORM F_GET_SECONDARY_DATA .
    
    data:v_data.
    
     SELECT  VBELN
              AUDAT
              AUART
              NETWR
     KUNNR FROM VBAK INTO TABLE IT_SALE
     WHERE KUNNR EQ IT_CUST-KUNNR.
      IF IT_SALE[] IS INITIAL .
       CALL FUNCTION 'POPUP_TO_CONFIRM'
         EXPORTING
          TITLEBAR                    = SY-REPID
    *      DIAGNOSE_OBJECT             = ' '
           TEXT_QUESTION               = 'NO SALES FOR THIS CUSTOMER'
    *      TEXT_BUTTON_1               = 'Ja'(001)
    *      ICON_BUTTON_1               = ' '
    *      TEXT_BUTTON_2               = 'Nein'(002)
    *      ICON_BUTTON_2               = ' '
          DEFAULT_BUTTON              = '1'
          DISPLAY_CANCEL_BUTTON       = 'X'
    *      USERDEFINED_F1_HELP         = ' '
    *      START_COLUMN                = 25
    *      START_ROW                   = 6
    *      POPUP_TYPE                  =
    *      IV_QUICKINFO_BUTTON_1       = ' '
    *      IV_QUICKINFO_BUTTON_2       = ' '
        IMPORTING
          ANSWER                      = v_data
    *    TABLES
    *      PARAMETER                   =
        EXCEPTIONS
          TEXT_NOT_FOUND              = 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.
    
    case v_data.
    
    when '2'.
    
    leave screen.
    
    when 'A'.
    
    leave to screen '0'.
    .
    
    endcase.
    
    
    
      ENDIF.
    ENDFORM.                    " F_GET_SECONDARY_DATA
    *&-----------------------------
    *&      Form  F_BUILD_FCAT1
    *&-----------------------------
    FORM F_BUILD_FCAT1 .
    
    REFRESH IT_FCAT1.
    
    CLEAR WA_FCAT1.
    
    ADD_FCAT1:
    
    
    
    '1' 'VBELN' 'VBAK' 'VBAK' 'X' ' ' 'X' 'C500',
    '2' 'AUDAT' 'VBAK' 'VBAK' ' ' ' ' ' ' 'C400',
    '3' 'AUART' 'VBAK' 'VBAK' ' ' ' ' ' ' 'C100',
    '4' 'NETWR' 'VBAK' 'VBAK' ' ' 'X' ' ' 'C300'.
    
    
    
    
    ENDFORM.                    " F_BUILD_FCAT1
    *&---------------------------------------------------------------------*
    *&      Form  F_GET_DISPLAY1
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *  -->  p1        text
    *  <--  p2        text
    *----------------------------------------------------------------------*
    FORM F_GET_DISPLAY1 .
    
    
    
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
         I_CALLBACK_PROGRAM                = SY-REPID
    *   I_CALLBACK_PF_STATUS_SET          = ' '
        I_CALLBACK_USER_COMMAND           =  'F_USER_COMMAND1'
         I_CALLBACK_TOP_OF_PAGE            = 'F_TOP_OF_PAGE1'
    *   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_FCAT1
    *   IT_EXCLUDING                      =
    *   IT_SPECIAL_GROUPS                 =
       IT_SORT                            = IT_SORT
    *   IT_FILTER                         =
    *   IS_SEL_HIDE                       =
    *   I_DEFAULT                         = 'X'
    *   I_SAVE                            = ' '
    *   IS_VARIANT                        =
         IT_EVENTS                         = IT_EVENTS1
    *   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_SALE
    * 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.                    " F_GET_DISPLAY1
    *&------------------------------------------
    *&      Form  F_BUILD_EVENTS
    *&--------------------------------------*
    FORM F_BUILD_EVENTS .
    
    clear wa_events1.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
       EXPORTING
         I_LIST_TYPE           = 0
       IMPORTING
         ET_EVENTS             = IT_EVENTS1.
    * 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.
    
      SORT IT_EVENTS1.
      read table It_events1 with key name = 'TOP_OF_PAGE'
      into WA_eventS1.
      if sy-subrc = 0.
        move 'F_TOP_OF_PAGE1' to WA_EventS1-form.
        append WA_eventS1 to it_events1.
      endif.
      READ TABLE IT_EVENTS WITH KEY NAME = 'USER_COMMAND'
      INTO WA_EVENTS1.
      IF SY-SUBRC = 0.
      MOVE 'F_USER_COMMAND1' TO WA_EVENTS1-FORM.
      APPEND WA_EVENTS1 TO IT_EVENTS1.
      ENDIF.
    *READ TABLE IT_EVENTS WITH KEY NAME = 'SUBTOTAL_TEXT'
    *  INTO WA_EVENTS1.
    *  IF SY-SUBRC = 0.
    *  MOVE 'F_SUBTOTAL_TEXT' TO WA_EVENTS1-FORM.
    *  APPEND WA_EVENTS1 TO IT_EVENTS1.
    *  ENDIF.
    *
    
    ENDFORM.                    " F_BUILD_EVENTS
    *&-----------------------------------
    *&      Form  F_TOP_OF_PAGE1
    *&------------------------------------
    FORM F_TOP_OF_PAGE1 .
    DATA: LS_HEADER TYPE SLIS_LISTHEADER.
    REFRESH : IT_LISTHEADER1.
      LS_HEADER-TYP = 'H'.
      LS_HEADER-INFO = 'SALES ORDER DETAILS FOR CUSTOMER'.
      APPEND LS_HEADER TO it_listheader1.
      CLEAR LS_HEADER.
      LS_HEADER-TYP  = 'S'.
      LS_HEADER-KEY = 'CUSTOMER NO:'.
      LS_HEADER-INFO = W_KUNNR.
      APPEND LS_HEADER TO IT_LISTHEADER1.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          IT_LIST_COMMENTARY       = IT_LISTHEADER1
         I_LOGO                   = 'DUCK'
    *   I_END_OF_LIST_GRID       =
    *   I_ALV_FORM               =
                .
    ENDFORM.                    " F_TOP_OF_PAGE
    *&---------------------------------------------------------------------*
    *&      Form  F_END_OF_PAGE
    *&---------------------------------------------------------------------*
    
    *       text
    *----------------------------------------------------------------------*
    *  -->  p1        text
    *  <--  p2        text
    *----------------------------------------------------------------------*
    FORM F_END_OF_PAGE .
    DATA:LS_FOOTER TYPE SLIS_LISTHEADER.
    
    LS_FOOTER-TYP = 'S'.
    LS_FOOTER-KEY = SY-UNAME.
    LS_FOOTER-INFO = 'DEVELOPED BY:'.
    APPEND LS_FOOTER TO IT_FOOTER.
    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
      EXPORTING
        IT_LIST_COMMENTARY       = IT_FOOTER
            .
    ENDFORM.                    " F_END_OF_PAG
    *&---------------------------------------------------------------------*
    *&      Form  F_USER_COMMAND1
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *  -->  p1        text
    *  <--  p2        text
    *----------------------------------------------------------------------*
    FORM F_USER_COMMAND1 USING R_UCOMM LIKE SY-UCOMM
                               RS_SELFIELD TYPE SLIS_SELFIELD.
    
    CASE R_UCOMM.
    
    WHEN '&IC1'.
    
    READ TABLE IT_SALE INDEX RS_SELFIELD-TABINDEX.
    
    PERFORM F_GET_SECONDARY2.
    
    PERFORM F_GET_FCAT3 USING:
    'VBELN' '1' 'C' '12' 'SALES_DOC'   'M'  'VBAP' 'X' 'C51' ' ',
    'POSNR' '2' ' '  '5' 'ITEM_NO'      'M'  'VBAP' ' ' 'C61' ' ',
    'MATNR' '3' ' '  '12' 'MATERIAL_NO' 'M'  'VBAP' ' ' 'C71' ' ',
    'CHARG' '4' ' ' '10' 'BATCH_NO'    'M'  'VBAP' ' ' 'C41' ' ',
    'MATKL' '5' ' ' '10' 'MAT_GROUP'   'M'  'VBAP' ' ' 'C31' ' ',
    'MEINS' '6' ' ' '12' 'BASE_UNIT'   'M'  'VBAP' ' ' 'C21' 'X' .
    
    
    PERFORM F_GET_EVENTS2 USING WA_EVENTS2
                         CHANGING IT_EVENTS2.
    
    
    
    PERFORM F_GET_DISPLAY3.
    
    REFRESH IT_FCAT3.
    ENDCASE.
    
    ENDFORM.                    " F_USER_COMMAND1
    *&---------------------------------------------------------------------*
    *&      Form  F_GET_SECONDARY2
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *  -->  p1        text
    *  <--  p2        text
    *----------------------------------------------------------------------*
    FORM F_GET_SECONDARY2 .
    
    SELECT VBELN
           POSNR
           MATNR
           MATKL
           MEINS
           FROM VBAP INTO
           TABLE IT_ITEM WHERE
           VBELN EQ IT_SALE-VBELN.
    
    IF SY-DBCNT EQ 0.
    MESSAGE E000(ZHAI) WITH TEXT-KO1.
    ENDIF.
    
    ENDFORM.                    " F_GET_SECONDARY2
    *&---------------------------------------------------------------------*
    *&      Form  F_GET_DISPLAY3
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *  -->  p1        text
    *  <--  p2        text
    *----------------------------------------------------------------------*
    FORM F_GET_DISPLAY3 .
    
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
     EXPORTING
       I_CALLBACK_PROGRAM                = SY-REPID
       I_CALLBACK_PF_STATUS_SET          = 'F_PF_STATUS'
    *   I_CALLBACK_USER_COMMAND           = ' '
    *   I_CALLBACK_TOP_OF_PAGE            = 'F_TOP_OF_PAGE3'
       I_CALLBACK_HTML_TOP_OF_PAGE       = 'F_TOP_OF_PAGE3'
    *   I_CALLBACK_HTML_END_OF_LIST       = ' '
    *   I_STRUCTURE_NAME                  =
    *   I_BACKGROUND_ID                   = ' '
    *   I_GRID_TITLE                      =
    *   I_GRID_SETTINGS                   =
       IS_LAYOUT                         = WA_LAYOUT1
       IT_FIELDCAT                       = IT_FCAT3
    *   IT_EXCLUDING                      =
    *   IT_SPECIAL_GROUPS                 =
    *   IT_SORT                           = IT_SORT
    *   IT_FILTER                         =
    *   IS_SEL_HIDE                       =
    *   I_DEFAULT                         = 'X'
    *   I_SAVE                            = ' '
    *   IS_VARIANT                        =
       IT_EVENTS                         = IT_EVENTS2
    *   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_ITEM
    * 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.                    " F_GET_DISPLAY3
    *&---------------------------------------------------------------------
    *
    *&      Form  F_GET_FCAT3
    *&---------------------------------------------------------------------
    *
    FORM F_GET_FCAT3  USING    VALUE(P1)
                               VALUE(P2)
                               VALUE(P3)
                               VALUE(P4)
                               VALUE(P5)
                               VALUE(P6)
                               VALUE(P7)
                               VALUE(P8)
                               VALUE(P9)
                              VALUE(P10).
    CLEAR WA_FCAT3.
    
    
    
      WA_FCAT3-FIELDNAME = P1.
      WA_FCAT3-COL_POS = P2.
      WA_FCAT3-JUST = P3.
      WA_FCAT3-OUTPUTLEN = P4.
      WA_FCAT3-SELTEXT_M  = P5.
      WA_FCAT3-DDICTXT = P6.
      WA_FCAT3-REF_TABNAME = P7.
      WA_FCAT3-HOTSPOT = P8.
      WA_FCAT3-EMPHASIZE = P9.
      WA_FCAT3-DO_SUM  = P10.
      APPEND WA_FCAT3 TO IT_FCAT3.
    
    
    ENDFORM.                    " F_GET_FCAT3
    *&---------------------------------------------------------------------*
    *&      Form  F_BUILD_LAYOUT1
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *  -->  p1        text
    *  <--  p2        text
    *----------------------------------------------------------------------*
    FORM F_BUILD_LAYOUT1 .
    WA_LAYOUT1-totals_text = 'TOTAL'.
    wa_layout1-detail_popup = 'X'.
    
    ENDFORM.                    " F_BUILD_LAYO
    *&---------------------------------------------------------------------*
    *&      Form  F_GET_EVENTS2
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *      -->P_IT_EVENTS2  text
    *      <--P_WA_EVENTS2  text
    *----------------------------------------------------------------------*
    FORM F_GET_EVENTS2  USING    VALUE(P_WA_EVENTS2) LIKE WA_EVENTS2
                        CHANGING P_IT_EVENTS2 LIKE IT_EVENTS2.
    
    P_WA_EVENTS2-NAME = 'HTML_TOP_OF_PAGE'.
    P_WA_EVENTS2-FORM = 'F_TOP_OF_PAGE3'.
    APPEND P_WA_EVENTS2 TO P_IT_EVENTS2.
    CLEAR P_WA_EVENTS2.
    
    P_WA_EVENTS2-NAME = 'PF_STATUS'.
    P_WA_EVENTS2-FORM = 'F_PF_STATUS'.
    APPEND P_WA_EVENTS2 TO P_IT_EVENTS2.
    CLEAR P_WA_EVENTS2.
    
    P_WA_EVENTS2-NAME = 'USER_COMMAND'.
    P_WA_EVENTS2-FORM = 'F_USER_COMMAND3'.
    APPEND P_WA_EVENTS2 TO P_IT_EVENTS2.
    CLEAR P_WA_EVENTS2.
    ENDFORM.                    " F_GET_EVENTS2
    *&---------------------------------------------------------------------*
    *&      Form  F_TOP_OF_PAGE3
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *  -->  p1        text
    *  <--  p2        text
    *----------------------------------------------------------------------*
    FORM F_TOP_OF_PAGE3 USING DOCUMENT TYPE REF TO cl_dd_document .
    
    data : link_area type ref to cl_dd_area,
           picture_area type ref to cl_dd_area.
    
    
    CALL METHOD DOCUMENT->ADD_TEXT
      EXPORTING
        TEXT          = 'ALV REPORT'
    *    TEXT_TABLE    =
    *    FIX_LINES     =
    *    SAP_STYLE     =
        SAP_COLOR     = cl_dd_area=>list_background_int
        SAP_FONTSIZE  = 'LARGE'
        SAP_FONTSTYLE = 'TIMES'
        SAP_EMPHASIS  = 'STRONG'
    *    STYLE_CLASS   =
    *  CHANGING
    *    DOCUMENT      =
        .
    CALL METHOD DOCUMENT->NEW_LINE.
    CALL METHOD DOCUMENT->ADD_PICTURE
      EXPORTING
        PICTURE_ID       = 'LOGO1'
        WIDTH            = '10%'
    
        .
    ENDFORM.                    " F_TOP_OF_PAGE3
    *&---------------------------------------------------------------------*
    *&      Form  F_GET_SORT
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *  -->  p1        text
    *  <--  p2        text
    *----------------------------------------------------------------------*
    FORM F_GET_SORT .
    
    WA_SORT-FIELDNAME = 'NETWR'.
    WA_SORT-SPOS  = 4.
    WA_SORT-UP = 'X'.
    WA_SORT-SUBTOT = 'X'.
    APPEND WA_SORT TO IT_SORT.
    
    ENDFORM.                    " F_GET_SORT
    *&---------------------------------------------------------------------*
    *&      Form  F_PF_STATUS
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *  -->  p1        text
    *  <--  p2        text
    *----------------------------------------------------------------------*
    FORM F_PF_STATUS USING RS_EXTAB TYPE SLIS_T_EXTAB .
    
    SET PF-STATUS 'ZHAIALV' EXCLUDING RS_EXTAB.
    
    ENDFORM.                    " F_PF_STATUS
    *&---------------------------------------------------------------------*
    *&      Form  F_USER_COMMAND3
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *  -->  p1        text
    *  <--  p2        text
    *----------------------------------------------------------------------*
    FORM F_USER_COMMAND3 USING R_UCOMM LIKE SY-UCOMM
                               RS_SELFIELD TYPE SLIS_SELFIELD.
    CASE R_UCOMM.
    
    WHEN '&SALE'.
    IF RS_SELFIELD-FIELDNAME = 'VBELN'.
    
    SET parameter ID 'AUN' FIELD rs_selfield-value.
    
    CALL TRANSACTION 'VA02' AND SKIP FIRST SCREEN.
    
    ENDIF.
    
    WHEN '&MAT'.
    
    IF RS_SELFIELD-FIELDNAME = 'MATNR'.
    
    SET PARAMETER ID 'MAT' FIELD RS_SELFIELD-VALUE.
    
    CALL TRANSACTION 'MM02' AND SKIP FIRST SCREEN.
    
    ENDIF.
    
    ENDCASE.
    
    ENDFORM.                    " F_USER_COMMAND3

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 27, 2008 at 08:28 AM

    Hi,

    Please refer the link below:

    http://www.sapdev.co.uk/reporting/alv/alvgrid_enhanced.htm

    Thanks,

    Sriram Ponna.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.