Interactive lists from ALV

Hi experts,
Please tell me how to generate Interactive list from ALV.
I have already created interactive list without ALV
( using AT LINE SELECTION)

Please refer to the below code.
A very good example with most of the company Standards.
*& Report  zalv                                                      *
REPORT zalv .
TYPE-POOLS: kkblo,
            slis.
TABLES: mara, marc, mard.
DATA:       disvariant   LIKE disvariant,
            eventcat     TYPE slis_t_event,
            eventcat_ln  LIKE LINE OF eventcat,
            fieldcat     TYPE slis_t_fieldcat_alv,
            fieldcat_kkb TYPE kkblo_t_fieldcat,
            fieldcat_ln  LIKE LINE OF fieldcat,
            keyinfo      TYPE slis_keyinfo_alv,
            layout       TYPE slis_layout_alv,
            layout_kkb   TYPE kkblo_layout,
            pgm          LIKE sy-repid,
            printcat     TYPE slis_print_alv,
            sortcat      TYPE slis_t_sortinfo_alv,
            sortcat_ln   LIKE LINE OF sortcat,
            BEGIN OF coltab OCCURS 50,
              fieldname LIKE fieldcat_ln-fieldname,
            END OF coltab.
DATA: print          TYPE slis_print_alv.
DATA : v_repid TYPE sy-repid.
DATA: BEGIN OF wa OCCURS 0,
        matnr TYPE mara-matnr,
        ersda TYPE mara-ersda,
        ernam TYPE mara-ernam,
        aenam TYPE mara-aenam,
        werks TYPE marc-werks,
        pstat TYPE marc-pstat,
        lfmon TYPE mard-lfmon,
      END OF wa.
DATA: itab LIKE TABLE OF wa.
**Selection Screen
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001..
SELECT-OPTIONS: mat_no FOR mara-matnr.
SELECTION-SCREEN SKIP.
SELECTION-SCREEN END OF BLOCK b1.
* Parameter for list viewer display variant
PARAMETERS:    variant  LIKE disvariant-variant.
AT SELECTION-SCREEN ON variant.
  CHECK NOT variant IS INITIAL.
  PERFORM check_variant_existence USING variant 'U'.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR variant.
  PERFORM f4_display_variant USING variant 'U'.
*Initialization
INITIALIZATION.
  v_repid = sy-repid.
*Start of selection
  PERFORM check_tcode_authority USING 'SA38'.
START-OF-SELECTION.
  SELECT a~matnr a~ersda
         a~ernam a~aenam
         c~werks c~pstat d~lfmon
  INTO TABLE itab
  UP TO 10 ROWS
  FROM mara AS a
  INNER JOIN marc AS c ON a~matnr = c~matnr
  INNER JOIN mard AS d ON c~matnr = d~matnr
  WHERE a~matnr IN mat_no.
*End of Selection
END-OF-SELECTION.
  PERFORM call_list_viewer.
*&      Form  call_list_viewer
*       text
FORM call_list_viewer .
  PERFORM build_fieldcat USING:
           'MATNR' 'ITAB'
            'Material #' 'CHAR'     18 ' ' ' ' ' ' ' ' ' ',
           'ERSDA' 'ITAB'
            'Date Created' 'CHAR'   10 ' ' ' ' ' ' ' ' ' ',
           'ERNAM' 'ITAB'
            'Created By' 'CHAR'     10 ' ' ' ' ' ' ' ' ' ',
           'AENAM' 'ITAB'
            'Changed By' 'CHAR'     10 ' ' ' ' ' ' ' ' ' ',
           'WERKS' 'ITAB'
            'Plant' 'CHAR'           4 ' ' ' ' ' ' ' ' ' ',
           'PSTAT' 'ITAB'
            'Status' 'CHAR'         10 ' ' ' ' ' ' ' ' ' ',
           'LFMON' 'ITAB'
            'Current Period' 'CHAR'  8 ' ' ' ' ' ' ' ' ' '.
  PERFORM build_eventcat USING: 'TOP_OF_LIST',
                                'TOP_OF_PAGE'.
  PERFORM list_display TABLES itab.
ENDFORM.                    "call_list_viewer
* build field catalog entry                                            *
FORM build_fieldcat USING a_fieldname
                          a_tabname
                          a_heading
                          a_datatype
                          a_outputlen
                          a_key
                          a_no_out
                          a_no_sum
                          a_do_sum
                          a_no_zero.
  CLEAR fieldcat_ln.
  fieldcat_ln-fieldname = a_fieldname.
  fieldcat_ln-tabname  = a_tabname.
  fieldcat_ln-outputlen = a_outputlen.
  fieldcat_ln-datatype = a_datatype.
  fieldcat_ln-reptext_ddic = a_heading.
  fieldcat_ln-key = a_key.
  fieldcat_ln-no_out = a_no_out.
  fieldcat_ln-no_sum = a_no_sum.
  fieldcat_ln-do_sum = a_do_sum.
  fieldcat_ln-no_zero = a_no_zero.
  APPEND fieldcat_ln TO fieldcat.
ENDFORM.                    "BUILD_FIELDCAT
*       FORM BUILD_EVENTCAT
FORM build_eventcat USING a_event.
  eventcat_ln-name = eventcat_ln-form = a_event.
  APPEND eventcat_ln TO eventcat.
ENDFORM.                    "BUILD_EVENTCAT
* call the ABAP list viewer                                            *
FORM list_display TABLES a_output.
  pgm = disvariant-report = sy-repid.
  disvariant-variant = variant.
* call list viewer
  CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
    EXPORTING
      i_callback_program       = pgm
*      i_callback_pf_status_set = 'SET_PF_STATUS'
      it_fieldcat              = fieldcat
      is_variant               = disvariant
      is_layout                = layout
      is_print                 = print
      i_save                   = 'A'
      it_events                = eventcat
      it_sort                  = sortcat
*      i_callback_user_command  = 'USER_COMMAND'
    TABLES
      t_outtab                 = a_output
    EXCEPTIONS
      program_error            = 1
      OTHERS                   = 2.
ENDFORM.                    "LIST_DISPLAY
*&      Form  top_of_page
*       text
FORM top_of_page.
  PERFORM standard_headings.
  PERFORM print_selection_screen TABLES:
               mat_no USING  'Material No  : ' 18 'N' 1.
ENDFORM.                    "top_of_page
*       FORM CHECK_VARIANT_EXISTENCE
*       Verify that a variant on the selection screen exists
FORM check_variant_existence USING varname LIKE disvariant-variant
                                   save   TYPE c.
  DATA: xdisvar LIKE disvariant.
  xdisvar-report  = sy-repid.
  xdisvar-variant = varname.
  CALL FUNCTION 'REUSE_ALV_VARIANT_EXISTENCE'
    EXPORTING
      i_save        = save
    CHANGING
      cs_variant    = xdisvar
    EXCEPTIONS
      wrong_input   = 1
      not_found     = 2
      program_error = 3
      OTHERS        = 4.
  IF sy-subrc <> 0.
    MESSAGE e256(56) WITH varname.
*   Anzeigevariante &1 nicht gefunden
  ENDIF.
  disvariant-report  = sy-repid.
  disvariant-variant = varname.
ENDFORM.                    "check_variant_existence
*       Form  F4_DISPLAY_VARIANT
*       F4 help to find a display variant
*       varname = name of the dynpro field for which f4 is requested
*       save    = type of list variant saving
*                 ' ' = no saving allowed
*                 'A' = standard & user specific variants can be saved
*                 'U' = only user specific variants can be saved
*                 'X' = only standard variants can be saved
FORM f4_display_variant USING varname LIKE disvariant-variant
                              save    TYPE c.
  disvariant-report = sy-repid.
  CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
    EXPORTING
      is_variant    = disvariant
      i_save        = save
    IMPORTING
      es_variant    = disvariant
    EXCEPTIONS
      not_found     = 1
      program_error = 2
      OTHERS        = 3.
  IF sy-subrc = 0.
    varname = disvariant-variant.
  ELSE.
    MESSAGE s245(56).
*   Keine Anzeigevariante(n) vorhanden
  ENDIF.
ENDFORM.                               " F4_DISPLAY_VARIANT
*       FORM STANDARD_HEADINGS                                        *
*       Print standard page headings for report                       *
FORM standard_headings.
  DATA: start_column TYPE i,
        title_len TYPE i,
        header_for_80_col(45),
        date_time_for_80_col(45),
        text_h0(11) VALUE 'Report No. ',
        text_h1(5) VALUE 'Date ',
        text_h2(6) VALUE 'Page -',
        text_h3(7) VALUE 'System ',
        text_h4(5) VALUE 'Time ',
        text_h5(11) VALUE 'Run By     '.
  FORMAT INTENSIFIED ON.
  CONDENSE syst-title.
  IF syst-linsz > 80.
    WRITE: /  text_h0,                 "Report No.
           12 syst-repid(8),
           23 text_h1,                 "Date
              sy-datlo.
    title_len = STRLEN( syst-title ) / 2.
    start_column = ( syst-linsz / 2 ) - title_len.
    IF start_column < 40.
      start_column = 40.
    ENDIF.
    WRITE: AT start_column syst-title.
  ELSE.
    WRITE: /  text_h0,                 "Report No.
           12 syst-repid(8).
    start_column = 22.
    WRITE syst-title TO header_for_80_col CENTERED.
    WRITE: header_for_80_col.
  ENDIF.
  start_column = syst-linsz - 12.
  WRITE: AT start_column text_h2, syst-pagno LEFT-JUSTIFIED.
  IF syst-linsz > 80.
    WRITE: / text_h3,                  "System
          12 syst-sysid(4),
             syst-mandt,
          23 text_h4,                  "Time
             syst-timlo.
    WRITE: / text_h5,                  "Run By
          12 syst-uname.
  ELSE.
    WRITE: / text_h3,                  "System
          12 syst-sysid(4),
             syst-mandt,
          23 text_h1,                  "Date
             syst-datlo.
    WRITE: / text_h5,                  "Run By
          12 syst-uname,
          23 text_h4,                  "Time
             syst-timlo.
  ENDIF.
  SKIP.
ENDFORM.                    "STANDARD_HEADINGS
*       FORM PRINT_SELECTION_SCREEN                                        *
*  -->  SIGN                                                          *
*  -->  OPTION                                                        *
*  -->  LOW                                                           *
*  -->  HIGH                                                          *
*  -->  D_IND                                                         *
*  -->  S_STRING                                                      *
FORM print_selection_screen TABLES r_selection TYPE table
                       USING  p_name
                              p_length TYPE i
                              p_ind
                              p_start_col.
  DATA: year(4)       TYPE c,
        month(2)      TYPE c,
        day(2)        TYPE c,
        low_date(10)  TYPE c,
        high_date(10) TYPE c,
        offset(80)    TYPE c.
  DATA: BEGIN OF l_selline,
          sign(1) TYPE c,
          option(2) TYPE c,
          data(200) TYPE c,
        END OF l_selline.
  DATA: l_string(80) TYPE c,
        l_temp(80) TYPE c,
        len TYPE i,
        len1 TYPE i.
  DESCRIBE FIELD p_name LENGTH len IN CHARACTER MODE.
  len = len + p_start_col + 2.
  LOOP AT r_selection.
    IF syst-tabix = 1.
      WRITE AT /p_start_col p_name.
    ELSE.
      len1 = ( STRLEN( l_string ) ).
      len = len1 + len + 2.
    ENDIF.
    MOVE r_selection TO l_selline.
    SHIFT l_selline-data LEFT DELETING LEADING '0'.
    CLEAR l_string.
    CASE l_selline-option.
      WHEN 'EQ'.
        CONCATENATE l_string '=' INTO l_string.
      WHEN 'NE'.
        CONCATENATE l_string 'not =' INTO l_string.
      WHEN 'LT'.
        CONCATENATE l_string '<' INTO l_string.
      WHEN 'GT'.
        CONCATENATE l_string '>' INTO l_string.
      WHEN 'LE'.
        CONCATENATE l_string '<=' INTO l_string.
      WHEN 'GE'.
        CONCATENATE l_string '>=' INTO l_string.
      WHEN 'BT'.
        CONCATENATE l_string 'between' INTO l_string.
      WHEN 'NB'.
        CONCATENATE l_string 'not between' INTO l_string.
      WHEN 'CP'.
        CONCATENATE l_string 'contains pattern' INTO l_string.
      WHEN 'NP'.
        CONCATENATE l_string 'no pattern' INTO l_string.
    ENDCASE.
    IF l_selline-sign EQ 'E'.
      CONCATENATE 'NOT' l_string INTO l_string SEPARATED BY ' '.
    ENDIF.
    IF p_ind EQ 'Y'.
      MOVE l_selline-data(4) TO year.
      MOVE l_selline-data+4(2) TO month.
      MOVE l_selline-data+6(2) TO day.
      CONCATENATE month '/' day '/' year INTO low_date.
      CONCATENATE l_string low_date INTO l_string SEPARATED BY ' '.
      IF l_selline-option EQ 'BT' OR l_selline-option EQ 'NB'.
        MOVE l_selline-data+p_length(4) TO year.
        offset = p_length + 4.
        MOVE l_selline-data+offset(2) TO month.
        ADD 2 TO offset.
        MOVE l_selline-data+offset(2) TO day.
        CONCATENATE month '/' day '/' year INTO high_date.
        CONCATENATE l_string 'and' high_date INTO l_string SEPARATED
                                              BY ' '.
      ENDIF.
    ELSE.
      MOVE l_selline-data(p_length) TO l_temp.
      CONCATENATE l_string l_temp INTO l_string SEPARATED BY ' '.
      IF l_selline-option EQ 'BT' OR l_selline-option EQ 'NB'.
        MOVE l_selline-data+p_length(p_length) TO l_temp.
        CONCATENATE l_string 'and' l_temp INTO l_string SEPARATED
                                                            BY ' '.
      ENDIF.
    ENDIF.
    WRITE AT len l_string.
  ENDLOOP.
  IF syst-subrc <> 0.
    WRITE: AT /p_start_col p_name, ' *** ALL ***'.
  ENDIF.
ENDFORM.                    "PRINT_SELECTION_SCREEN
*       FORM CHECK_TCODE_AUTHORITY                                    *
*       Check User Security Against A SAP Transaction                 *
*  -->  a_tcode  Transaction Code For Security                        *
FORM check_tcode_authority USING a_tcode.
* if tcode is not passed, then return ok.
  IF NOT a_tcode IS INITIAL.
    CALL FUNCTION 'AUTHORITY_CHECK_TCODE'"Only People that
         EXPORTING                     " have access to
           tcode  = a_tcode            " Transaction t-tcode
         EXCEPTIONS                    " are ALLOWED to execute
              ok     = 1               " this Program
              not_ok = 2.
    IF syst-subrc NE 1.
      MESSAGE a999(zz) WITH 'YOU Do Not Have Authority to Execute'.
    ENDIF.
  ELSE.
    MOVE 1 TO syst-subrc.
  ENDIF.
ENDFORM.                    "CHECK_TCODE_AUTHORITY
Shreekant

Similar Messages

  • How to handle interactive list in alv reports

    hi experts.
    how to handle interactive list in alv reports.
    regards.
    subhasis

    HI Subhasis,
    below is the sample code for handling an interactive ALV report, hope this helps you ..
    REPORT  ZTEST_ALV123.                           
    TYPE-POOLS:SLIS.
    DATA :   IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
              IT_FIELDCAT1 TYPE SLIS_T_FIELDCAT_ALV.
    DATA: BEGIN OF ITAB OCCURS 0,
           VBELN LIKE VBAK-VBELN,
           POSNR LIKE VBAP-POSNR,
           END OF ITAB.
    DATA: BEGIN OF ITAB1 OCCURS 0,
           VBELN LIKE LIKP-VBELN,
           POSNR LIKE LIPS-POSNR,
           VGBEL LIKE LIPS-VGBEL,
           VGPOS LIKE LIPS-VGPOS,
           END OF ITAB1.
    DATA: IT_LIPS LIKE ITAB1 OCCURS 0 WITH HEADER LINE.
    SELECT  VBELN
            POSNR
            FROM VBAP
            INTO TABLE ITAB.
    IF SY-SUBRC = 0.
      SORT ITAB BY VBELN .
      SELECT VBELN
       POSNR
       VGBEL
       VGPOS
       INTO TABLE ITAB1
       FROM LIPS
       FOR ALL ENTRIES IN ITAB
       WHERE VGBEL = ITAB-VBELN
         AND    VGPOS = ITAB-POSNR.
    ENDIF.
    DATA: X_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
    X_FIELDCAT-FIELDNAME = 'VBELN'.
    X_FIELDCAT-TABNAME = 'ITAB'.
    X_FIELDCAT-COL_POS  = 1.
    APPEND X_FIELDCAT TO IT_FIELDCAT.
    CLEAR X_FIELDCAT.
    X_FIELDCAT-FIELDNAME = 'POSNR'.
    X_FIELDCAT-TABNAME = 'ITAB'.
    X_FIELDCAT-COL_POS  = 1.
    APPEND X_FIELDCAT TO IT_FIELDCAT.
    CLEAR X_FIELDCAT.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
      EXPORTING
        I_CALLBACK_PROGRAM       = SY-REPID
        I_CALLBACK_PF_STATUS_SET = 'PFSTATUS'
        I_CALLBACK_USER_COMMAND  = 'HANDLE_USER_COMMAND'
        IT_FIELDCAT              = IT_FIELDCAT
      TABLES
        T_OUTTAB                 = ITAB
      EXCEPTIONS
        PROGRAM_ERROR            = 1
        OTHERS                   = 2.
    IF SY-SUBRC  = 0.
    ENDIF.
    *&      Form  POPUP
          text
         -->P_EXTAB    text
    FORM POPUP USING P_EXTAB TYPE SLIS_T_EXTAB.
    "here double click on PFSTATUS and create the status, "activate, before that set PICK for choose(F2).
    *- Pf status
      SET PF-STATUS 'PFSTATUS'.
    ENDFORM.                 " POPUP
    *&      Form  HANDLE_USER_COMMAND
          text
         -->R_UCOMM      text
         -->RS_SELFIELD  text
    FORM HANDLE_USER_COMMAND USING R_UCOMM     LIKE SY-UCOMM
                                   RS_SELFIELD TYPE SLIS_SELFIELD.
      CASE R_UCOMM.
        WHEN '&IC1'.
          IF RS_SELFIELD-FIELDNAME = 'VBELN'.
            READ TABLE ITAB INDEX RS_SELFIELD-TABINDEX.
            LOOP AT ITAB1 WHERE VGBEL = ITAB-VBELN
                              AND VGPOS = ITAB-POSNR.
              MOVE-CORRESPONDING ITAB1 TO IT_LIPS.
              APPEND IT_LIPS.
            ENDLOOP.
            PERFORM INTERACTIVE_REPORT.
          ENDIF.
      ENDCASE.
    ENDFORM.                    "HANDLE_USER_COMMAND
    *&      Form  interactive_report
          text
    FORM INTERACTIVE_REPORT .
      X_FIELDCAT-FIELDNAME = 'VBELN'.
      X_FIELDCAT-SELTEXT_L = 'VBELN'.
      X_FIELDCAT-TABNAME = 'IT_LIPS'.
      X_FIELDCAT-COL_POS  = 1.
      APPEND X_FIELDCAT TO IT_FIELDCAT1.
      CLEAR X_FIELDCAT.
      X_FIELDCAT-FIELDNAME = 'POSNR'.
      X_FIELDCAT-SELTEXT_L = 'ITEM'.
      X_FIELDCAT-TABNAME = 'IT_LIPS'.
      X_FIELDCAT-COL_POS  = 2.
      APPEND X_FIELDCAT TO IT_FIELDCAT1.
      CLEAR X_FIELDCAT.
      X_FIELDCAT-FIELDNAME = 'VGBEL'.
      X_FIELDCAT-SELTEXT_M = 'SO #'.
      X_FIELDCAT-TABNAME = 'IT_LIPS'.
      X_FIELDCAT-COL_POS  = 3.
      APPEND X_FIELDCAT TO IT_FIELDCAT1.
      CLEAR X_FIELDCAT.
      X_FIELDCAT-FIELDNAME = 'VGPOS'.
      X_FIELDCAT-SELTEXT_M = 'SO ITEM'.
      X_FIELDCAT-TABNAME = 'IT_LIPS'.
      X_FIELDCAT-COL_POS  = 4.
      APPEND X_FIELDCAT TO IT_FIELDCAT1.
      CLEAR X_FIELDCAT.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          I_CALLBACK_PROGRAM = SY-REPID
          IT_FIELDCAT        = IT_FIELDCAT1
        TABLES
          T_OUTTAB           = IT_LIPS
        EXCEPTIONS
          PROGRAM_ERROR      = 1
          OTHERS             = 2.
      IF SY-SUBRC  = 0.
      ENDIF.
    ENDFORM.                    " interactive_report
    Regards,
    Ranjita
    null

  • Interactive list in ALV

    Hi All,
    Is there any sample program for an interactive list in ALV? I would like to try an interactive ALV list option for one of my reports
    Thanks

    One more example - ALV Interactive ( two times REUSE_ALV_GRID_DISPLAY )
    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.

  • Regarding Interactive  list in alv

    Hi Experts,
    I want to know how to do a inteactive report in alv.
    For example: First i will display a alv list. Then when i double click on a field of a line or click on button (Details) by selecting  a line ,  then it will navigate me to the alv list with corresponding records where i clicked previously.
    How to use buttons in this case as we r using in simple interactive report.
    Can anyone pls help me in creating a simple example for the above???
    Thanks
    Sudhansu

    Hi,
    Example for Interactive ALV report.
    Please reward if useful.
    report  zreport no standard page heading
                                    message-id zw.
    Type Pools                                                           *
    type-pools: icon, slis.
    Tables                                                               *
    tables: tvst,
            likp,
            t30b,
            vekp,
            zpallettr,
            zvantr.
    Types                                                                *
    types:
      begin of ty_data,
         lgtor       like likp-lgtor,             " door
         vbeln       like likp-vbeln,             " delivery
         wbstk       like vbuk-wbstk,             " Goods movement status
         kostk       like vbuk-kostk,             " Picking status
         posnr       like lips-posnr,             " item
         route       like likp-route,             " route
         wadat       like likp-wadat,             " goods issue date
         lvsta       like vbup-lvsta,             " warehouse status
         packvorschr like vekp-packvorschr,       " pack mnemonic
         exidv       like vekp-exidv,             " handling unit
         zpallet_no(10),  "like zpallettr-zpallet_no,   " pallet no
         zcount_check like zpallettr-zcount_check," count check flag
         zvan_no(10),     "like zvantr-zvan_no,         " van no
         zvan_print  like zvantr-zvan_print,      " van manifest print
         zeod_print  like zvantr-zeod_print,      " eod manifest print
         zzpackclass like vekp-zzpackclass,       " package class
         zzti        like vekp-zzti,              " T.I. value
      end of ty_data.
    Data                                                                 *
    ranges: r_del   for likp-vbeln,
            r_lgtor for likp-lgtor.
    ranges: r_vanno for zvantr-zvan_no,
            r_palno for zpallettr-zpallet_no.
    data: begin of number_range occurs 0,
             mark(1),
             id(3),
             num(10) type n,
             desc like zpalletmd-zdesc,
          end of number_range.
    data: t_disp_tab  type standard table of zpickdisp,
          t_data_tab  type ty_data  occurs 0 with header line,
          t_disp_head type standard table of zpickhead.
    data: w_numrnge like number_range,
          w_number(10) type n.
    data: t_likp     like likp      occurs 0 with header line,
          t_lips     like lips      occurs 0 with header line,
          t_vbuk     like vbuk      occurs 0 with header line,
          t_vbup     like vbup      occurs 0 with header line,
          t_vepo     like vepo      occurs 0 with header line,
          t_vekp     like vekp      occurs 0 with header line,
          t_vantr    like zvantr    occurs 0 with header line,
          t_pallettr like zpallettr occurs 0 with header line,
          w_likp     like likp,
          w_lips     like lips,
          w_vbuk     like vbuk,
          w_vbup     like vbup,
          w_vepo     like vepo,
          w_vekp     like vekp.
    ALV DATA *****
    data:
         g_grid             type ref to cl_gui_alv_grid,
         g_sort             type slis_t_sortinfo_alv,
         g_custom_container type ref to cl_gui_custom_container,
         g_layout           type slis_layout_alv,
         gt_fieldcat        type slis_t_fieldcat_alv,
         t_fldcat           like line of gt_fieldcat,
         g_keyinfo          type slis_keyinfo_alv,
         gt_events          type slis_t_event,
         gs_event           type slis_alv_event,
         w_sy_repid         like sy-repid.
    data: begin of seltab occurs 0.
            include structure rsparams.
    data: end of seltab.
    SYSTEM GENERATED TABLE CONTROL DATA ********
    DECLARATION OF TABLECONTROL 'TC_TABCON' ITSELF
    controls: tc_tabcon type tableview using screen 0100.
    LINES OF TABLECONTROL 'TC_TABCON'
    data:     g_tc_tabcon_lines  like sy-loopc.
    data:     ok_code like sy-ucomm.
    Constants                                                            *
    constants: c_data_class like klah-class value 'DG_DATA',
               c_mat_class  like rmclf-klart value '001',
               c_pack       like lips-mtart value 'VERP',
               c_a(1)            value 'A',
               c_b(1)            value 'B',
               c_c(1)            value 'C',
               c_yes(1)          value 'X',
               c_no(1)           value ' '.
    Selection screen                                                     *
    standard report select options block
    selection-screen begin of block a with frame title text-002.
    select-options:
      s_wadat for likp-wadat no-extension obligatory.  " Goods Issue Date
    *parameters:                                           "TR01-
    p_vstel like tvst-vstel obligatory. " Shipping Point "TR01-
    select-options:                                             "TR01+
      p_vstel for tvst-vstel.            " Shipping Point  "TR01+
    select-options:
      s_lfart for likp-lfart,            " Delivery type
      s_lgtor for t30b-lgtor,            " Door selection
      s_exidv for vekp-exidv,            " Handling Unit
      s_vbeln for likp-vbeln.            " Delivery
    parameters:
      p_exdata as checkbox.              " Show extra columns flag
    selection-screen end of block a.
    van/pallet specific select options block
    selection-screen begin of block b with frame title text-001.
    select-options:
      s_palno for zpallettr-zpallet_no, " no-extension,
      s_vanno for zvantr-zvan_no.       " no-extension.
    selection-screen end of block b.
    Value Request Events                                                 *
    at selection-screen on value-request for s_palno-low.
      clear: number_range, w_number .
      refresh number_range.
    select numbers and display pop up screen for selection
      perform select_pal_nos.
      s_palno-low = w_number.
    at selection-screen on value-request for s_palno-high.
      clear: number_range, w_number .
      refresh number_range.
    select numbers and display pop up screen for selection
      perform select_pal_nos.
      s_palno-high = w_number.
    at selection-screen on value-request for s_vanno-low.
      clear: number_range, w_number .
      refresh number_range.
    select numbers and display pop up screen for selection
      perform select_van_nos.
      s_vanno-low = w_number.
    at selection-screen on value-request for s_vanno-high.
      clear: number_range, w_number .
      refresh number_range.
    select numbers and display pop up screen for selection
      perform select_van_nos.
      s_vanno-high = w_number.
    At Selection Screen                                                  *
    at selection-screen.
      perform validate_selections.
    Initialization                                                       *
    initialization.
    Start of selection                                                   *
    start-of-selection.
    clear all data tables
      clear: t_likp,
             t_lips,
             t_vbuk,
             t_vbup,
             t_vepo,
             t_vantr,
             t_pallettr,
             w_likp,
             w_lips,
             w_vbuk,
             w_vbup,
             w_vepo,
             w_vekp.
      refresh: t_likp,
               t_lips,
               t_vbuk,
               t_vbup,
               t_vepo,
               t_vantr,
               t_pallettr.
    select data for ALV
    due to different input parameters being used, to streamline the data
    selection process, different selection methods are required
      if not s_vanno is initial
      or not s_palno is initial.
      if selecting by van/pallet number, need to select the data from the
      handling unit upwards to delivery
        perform select_data_up.
      else.
      otherwise the data can be selected from the delivery downwards
        perform select_data_down.
      endif.
    End of selection                                                     *
    end-of-selection.
    call hierarchical ALV display function module
      call function 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
           exporting
                i_callback_program       = 'ZWMR_PICK_STATUS_REPORT'
                i_callback_pf_status_set = 'SET_STATUS'
                i_callback_user_command =
                   'USER_COMMAND' "custom gui status form
                is_layout                = g_layout  "user command form
                it_fieldcat              = gt_fieldcat
                it_sort                  = g_sort
                it_events                = gt_events
                i_tabname_header         = 't_disp_head'
                i_tabname_item           = 't_disp_tab'
                i_structure_name_header  = 'ZPICKHEAD'
                i_structure_name_item    = 'ZPICKDISP'
                is_keyinfo               = g_keyinfo
           tables
                t_outtab_header          = t_disp_head
                t_outtab_item            = t_disp_tab.
      if sy-subrc <> 0.
        message id sy-msgid type sy-msgty number sy-msgno
                with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      endif.
                                FORMS                                    *
    Includes inserted by Screen Painter Wizard. DO NOT CHANGE THIS LINE!
      include zwmr_pick_status_reporto01 .
      include zwmr_pick_status_reporti01 .
      include zwmr_pick_status_reportf01 .
    *&      Form  select_pal_nos
          select pallet numbers for search help
    form select_pal_nos.
      data: begin of t_palno occurs 0,
              zpallet_no like zpallettr-zpallet_no,
            end of t_palno.
    select all available pallet numbers
      select distinct zpallet_no from zpallettr
                      into corresponding fields of table t_palno.
      loop at t_palno.
      get pallet id
        select single zpallet_id from zpallettr
                      into number_range-id
                      where zpallet_no = t_palno-zpallet_no.
      get pallet description
        select single zdesc from zpalletmd
                      into number_range-desc
                      where zpallet_id = number_range-id.
        number_range-num = t_palno-zpallet_no.
      append to search help table
        append number_range.
      endloop.
    call pop up dialog box
      call screen 0100 starting at 5 5.
    endform.                    " select_pal_nos
    *&      Form  select_van_nos
          select van numbers for search help
    form select_van_nos.
      data: begin of t_vanno occurs 0,
              zvan_no like zvantr-zvan_no,
            end of t_vanno.
    select available van numbers
      select distinct zvan_no from zvantr
                      into corresponding fields of table t_vanno.
      loop at t_vanno.
      select van id
        select single zvan_id from zvantr
                      into number_range-id
                      where zvan_no = t_vanno-zvan_no.
      select van description (maintained in pallet tables)
        select single zdesc from zpalletmd
                      into number_range-desc
                      where zpallet_id = number_range-id.
        number_range-num = t_vanno-zvan_no.
      append to search help table
        append number_range.
      endloop.
    call pop up dialog box
      call screen 0100 starting at 5 5.
    endform.                    " select_van_nos
    *&      Form  select_data_down
          select data if selecting from delivery down
    form select_data_down.
    select all deliveries from LIKP that fulfill selection criteria
      select * from likp into table t_likp
                         where vbeln in s_vbeln
                       and   vstel eq p_vstel                 "TR01-
                         and   vstel in p_vstel
                         and   lgtor in s_lgtor
                         and   wadat in s_wadat
                         and   lfart in s_lfart.
      if sy-subrc ne 0.
      no data found
        message i007.
        exit.
      endif.
      if not t_likp[] is initial.
      select sales document headers from VBUK
        select * from vbuk into table t_vbuk
                      for all entries in t_likp
                      where vbeln eq t_likp-vbeln.
      select all relevant delivery items from LIPS
        select * from lips into table t_lips
                      for all entries in t_likp
                      where vbeln eq t_likp-vbeln
                      and   pstyv ne 'ZPAC'
                      and   pstyv ne 'ZGDP'                     "TR02+
                      and   lfimg gt 0.                         "TR01+
      endif.
      if not t_lips[] is initial.
      select all sales document line items from VBUP
        select * from vbup into table t_vbup
                      for all entries in t_lips
                      where vbeln eq t_lips-vbeln
                      and   posnr = t_lips-posnr.
      select corresponding handling unit ID's (venum)
    TR03 Replace start
       select * from vepo appending corresponding fields of table t_vepo
                     for all entries in t_lips
                     where vbeln = t_lips-vbeln
                     and   posnr = t_lips-posnr
                     and   matnr = t_lips-matnr
                     and   charg = t_lips-charg.
        select * from vepo
                      inner join vekp on vepovenum = vekpvenum
                      appending corresponding fields of table t_vepo
                      for all entries in t_lips
                      where vepo~vbeln = t_lips-vbeln
                      and   vepo~posnr = t_lips-posnr
                      and   vepo~matnr = t_lips-matnr
                      and   vepo~charg = t_lips-charg
                      and   vekp~exidv in s_exidv.
    TR03 Replace end
      endif.
    build process table
      perform move_to_table.
    endform.   "select_data_down
    *&      Form  select_data_up
          select data if selecting from van/pallet up
    form select_data_up.
      if not s_vanno is initial.
      if van then select van numbers and hence pallet numbers
        select * from zvantr into table t_vantr
                              where zvan_no in s_vanno.
                            and   vstel   eq p_vstel."TR01-
        if not t_vantr[] is initial.
          select * from zpallettr into table t_pallettr
                                  for all entries in t_vantr
                                  where zpallet_no eq t_vantr-zpallet_no.
                                and   vstel      eq p_vstel."TR01-
        endif.
      else.
      otherwise can get pallet numbers directly
        select * from zpallettr into table t_pallettr
                                where zpallet_no in s_palno.
                              and   vstel      eq p_vstel."TR01-
      endif.
      if not t_pallettr[] is initial.
      from the pallet nos. we can select the handling units
        select * from vekp into table t_vekp
                           for all entries in t_pallettr
                           where exidv eq t_pallettr-exidv
                           and   exidv ne space
                           and   exidv in s_exidv               "TR03+
                           and ( exida = 'E'                    "TR01+
                           or    exida = 'F' ).                 "TR01+
      endif.
      if not t_vekp[] is initial.
      build vbeln range from t_vekp.
        loop at t_vekp.
          r_del-sign = 'I'.
          r_del-option = 'EQ'.
          r_del-low = t_vekp-vpobjkey.
          append r_del.
        endloop.
      select all deliveries from LIKP that correspond to HU's
        select * from likp into table t_likp
                           where vbeln in r_del
                           and   wadat in s_wadat
                           and   lfart in s_lfart.
      endif.
      if not t_likp[] is initial.
      select sales document headers from VBUK
        select * from vbuk into table t_vbuk
                      for all entries in t_likp
                      where vbeln eq t_likp-vbeln.
      select all relevant delivery items from LIPS
        select * from lips into table t_lips
                      for all entries in t_likp
                      where vbeln eq t_likp-vbeln
                      and   pstyv ne 'ZPAC'
                      and   pstyv ne 'ZGDP'                     "TR02+
                      and   lfimg gt 0.                         "TR01+
      endif.
      if not t_lips[] is initial.
      select all sales document line items from VBUP
        select * from vbup into table t_vbup
                      for all entries in t_lips
                      where vbeln eq t_lips-vbeln
                      and   posnr = t_lips-posnr.
      select corresponding handling unit ID's (venum)
        select * from vepo appending corresponding fields of table t_vepo
                      for all entries in t_lips
                      where vbeln = t_lips-vbeln
                      and   posnr = t_lips-posnr
                      and   matnr = t_lips-matnr
                      and   charg = t_lips-charg.
      endif.
    build process table
      perform move_to_table.
    endform.   "select_data_up
    *&      Form  move_to_table
          move data to processing table
    form move_to_table.
      loop at t_vepo.
        clear t_data_tab.
      delivery lines.
        clear w_lips.
        read table t_lips with key vbeln = t_vepo-vbeln
                                   posnr = t_vepo-posnr
                                   into w_lips.
        move-corresponding w_lips to t_data_tab.
      sales document line items
        clear w_vbup.
        read table t_vbup with key vbeln = t_vepo-vbeln
                                   posnr = t_vepo-posnr
                                   into w_vbup.
      if w_vbup-kosta = space.                   "TR01-
        not relevant for picking
        delete t_vepo.                           "TR01-
        continue.                                "TR01-
      else.                                      "TR01-
        move-corresponding w_vbup to t_data_tab.
      endif.                                     "TR01-
      sales doc header
        clear w_vbuk.
        read table t_vbuk with key vbeln = t_vepo-vbeln
                               into w_vbuk.
        move-corresponding w_vbuk to t_data_tab.
      delivery header
        clear w_likp.
        read table t_likp with key vbeln = t_vepo-vbeln
                               into w_likp.
        move-corresponding w_likp to t_data_tab.
      select handling unit info using vepo entry
        clear w_vekp.
        if t_vekp[] is initial.
          select single * from vekp into w_vekp
                                    where venum = t_vepo-venum.
        else.
          read table t_vekp with key venum = t_vepo-venum
                                     into w_vekp.
          if sy-subrc ne 0.
            select single * from vekp into w_vekp
                            where venum = t_vepo-venum.
          endif.
        endif.
        move-corresponding w_vekp to t_data_tab.
      select pallet / van load information
        select single zpallet_no zcount_check from zpallettr
                                 into (t_data_tab-zpallet_no,
                                       t_data_tab-zcount_check)
                                 where exidv eq w_vekp-exidv.
        if not t_data_tab-zpallet_no in s_palno.                "TR01+
          continue.                                             "TR01+
        endif.                                                  "TR01+
        if sy-subrc = 0.
          select single zvan_no zvan_print zeod_print from zvantr
                        into (t_data_tab-zvan_no,
                              t_data_tab-zvan_print,
                              t_data_tab-zeod_print)
                        where zpallet_no eq t_data_tab-zpallet_no.
          if not t_data_tab-zvan_no in s_vanno.                 "TR01+
            continue.                                           "TR01+
          endif.                                                "TR01+
        endif.
        append t_data_tab.
      endloop.
    *-----> TR01+ start
    If the delivery has yet to be packed, then need to include in report
    Thus delete t_lips here and if any entries left after looping through
    t_vepo, these will also need to be added to t_data_tab
    if the selection is by handling unit though we do not want these"TR03+
      if s_exidv is initial.                                          "TR03+
        loop at t_vepo.
          read table t_lips with key vbeln = t_vepo-vbeln
                                     posnr = t_vepo-posnr.
          if sy-subrc = 0.
            delete t_lips index sy-tabix.
          endif.
        endloop.
        if not t_lips[] is initial.
      move any unpacked items to the data table
          perform move_lips_to_table.
        endif.
      endif.                                                          "TR03+
    *<---- TR01+ End
    get relevant status icons
      perform select_icons.
    prepare ALV data
      perform prepare_alv.
    endform.                    " select_data
    *&      Form  select_icons
          select icons for display and move data to display table
    form select_icons.
      data: w_disp_tab like zpickdisp,
            w_disp_head like zpickhead,
            w_color like zpickdisp-color,
            ov_icon like zpickdisp-ov_icon,
            gi_icon like zpickdisp-gi_icon,
            to_icon like zpickdisp-to_icon,
            lp_icon like zpickdisp-lp_icon,
            pc_icon like zpickdisp-pc_icon,
            lv_icon like zpickdisp-lv_icon,
            vm_icon like zpickdisp-vm_icon,
            em_icon like zpickdisp-em_icon,
            t_ovst_tab like t_disp_tab with header line.
      constants: c_col1(3) value 'C10',
                 c_col2(3) value 'C20'.
      sort t_data_tab by lgtor vbeln.
      w_color = c_col2.
      loop at t_data_tab.
        at new lgtor.
        fill ALV header table
          clear w_disp_head.
          w_disp_head-lgtor = t_data_tab-lgtor.
          append w_disp_head to t_disp_head.
        endat.
      goods issue status & overall amber/green only
        case t_data_tab-wbstk.
          when c_c.
            move icon_green_light to gi_icon.
            move icon_green_light to ov_icon.
          when others.
            move icon_red_light to gi_icon.
            move icon_yellow_light to ov_icon.
        endcase.
      transfer order status
        case t_data_tab-lvsta.
          when c_a.
            move icon_red_light to to_icon.
          when c_b.
            move icon_yellow_light to to_icon.
          when c_c.
            move icon_green_light to to_icon.
          when space.
          write N/A
            to_icon = 'N/A'.
        endcase.
      loaded to pallet status
        if not t_data_tab-zpallet_no is initial.
          move icon_green_light to lp_icon.
        else.
          move icon_red_light to lp_icon.
        endif.
      pallet count status
        if not t_data_tab-zcount_check is initial.
          move icon_green_light to pc_icon.
        else.
          move icon_red_light to pc_icon.
        endif.
      loaded to van status
        if not t_data_tab-zvan_no is initial.
          move icon_green_light to lv_icon.
        else.
          move icon_red_light to lv_icon.
        endif.
      van manifest status
        if not t_data_tab-zvan_print is initial.
          move icon_green_light to vm_icon.
        else.
          move icon_red_light to vm_icon.
        endif.
      end of day manifest status
        if not t_data_tab-zeod_print is initial.
          move icon_green_light to em_icon.
        else.
          move icon_red_light to em_icon.
        endif.
      move working data table to display table
        move-corresponding t_data_tab to w_disp_tab.
        w_disp_tab-ov_icon = ov_icon.
        w_disp_tab-gi_icon = gi_icon.
        w_disp_tab-to_icon = to_icon.
        w_disp_tab-lp_icon = lp_icon.
        w_disp_tab-pc_icon = pc_icon.
        w_disp_tab-lv_icon = lv_icon.
        w_disp_tab-vm_icon = vm_icon.
        w_disp_tab-em_icon = em_icon.
        w_disp_tab-color = w_color.
      fill N/A values for initial fields for display
        if w_disp_tab-packvorschr is initial.
          w_disp_tab-packvorschr = 'N/A'.
        endif.
        if w_disp_tab-exidv is initial.
          w_disp_tab-exidv = 'N/A'.
        endif.
        if w_disp_tab-zpallet_no is initial.
          write 'N/A' to w_disp_tab-zpallet_no.
        endif.
        if w_disp_tab-zvan_no is initial.
          write 'N/A' to w_disp_tab-zvan_no.
        endif.
      display different color for new doc number
        at end of vbeln.
          if w_color = c_col1.
            w_color = c_col2.
          elseif w_color = c_col2.
            w_color = c_col1.
          endif.
        endat.
        append w_disp_tab to t_disp_tab.
        clear w_disp_tab.
      endloop.
    we have all the icons in display but need to check the overall status
    as this refers to the line items
    green and amber statuses already set and use the same criteria as the
    goods issue status unless detected as red here
      data: ov_stat_red(1).
      clear w_disp_tab.
      sort t_disp_tab by vbeln.
      loop at t_disp_tab into w_disp_tab.
        at new vbeln.
        check all line items for delivery
          loop at t_data_tab where vbeln = w_disp_tab-vbeln.
            if t_data_tab-lvsta = c_a.
            set overall status to red
              ov_stat_red = c_yes.
              exit.
            else.
            leave green/amber status icon as previosly determined
            endif.
          endloop.
          if ov_stat_red = c_yes.
          set overall status to red for all items in that delivery
            clear ov_stat_red.
            move icon_red_light to w_disp_tab-ov_icon.
            modify t_disp_tab from w_disp_tab transporting ov_icon
                              where vbeln = w_disp_tab-vbeln.
          endif.
        endat.
      endloop.
    endform.                    " select_icons
    *&      Form  fill_layout
          fill ALV layout parameters
    form fill_layout.
      clear g_layout.
      g_layout-colwidth_optimize = c_yes.   " column width optimisation
      g_layout-zebra = space.               " alternate line colors
      g_layout-box_fieldname = 'MARK'.      " checkbox fieldname
      g_layout-info_fieldname = 'COLOR'.    " highlight row indicator
      g_layout-no_vline = space.            " vertical line
      g_layout-key_hotspot = space.         " hotspot field
      g_layout-f2code = 'PICK'.             " F2 ok_code
      g_layout-numc_sum = c_yes.            " sum numc fields
      g_layout-box_tabname = 't_disp_head'. " checkbox table name
      g_layout-expand_fieldname = 'EXPAND'. " expand field name
    endform.                    " fill_layout
    *&      Form  fill_sort
          fill ALV sort table
    form fill_sort.
      data: w_g_sort type slis_sortinfo_alv.
      w_g_sort-spos      = 1.
      w_g_sort-fieldname = 'LGTOR'.
      w_g_sort-tabname   = 't_disp_tab'.
      w_g_sort-up        = c_yes.
      append w_g_sort to g_sort.
      w_g_sort-spos      = 2.
      w_g_sort-fieldname = 'VBELN'.
      w_g_sort-tabname   = 't_disp_tab'.
      w_g_sort-up        = c_yes.
      append w_g_sort to g_sort.
      w_g_sort-spos      = 3.
      w_g_sort-fieldname = 'POSNR'.
      w_g_sort-tabname   = 't_disp_tab'.
      w_g_sort-up        = c_yes.
      append w_g_sort to g_sort.
      w_g_sort-spos      = 4.
      w_g_sort-fieldname = 'WADAT'.
      w_g_sort-tabname   = 't_disp_tab'.
      w_g_sort-up        = c_yes.
      append w_g_sort to g_sort.
    endform.                    " fill_sort
    *&      Form  fill_fieldcat
          Fill field category structure for ALV
    form fill_fieldcat.
      clear t_fldcat.
    create field catalogue for header table
      call function 'REUSE_ALV_FIELDCATALOG_MERGE'
           exporting
                i_program_name         = 'ZWMR_PICK_STATUS_REPORT'
                i_internal_tabname     = 't_disp_head'
                i_structure_name       = 'ZPICKHEAD'
                i_client_never_display = c_yes
           changing
                ct_fieldcat            = gt_fieldcat[].
      if sy-subrc <> 0.
        message id sy-msgid type sy-msgty number sy-msgno
                with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      endif.
    ceate field catalogue for items table
      call function 'REUSE_ALV_FIELDCATALOG_MERGE'
           exporting
                i_program_name         = 'ZWMR_PICK_STATUS_REPORT'
                i_internal_tabname     = 't_disp_tab'
                i_structure_name       = 'ZPICKDISP'
                i_client_never_display = c_yes
           changing
                ct_fieldcat            = gt_fieldcat[].
      if sy-subrc <> 0.
        message id sy-msgid type sy-msgty number sy-msgno
                with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      endif.
    modify field catalogue for this report
    set no display flag if not requested on selection screen
      if p_exdata ne c_yes.
        t_fldcat-no_out    =  c_yes.
        modify gt_fieldcat from t_fldcat transporting no_out
                           where fieldname eq 'PACKVORSCHR'
                           or    fieldname eq 'EXIDV'
                           or    fieldname eq 'ZPALLET_NO'
                           or    fieldname eq 'ZVAN_NO'
                           or    fieldname eq 'ZZPACKCLASS'
                           or    fieldname eq 'ZZTI'.
      endif.
    set no display flag for item level LGTOR field
      t_fldcat-no_out    =  c_yes.
      modify gt_fieldcat from t_fldcat transporting no_out
                         where fieldname eq 'LGTOR'
                         and   tabname   eq 't_disp_tab'.
    prevent display of technical fields
      t_fldcat-tech = c_yes.
      modify gt_fieldcat from t_fldcat transporting tech
                         where fieldname eq 'EXPAND'
                         or    fieldname eq 'SELKZ'.
    set vbeln as key
      t_fldcat-key = c_yes.
      modify gt_fieldcat from t_fldcat transporting key
                         where fieldname eq 'VBELN'.
    prevent scrolling for info fields
      t_fldcat-fix_column = c_yes.
      modify gt_fieldcat from t_fldcat transporting fix_column
                         where fieldname eq 'VBELN'.
    endform.                    " fill_fieldcat
    *&      Form  prepare_ALV
          Fill ALV parameters
    form prepare_alv.
    fill ALV key info
      g_keyinfo-header01 = 'LGTOR'.
      g_keyinfo-item01   = 'LGTOR'.
    fill ALV events
      gs_event-name = 'TOP_OF_PAGE'.
      gs_event-form = 'TOP_OF_PAGE'.
      append gs_event to gt_events.
    fill ALV sort table
      perform fill_sort.
    fill ALV layout structure
      perform fill_layout.
    fill ALV field category
      perform fill_fieldcat.
    endform.                    " prepare_ALV
    *&      Form  user_command
          form called on user command from ALV list
    form user_command using r_ucomm     like sy-ucomm
                            rs_selfield type slis_selfield.
      data: index type i,
            w_disp_head like line of t_disp_head,
            w_door like likp-lgtor.
      clear r_lgtor. refresh r_lgtor.
      case r_ucomm.
        when 'PICK'. " Double click line
        when 'VANM'. " Van Manifest button
        read the header table where has been selected
          loop at t_disp_head into w_disp_head where mark = c_yes.
            r_lgtor-sign   = 'I'.
            r_lgtor-option = 'EQ'.
            r_lgtor-low    = w_disp_head-lgtor.
            append r_lgtor.
          endloop.
        print the van manifest
          perform print_van_manifest tables r_lgtor.
        when 'EODM'. " EOD Manifest button
        read the header table where has been selected
          loop at t_disp_head into w_disp_head where mark = c_yes.
            r_lgtor-sign   = 'I'.
            r_lgtor-option = 'EQ'.
            r_lgtor-low    = w_disp_head-lgtor.
            append r_lgtor.
          endloop.
        print the end of day manifest
          perform print_eod_manifest tables r_lgtor.
        when 'REFR'. "Refresh
        refresh display
          w_sy_repid = sy-repid.
          call function 'RS_REFRESH_FROM_SELECTOPTIONS'
               exporting
                    curr_report     = w_sy_repid
               tables
                    selection_table = seltab.
              exceptions
                  not_found       = 1
                  no_report     

  • Interactive reports in ALV GRID

    Dear gurus,
    can we have interactive list in ALV ?
    Regards
    R.Rajendran

    Hi,
    Hope this will help You
    *& Report  ZAlv
    REPORT  ZAlv.
    TYPE-POOLS : SLIS.
    TABLES : KNA1,VBAK.
    DATA : BEGIN OF ITAB OCCURS 0 ,
           KUNNR LIKE KNA1-KUNNR,
           NAME1 LIKE KNA1-NAME1,
           LAND1 LIKE KNA1-LAND1,
           ORT01 LIKE KNA1-ORT01,
           END OF ITAB.
    DATA : BEGIN OF JTAB OCCURS 0,
          VBELN LIKE VBAK-VBELN ,
          ERNAM LIKE VBAK-ERNAM ,
          ERDAT LIKE VBAK-ERDAT,
          KUNNR LIKE VBAK-KUNNR,
          END OF JTAB .
    DATA : BEGIN OF JTAB1 OCCURS 0,
        VBELN LIKE VBAK-VBELN ,
        ERNAM LIKE VBAK-ERNAM ,
        ERDAT LIKE VBAK-ERDAT,
        KUNNR LIKE VBAK-KUNNR,
        END OF JTAB1.
    DATA : V_REPID LIKE SY-REPID,
           V_LAYOUT TYPE SLIS_LAYOUT_ALV,
          V_EVENTS TYPE SLIS_T_EVENT,
          V_PRINT TYPE SLIS_PRINT_ALV,
          L_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
    DATA : FIELD1 TYPE SLIS_FIELDCAT_ALV.
    DATA : FIELDCAT1 TYPE SLIS_T_FIELDCAT_ALV.
    DATA : FIELDCAT2 TYPE SLIS_T_FIELDCAT_ALV.
    SELECT-OPTIONS : CNO FOR KNA1-KUNNR.
    START-OF-SELECTION.
      V_REPID  = SY-REPID .
      SELECT KUNNR NAME1 LAND1 ORT01 FROM KNA1 INTO CORRESPONDING FIELDS OF
      TABLE ITAB WHERE KUNNR IN CNO .
      SELECT VBELN ERNAM ERDAT KUNNR FROM VBAK INTO CORRESPONDING FIELDS OF
    TABLE JTAB  FOR ALL ENTRIES IN ITAB WHERE KUNNR = ITAB-KUNNR.
      CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
       EXPORTING
         I_PROGRAM_NAME               = V_REPID
         I_INTERNAL_TABNAME           = 'ITAB'
      I_STRUCTURE_NAME             =
      I_CLIENT_NEVER_DISPLAY       = 'X'
         I_INCLNAME                   = V_REPID
      I_BYPASSING_BUFFER           = 'X'
      I_BUFFER_ACTIVE              = ' '
        CHANGING
          CT_FIELDCAT                  = FIELDCAT1
    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.
    LOOP AT FIELDCAT1 INTO l_fieldcat.
       CASE l_fieldcat-fieldname.
         WHEN 'KUNNR'.
           l_fieldcaT-hotspot = 'X'.
           MODIFY FIELDCAT1 FROM l_fieldcat.
       ENDCASE.
    ENDLOOP.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
      I_INTERFACE_CHECK              = ' '
      I_BYPASSING_BUFFER             = 'X'
      I_BUFFER_ACTIVE                = ' '
         I_CALLBACK_PROGRAM             = V_REPID
      I_CALLBACK_PF_STATUS_SET       = ' '
         I_CALLBACK_USER_COMMAND        = 'USER_COMMAND'
      I_STRUCTURE_NAME               =
      IS_LAYOUT                      =
         IT_FIELDCAT                    = FIELDCAT1
      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
      IR_SALV_LIST_ADAPTER           =
      IT_EXCEPT_QINFO                =
      I_SUPPRESS_EMPTY_DATA          = ABAP_FALSE
    IMPORTING
      E_EXIT_CAUSED_BY_CALLER        =
      ES_EXIT_CAUSED_BY_USER         =
        TABLES
          T_OUTTAB                       = ITAB
       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.
    *&      Form  user_command
          text
         -->R_UCOMM      text
         -->RS_SELFIELD  text
    FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
                            RS_SELFIELD TYPE SLIS_SELFIELD.
      IF RS_SELFIELD-FIELDNAME EQ 'KUNNR'.
        CASE R_UCOMM.
          WHEN '&IC1'.
            READ TABLE ITAB INDEX RS_SELFIELD-TABINDEX.
            REFRESH JTAB1.
           CLEAR JTAB1.
            LOOP AT JTAB WHERE KUNNR = ITAB-KUNNR.
              APPEND JTAB TO JTAB1.
            ENDLOOP.
            CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
             EXPORTING
               I_PROGRAM_NAME               = V_REPID
               I_INTERNAL_TABNAME           = 'JTAB1'
      I_STRUCTURE_NAME             =
      I_CLIENT_NEVER_DISPLAY       = 'X'
               I_INCLNAME                   = V_REPID
      I_BYPASSING_BUFFER           =
      I_BUFFER_ACTIVE              =
              CHANGING
                CT_FIELDCAT                  = FIELDCAT2
    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.
            CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
             EXPORTING
      I_INTERFACE_CHECK              = ' '
      I_BYPASSING_BUFFER             = 'X'
      I_BUFFER_ACTIVE                = ' '
               I_CALLBACK_PROGRAM             = V_REPID
      I_CALLBACK_PF_STATUS_SET       = ' '
      I_CALLBACK_USER_COMMAND        = ' '
      I_STRUCTURE_NAME               =
      IS_LAYOUT                      =
               IT_FIELDCAT                    = FIELDCAT2
      IT_EXCLUDING                   =
      IT_SPECIAL_GROUPS              =
      IT_SORT                        =
      IT_FILTER                      =
      IS_SEL_HIDE                    =
      I_DEFAULT                      = 'X'
      I_SAVE                         = 'A'
      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
      IR_SALV_LIST_ADAPTER           =
      IT_EXCEPT_QINFO                =
      I_SUPPRESS_EMPTY_DATA          = ABAP_FALSE
    IMPORTING
      E_EXIT_CAUSED_BY_CALLER        =
      ES_EXIT_CAUSED_BY_USER         =
              TABLES
                T_OUTTAB                       = JTAB1
    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.
        ENDCASE.
      ENDIF.
    ENDFORM.                    "user_command
    Regards,
    Sravanthi

  • Extract from ALV List

    Hello All,
    Please suggest me is there any way to extract the data from ALV LIST.
    For example:
    SUBMIT  XXX WITH SELECTION-TABLE rspar_tab AND RETURN.
    This XXX  program gives the result in alv list.Once it returns back to original program i want to fetch the results.
    Thanks and Best Regards,
    Vinoth

    Hi Vinoth...
    SUBMIT XXX WITH SELECTION-TABLE rspar_tab AND RETURN.
    Whether ur submit program (XXX) is standard or Zreport?
    1, If it is standard means u need to copy the program  in to ZXXX..
        And now change the ZXXX.
        Fetch where the final Internal table is populating for output display..
    There u need to Export that internal table ..
    eg:
    export g_t_belege1 to memory id 'ZSARA'.
    export bestand1 to memory id 'ZSARA1'.
    1,g_t_belege1
    2,bestand1
    these are internal tables in the Submit program (ZXXX)..
    Now u may come to ur original program..
    and import this..
      import g_t_belege1 from memory id 'ZSARA'.
      import bestand1 from memory id 'ZSARA1'.
    g_t_belege1,bestand1 these internal table structures sholud be same as Submit program structures..
    Else.. it may give Dump ..
    Now u may process the internal tables  g_t_belege1,bestand1 by ur wish..
    2,
    If it Zreport means no need to copy ..
    Just export into one id and import in ur original program.
    Hope it will helps..
    Reward if it is useful means.
    Regards
    Bala..
    Message was edited by:
            S Balasubramanian

  • Move data from multiple Tables to a Single Table & Convert the list to ALV.

    Hi,
    My aim is to get the list of Materials with their descriptions, with MRP Controller, with Unrestriced Qty. & the Reorder Qty. So, I have to fetch the data from different tables. But finally I am not able to copy or move the fetched data from multiple tables into the single final table.
    Also tell me how to convert this list into ALV.
    Below is the program code.
    *& Report  Y_REORDER_REPORT
    REPORT  Y_REORDER_REPORT.
    tables : marc,makt, mard.
    DATA: Begin of i_final occurs 0,
            matnr type marc-matnr,
            maktx type makt-maktx,
            DISPO type marc-DISPO,
            MINBE type marc-MINBE,
            LABST type mard-LABST,
          end of i_final.
    DATA: Begin of i_marc occurs 0,
           matnr type marc-matnr,
           DISPO type marc-DISPO,
           MINBE type marc-MINBE,
          end of i_marc.
    DATA: Begin of i_makt occurs 0,
           matnr type makt-matnr,
           maktx type makt-maktx,
          end of i_makt.
    DATA: Begin of i_mard occurs 0,
           matnr type mard-matnr,
           LABST type mard-LABST,
           LGORT TYPE MARD-LGORT,
          end of i_mard.
    SELECT  matnr
            dispo
            minbe from marc
            into corresponding fields of table i_marc
            where dispo EQ 'STR'.
    SORT I_MARC by MATNR.
    WRITE: /10  'Material',
            75  'MRP',
            80  'Reorder Qty.'.
    LOOP at i_marc.
    Write: /10  i_marc-matnr,
            75  i_marc-dispo,
            80  i_marc-minbe.
    ENDLOOP.
    write: /.
    SELECT  matnr
            MAKTX from makt
            into corresponding fields of table i_makt
            for all entries in i_marc
            where matnr = i_marc-matnr.
    LOOP at i_makt.
    Write: /10 i_makt-matnr,
            30 i_makt-maktx.
    ENDLOOP.
    SELECT  matnr
            LGORT
            LABST from mard
            into corresponding fields of table i_mard
            for all entries in i_marc
            where matnr = i_marc-matnr.
    LOOP at i_mard.
    Write: /10 i_mard-matnr,
            30 I_MARD-LGORT,
            40 i_mard-labst.
    ENDLOOP.
    move  i_mard-matnr to i_final-matnr.
    move  i_marc-dispo to i_final-dispo.
    move  i_marc-minbe to i_final-minbe.
    move  i_makt-maktx to i_final-maktx.
    move  i_mard-labst to i_final-labst.
    WRITE: /10  'Material',
            30  'Material Desc.',
            75  'MRP',
            80  'Reorder Qty.',
            105 'Current Stock'.
    LOOP at i_final.
    Write: /10  i_final-matnr,
            30  i_final-maktx,
            75  i_final-dispo,
            80  i_final-minbe,
            105 i_final-labst.
    ENDLOOP.
    *LOOP at i_mard.
    *Write: /10  i_mard-matnr,
           30  i_makt-maktx,
           75  i_marc-dispo,
           80  i_marc-minbe,
           105 i_mard-labst.
    *ENDLOOP.
    Regards,
    Vishal

    Change like this,
    SELECT matnr
    lgort
    labst FROM mard
    INTO CORRESPONDING FIELDS OF TABLE i_mard
    FOR ALL ENTRIES IN i_marc
    WHERE matnr = i_marc-matnr.
    LOOP AT i_mard.
       WRITE: /10 i_mard-matnr,
       30 i_mard-lgort,
       40 i_mard-labst.
    ENDLOOP.
    LOOP AT i_marc.
       READ TABLE i_mard WITH KEY matnr =  i_marc-matnr.
       READ TABLE i_makt WITH KEY matnr =  i_marc-matnr.
       MOVE i_mard-matnr TO i_final-matnr.
       MOVE i_marc-dispo TO i_final-dispo.
       MOVE i_marc-minbe TO i_final-minbe.
       MOVE i_makt-maktx TO i_final-maktx.
       MOVE i_mard-labst TO i_final-labst.
       APPEND i_final.
    ENDLOOP.
    WRITE: /10 'Material',
    30 'Material Desc.',
    75 'MRP',
    80 'Reorder Qty.',
    105 'Current Stock'.

  • I cannot dowload all fields from ALV list to Excel - urgent, please help me

    I developed a report and displayed in ALV list using FM 'REUSE_ALV_GRID_DISPLAY'.The list contains 200 fields.But when i am trying to download in EXCEL file from ALV list, it is unable to download all the fields from ALV list into EXCEL.
    Thanks in advance,
    Katta.

    is your list having packed decimals or any fields which are of large length (around 128 char)?
    It can happen so.

  • Picking data directly from ALV List

    HI experts !
    I have a scenario in which the client is executing some tcodes ( Some hourly, some daily , some weekly, ome monthly ) and all the data gets displayed in alv list . The requirement is that is it possible for XI to pick that data directly from alv and update the data base?
    OR
    If the above case is not possible then the client is thinking of putting the data in a spool and then by running some program they fetch the data ?
    Guide me on this ? how to execute such scenario?
    Regards
    saras jain

    Create and outbound interface with needed datatypes and message types. Create a client proxu for this.
    Create a report, which gets all these data in to internal tables and then call the client proxy from XI. You can have whatever adapter on the receiver side..
    VJ

  • Pickking data from ALV List diractly into XI

    HI experts !
    I have a scenario in which the client is executing some tcodes ( Some hourly, some daily , some weekly, ome monthly ) and all the data gets displayed in alv list . The requirement is that is it possible for XI to pick that data directly from alv and update the data base?
    OR
    If the above case is not possible then the client is thinking of putting the data in a spool and then by running some program they fetch the data ?
    Guide me on this ? how to execute such scenario?
    Regards
    saras jain

    Option 1 : As a standard you can go for client ABAP proxies. When ever the tcode is executed, in the ABAP code that gets executed in the back ground add a part that will pass all the required values to the client proxy which triggers a message to XI.
    Option 2 : Write all the data you want to a flat/xml file and make File adapter poll this directory.
    Option 1 is more perfomant than 2.
    Regards,
    Jai Shankar

  • How to remove a Sort button from ALV List

    Hi Experts,
    How to remove sort button from ALV List.
    I have requirement where I need to remove the sort button from ALV list.
    Kindly give me useful clues.
    Higher points will be awarded for the useful inputs.
    Thanks in Advance,
    Dharani

    Hi dharani,
    1. UP and Down Sort Button will get removed.
    2. Important code is marked in bold
    3. Just copy paste.
    4.
    report abc.
    TYPE-POOLS : slis.
    DATA : alvfc TYPE slis_t_fieldcat_alv.
    DATA : alvfcwa TYPE slis_fieldcat_alv.
    <b>data : excl type SLIS_T_EXTAB.
    data : exclwa type SLIS_EXTAB.</b>
    data : begin of itab occurs 0.
            include structure usr02.
    data : end of itab.
    START-OF-SELECTION.
      select * from usr02
      into table itab.
      CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
        EXPORTING
          i_program_name         = sy-repid
          i_internal_tabname     = 'ITAB'
          i_inclname             = sy-repid
        CHANGING
          ct_fieldcat            = alvfc
        EXCEPTIONS
          inconsistent_interface = 1
          program_error          = 2
          OTHERS                 = 3.
    <b>*----
    IMPORTANT
    fcodes to remove
    Up and Down Sort Button
    exclwa-fcode = '&OUP'.
    append exclwa to excl.
    exclwa-fcode = '&ODN'.
    append exclwa to excl.</b>
    Display
      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
        EXPORTING
          it_fieldcat   = alvfc
          <b>IT_EXCLUDING     = excl</b>
        TABLES
          t_outtab      = itab
        EXCEPTIONS
          program_error = 1
          OTHERS        = 2.
    regards,
    amit m.

  • How to Downlaod Data from Alv List to Excel File

    Hi,
      I have a Requirement like While download data from ALV to Excel File .After Download data into Excel we will not allow user to edit the Excel data..
    Plz  help me to complete this scenario.
    Thanks & Regards,
    Kumaran Duraiswamy.

    hi,
    try these following fm's
    MS_EXCEL_OLE_STANDARD_DAT
    EXCEL_OLE_STANDARD_DAT
    CALL FUNCTION 'MS_EXCEL_OLE_STANDARD_DAT'
    EXPORTING
    file_name = 'Your Path' " enter your path to save the file.
    CREATE_PIVOT = 0
    * DATA_SHEET_NAME = ' '
    * PIVOT_SHEET_NAME = ' '
    * PASSWORD = ' '
    * PASSWORD_OPTION = 0
    VISIBLE = '0'
    No_DIALOG = 'X'
    TABLES
    * PIVOT_FIELD_TAB =
    DATA_TAB = t_deli_final
    * FIELDNAMES =
    EXCEPTIONS
    FILE_NOT_EXIST = 1
    FILENAME_EXPECTED = 2
    COMMUNICATION_ERROR = 3
    OLE_OBJECT_METHOD_ERROR = 4
    OLE_OBJECT_PROPERTY_ERROR = 5
    INVALID_FILENAME = 6
    INVALID_PIVOT_FIELDS = 7
    DOWNLOAD_PROBLEM = 8
    OTHERS = 9
    IF sy-subrc 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    2nd fm
      CALL FUNCTION 'EXCEL_OLE_STANDARD_DAT'
           EXPORTING
                FILE_NAME                 = 'Your Path' "path to save your file
                DATA_SHEET_NAME           = V_SHEET_NAME
           TABLES
                DATA_TAB                  = TLX
           EXCEPTIONS
                FILE_NOT_EXIST            = 1
                FILENAME_EXPECTED         = 2
                COMMUNICATION_ERROR       = 3
                OLE_OBJECT_METHOD_ERROR   = 4
                OLE_OBJECT_PROPERTY_ERROR = 5
                INVALID_FILENAME          = 6
                INVALID_PIVOT_FIELDS      = 7
                DOWNLOAD_PROBLEM          = 8
                OTHERS                    = 9.
      IF SY-SUBRC NE 0.
        WRITE:/ 'ERROR OPENING EXCEL'.
      ENDIF.
    ELSE.
      WRITE:/ 'ERROR OR NO DATA'.
    ENDIF.

  • Drop down list in ALV grid

    Dear Expert,
    I am new to OOPS ,
    I want to display drop down list for a particular field in my output, so I am using OOPS but in my below code
    I am facing problem in displaying the output as I am getting the error message
    Field catalog not found...
    Also advice me how to display drop down list in a particular field.
    Please advice
    MODULE pbo OUTPUT.
      SET PF-STATUS 'ZTEST'.
      IF g_custom_container IS INITIAL.
        DATA: lt_exclude TYPE ui_functions,
              lt_f4 TYPE lvc_t_f4 WITH HEADER LINE.
        CREATE OBJECT g_custom_container
          EXPORTING
            container_name = g_container.
        CREATE OBJECT g_grid
          EXPORTING
            i_parent = g_custom_container.
        PERFORM field_catalog TABLES it_lvc_t_fcat
           USING: 'S_FINAL' 'MATNR' ' ' 'Part Number' ' ' ' ',
                       'S_FINAL' 'MAKTX' ' ' 'Part Description' ' ' ' ',
                       'S_FINAL' 'MBLNR' ' ' 'Document No' ' ' ' ',
                       'S_FINAL' 'BLDAT' ' ' 'Document date' ' ' ' ',
                       'S_FINAL' 'LIFNR' ' ' 'Vendor Number' ' ' ' ',
                       'S_FINAL' 'STATUS' ' ' 'Acknowledgement' ' ' 'X',
                       'S_FINAL' 'REMARKS' ' ' 'Remarks' ' ' 'X'.
        CALL METHOD g_grid->set_table_for_first_display
           EXPORTING
    *    I_STRUCTURE_NAME              =
         is_layout                                =   it_lvc_s_layo
           CHANGING
             it_outtab                        =   i_final
         it_fieldcatalog                =   it_lvc_t_fcat
      ENDIF.
    ENDMODULE.                 " PBO  OUTPUT
    FORM field_catalog  TABLES t_field_catalog STRUCTURE wt_lvc_s_fcat
    USING fp_tabname TYPE any
    fp_fieldname TYPE any
    fp_key TYPE any
    fp_text TYPE any
    fp_do_sum TYPE any
    fp_edit TYPE any.
      t_field_catalog-tabname = fp_tabname.
      t_field_catalog-fieldname = fp_fieldname.
      t_field_catalog-key = fp_key.
      t_field_catalog-seltext = fp_text.
      t_field_catalog-do_sum = fp_do_sum .
      t_field_catalog-edit = fp_edit .
    ENDFORM.                    "field_catalog
    Edited by: Karthik R on Mar 15, 2010 6:11 PM

    Hi Karthik,
    Below mentioned  is a Simple code for creating dropdown lists for columns in ALV grid output
    REPORT z_alv_dropdown.
    *Type pools declarations for ALV
    TYPE-POOLS : slis.
    *data declarations for ALV container, ALV grid,  Field catalogues & layout
    DATA: g_grid  TYPE REF TO cl_gui_alv_grid,
          g_custom_container TYPE REF TO cl_gui_custom_container,
          gt_fieldcat TYPE lvc_t_fcat,
          gs_layout TYPE lvc_s_layo.
    *INTERNAL TABLE AND WA DECLARATIONS FOR t517 A table
    DATA: gt_outtab TYPE STANDARD TABLE OF t517a INITIAL SIZE 0,
          wa_outtab TYPE t517a.
    *initialisation event
    INITIALIZATION.
    *Start of selection event
    START-OF-SELECTION.
    *Call to ALV
      CALL SCREEN 600.
    *On this statement double click  it takes you to the screen painter SE51.
    *Create a Custom container and name it CCONT and OK code as OK_CODE.
    *Save check and Activate the screen painter.
    *Now a normal screen with number 600 is created which holds the ALV grid.
    PBO of the actual screen , Here we can give a title and customized menus
    Here we also call the subroutine for ALV output.
          MODULE PBO OUTPUT                                             *
    MODULE pbo OUTPUT.
    set pf-status 'xxx'.
    set titlebar 'MAIN100'.
    Subroutine to display the output in alv
      PERFORM alv_output.
    ENDMODULE.                    "pbo OUTPUT
    PAI module of the screen created. In case we use an interactive ALV or
    *for additional functionalities we can create OK codes and
    based on the user command we can do the coding.
          MODULE PAI INPUT                                              *
    MODULE pai INPUT.
    ENDMODULE.                    "pai INPUT
    *&      Form  BUILD_FIELDCAT
    FORM build_fieldcat.
      DATA ls_fcat TYPE lvc_s_fcat.
    *Build the field catalogue
      CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
        EXPORTING
          i_structure_name = 'T517A'
        CHANGING
          ct_fieldcat      = gt_fieldcat.
    To assign dropdown in the fieldcataogue
      LOOP AT gt_fieldcat INTO ls_fcat.
        CASE ls_fcat-fieldname.
          WHEN 'SLART'.
    *drdn-hndl = '1' is the first list box
            ls_fcat-drdn_hndl = '1'.
            ls_fcat-outputlen = 15.
            MODIFY gt_fieldcat FROM ls_fcat.
    *drdn-hndl = '2' is the second list box
          WHEN 'ABART'.
            ls_fcat-drdn_hndl = '2'.
            ls_fcat-outputlen = 15.
            MODIFY gt_fieldcat FROM ls_fcat.
        ENDCASE.
      ENDLOOP.
    ENDFORM.                    "build_fieldcat
    *&      Form  ALV_OUTPUT
    FORM alv_output .
    *Create object for container
      CREATE OBJECT g_custom_container
             EXPORTING container_name = 'CCONT'.
    *create object for grid
      CREATE OBJECT g_grid
             EXPORTING i_parent = g_custom_container.
    Build fieldcat and set column
    *Assign a handle for the dropdown listbox.
      PERFORM build_fieldcat.
    *Build layout
      PERFORM build_layout.
    Define a drop down table.
      PERFORM dropdown_table.
    *fetch values from the T517A table
      SELECT * FROM t517a INTO TABLE gt_outtab.
    *Display ALV output
      CALL METHOD g_grid->set_table_for_first_display
        EXPORTING
          is_layout       = gs_layout
        CHANGING
          it_fieldcatalog = gt_fieldcat
          it_outtab       = gt_outtab.
    ENDFORM.                               "ALV_OUTPUT
    *&      Form  dropdown_table
          text
    -->  p1        text
    <--  p2        text
    FORM dropdown_table.
    *Declarations for drop down lists in ALV.
      DATA: lt_dropdown TYPE lvc_t_drop,
            ls_dropdown TYPE lvc_s_drop.
    First SLART listbox (handle '1').
      ls_dropdown-handle = '1'.
      ls_dropdown-value = '01 Pink'.
      APPEND ls_dropdown TO lt_dropdown.
      ls_dropdown-handle = '1'.
      ls_dropdown-value = '02 Yellow'.
      APPEND ls_dropdown TO lt_dropdown.
      ls_dropdown-handle = '1'.
      ls_dropdown-value = '03 Green'.
      APPEND ls_dropdown TO lt_dropdown.
      ls_dropdown-handle = '1'.
      ls_dropdown-value = '04 Black'.
      APPEND ls_dropdown TO lt_dropdown.
      ls_dropdown-handle = '1'.
      ls_dropdown-value = '05 White'.
      APPEND ls_dropdown TO lt_dropdown.
      ls_dropdown-handle = '1'.
      ls_dropdown-value = '06 Blue'.
      APPEND ls_dropdown TO lt_dropdown.
      ls_dropdown-handle = '1'.
      ls_dropdown-value = '09 Other Colors'.
      APPEND ls_dropdown TO lt_dropdown.
    *method to display the dropdown in ALV
      CALL METHOD g_grid->set_drop_down_table
        EXPORTING
          it_drop_down = lt_dropdown.
    ENDFORM.                               " dropdown_table
    *&      Form  build_layout
          text
    *layout for ALV output
    FORM build_layout .
      gs_layout-cwidth_opt = 'X'.
      gs_layout-grid_title = 'ALV DROPDOWN LISTS'.
      gs_layout-no_toolbar = 'X'.
    ENDFORM.                    " build_layout
    Hope it is helpful,
    Regards,
    Soundarya.

  • How we can get an interactive report  in alv grid display?

    Hi experts
    Plz tell me how we can get an interactive report in alv grid disply pls send me one sample code to understand this
    thanks in advance

    hi,
    check this one
    *& Report  ZALV_FIELD_GRID1
    REPORT  ZALV_FIELD_GRID1
            NO STANDARD PAGE HEADING.
    TABLES MARA.
    type-pools :slis.
    TYPES : BEGIN OF TMARA ,
            MATNR LIKE MARA-MATNR,
            MEINS LIKE MARA-MEINS,
            ERSDA LIKE MARA-ERSDA,
            color(4) type c,
            SEL type c,
            LIGHT TYPE C,
            END OF TMARA.
    TYPES: BEGIN OF TMAKT,
           MATNR LIKE MAKT-MATNR,
           MAKTX LIKE MAKT-MAKTX,
           MAKTG LIKE MAKT-MAKTG,
           SEL TYPE C,
           COLOR(4),
           END OF TMAKT.
    DATA:  ITAB TYPE TMARA OCCURS 0 WITH HEADER LINE,
           ITAB1 TYPE TMAKT OCCURS 0 WITH HEADER LINE,
           wa_fieldcat type slis_fieldcat_alv,
           fieldcat type slis_fieldcat_alv occurs 0,
           i_layout type slis_layout_alv,
           WA_LISTHEADER TYPE SLIS_LISTHEADER,
           i_LISTHEADER TYPE SLIS_LISTHEADER OCCURS 0,
           V_EVENTS TYPE SLIS_T_EVENT ,
           WA_EVENT TYPE SLIS_ALV_EVENT,
           I_TITLE_MARA TYPE LVC_TITLE VALUE 'FIRST LIST DISPLAYED',
           I_TITLE_MAKT TYPE LVC_TITLE VALUE 'SECONDRY LIST DISPLAYED',
           SORT TYPE slis_t_sortinfo_alv WITH HEADER LINE,
           PRINT_CONT type slis_print_alv.
    SELECTION SCREE
    selection-screen  begin of block screen1  with frame title TEXT-001.
    SELECTION-SCREEN SKIP.
    SELECTION-SCREEN COMMENT /32(35) COMM1.
    SELECTION-SCREEN ULINE /27(35).
    SELECTION-SCREEN SKIP.
    SELECT-OPTIONS MATNR FOR MARA-MATNR.
    SELECTION-SCREEN SKIP.
    SELECTION-SCREEN ULINE.
    SELECTION-SCREEN COMMENT /30(50) COMM2.
    SELECTION-SCREEN ULINE /27(40).
    SELECTION-SCREEN SKIP.
    SELECT-OPTIONS ERSDA FOR MARA-ERSDA.
    SELECTION-SCREEN SKIP.
    selection-screen  end of block screen1.
        INITIALIZATION
    INITIALIZATION.
      MATNR-low = '23'.
      MATNR-high = '1000'.
      MATNR-option = 'BT'.
      MATNR-sign = 'I'.
      APPEND MATNR.
      ERSDA-low = '20030124'.
      ERSDA-high = '20050302' .
      APPEND ERSDA.
      PERFORM FILLFIELD.
      PERFORM FILLLAYOUT.
      PERFORM build_print_params.
      PERFORM FILL_SORT.
      PERFORM EVENT_CALL.
      PERFORM POPULATE_EVENT.
            SELECTION-SCREEN OUTPUT
    AT SELECTION-SCREEN OUTPUT.
      comm1 ='SELECT MATERIAL NUMBER  RANGE'.
      comm2 ='SELECT MATERIAL CREATION DATE'.
               START-OF-SELECTION
    START-OF-SELECTION.
      PERFORM READDATA.
      PERFORM POPDATA.
    *&      Form  READDATA
          text
    FORM READDATA .
      CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
        EXPORTING
          INPUT  = MATNR-LOW
        IMPORTING
          OUTPUT = MATNR-LOW.
      CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
        EXPORTING
          INPUT  = MATNR-HIGH
        IMPORTING
          OUTPUT = MATNR-HIGH.
      SELECT MATNR
             ERSDA
             MEINS
             FROM MARA
             INTO CORRESPONDING FIELDS OF
            TABLE ITAB
            WHERE MATNR IN MATNR AND ERSDA IN ERSDA.
      LOOP AT ITAB.
        data id_color type i VALUE 1.
        data id_colors(2) type c.
        IF ITAB-MATNR < '000000000000000100'.
          ITAB-LIGHT = '1'.
        ELSEIF ITAB-MATNR < '000000000000000150' AND ITAB-MATNR >
       '000000000000000100' .
          ITAB-LIGHT = '2'.
        ELSE.
          ITAB-LIGHT = '3'.
        ENDIF.
        id_color = id_color + 1.
        if id_color > 7.
          id_color = 1.
        endif.
        id_colors = id_color.
        concatenate 'C' id_colors '10' into itab-color.
        modify itab.
        CLEAR ITAB.
      endloop.
    ENDFORM.                    " READDATA
         Form  FILLFIELD
    FORM FILLFIELD .
      WA_FIELDCAT-FIELDNAME = 'MATNR'.
      WA_FIELDCAT-KEY = 'X'.
      WA_FIELDCAT-COL_POS = '1'.
      WA_FIELDCAT-outputlen   = 20.
      WA_FIELDCAT-HOTSPOT = 'X'.
      wa_fieldcat-seltext_m = 'MATERIAL NUMBER'.
    *WA_FIELDCAT-EMPHASIZE = 'C210'.
      APPEND WA_FIELDCAT TO FIELDCAT.
      clear wa_fieldcat.
      WA_FIELDCAT-FIELDNAME = 'MEINS'.
      WA_FIELDCAT-COL_POS = '2'.
    *WA_FIELDCAT-EMPHASIZE = 'C510'.
      WA_FIELDCAT-outputlen   = 10.
      wa_fieldcat-seltext_m = 'UNIT'.
      APPEND WA_FIELDCAT TO FIELDCAT.
      clear wa_fieldcat.
      WA_FIELDCAT-FIELDNAME = 'ERSDA'.
      WA_FIELDCAT-COL_POS = '3'.
      WA_FIELDCAT-outputlen   = 15.
    *WA_FIELDCAT-EDIT_MASK  = 'DD.MM.YYYY'.
    *WA_FIELDCAT-EMPHASIZE = 'C710'.
      wa_fieldcat-seltext_m = 'CREAT DATE'.
      APPEND WA_FIELDCAT TO FIELDCAT.
      clear wa_fieldcat.
    ENDFORM.                    "FILLFIELD
          Setup print parameters
    form build_print_params.
      PRINT_CONT-reserve_lines = '3'.   "Lines reserved for footer
      PRINT_CONT-no_coverpage = 'X'.
    endform.                    " BUILD_PRINT_PARAMS
         Form  POPDATA
    FORM POPDATA .
      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             = 'TOPPAGE'
      I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
      I_CALLBACK_HTML_END_OF_LIST       = ' '
      I_STRUCTURE_NAME                  =
      I_BACKGROUND_ID                   = ' '
         I_GRID_TITLE                       = I_TITLE_MARA
      I_GRID_SETTINGS                   =
         IS_LAYOUT                          = I_LAYOUT
         IT_FIELDCAT                        = fieldcat
      IT_EXCLUDING                      =
      IT_SPECIAL_GROUPS                 =
        IT_SORT                           =  SORT[]
      IT_FILTER                         =
      IS_SEL_HIDE                       =
      I_DEFAULT                         = 'X'
      I_SAVE                            = ' '
      IS_VARIANT                        =
         IT_EVENTS                          = V_EVENTS
      IT_EVENT_EXIT                     =
       IS_PRINT                          = PRINT_CONT
        TABLES
          T_OUTTAB                          = ITAB
    EXCEPTIONS
       PROGRAM_ERROR                     = 1
       OTHERS                            = 2
    ENDFORM.                    " POPDATA
         Form  TOPPAGE
    FORM TOPPAGE.
      REFRESH I_LISTHEADER.
      DATA: ld_lines type i,
            ld_linesc(10) type c,
            I_DATE(10) TYPE C,
            I_INFO LIKE WA_LISTHEADER-INFO.
      WA_LISTHEADER-TYP = 'H'.
      WA_LISTHEADER-INFO = 'MATERIAL DETAIL'.
      APPEND WA_LISTHEADER TO I_LISTHEADER.
      CLEAR WA_LISTHEADER.
      WA_LISTHEADER-TYP = 'S'.
      WA_LISTHEADER-KEY = 'DATE :'.
      CONCATENATE SY-DATUM+6(2) '.'
                           SY-DATUM+4(2) '.'
                           SY-DATUM(4) INTO I_DATE.
      WA_LISTHEADER-INFO = I_datE.
      APPEND WA_LISTHEADER TO I_LISTHEADER.
      CLEAR WA_LISTHEADER.
      describe table ITAB lines ld_lines.
      ld_linesc = ld_lines.
      concatenate 'TOTAL NUMBER OF RECORD SELECTED: ' ld_linesc
                        into I_INFO separated by space.
      WA_LISTHEADER-TYP  = 'A'.
      WA_LISTHEADER-INFO = I_INFO.
      append WA_LISTHEADER to I_LISTHEADER.
      clear: WA_LISTHEADER , I_INFO.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          IT_LIST_COMMENTARY = I_LISTHEADER
          I_LOGO             = 'ENJOYSAP_LOGO'.
    ENDFORM.                    "TOPPAGE
         Form  FILLLAYOUT
    FORM FILLLAYOUT .
      i_layout-zebra = 'X'.
      i_layout-info_fieldname = 'COLOR'.
      i_layout-box_fieldname = 'SEL'.
      I_LAYOUT-lights_fieldname = 'LIGHT'.
      I_LAYOUT-EDIT ='X'.
      I_LAYOUT-colwidth_optimize = 'X'.
      I_LAYOUT-window_titlebar = 'EXAMPLE FOR ALV GRID'.
      I_LAYOUT-no_totalline = 'X'.
    ENDFORM.                    "FILLLAYOUT
        Form  FILL_SORT
    FORM FILL_SORT .
      SORT-DOWN = 'X'.
      SORT-SPOS = 1.
      SORT-FIELDNAME = 'MATNR'.
      SORT-tabname = 'MARA'.
      APPEND SORT.
    ENDFORM.                    " FILL_SORT
         Form  EVENT_CALL
    FORM EVENT_CALL .
      DATA: I_EVENT LIKE V_EVENTS.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
        EXPORTING
          I_LIST_TYPE = 0
        IMPORTING
          ET_EVENTS   = V_EVENTS.
      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
    FORM POPULATE_EVENT .
      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.
    READ TABLE V_EVENTS WITH KEY NAME = SLIS_EV_END_OF_PAGE
                                          INTO WA_EVENT.
    IF SY-SUBRC = 0.
       move 'END_OF_PAGE' to WA_EVENT-FORM.
       MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =
       WA_EVENT-NAME.
      endif.
      ENDIF.
    ENDFORM.                    "POPULATE_EVENT
    FORM END_OF_PAGE.
      write: sy-uline(50).
      skip.
      write:/40 'Page:', sy-pagno .
    ENDFORM.
    *&      Form  USER_COMMAND
    FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
    RS_SELFIELD TYPE SLIS_SELFIELD.
      CASE R_UCOMM.
        WHEN '&IC1'.
          CASE RS_SELFIELD-FIELDNAME.
            when 'MATNR'.
              read table itab with key matnr = RS_SELFIELD-VALUE.
              if sy-subrc = 0.
                PERFORM DATA_RETRIEVAL_MAKT USING RS_SELFIELD-VALUE.
                PERFORM BUILD_FIELDCATLOG_MAKT.
                PERFORM FILLLAYOUT_MAKT.
                PERFORM DISPLAY_ALV_MAKT.
                CLEAR RS_SELFIELD.
              ENDIF.
          ENDCASE.
      ENDCASE.
    ENDFORM.                    "user_command
         Form  DATA_RETRIEVAL_MAKT
    FORM DATA_RETRIEVAL_MAKT USING TMATNR .
      SELECT MATNR
             MAKTX
             MAKTG
             UP TO 100 ROWS
             FROM MAKT
             INTO TABLE ITAB1
             WHERE SPRAS = 'EN' AND MATNR = TMATNR.
      LOOP AT ITAB1.
        data id_color type i VALUE 1.
        data id_colors(2) type c.
        id_color = id_color + 1.
        if id_color > 7.
          id_color = 1.
        endif.
        id_colors = id_color.
        concatenate 'C' id_colors '10' into itab1-color.
        modify itab1.
        CLEAR ITAB1.
      ENDLOOP.
    ENDFORM.                    "DATA_RETRIEVAL_MAKT
         Form  FILLLAYOUT_MAKT
    FORM FILLLAYOUT_MAKT .
      CLEAR I_LAYOUT.
      i_layout-zebra = 'X'.
      i_layout-info_fieldname = 'COLOR'.
      i_layout-box_fieldname = 'SEL'.
      I_LAYOUT-EDIT ='X'.
      I_LAYOUT-colwidth_optimize = 'X'.
      I_LAYOUT-window_titlebar = 'EXAMPLE FOR ALV GRID'.
    ENDFORM.                    " LAYOUT_MAKT
        Form  BUILD_FIELDCATLOG_MAKT
    FORM BUILD_FIELDCATLOG_MAKT .
      REFRESH FIELDCAT.
      WA_FIELDCAT-FIELDNAME = 'MATNR'.
      WA_FIELDCAT-KEY = 'X'.
      WA_FIELDCAT-COL_POS = '1'.
    *WA_FIELDCAT-EDIT_MASK  = 'DD.MM.YYYY'.
      WA_FIELDCAT-EMPHASIZE = 'C510'.
      wa_fieldcat-seltext_m = 'MATERIAL NUMBER'.
      APPEND WA_FIELDCAT TO FIELDCAT.
      clear wa_fieldcat.
      WA_FIELDCAT-FIELDNAME = 'MAKTX'.
      WA_FIELDCAT-COL_POS = '2'.
      WA_FIELDCAT-EMPHASIZE = 'C710'.
      wa_fieldcat-seltext_m = 'MATERIAL DESCRIPTION'.
      APPEND WA_FIELDCAT TO FIELDCAT.
      clear wa_fieldcat.
      WA_FIELDCAT-FIELDNAME = 'MAKTG'.
      WA_FIELDCAT-COL_POS = '3'.
      WA_FIELDCAT-EMPHASIZE = 'C210'.
      wa_fieldcat-seltext_m = 'MATERIAL DESCRIPTION'.
      APPEND WA_FIELDCAT TO FIELDCAT.
      clear wa_fieldcat.
    ENDFORM.                    " BUILD_FIELDCATLOG_MAKT
         Form  DISPLAY_ALV_MAKT
    FORM TOP-OF-PAGE.
      REFRESH I_LISTHEADER.
      DATA: ld_lines type i,
            ld_linesc(10) type c,
            I_DATE(10) TYPE C,
            I_INFO LIKE WA_LISTHEADER-INFO.
      WA_LISTHEADER-TYP = 'H'.
      WA_LISTHEADER-INFO = 'MATERIAL DESCRIPTION FOR SELECTED NUMBER'.
      APPEND WA_LISTHEADER TO I_LISTHEADER.
      CLEAR WA_LISTHEADER.
      WA_LISTHEADER-TYP = 'S'.
      WA_LISTHEADER-KEY = 'DATE :'.
      CONCATENATE SY-DATUM+6(2) '.'
                           SY-DATUM+4(2) '.'
                           SY-DATUM(4) INTO I_DATE.
      WA_LISTHEADER-INFO = I_datE.
      APPEND WA_LISTHEADER TO I_LISTHEADER.
      CLEAR WA_LISTHEADER.
      describe table ITAB1 lines ld_lines.
      ld_linesc = ld_lines.
      concatenate 'TOTAL NUMBER OF RECORD SELECTED: ' ld_linesc
                        into I_INFO separated by space.
      WA_LISTHEADER-TYP  = 'A'.
      WA_LISTHEADER-INFO = I_INFO.
      append WA_LISTHEADER to I_LISTHEADER.
      clear: WA_LISTHEADER , I_INFO.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          IT_LIST_COMMENTARY = I_LISTHEADER
          I_LOGO             = 'ENJOYSAP_LOGO'.
      I_END_OF_LIST_GRID       =
      I_ALV_FORM               =
    ENDFORM.                    "TOP-OF-PAGE
    *&      Form  DISPLAY_ALV_MAKT
          text
    FORM DISPLAY_ALV_MAKT .
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          I_CALLBACK_PROGRAM     = SY-REPID
          I_CALLBACK_TOP_OF_PAGE = 'TOP-OF-PAGE'
          I_GRID_TITLE           = I_TITLE_MAKT
          IS_LAYOUT              = I_LAYOUT
          IT_FIELDCAT                       = fieldcat
        TABLES
          T_OUTTAB               = ITAB1
        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_MAKT
    Rewards points

  • Leading spaces in excel file from ALV

    Hi Guys,
    once I export a record from ALV to excel. Some values I think all values that are TYPE I. How can I remove this leading spaces.
    Ex: '                                                      100'
    something like that.. so if you dont expand the column with you wont see the value 100. I checked the internal table being passed to ALV. It doesnt have leading spaces also in the ALV display. there is no leading spaces. Is there something to to with column width optimization? I need this to optimize the column headers. Thanks in Advance!
    Regards,
    Michael Nacionales

    There is one table CRVS_B with field SFHNR, while creating PRTS I need this field, so I do like this:
    select max( SFHNR ) into l_sfhnr
    from CRVS_B.
    add var to l_sfhnr.
    So for example l_sfhnr is equal to 000000000000000010, then after add, it gives me 11, and surprisingly in database 11 is placing position in such a way that last char is empty so it is not 11 but 00000000000000011 ( 17 chars ) as after 11 one empty space, and when it comes next time:
    select max( SFHNR ) into l_sfhnr
    from CRVS_B.
    add var to l_sfhnr.
    the value of l_sfhnr is still 000000000000000010......
    else try this
    Hi
    Field_catalog:
    Field catalog with field descriptions
    2.7.1. Description
    Field catalog containing descriptions of the list output fields (usually a subset of the internal output table fields). A field catalog is required for every ALV list output.
    The field catalog for the output table is built-up in the caller's coding. The build-up can be completely or partially automated by calling the REUSE_ALV_FIELDCATALOG_MERGE module
    See also the documentation of the function module REUSE_ALV_FIELDCATALOG_MERGE.
    The minimal field catalog is documented under 'default'. The caller can use the other optional parameters to assign output attributes to a field which differ from the default.
    A field catalog need not be built-up and passed explicitly only under the following conditions:
    • The internal table to be output has the same structure as a Data Dictionary structure which is referred to in the internal table declaration using LIKE or INCLUDE STRUCTURE.
    • all fields in this structure are to be output
    • the structure name is passed to ALV in the parameter I_STRUCTURE_NAME.
    See also the documentation of the IMPORTING paramter I_STRUCTURE_NAME.
    Positioning
    • row_pos (row position)
    value set: 0, 1 - 3
    Only relevant if the list output is to be multi-line (two or three lines) by default.
    A multi-line list can also be defined by the user interactively if the default list is one-line.
    The parameter specifies the relative output line of the column in a multi-line list.
    • col_pos (column position)
    value set: 0, 1 - 60
    only relevant when the default relative column positions differ from the field catalog field sequence. The parameter specifies the relative column position of the field in the list output. The column order can be changed interactively by the user. If this parameter is initial for all field catalog entries, columns appear in the field catalog field sequence.
    Identification
    • fieldname (field name)
    value set: internal output table field name (required parameter)
    Name of the internal output table field which is described by this field catalog entry
    • tabname (internal output table)
    value set: SPACE, internal output table name
    This parameter is used in 'manual' field catalog build-up only for hierarchical-sequential lists.
    Name of the internal output table which contains the field FIELDCAT-FIELDNAME.
    Data Dictionary reference
    • ref_fieldname (reference field name)
    value set: SPACE, Data Dictionary field name
    Name of the Data Dictionary field referred to.
    This parameter is only used when the internal output table field described by the current field catalog entry has a reference to the Data Dictionary (not a program field), and the field name in the internal output table is different from the name of the field in the Data Dictionary. If the field names are identical, naming the Data Dictionary structure or table in the FIELDCAT-REF_TABNAME parameter is sufficient.
    • ref_tabname (reference table/structure field name)
    value set: SPACE, name of a Data Dictionary structure or table
    Structure or table name of the referred Data Dictionary field.
    This parameter is only used when the internal output table field described by the current field catalog entry has a Data Dictionary reference (not a program field).
    Reference to fields with currency/measurement unit
    Each internal output table sum or quantity field whose decimal places are to be formatted appropriately for the unit in the list must follow the convention:
    • the field is of data type QUAN or CURR (internal type P) (the field must really have this physical data type. Overwriting the physical data type with the parameter FIELDCAT-DATATYPE has no effect)
    • There is a field in the internal output table which contains the associated unit.
    • There is also an entry in the field catalog for the unit field.
    (If the unit is not to appear as a column in the list, and cannot be interactively displayed as a column, e.g. because it is always unambiguous and is therefore explicitly output by the caller in the list header, the field catalog units field entry can take the parameter FIELDCAT-TECH = 'X'.
    The association of a value field to a unit affects the output as follows:
    • appropriate decimal places display for the unit
    • an initialized field with a link to a non-initial unit is output as '0' for the unit (if FIELDCAT-NO_ZERO is initial). When this field is summed, this unit affects whether the units are homogeneous.
    • an initialized field with a link to an initial unit is output as SPACE. When this field is summed, the unit SPACE does not affect the homogeneity of the units.
    • When non-initial fields with an initial unit are summed, the unit SPACE is considered to be a unit.
    Link to currency unit
    • cfieldname (currency unit field name)
    value set: SPACE, output table field name
    Only relevant for amount columns with associated unit.
    Name of the internal output table field containing the currency unit associated with the amount field FIELDCAT-FIELDNAME. The field in FIELDCAT-CFIELDNAME must have its own field catalog entry.
    • ctabname (internal currency unit field output table)
    value set: SPACE, output table field name
    only relevant for hierarchical-sequential lists
    Name of the internal output table containing the FIELDCAT-CFIELDNAME field.
    Link to measurement unit
    • qfieldname (measurement unit field name)
    value set: SPACE, output table field name
    only relevant for quantity columns with unit link.
    Name of the internal output table field containing the measurement unit associated with the quantity field FIELDCAT-FIELDNAME.
    The field in FIELDCAT-QFIELDNAME must have its own field catalog entry.
    • qtabname (internal measurement unit field output table)
    value set: SPACE, output table field name
    only relevant for hierarchical-sequential lists
    Name of the internal output table containing the FIELDCAT-QFIELDNAME field.
    Column output options
    • outputlen (column width)
    value set: 0 (initial), n
    For fields with a Data Dictionary link this parameter can be left initial.
    For fields without a Data Dictionary link (program field) the parameter must be given the value of the desired field list output length (column width).
    initial = column width is the output length of the referred Data Dictionary field (domain).
    n = column width is n characters
    • key (key column)
    value set: SPACE, 'X' 'X' = kex field (key field output in color)
    Key fields can not be interactively hidden. Parameter FIELDCAT-NO_OUT must be left initial.
    For exceptions see the documentation of the FIELDCAT-KEY_SEL parameter.
    • key_sel (hideable key column)
    value set: SPACE, 'X'
    only relevant when FIELDCAT-KEY = 'X'
    Key field which can be hidden interactively.
    The key column sequence cannot be changed interactively by the user.
    The output is controlled by the FIELDCAT-NO_OUT parameter analogously to non-key fields.
    • no_out (field in field list)
    value set: SPACE, 'X' 'X' = field is not displayed in the current list.
    The user can interactively choose the field for output from the field list.
    The user can display the contents of these fields at line level using the 'Detail' function.
    See also the 'Detail screen' documentation of the parameter IS_LAYOUT.
    • tech (technical field)
    value set: SPACE, 'X' 'X' = technical field
    Field cannot be output in the list and cannot be displayed interactively.
    Field can only be used in the field catalog (not in IT_SORT, ...).
    • emphasize (highlight columns in color)
    value set: SPACE, 'X' or 'Cxyz' (x:'1'-'9'; y,z: '0'=off '1'=on)
    'X' = column is colored with the default column highlight color.
    'Cxyz' = column is colored with a coded color:
    • C: Color (coding must begin with C)
    • x: color number
    • y: bold
    • z: inverse
    • hotspot (column as hotspot)
    value set: SPACE, 'X'
    'X' = column cells are output as hotspots
    • fix_column (fix column)
    value set: SPACE, 'X'
    Not relevant for block lists (output of several lists consecutively)
    'X' = column fixed (does not scroll horizontally)
    All columns to be fixed must have this flag, starting from the left. If a column without this flag is output, only the columns to the left of this column are fixed. The user can change the column fixing interactively. See also the documentation of the Layout parameter
    IS_LAYOUT-NO_KEYFIX of the IMPORTING paramter IS_LAYOUT.
    • do_sum (sum over column)
    value set: SPACE, 'X' 'X' = a sum is to be calculated over this internal output table field.
    This function can also be called by the user interactively.
    • no_sum (sums forbidden)
    value set: SPACE, 'X' 'X' = no sum can be calculated over this field, although the data type of the field would allow summing.
    • input (column ready for input)
    Function not available
    Format column contents
    • icon
    value set: SPACE, 'X' 'X' = column contents to be output as an icon.
    The caller must consider the printability of icons.
    • symbol
    value set: SPACE, 'X' 'X' = column contents are to be output as a symbol.
    The internal output table column must be a valid symbol character.
    The caller must consider the printability of symbols.
    Symbols can usually be printed, but may not always be output correctly, depending on the printer configuration.
    • just (justification)
    value set: SPACE, 'R', 'L', 'C'
    Only relevant for fields of data type CHAR or NUMC
    ' ' = default justification for this data type
    'R' = right-justified output
    'L' = left-justified output
    'C' = centered output
    The justification of the column header always follows the justification of the columns. Independent justification of the column neader is not possible.
    • lzero (leading zeros)
    value set: SPACE, 'X'
    Only relevant for fields of data type NUMC
    ALV outputs NUMC fields right-justified without leading zeros by default.
    'X' = output with leading zeros
    Note: If a NUMC field is output left-justified or centered by FIELDCAT-JUST, leading zeros are output. If the output of leading zeros is suppressed by a Data Dictionary reference ALPHA conversion exit, the output is always left-justified.
    • no_sign (no +/- sign) Only relevant for value fields
    value set: SPACE, 'X' 'X' = value output without +/ sign
    • no_zero (suppress zeros) Only relevant for value fields
    value set: SPACE, 'X' 'X' = suppress zeros
    • edit_mask (field formatting)
    value set: SPACE, template
    template = see documentation of WRITE formatting option USING EDIT MASK template
    The output conversion conv can be made by template = '== conv'.
    Texts
    The following text parameters should be specified for program fields without a Data Dictionary reference. The texts are taken from the Data Dictionary for fields with a Data Dictionary reference. If this is not desired, the text parameters can also be specified. The Data Dictionary texts are then ignored. If the user changes the column width interactively, the column header text with the appropriate length is always used. The interactive function 'Optimize column width' takes account of both the field contents and the column headers: if all field contents are shorter than the shortest column header, the column width depends on the column header.
    The 'long field label' is also used in display variant definition, sort, etc. popups.
    • seltext_l (long field label)
    • seltext_m (medium field label)
    • seltext_s (short field label)
    • reptext_ddic (header)
    analogous to the Data element maintenance 'Header'
    The specified text is not necessarily output in the list, an optimum among all texts is sought.
    • ddictxt (specify text)
    value set: SPACE, 'L', 'M', 'S'
    You can specify with values 'L', 'M', and 'S', the keyword that should always be used as column header. If the column width changes, no attempt is made in this case to find an appropriate header for the new output width.
    Parameters for program fields without Data Dictionary reference
    see also 'Text' parameters
    • datatype (data type)
    value set: SPACE, Data Dictionary data type (CHAR, NUMC,...)
    Only relevant for fields without Data Dictionary reference
    Program field data type
    • ddic_outputlen (external output length)
    value set: 0 (initial), n
    Only relevant for fields without Data Dictionary reference whose output is nevertheless to be modified by a conversion exit.
    Prerequisites:
    • FIELDCAT-EDIT_MASK = '==conv'
    see also the documentation of the parameter FIELDCAT-EDIT_MASK
    • FIELDCAT-INTLEN = n
    see also the documentation of the parameter FIELDCAT-INTLEN
    n = external format field output length
    The column width FIELDCAT-OUTPUTLEN need not be the same as the external format output length (FIELDCAT-DDIC_OUTPUTLEN).
    • intlen (internal output length)
    value set: 0 (initial), n
    Only relevant for fields without Data Dictionary reference whose output is nevertheless to be modified by a conversion exit.
    Prerequisites:
    • FIELDCAT-EDIT_MASK = '==conv'
    see also the documentation of the parameter FIELDCAT-EDIT_MASK
    • FIELDCAT-DDIC_OUTPUTLEN = n
    see also the documentation of the parameter FIELDCAT-DDIC_OUTPUTLEN
    n = internal format field output length
    • rollname (data element)
    value set: SPACE, Data Dictionary data element name
    F1 help can be provided for a program field without a Data Dictionary reference, or F1 help which differs from the Data Dictionary help can be provided for a field with a Data Dictionary reference, using this parameter.
    When F1 help is called for this field, the documentation of the specified data element is displayed.
    If the FIELDCAT-ROLLNAME is initial for fields with a Data Dictionary reference, the documentation of the data element of the referred Data Dictionary field is output.
    Others
    • sp_group (field group key)
    value set: SPACE, CHAR(1)
    Field group key.
    Keys are assigned to group names in the IT_SPECIAL_GROUPS parameter (see also the documentation of the parameter IT_SPECIAL_GROUPS).
    When such an assignment is made in the field catalog and in IT_SPECIAL_GROUPS, the fields are grouped correspondingly in the display variant popup.
    • reprep (Report/Report interface selection criterion)
    value set: SPACE, 'X'
    Prerequisites:
    • The system contains the Report/Report interface (function group RSTI, table TRSTI)
    • Parameter LAYOUT-REPREP = 'X'
    (see also the documentation of the parameter LAYOUT-REPREP of the IMPORTING parameter IS_LAYOUT )
    'X' = When the Report/Report interface is called, the value of this field is passed in the selected interface start record as a selection criterion.
    2.7.2. Default
    • The following entries are usually sufficient for internal table fields with a reference to a field defined in the Data Dictionary :
    • fieldname
    • ref_tabname
    Notes:
    ALV gets the remaining information from the Data Dictionary.
    If no relative column position (COL_POS) is specified, the fields are output in the list in the order in which they were added to the field catalog.
    REF_FIELDNAME need only be specifid when the name of the internal table field differs from the name of the referred Data Dictionary field.
    Information which is explicitly entered in the field catalog is not overwritten by information from the Data Dictionary.
    Priority rule:
    Entries in the field catalog have priority over differing entries in the Data Dictionary.
    • The following entries are usually sufficient for internal table fields without a reference to the Data Dictionary (program fields):
    • fieldname
    • outputlen
    • datatype
    • seltext_s
    • seltext_m
    • seltext_l
    Notes:
    F1 help can be provided for program fields by assigning a data element to the parameter ROLLNAME.
    If the parameters SELTEXT_S, SELTEXT_M, SELTEXT_L, and REPTEXT_DDIC contain appropriate field labels, the program field column headers are also adjusted appropriately when the column width changes.
    B. REUSE_ALV_FIELDCATALOG_MERGE : This function module is used to populate a fieldcatalog which is essential to display the data in ALV. If the output data is from a single dictionary table and all the columns are selected, then we need not exclusively create the field catalog. Its enough to mention the table name as a parameter(I_structure name) in the REUSE_ALV_LIST_DISPLAY. But in other cases we need to create it.
    The Important Parameters are :
    I. Export :
    i. I_program_name : report id
    ii. I_internal_tabname : the internal output table
    iii. I_inclname : include or the report name where all the dynamic forms are handled.
    II Changing
    ct_fieldcat : an internal table with the type SLIS_T_FIELDCAT_ALV which is
    declared in the type pool SLIS.
    Reward points if useful
    Regards
    Anji
    Vijayendra Rao  
    Posts: 1,699
    Questions: 28
    Registered: 9/14/04
    Forum points: 3,018 
      Re: ALV  
    Posted: May 14, 2007 8:29 PM    in response to: kotireddy       Reply 
    Hi,
    Field catalog defines the attributes and specifies the technical details of the columns displayed in an ALV output.
    You can check the following thread to see how to build a field catalog and how to work with ALV.
    Message was edited by:
            Karthikeyan Pandurangan

Maybe you are looking for