Display additional Text in ALV Grid

Hello,
I have an ALV Grid display and need to display additional information on the top of the list. I have used the grid-title, but the field is defined as 70 characters and thats not enough.
Is it possible to display more text with alv grid?
Regards Michael

Hi Ravi,
I´m creating my alv object orientated and I don´t know, how to manage that now. Can You explain me, where and how I have to do it?
My Dynpro has one custom container and I´m calling the method SET_TABLE_FOR_FIRST_DISPLAY in PBO.
And I need the comment to be printed with the ALV by pressing the print button in the toolbar of the ALV
Thank You!
Message was edited by: Michael Schmidt

Similar Messages

  • Problem displaying 'Total' text in ALV grid

    My ALV works and displays correct output. However, I am struggling to display the text 'Total' on position in the last row of the grid. The total is for the salary. My code is below..
    I have looked on numerous sites and forums for assistance.
    *& Report  ZALV
    REPORT  ZALV.
    TABLES: ZCONTACT.
    TYPE-POOLS: slis. "slis contains all of the ALV data types.
    DATA: "fieldcatALOG TYPE slis_t_fieldcat_alv WITH HEADER LINE,
           it_zcontact TYPE TABLE OF zcontact,"declares an internal table of type ZCONTACT
           alv_prog_name LIKE sy-repid,
           g_variant TYPE disvariant,
           gx_variant TYPE disvariant,
           g_save TYPE c VALUE 'X',
           it_fieldcat TYPE slis_t_fieldcat_alv,"declares field catalog table of line type alv
           wa_fieldcat TYPE slis_fieldcat_alv, "declares the work area of the field catalog
           it_list_top_of_page TYPE slis_t_listheader,
           izontact TYPE TABLE OF zcontact,
           h1(10) TYPE c VALUE 'Toatall',
            "i_logo TYPE OT.
           gt_events     TYPE slis_t_event,
           gd_prntparams TYPE slis_print_alv,
           text(40) type c,
           wa_layout TYPE slis_layout_alv.
    **Selection Screen details
    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME.
    PARAMETERS: variant like disvariant-variant.
    SELECTION-SCREEN END OF BLOCK B1.
    **Getting default variant
    INITIALIZATION.
    gx_variant-report = sy-repid.
    CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
    EXPORTING
       I_SAVE = G_SAVE
       CHANGING
         CS_VARIANT = GX_VARIANT
       EXCEPTIONS
         NOT_FOUND = 2.
    IF SY-SUBRC = 0.
       VARIANT = GX_VARIANT-VARIANT.
       ENDIF.
    START-OF-SELECTION.
      PERFORM DATA_RETRIEVAL.
      PERFORM BUILD_FIELDCATALOG.
      PERFORM DISPLAY_ALV_REPORT.
      "PERFORM build_alv_header
    FORM BUILD_FIELDCATALOG.
    *Build field catalog
    wa_fieldcat-fieldname = 'ID'.
    wa_fieldcat-seltext_m = 'ID'.
    wa_fieldcat-col_pos   = 0.
    wa_fieldcat-outputlen = 10.
    wa_fieldcat-emphasize  = 'X'.
    wa_fieldcat-key       = 'X'.
    APPEND wa_fieldcat TO it_fieldcat.
    CLEAR wa_fieldcat.
    wa_fieldcat-fieldname = 'LASTNAME'.
    wa_fieldcat-seltext_m = 'LASTNAME'.
    wa_fieldcat-col_pos   = 1.
    APPEND wa_fieldcat TO it_fieldcat.
    CLEAR wa_fieldcat.
    wa_fieldcat-fieldname = 'FIRSTNAME'.
    wa_fieldcat-seltext_m = 'FIRSTNAME'.
    APPEND wa_fieldcat TO it_fieldcat.
    CLEAR wa_fieldcat.
    wa_fieldcat-fieldname = 'DOB'.
    wa_fieldcat-seltext_m = 'DOB'.
    wa_fieldcat-col_pos = 3.
    APPEND wa_fieldcat TO it_fieldcat.
    CLEAR wa_fieldcat.
    wa_fieldcat-fieldname = 'TEL'.
    wa_fieldcat-seltext_m = 'Tel'.
    APPEND wa_fieldcat TO it_fieldcat.
    CLEAR wa_fieldcat.
    wa_fieldcat-fieldname = 'ADDRESS'.
    wa_fieldcat-seltext_m = 'ADDRESS'.
    APPEND wa_fieldcat TO it_fieldcat.
    CLEAR wa_fieldcat.
    wa_fieldcat-fieldname = 'OCCUPATION'.
    wa_fieldcat-seltext_m = 'OCCUPATION'.
    APPEND wa_fieldcat TO it_fieldcat.
    CLEAR wa_fieldcat.
    wa_fieldcat-fieldname = 'WEIGHT'.
    wa_fieldcat-seltext_m = 'WEIGHT'.
    wa_fieldcat-do_sum    = 'X'.
    APPEND wa_fieldcat TO it_fieldcat.
    CLEAR wa_fieldcat.
    wa_fieldcat-fieldname = 'AGE'.
    wa_fieldcat-seltext_m = 'AGE'.
    wa_fieldcat-do_sum   = 'X'.        "Display column total
    APPEND wa_fieldcat TO it_fieldcat.
    "CLEAR wa_fieldcat.
    wa_fieldcat-fieldname = 'SALARY'.
    wa_fieldcat-seltext_m = 'SALARY'.
    wa_fieldcat-do_sum    = 'X'.
    wa_fieldcat-cfieldname = 'CURRENCYKEY'.
    APPEND wa_fieldcat TO it_fieldcat.
    wa_fieldcat-fieldname = 'CURRENCY'.
    wa_fieldcat-seltext_s = 'CURRENCY'.
    APPEND wa_fieldcat TO it_fieldcat.
    "CLEAR wa_fieldcat.
    ENDFORM. "BUILDING THE FIELD CATALOG
    **FORM layout.
    *wa_layout-colwidth_optimize = 'X'.
    *wa_layout-totals_text ='TOTAL'.
    *wa_layout-zebra = 'X'.
    *ENDFORM.
    "ls_layout-cell_merge = 'X'.
    FORM DISPLAY_ALV_REPORT.
    alv_prog_name = sy-repid.
    *Pass data and field catalog to ALV function module to display ALV list
       CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
         EXPORTING
           it_fieldcat            = it_fieldcat[]
           i_callback_program     = alv_prog_name
           is_layout              = wa_layout
           i_callback_top_of_page =  'TOP_OF_PAGE'
           i_callback_user_command =  'USER_COMMAND'
           i_structure_name       =  'ZCONTACT'
           i_save                 = 'X'
           it_events               = gt_events
           is_print                = gd_prntparams
           is_variant             = g_variant
           "is_layout     = ls_layout
    TABLES
           t_outtab      = it_zcontact
    EXCEPTIONS
           program_error = 1
           OTHERS        = 2.
    WRITE: H1 UNDER 'SALARY'.
    ENDFORM.
    **Fetch data from the database
    FORM DATA_RETRIEVAL.
    SELECT * FROM zcontact INTO TABLE it_zcontact.
    ENDFORM.
    FORM top_of_page.
    *ALV Header declarations
       DATA: it_listheader TYPE slis_t_listheader,
             wa_listheader TYPE slis_listheader,
             t_line like wa_listheader-info,
             ld_lines TYPE I,
             ld_linesc(10) TYPE C.
    wa_listheader-typ = 'H'.
    wa_listheader-info = 'Contact Details'.
    APPEND wa_listheader TO it_listheader.
    CLEAR wa_listheader.
    wa_listheader-typ = 'S'.
    wa_listheader-info = sy-repid.
    wa_listheader-key = 'Program Name:'.
    APPEND wa_listheader TO it_listheader.
    CLEAR wa_listheader.
    wa_listheader-typ = 'S'.
    wa_listheader-info = sy-uname.
    wa_listheader-key = 'User Name:'.
    APPEND wa_listheader TO it_listheader.
    CLEAR wa_listheader.
    wa_listheader-typ = 'S'.
    wa_listheader-key = 'Run Date :'.
    CONCATENATE sy-datum+6(2)
                 sy-datum+4(2)
                 sy-datum(4)
                 INTO wa_listheader-info
                 SEPARATED BY '/'.
    APPEND wa_listheader TO it_listheader.
    CLEAR wa_listheader.
    wa_listheader-typ = 'S'.
    wa_listheader-key = 'Time :'.
    CONCATENATE sy-uzeit(2)
                 sy-uzeit+2(2)
                 sy-uzeit+4(2)
                 INTO wa_listheader-info
                 SEPARATED BY ':'.
    APPEND wa_listheader TO it_listheader.
    CLEAR wa_listheader.
       CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
         EXPORTING
           it_list_commentary = it_listheader[]
           i_logo = 'KLOGO'.
    ENDFORM.                    "top_of_page

    I did this but still i cant display the total text..I have reposted my code. please assist. Im only missing that total label
    *& Report  ZALV
    REPORT  ZALV.
    TABLES: ZCONTACT.
    TYPE-POOLS: slis. "slis contains all of the ALV data types.
    TYPES: BEGIN OF t_zcontact,
         text(40) TYPE c, "storing the total text
       mandt TYPE mandt,
       id TYPE zcontactid,
       lastname type zcontactlname,
       firstname TYPE zcontactfname,
       dob TYPE zdateofbirth,
       tel TYPE ztel,
       address TYPE zaddress,
       occupation TYPE zoccup,
       weight type zweight,
       age TYPE zage,
       salary TYPE zsalary,
       ecurrency TYPE curcy,
       END OF t_zcontact.
    TYPES: BEGIN OF wa_zcontact,
       mandt TYPE mandt,
       id TYPE zcontactid,
       lastname type zcontactlname,
       firstname TYPE zcontactfname,
       dob TYPE zdateofbirth,
       tel TYPE ztel,
       address TYPE zaddress,
       occupation TYPE zoccup,
       weight type zweight,
       age TYPE zage,
       salary TYPE zsalary,
       ecurrency TYPE curcy,
       END OF wa_zcontact.
    TYPES:
    i_zcontact TYPE STANDARD TABLE OF t_zcontact." INITIAL SIZE 0.
       DATA: itt_zcontact TYPE STANDARD TABLE OF wa_zcontact INITIAL SIZE 0,
             wat_zcontact TYPE wa_zcontact.
    DATA: "it_zcontact TYPE TABLE OF zcontact,"declares an internal table of type ZCONTACT
           gd_repid LIKE sy-repid,
           g_variant TYPE disvariant,
           gx_variant TYPE disvariant,
           g_save TYPE c VALUE 'X',
           fieldcatalog TYPE slis_t_fieldcat_alv WITH HEADER LINE,"declares field catalog table of line type alv
            gd_tab_group type slis_t_sp_group_alv,
            gd_prntparams TYPE slis_print_alv,
           fieldcat TYPE slis_fieldcat_alv, "declares the work area of the field catalog
           it_list_top_of_page TYPE slis_t_listheader,
           i_zcontact TYPE TABLE OF zcontact,
           "h1(10) TYPE c VALUE 'Toatall',
            "i_logo TYPE OT.
           gt_events TYPE slis_t_event,
           gd_layout TYPE slis_layout_alv."work area for the alv layout
    data: it_sortcat type slis_sortinfo_alv occurs 1,
             wa_sort LIKE LINE OF it_sortcat.
    START-OF-SELECTION.
      PERFORM DATA_RETRIEVAL.
      PERFORM BUILD_FIELDCATALOG.
      PERFORM DISPLAY_ALV_REPORT.
      PERFORM BUILD_LAYOUT.
      perform build_sortcat.
      PERFORM sub_add_text.
      "PERFORM build_events.
      PERFORM top-of-page.
      "PERFORM build_alv_header.
      END-OF-SELECTION.
    *DATA: gd_layout TYPE slis_layout_alv.
    *      gd_layout-totals_text = 'TOTAL'.
    **Selection Screen details
    *SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME.
    *PARAMETERS: variant like disvariant-variant.
    *SELECTION-SCREEN END OF BLOCK B1.
    ***Getting default variant
    *INITIALIZATION.
    *gx_variant-report = sy-repid.
    *CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
    *EXPORTING
    *  I_SAVE = G_SAVE
    *  CHANGING
    *    CS_VARIANT = GX_VARIANT
    *  EXCEPTIONS
    *    NOT_FOUND = 2.
    *IF SY-SUBRC = 0.
    *  VARIANT = GX_VARIANT-VARIANT.
    *  ENDIF.
    FORM BUILD_FIELDCATALOG.
    *Build field catalog
    fieldcatalog-fieldname = 'ID'.
    fieldcatalog-seltext_m = 'ID'.
    fieldcatalog-col_pos   = 2.
    fieldcatalog-outputlen = 10.
    fieldcatalog-datatype = 'CHAR'.
      "fieldcatalog-do_sum      = 'X'.
    fieldcatalog-no_zero     = 'X'.
    fieldcatalog-emphasize  = 'X'.
    fieldcatalog-key       = 'X'.
    APPEND fieldcatalog TO fieldcatalog.
    CLEAR fieldcatalog.
    fieldcatalog-fieldname = 'LASTNAME'.
    fieldcatalog-seltext_m = 'LASTNAME'.
    fieldcatalog-col_pos   = 3.
    APPEND fieldcatalog TO fieldcatalog.
    CLEAR fieldcatalog.
    fieldcatalog-fieldname = 'FIRSTNAME'.
    fieldcatalog-seltext_m = 'FIRSTNAME'.
      fieldcatalog-col_pos = 4.
    APPEND fieldcatalog TO fieldcatalog.
    CLEAR fieldcatalog.
    fieldcatalog-fieldname = 'DOB'.
    fieldcatalog-seltext_m = 'DOB'.
    fieldcatalog-col_pos = 5.
    APPEND fieldcatalog TO fieldcatalog.
    CLEAR fieldcatalog.
    fieldcatalog-fieldname = 'TEL'.
    fieldcatalog-seltext_m = 'Tel'.
      fieldcatalog-col_pos = 6.
    APPEND fieldcatalog TO fieldcatalog.
    CLEAR fieldcatalog.
    fieldcatalog-fieldname = 'ADDRESS'.
    fieldcatalog-seltext_m = 'ADDRESS'.
      fieldcatalog-col_pos = 7.
    APPEND fieldcatalog TO fieldcatalog.
    CLEAR fieldcatalog.
    fieldcatalog-fieldname = 'OCCUPATION'.
    fieldcatalog-seltext_m = 'OCCUPATION'.
      fieldcatalog-col_pos = 8.
    APPEND fieldcatalog TO fieldcatalog.
    CLEAR fieldcatalog.
    fieldcatalog-fieldname = 'WEIGHT'.
    fieldcatalog-seltext_m = 'WEIGHT'.
    "fieldcatalog-do_sum    = 'X'.
      fieldcatalog-col_pos = 9.
    APPEND fieldcatalog TO fieldcatalog.
    CLEAR fieldcatalog.
    fieldcatalog-fieldname = 'AGE'.
    fieldcatalog-seltext_m = 'AGE'.
    "fieldcatalog-do_sum   = 'X'.        "Display column total
      fieldcatalog-col_pos = 10.
    APPEND fieldcatalog TO fieldcatalog.
    CLEAR fieldcatalog.
    fieldcatalog-fieldname = 'SALARY'.
    fieldcatalog-seltext_m = 'SALARY'.
    fieldcatalog-do_sum    = 'X'.
    fieldcatalog-outputlen = 15.
    fieldcatalog-datatype ='CURR'.
      fieldcatalog-col_pos = 11.
    APPEND fieldcatalog TO fieldcatalog.
    CLEAR fieldcatalog.
    "fieldcatalog-fieldname = 'ECURRENCY'.
    "fieldcatalog-seltext_s = 'ECURRENCY'.
    "APPEND fieldcatalog TO fieldcatalog.
    "CLEAR fieldcatalog.
       fieldcatalog-fieldname   = 'TEXT'.
       fieldcatalog-col_pos = 0.
       "fieldcatalog-seltext_m   = 'TEXT'.
       fieldcatalog-tech        = 'X'.
       fieldcatalog-no_out      = 'X'.
       append fieldcatalog to fieldcatalog.
       clear  fieldcatalog.
    ENDFORM.
    *&      Form  build_sortcat
    *       Build Sort catalog
    FORM build_sortcat .
       "wa_sort-spos      = 1.
       wa_sort-fieldname = 'TEXT'.
       "wa_sort-SUBTOT    = 'X'. "subtotals any totals column by this field
       wa_sort-up        = 'X'.
       APPEND wa_sort TO it_sortcat.
       CLEAR wa_sort.
    ENDFORM.                    " build_sortcat
    FORM BUILD_LAYOUT.
    *gd_layout-no_input = 'X'.
    *gd_layout-colwidth_optimize = 'X'.
    *gd_layout-totals_text  =  'Totals'(201).
    *"gd_LAYOUT-coltab_fieldname = 'SALARY'.
    gd_layout-no_totalline = 'X'.
    ENDFORM.
    *IF sy-subrc = 0.
    *      LOOP AT fieldcatalog INTO fieldcat.
    *        IF fieldcat-fieldname = 'WEIGHT' OR
    *          fieldcat-fieldname = 'AGE'.
    **         Summation for WEIGHT & AGE
    *          fieldcat-do_sum = 'X'.
    *          MODIFY fieldcatalog FROM fieldcat TRANSPORTING do_sum.
    *        ENDIF.
    *        IF fieldcat-fieldname = 'TEXT'.
    **         Hide this field so that it can display it's content i.e.
    **         Total text in Subtotal level
    *          fieldcat-tech = 'X'.
    *          fieldcat-no_out = 'X'.
    *          MODIFY fieldcatalog FROM fieldcat TRANSPORTING tech no_out.
    *        ENDIF.
    *        CLEAR fieldcat.
    *      ENDLOOP.
    *    ENDIF.
    *ENDFORM. "BUILDING THE FIELD CATALOG
    *form build_events.
    *  data: ls_event type slis_alv_event.
    *  call function 'REUSE_ALV_EVENTS_GET'
    *       exporting
    *            i_list_type = 0
    *       importing
    *            et_events   = gt_events[].
    *  read table gt_events with key name =  slis_ev_top_of_page
    *                           into ls_event.
    *  if sy-subrc = 0.
    *    move 'TOP-OF-PAGE' to ls_event-form.
    *    append ls_event to gt_events.
    *  endif.
    *    read table gt_events with key name =  slis_ev_end_of_list
    *                           into ls_event.
    *  if sy-subrc = 0.
    *    move 'END_OF_LIST' to ls_event-form.
    *    append ls_event to gt_events.
    *  endif.
    *endform.                    " BUILD_EVENTS
    "ls_layout-cell_merge = 'X'.
    FORM DISPLAY_ALV_REPORT.
    gd_repid = sy-repid.
    *Pass data and field catalog to ALV function module to display ALV list
       CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
         EXPORTING
           it_fieldcat         = fieldcatalog[]
           it_sort  =  it_sortcat
           i_callback_program     = gd_repid
           is_layout              = gd_layout
           i_callback_top_of_page =  'TOP-OF-PAGE'
           i_callback_user_command =  'USER_COMMAND'
           i_structure_name       =  'ZCONTACT'
           i_save                 = 'X'
           it_events               = gt_events
           is_print                = gd_prntparams
           is_variant             = g_variant
           "is_layout     = ls_layout
    TABLES
           t_outtab      = itt_zcontact
    EXCEPTIONS
           program_error = 1
           OTHERS        = 2.
    "WRITE: 'TOTAL' UNDER 'ID'.
    ENDFORM.
    **Fetch data from the database
    FORM DATA_RETRIEVAL.
    "DATA: ld_subtot(1) type c.
    SELECT * FROM zcontact INTO TABLE itt_zcontact UP TO 10 ROWS.
    ENDFORM.
    FORM sub_add_text.
    *Populate field with text value
       DATA:
       wt_zcontact TYPE t_zcontact,
       last TYPE zcontact-ID,
       l_text(40) type c,
       num type n.
    loop at itt_zcontact into wat_zcontact.
    * Populate final table
       wt_zcontact-TEXT = 'Total salary:  '.
       "ld_subtot = ld_subtot + 1.
       "wat_zcontact-text = ld_subtot.
         modify itt_zcontact FROM wat_zcontact.
         clear wat_zcontact.
       "APPEND wat_zcontact TO itt_zcontact.
    endloop.
    ENDFORM.
    FORM top-of-page.
    *ALV Header declarations
       DATA: it_listheader TYPE slis_t_listheader,
             wa_listheader TYPE slis_listheader,
             t_line like wa_listheader-info,
             ld_lines TYPE I,
             ld_linesc(10) TYPE C.
    wa_listheader-typ = 'H'.
    wa_listheader-info = 'Contact Details'.
    APPEND wa_listheader TO it_listheader.
    CLEAR wa_listheader.
    wa_listheader-typ = 'S'.
    wa_listheader-info = sy-repid.
    wa_listheader-key = 'Program Name:'.
    APPEND wa_listheader TO it_listheader.
    CLEAR wa_listheader.
    wa_listheader-typ = 'S'.
    wa_listheader-info = sy-uname.
    wa_listheader-key = 'User Name:'.
    APPEND wa_listheader TO it_listheader.
    CLEAR wa_listheader.
    wa_listheader-typ = 'S'.
    wa_listheader-key = 'Run Date :'.
    CONCATENATE sy-datum+6(2)
                 sy-datum+4(2)
                 sy-datum(4)
                 INTO wa_listheader-info
                 SEPARATED BY '/'.
    APPEND wa_listheader TO it_listheader.
    CLEAR wa_listheader.
    wa_listheader-typ = 'S'.
    wa_listheader-key = 'Time :'.
    CONCATENATE sy-uzeit(2)
                 sy-uzeit+2(2)
                 sy-uzeit+4(2)
                 INTO wa_listheader-info
                 SEPARATED BY ':'.
    APPEND wa_listheader TO it_listheader.
    CLEAR wa_listheader.
       CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
         EXPORTING
           it_list_commentary = it_listheader[]
           i_logo = 'KLOGO'.
    ENDFORM.                    "top_of_page

  • How to get Grand Total Text in ALV GRID

    Hi Folks,
    I am able to get the SUBTOTAL TEXT .....But i need...
    How to get Grand Total Text in ALV GRID Display...
    Can any one give a Solution for this...

    Hi Surendar,
    Check out this code.. this is showing Total Text in Toal line in the very first column.
    REPORT  zsales_ord_det_1                        .
    TABLES: ztable_10.
    TYPE-POOLS: slis.
    DATA: BEGIN OF it OCCURS 0,
    srno(6) type c,
    name LIKE ztable_10-name,
    age LIKE ztable_10-age,
    END OF it.
    DATA : BEGIN OF it_temp OCCURS 0,
    name LIKE ztable_10-name,
    age LIKE ztable_10-age,
    END OF it_temp.
    DATA: i_fieldcat  TYPE slis_t_fieldcat_alv,
          wa_fieldcat TYPE  slis_fieldcat_alv.
    DATA: v_repid LIKE sy-repid,
           i_index TYPE STANDARD TABLE OF i WITH HEADER LINE,
           gs_layout TYPE slis_layout_alv,
           gd_layout TYPE slis_layout_alv,
           i_sort TYPE STANDARD TABLE OF slis_sortinfo_alv,
           wa_sort TYPE slis_sortinfo_alv.
    START-OF-SELECTION.
      v_repid = sy-repid.
      SELECT * FROM ztable_10 INTO TABLE it_temp.
      LOOP AT it_temp .
        it-srno = 'Total'.
        it-name = it_temp-name.
        it-age = it_temp-age.
        APPEND  it.
      ENDLOOP.
    END-OF-SELECTION.
      CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
       EXPORTING
         i_program_name               = v_repid
         i_internal_tabname           = 'IT'
      I_STRUCTURE_NAME             =
      I_CLIENT_NEVER_DISPLAY       = 'X'
         i_inclname                   = v_repid
      I_BYPASSING_BUFFER           =
      I_BUFFER_ACTIVE              =
        CHANGING
          ct_fieldcat                  = i_fieldcat[]
       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.
    wa_fieldcat-row_pos = 1.
    wa_fieldcat-col_pos = 1.
    wa_fieldcat-fieldname = 'SRNO'.
    wa_fieldcat-tabname = it.
    append wa_fieldcat to i_fieldcat.
      LOOP AT i_fieldcat INTO wa_fieldcat.
        IF wa_fieldcat-fieldname = 'AGE'.
          wa_fieldcat-do_sum = 'X'.
          MODIFY i_fieldcat FROM wa_fieldcat.
        ENDIF.
       IF wa_fieldcat-fieldname = 'SRNO'.
         Hide this field so that it can display it's content i.e.
            Total text in Subtotal level
        wa_fieldcat-tech = 'X'.
          wa_fieldcat-no_out = 'X'.
          MODIFY i_fieldcat FROM wa_fieldcat TRANSPORTING tech no_out.
       ENDIF.
      ENDLOOP.
    wa_sort-spos = 1.
    wa_sort-fieldname = 'SRNO'.
    wa_sort-up = 'X'.
    wa_sort-subtot = 'X'.
    APPEND wa_sort TO i_sort.
      gd_layout-no_totalline = 'X'.
      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                = 'USER_COMMAND'
      I_CALLBACK_TOP_OF_PAGE         = ' '
      I_CALLBACK_HTML_TOP_OF_PAGE  = ' '
      I_CALLBACK_HTML_END_OF_LIST    = ' '
      I_STRUCTURE_NAME                       =
      I_BACKGROUND_ID                        = ' '
      I_GRID_TITLE                                  =
      I_GRID_SETTINGS                          =
         is_layout                                      = gd_layout
         it_fieldcat                                      = i_fieldcat[]
      IT_EXCLUDING                      =
      IT_SPECIAL_GROUPS                 =
         it_sort                           = i_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
      IT_ALV_GRAPHICS                   =
      IT_HYPERLINK                      =
      IT_ADD_FIELDCAT                   =
      IT_EXCEPT_QINFO                   =
      I_HTML_HEIGHT_TOP                 =
      I_HTML_HEIGHT_END                 =
    IMPORTING
      E_EXIT_CAUSED_BY_CALLER           =
      ES_EXIT_CAUSED_BY_USER            =
        TABLES
          t_outtab                          = it
       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.
    Regards,
    Seema

  • SUBTOTAL TEXT IN ALV GRID

    HI ALL,
    could any one  send me how to display the subtotal Text  in ALV grid output with code sample.
    with thanks.
    kannan

    hi,
    means u want to print some text instead of star ( coming in subtotal) ?
    If so than try like,
    *& Report  ZALV_LIST
    REPORT  zalv_list.
    TABLES : mseg.
    TYPE-POOLS : slis.
    DATA : BEGIN OF itab OCCURS 0,
            mblnr LIKE mseg-mblnr,
            matnr LIKE mseg-matnr,
            werks LIKE mseg-werks,
            menge LIKE mseg-menge,
            line_color(4) TYPE c,
           END OF itab.
    DATA : BEGIN OF itab1 OCCURS 0,
            mblnr LIKE mseg-mblnr,
            matnr LIKE mseg-matnr,
            werks LIKE mseg-werks,
            menge LIKE mseg-menge,
            line_color(4) TYPE c,
           END OF itab1.
    DATA : t_fcat TYPE slis_t_fieldcat_alv,
           t_eve TYPE slis_t_event,
           t_subtot TYPE slis_t_sortinfo_alv,
           subtot LIKE LINE OF t_subtot,
           wa_fcat LIKE LINE OF t_fcat,
           gd_layout    TYPE slis_layout_alv.
    DATA : gt_menge LIKE mseg-menge,
           st_menge LIKE mseg-menge.
    SELECTION-SCREEN : BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
    SELECT-OPTIONS : doc FOR mseg-mblnr.
    SELECTION-SCREEN : END OF BLOCK blk1.
    INITIALIZATION.
      PERFORM build_cat USING t_fcat.
      PERFORM build_eve.
      PERFORM build_layout.
    START-OF-SELECTION.
      PERFORM get_data.
      PERFORM display.
    *&      Form  build_cat
          text
         -->TEMP_FCAT  text
    FORM build_cat USING temp_fcat TYPE slis_t_fieldcat_alv.
      wa_fcat-tabname = 'ITAB'.
      wa_fcat-fieldname = 'MBLNR'.
      wa_fcat-seltext_m = 'Material Doc.'.
      APPEND wa_fcat TO temp_fcat.
      CLEAR wa_fcat.
      wa_fcat-tabname = 'ITAB'.
      wa_fcat-fieldname = 'MATNR'.
      wa_fcat-seltext_m = 'Material'.
      APPEND wa_fcat TO temp_fcat.
      CLEAR wa_fcat.
      wa_fcat-tabname = 'ITAB'.
      wa_fcat-fieldname = 'WERKS'.
      wa_fcat-seltext_m = 'Plant'.
      APPEND wa_fcat TO temp_fcat.
      CLEAR wa_fcat.
      wa_fcat-tabname = 'ITAB'.
      wa_fcat-fieldname = 'MENGE'.
      wa_fcat-seltext_m = 'Quantity'.
    wa_fcat-do_sum = 'Y'.
      APPEND wa_fcat TO temp_fcat.
      CLEAR wa_fcat.
    subtot-spos = 1.
    subtot-fieldname = 'MBLNR'.
    subtot-tabname = 'ITAB'.
    subtot-up = 'X'.
    subtot-group = 'X'.
    subtot-subtot = 'X'.
    subtot-expa = 'X'.
    APPEND subtot TO t_subtot.
    ENDFORM.                    "build_cat
    *&      Form  build_eve
          text
    FORM build_eve.
      DATA : wa_eve TYPE slis_alv_event.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
        EXPORTING
          i_list_type     = 0
        IMPORTING
          et_events       = t_eve
        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.
      READ TABLE t_eve WITH KEY name =  slis_ev_top_of_page
                             INTO wa_eve.
      IF sy-subrc = 0.
        MOVE 'TOP_OF_PAGE' TO wa_eve-form.
        APPEND wa_eve TO t_eve.
      ENDIF.
    ENDFORM.                    "build_eve
    *&      Form  build_layout
          text
    FORM build_layout.
      gd_layout-no_input          = 'X'.
      gd_layout-colwidth_optimize = 'X'.
      gd_layout-info_fieldname =      'LINE_COLOR'.
      gd_layout-subtotals_text = 'Sub Total'.
    ENDFORM.                    " BUILD_LAYOUT
    *&      Form  get_data
          text
    FORM get_data.
      SELECT mblnr matnr werks menge FROM mseg INTO CORRESPONDING FIELDS OF TABLE itab
      WHERE mblnr IN doc.
      SORT itab BY mblnr.
      LOOP AT itab.
        AT NEW mblnr.
          LOOP AT itab WHERE mblnr = itab-mblnr.
            st_menge = st_menge + itab-menge.
            itab1-mblnr = itab-mblnr.
            itab1-matnr = itab-matnr.
            itab1-werks = itab-werks.
            itab1-menge = itab-menge.
            APPEND itab1.
          ENDLOOP.
          itab1-mblnr = 'Sub_Total'.
          itab1-matnr = ''.
          itab1-werks = ''.
          itab1-menge = st_menge.
          itab1-line_color = 'C710'.
          APPEND itab1.
          itab1-line_color = ''.
          CLEAR st_menge.
        ENDAT.
      ENDLOOP.
      LOOP AT itab.
        gt_menge = gt_menge + itab-menge.
      ENDLOOP.
      itab1-mblnr = 'Total'.
      itab1-matnr = ''.
      itab1-werks = ''.
      itab1-menge = gt_menge.
      itab1-line_color = 'C310'.
      APPEND itab1.
    ENDFORM.                    "get_data
    *&      Form  display
          text
    FORM display.
      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
       EXPORTING
         i_callback_program             = 'ZALV_LIST'
         is_layout                      = gd_layout
         it_fieldcat                    = t_fcat
        it_sort                        = t_subtot
         it_events                      = t_eve
        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
    *&      Form  top_of_page
          text
    FORM top_of_page.
      WRITE:/ 'Data'.
    ENDFORM.                    "top_of_page
    reward if useful....
    Edited by: Dhwani shah on Dec 20, 2007 1:20 PM

  • How to get a Footer text in alv grid?

    Hi,
    am using RESUE_ALV_COMMENTARy_write... it is getting only on top of page..
    suggest me to get Footer text in ALV GRiD.
    Regards,
    sodanapalli
    Moderator message: please do more research before asking, all points removed (both replies were copy/pasted anyway)
    Edited by: Thomas Zloch on May 19, 2011 5:41 PM

    Step1: Populate the ALV event table with 'END_OF_LIST' event
    Step2: Populate the footer text in to an internal table which is of type
    slis_t_listheader.
    Step3: Create a subroutine with name 'END_OF_LIST' and with in this form we have to call the function module u2018REUSE_ALV_COMMENTARY_WRITEu2019.
    Step4: Now call the function module REUSE_ALV_GRID_DISPLAYu2019 to display the ALV report. Whenever u2018END_OF_LIST' event is get fired it executes the subroutine END_OF_LIST and displays the text into the footer of the ALV GRID.
    Code:
    *& Report Z_TEST_ALV
    REPORT z_test_alv.
    TYPE-POOLS: slis.
    DATA: i_mara TYPE STANDARD TABLE OF mara INITIAL SIZE 0,
                i_events TYPE slis_t_event,
                i_end_of_page TYPE slis_t_listheader,
                w_events TYPE slis_alv_event,
                v_repid LIKE sy-repid.
    START-OF-SELECTION.
    SELECT * FROM
    mara INTO TABLE i_mara
    UP TO 100 ROWS.
    CHECK sy-subrc = 0.
    PERFORM populate_alv_event.
    PERFORM comment_build USING i_end_of_page[].
    PERFORM display_grid.
    *& Form POPULATE_ALV_EVENT
    FORM populate_alv_event .
    Populate event table
    w_events-name = 'END_OF_LIST'.
    w_events-form = 'END_OF_LIST'.
    APPEND w_events TO i_events.
    ENDFORM. " POPULATE_ALV_EVENT
    *& Form COMMENT_BUILD
    FORM comment_build USING p_i_end_of_page TYPE slis_t_listheader.
    DATA: ls_line TYPE slis_listheader.
    REFRESH p_i_end_of_page.
    CLEAR ls_line.
    ls_line-typ = 'H'.
    ls_line-info = 'This is end of list'(001).
    APPEND ls_line TO p_i_end_of_page.
    ENDFORM. " COMMENT_BUILD
    *& Form end_of_list
    FORM end_of_list.
    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
    it_list_commentary = i_end_of_page.
    ENDFORM. "end_of_list
    *& Form DISPLAY_GRID
    FORM display_grid .
    v_repid = sy-repid.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    i_callback_program = v_repid
    i_structure_name = 'MARA'
    it_events = i_events
    TABLES
    it_outtab = i_mara
    EXCEPTIONS
    program_error = 1
    OTHERS = 2.
    IF sy-subrc <> 0.
    ENDIF.
    ENDFORM. " DISPLAY_GRID
    Check the output  where footer will be displayed as 'THIS IS END OF LIST'

  • Alv- displaying long text in alv output

    hi,
              as per my requirement, i need to be display long text (length >1000 characters) in alv list or alv grid.
    i get the entaire long text and keep it in final internal table and pass it to alv functional module,  but  it unable to display the compleate long text( in alv-grid).
    the alv list displays the complete long text but not in the row, it displays in the second rown and few field labes of long text and its previous field label are displayed in impro[per order.
    is there any possible way to display long text in alv.
    regards,
    revoori

    Hi Ashok,
    try to pass the below while filling your long text.
    wa_fieldcat-seltext_l  = 'Your Long Text'.
    wa_fieldcat-ddictxt = 'L'.
    for more info check below
    Long Text --- 1000 characters
    hope it works
    Thnaks!
    Edited by: Prasanth on Mar 8, 2009 4:03 PM

  • Display only cell in ALV Grid in OO

    Hi Folks,
    Hope someone can help me with this little issue.  I have a series of columns in my ALV grid that are editable, but I need to a) make some of the cells on specific lines uneditable and b) display time based fields on this line as blank (presently they shoe 00:00:00). 
    For problem a) I have set the layout style frame as 'cellstyles' 
        es_layout-stylefname = 'CELLSTYLES'.
    I have also set the edit flag in the field catalog for the individual columns to 'X' eg     
         WHEN 'CUSTTS_DATE_N'.
              ls_fieldcat-edit = 'X'.
    And coded:
           gwa_stylerow-fieldname = 'CUSTTS_DATE_N'.
          gwa_stylerow-style = cl_gui_alv_grid=>mc_style_disabled.
          APPEND gwa_stylerow TO gt_stylerow.
          wa_delivery_list-cellstyle[] = gt_stylerow[].
          APPEND wa_delivery_list TO it_delivery_list.
    Yet, the ALV cells are still being displayed as editable.  Can't for the life of me figure out what's missing.  The only other thought I had around this is that the wa_delivery_list-cellstyle table is being set in the data extraction code, before the ALV grid is built, and that the cell formats are being overwritten/on not being called by the field catalog entries.  Any thoughts on how to make these fields/cells display only when the ALV is first displayed would be greatly appreciated.
    As for option b) I'm clueless, as the cell style commands are not being picked up (see problem a.).  Again any thoughts would be appreciated, and points will be rewarded for solutions/suggestions that lead to solutions.
    Cheers,
    Stephen Keam

    Hello Stephen
    I have created a simple report ZUS_SDN_ALV_EDITABLE_1B which shows how to use editability on cell level.
    The crucial parts of the coding for your requirements are shown below, followed by the entire report.
      READ TABLE gt_fcat INTO ls_fcat
           WITH KEY fieldname = 'UPTIM'.
      IF ( syst-subrc = 0 ).
        DELETE gt_fcat INDEX syst-tabix.
        ls_fcat-no_zero = abap_true.  " suppresses 00:00:00
        INSERT ls_fcat INTO gt_fcat INDEX 7.
      ENDIF.
    *&      Form  SET_CELL_EDITABLE
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM set_cell_editable .
    * define local data
      DATA: ld_idx      TYPE i,
            ls_outtab   TYPE ty_s_outtab,
            ls_style    TYPE lvc_s_styl.
      LOOP AT gt_outtab INTO ls_outtab.
        ld_idx = syst-tabix.
        REFRESH: ls_outtab-celltab.
        " NOTE: if you change the year of column ERDAT to 2008 then two columns will become non-editable
        IF ( ls_outtab-erdat+0(4) = '2008' ).
          CLEAR: ls_style.
          ls_style-fieldname = 'UPDAT'.
          ls_style-style     = cl_gui_alv_grid=>mc_style_disabled.
          INSERT ls_style INTO TABLE ls_outtab-celltab.
          CLEAR: ls_style.
          ls_style-fieldname = 'UPTIM'.
          ls_style-style     = cl_gui_alv_grid=>mc_style_disabled.
          INSERT ls_style INTO TABLE ls_outtab-celltab.
        ELSE.
        ENDIF.
        MODIFY gt_outtab FROM ls_outtab INDEX ld_idx
          TRANSPORTING celltab.
      ENDLOOP.
    ENDFORM.                    " SET_CELL_EDITABLE
    *& Report  ZUS_SDN_ALV_EDITABLE
    *& Thread: Display only cell in ALV Grid in OO
    *& <a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="765083"></a>
    * Flow logic of screen '100' (no elements, ok-code => gd_okcode ):
    **PROCESS BEFORE OUTPUT.
    **  MODULE STATUS_0100.
    **PROCESS AFTER INPUT.
    **  MODULE USER_COMMAND_0100.
    *& GUI-Status: ok-codes BACK, EXIT, CANC
    REPORT  zus_sdn_alv_editable_1b.
    TYPE-POOLS: abap.
    CONSTANTS:
      gc_tabname       TYPE tabname  VALUE 'KNB1'.
    TYPES: BEGIN OF ty_s_outtab.
    INCLUDE TYPE knb1 AS knb1.
    TYPES: celltab    TYPE lvc_t_styl.
    TYPES: END OF ty_s_outtab.
    TYPES: ty_t_outtab    TYPE STANDARD TABLE OF ty_s_outtab
                          WITH DEFAULT KEY.
    DATA:
      gd_okcode        TYPE ui_func,
      gd_repid         TYPE syst-repid,
      gt_fcat          TYPE lvc_t_fcat,
      gs_layout        TYPE lvc_s_layo,
      gs_variant       TYPE disvariant,
      go_docking       TYPE REF TO cl_gui_docking_container,
      go_grid          TYPE REF TO cl_gui_alv_grid.
    DATA:
      gs_outtab        TYPE ty_s_outtab,
      gt_outtab        TYPE ty_t_outtab,
      gt_outtab_pbo    TYPE ty_t_outtab.
    DATA:
      gd_answer        TYPE c.
    *       CLASS lcl_eventhandler DEFINITION
    CLASS lcl_eventhandler  DEFINITION.
      PUBLIC SECTION.
        CLASS-METHODS:
          handle_data_changed
             FOR EVENT data_changed OF cl_gui_alv_grid
                 IMPORTING er_data_changed.
    ENDCLASS.                    "lcl_eventhandler DEFINITION
    *       CLASS lcl_eventhandler IMPLEMENTATION
    CLASS lcl_eventhandler IMPLEMENTATION.
      METHOD handle_data_changed.
        " Just trigger PAI followed by PBO
        CALL METHOD cl_gui_cfw=>set_new_ok_code
          EXPORTING
            new_code = 'REFRESH'
    *        IMPORTING
    *          rc       =
      ENDMETHOD.                    "handle_data_changed
    ENDCLASS.                    "lcl_eventhandler IMPLEMENTATION
    START-OF-SELECTION.
      SELECT * FROM  (gc_tabname) INTO CORRESPONDING FIELDS
                                  OF TABLE gt_outtab UP TO 99 ROWS.
      gt_outtab_pbo = gt_outtab.  " set PBO data
      PERFORM init_controls.
    * ok-code field = GD_OKCODE
      CALL SCREEN '0100'.
    END-OF-SELECTION.
    *&      Form  INIT_CONTROLS
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM init_controls .
    * Create docking container
      CREATE OBJECT go_docking
        EXPORTING
          parent = cl_gui_container=>screen0
          ratio  = 90
        EXCEPTIONS
          OTHERS = 6.
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    * Create ALV grid
      CREATE OBJECT go_grid
        EXPORTING
          i_parent = go_docking
        EXCEPTIONS
          OTHERS   = 5.
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      " NOTE: not required
    *  set handler:
    *    lcl_eventhandler=>handle_data_changed for go_grid.
    * Build fieldcatalog and set hotspot for field KUNNR
      PERFORM build_fieldcatalog.
      PERFORM set_layout_and_variant.
      PERFORM set_cell_editable.
    *§3.Optionally register ENTER to raise event DATA_CHANGED.
    *   (Per default the user may check data by using the check icon).
      CALL METHOD go_grid->register_edit_event
        EXPORTING
          i_event_id = cl_gui_alv_grid=>mc_evt_enter.
      SET HANDLER: lcl_eventhandler=>handle_data_changed FOR go_grid.
    * Display data
      CALL METHOD go_grid->set_table_for_first_display
        EXPORTING
          is_layout       = gs_layout
          is_variant      = gs_variant
          i_save          = 'A'
        CHANGING
          it_outtab       = gt_outtab
          it_fieldcatalog = gt_fcat
        EXCEPTIONS
          OTHERS          = 4.
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    * NOTE:
    * Documenation of I_SAVE ("An Easy Reference for ALV Grid Control")
    *I_SAVE
    *Determines the options available to the user for saving a layout:
    *? 'X': global saving only
    *? 'U': user-specific saving only
    *? 'A': corresponds to 'X' and 'U'
    *? SPACE: no saving
    * Link the docking container to the target dynpro
      gd_repid = syst-repid.
      CALL METHOD go_docking->link
        EXPORTING
          repid                       = gd_repid
          dynnr                       = '0100'
    *      CONTAINER                   =
        EXCEPTIONS
          OTHERS                      = 4.
      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.                    " INIT_CONTROLS
    *&      Module  STATUS_0100  OUTPUT
    *       text
    MODULE status_0100 OUTPUT.
      SET PF-STATUS 'STATUS_0100'.
    *  SET TITLEBAR 'xxx'.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
    *       text
    MODULE user_command_0100 INPUT.
      " NOTE: retrieve changed data from frontend (grid control) into
      "       the backend (itab in ABAP)
      go_grid->check_changed_data( ).
      CASE gd_okcode.
        WHEN 'BACK'  OR
             'EXIT'  OR
             'CANC'.
          SET SCREEN 0. LEAVE SCREEN.
        WHEN 'REFRESH'.
          PERFORM set_cell_editable.
          " NOTE: Refresh required
          CALL METHOD go_grid->refresh_table_display
    *        EXPORTING
    *          is_stable      =
    *          i_soft_refresh =
    *        EXCEPTIONS
    *          finished       = 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.
        WHEN 'SAVE'.
          IF ( gt_outtab = gt_outtab_pbo ).
            MESSAGE 'No data changed' TYPE 'S'.
          ELSE.
            CLEAR: gd_answer.
            CALL FUNCTION 'POPUP_TO_CONFIRM'
              EXPORTING
    *             TITLEBAR                    = ' '
    *             DIAGNOSE_OBJECT             = ' '
                text_question               = 'Save data?'
    *             TEXT_BUTTON_1               = 'Ja'(001)
    *             ICON_BUTTON_1               = ' '
    *             TEXT_BUTTON_2               = 'Nein'(002)
    *             ICON_BUTTON_2               = ' '
    *             DEFAULT_BUTTON              = '1'
    *             DISPLAY_CANCEL_BUTTON       = 'X'
    *             USERDEFINED_F1_HELP         = ' '
    *             START_COLUMN                = 25
    *             START_ROW                   = 6
    *             POPUP_TYPE                  =
    *             IV_QUICKINFO_BUTTON_1       = ' '
    *             IV_QUICKINFO_BUTTON_2       = ' '
              IMPORTING
                answer                      = gd_answer
    *           TABLES
    *             PARAMETER                   =
              EXCEPTIONS
                text_not_found              = 1
                OTHERS                      = 2.
            IF sy-subrc <> 0.
    *       MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *               WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
            ENDIF.
            IF ( gd_answer = '1' ).  " yes
              MESSAGE 'Data successfully saved' TYPE 'S'.
              gt_outtab_pbo = gt_outtab.  " update PBO data !!!
            ELSE.
              MESSAGE 'Action cancelled by user'  TYPE 'S'.
            ENDIF.
          ENDIF.
        WHEN OTHERS.
      ENDCASE.
      CLEAR: gd_okcode.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    *&      Form  BUILD_FIELDCATALOG
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM build_fieldcatalog .
    * define local data
      DATA:
        ls_fcat        TYPE lvc_s_fcat.
      CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
        EXPORTING
    *     I_BUFFER_ACTIVE              =
          i_structure_name             = gc_tabname
    *     I_CLIENT_NEVER_DISPLAY       = 'X'
    *     I_BYPASSING_BUFFER           =
    *     I_INTERNAL_TABNAME           =
        CHANGING
          ct_fieldcat                  = gt_fcat
        EXCEPTIONS
          inconsistent_interface       = 1
          program_error                = 2
          OTHERS                       = 3.
      IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      ls_fcat-edit = abap_true.
      MODIFY gt_fcat FROM ls_fcat
          TRANSPORTING edit
        WHERE ( key NE abap_true ).
      READ TABLE gt_fcat INTO ls_fcat
           WITH KEY fieldname = 'UPTIM'.
      IF ( syst-subrc = 0 ).
        DELETE gt_fcat INDEX syst-tabix.
        ls_fcat-no_zero = abap_true.  " suppresses 00:00:00
        INSERT ls_fcat INTO gt_fcat INDEX 7.
      ENDIF.
      READ TABLE gt_fcat INTO ls_fcat
       WITH KEY fieldname = 'UPDAT'.
      IF ( syst-subrc = 0 ).
        DELETE gt_fcat INDEX syst-tabix.
        INSERT ls_fcat INTO gt_fcat INDEX 7.
      ENDIF.
      LOOP AT gt_fcat INTO ls_fcat.
        ls_fcat-col_pos = syst-tabix.
        MODIFY gt_fcat FROM ls_fcat INDEX syst-tabix.
        IF ( syst-tabix > 10 ).
          DELETE gt_fcat INDEX syst-tabix.
        ENDIF.
      ENDLOOP.
    ENDFORM.                    " BUILD_FIELDCATALOG
    *&      Form  SET_LAYOUT_AND_VARIANT
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM set_layout_and_variant .
      CLEAR: gs_layout,
             gs_variant.
      gs_layout-cwidth_opt = abap_true.
      gs_layout-zebra      = abap_true.
    *§3.Provide the fieldname of the celltab field by using field
    *   STYLEFNAME of the layout structure.
      gs_layout-stylefname = 'CELLTAB'.
      gs_variant-report = syst-repid.
      gs_variant-handle = 'GRID'.
    ENDFORM.                    " SET_LAYOUT_AND_VARIANT
    *&      Form  SET_CELL_EDITABLE
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM set_cell_editable .
    * define local data
      DATA: ld_idx      TYPE i,
            ls_outtab   TYPE ty_s_outtab,
            ls_style    TYPE lvc_s_styl.
      LOOP AT gt_outtab INTO ls_outtab.
        ld_idx = syst-tabix.
        REFRESH: ls_outtab-celltab.
        IF ( ls_outtab-erdat+0(4) = '2008' ).
          CLEAR: ls_style.
          ls_style-fieldname = 'UPDAT'.
          ls_style-style     = cl_gui_alv_grid=>mc_style_disabled.
          INSERT ls_style INTO TABLE ls_outtab-celltab.
          CLEAR: ls_style.
          ls_style-fieldname = 'UPTIM'.
          ls_style-style     = cl_gui_alv_grid=>mc_style_disabled.
          INSERT ls_style INTO TABLE ls_outtab-celltab.
        ELSE.
        ENDIF.
        MODIFY gt_outtab FROM ls_outtab INDEX ld_idx
          TRANSPORTING celltab.
      ENDLOOP.
    ENDFORM.                    " SET_CELL_EDITABLE
    Regards
      Uwe

  • Long text in alv grid

    Hi ,
    I wanted to display a long text in my grid. Suppose I have a field's  long text having field length 3000.
    It is varying for other fields.
    Anybody will tell me how to display the whole long text in alv grid.

    hi,
    if it is a heading then in the field catlog u can do it.
    i don know th length limitation.
    fieldcatalog-fieldname   = 'EBELP'.
    <b>  fieldcatalog-seltext_m   = 'PO Item'.
    fieldcatalog-seltext_s   = 'PO Item'.
    fieldcatalog-seltext_l   = 'PO Item'.</b>
      fieldcatalog-col_pos     = 1.
      append fieldcatalog to fieldcatalog.
    rgds
    Anver

  • To Display Report in a ALV GRID Format

    Hi All,
    I want to display dome information in ALV Grid format.
    Can anybody give example for displaying data in ALV Grid Format.
    Thanks in advance.
    Thanks & Regards,
    Rayeez.

    Hi ,
    1.FOR ALV Lists..
    REPORT Y_DEMO_ALV NO STANDARD PAGE HEADING.
    Data to be displayed
    DATA: I_SFLIGHT TYPE TABLE OF SFLIGHT.
    Selection
      SELECT * FROM SFLIGHT INTO TABLE I_SFLIGHT.
    Call ABAP List Viewer (ALV)
      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
           EXPORTING
                I_STRUCTURE_NAME   = 'SFLIGHT'
           TABLES
                T_OUTTAB           = I_SFLIGHT.
    2.Using Grids..
    REPORT Y_DEMO_ALV_1.
    Data to be displayed
    DATA: I_SFLIGHT TYPE TABLE OF SFLIGHT.
    Selection
      SELECT * FROM SFLIGHT INTO TABLE I_SFLIGHT.
    Call ABAP List Viewer (ALV)
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
           EXPORTING
                I_STRUCTURE_NAME   = 'SFLIGHT'
           TABLES
                T_OUTTAB           = I_SFLIGHT.
    3.Demo Using most of the ALv Functionalities..
    REPORT  ZSATTRIAL4.
    TYPE-POOLS: slis.
    DB-Table
    TABLES sflight.
    Includes
    INCLUDE <icon>.
    INCLUDE <symbol>.
    CONSTANTS:
    c_formname_top_of_page TYPE slis_formname VALUE 'TOP_OF_PAGE'.
    DATA: i_fieldcat TYPE slis_t_fieldcat_alv,
          i_layout   TYPE slis_layout_alv,
          i_sp_group TYPE slis_t_sp_group_alv,
          i_events   TYPE slis_t_event,
          i_print    TYPE slis_print_alv,
          i_sort     TYPE slis_t_sortinfo_alv.
    *internal table for data to be displayed
    DATA: BEGIN OF i_sflight OCCURS 0.
            INCLUDE STRUCTURE sflight.
    DATA:  box,
           lights.
    DATA: END OF i_sflight.
    DATA: w_repid LIKE sy-repid.
    DATA: i_list_top_of_page TYPE slis_t_listheader.
    Report Selections
    SELECT-OPTIONS s_carrid FOR sflight-carrid.
    SELECT-OPTIONS s_connid FOR sflight-connid.
    SELECT-OPTIONS s_fldate FOR sflight-fldate.
    *SELECTION-SCREEN SKIP 1.
    Parameters
    PARAMETERS: p_maxrow TYPE i DEFAULT 30."to limit the selection
    SELECTION-SCREEN SKIP 1.
    Variant for ALV display
    SELECTION-SCREEN BEGIN OF BLOCK 0 WITH FRAME TITLE text-000.
    PARAMETERS: p_varnt LIKE disvariant-variant.
    SELECTION-SCREEN END OF BLOCK 0.
    Layout of the report display
    SELECTION-SCREEN BEGIN OF BLOCK a WITH FRAME TITLE text-001.
    PARAMETERS: p_zebra AS CHECKBOX DEFAULT ' ',        "Striped pattern
                p_nocolh AS CHECKBOX DEFAULT ' ',        "No column heading
                p_novlin AS CHECKBOX DEFAULT ' ',        "No vertical lines
                p_colopt AS CHECKBOX DEFAULT ' ',        "Optimizes col. wd
                p_keyhot AS CHECKBOX DEFAULT ' ',        "Key fields hot
                p_noinpt AS CHECKBOX DEFAULT ' '.        "No field for input
    SELECTION-SCREEN END OF BLOCK a.
    SELECTION-SCREEN BEGIN OF BLOCK b WITH FRAME TITLE text-002.
    PARAMETERS: p_lights AS CHECKBOX DEFAULT 'X',
                p_lightc AS CHECKBOX DEFAULT 'X'.
    SELECTION-SCREEN END OF BLOCK b.
    SELECTION-SCREEN BEGIN OF BLOCK c WITH FRAME TITLE text-003.
    PARAMETERS: p_totonl AS CHECKBOX DEFAULT ' ',
                p_totext(60),
                p_sttext(60).
    SELECTION-SCREEN END OF BLOCK c.
    SELECTION-SCREEN BEGIN OF BLOCK d WITH FRAME TITLE text-004.
    PARAMETERS: p_chkbox AS CHECKBOX DEFAULT 'X',
                p_detpop AS CHECKBOX DEFAULT 'X',
                p_groupb AS CHECKBOX DEFAULT ' ',
                p_groups AS CHECKBOX DEFAULT ' '.
    SELECTION-SCREEN END OF BLOCK d.
    SELECTION-SCREEN BEGIN OF BLOCK e WITH FRAME TITLE text-005.
    PARAMETERS: p_print AS CHECKBOX DEFAULT ' ',
                p_nosinf AS CHECKBOX DEFAULT ' ',
                p_nocove AS CHECKBOX DEFAULT ' ',
                p_nonewp AS CHECKBOX DEFAULT ' ',
                p_nolinf AS CHECKBOX DEFAULT ' ',
                p_reserv TYPE i.
    SELECTION-SCREEN END OF BLOCK e.
    DATA: w_boxnam TYPE slis_fieldname VALUE  'BOX',
                w_f2code LIKE sy-ucomm       VALUE  '&ETA',
                w_lignam TYPE slis_fieldname VALUE  'LIGHTS',
                w_save(1) TYPE c,
                w_default(1) TYPE c,
                w_exit(1) TYPE c,
                i_variant LIKE disvariant,
                i_variant1 LIKE disvariant.
    INITIALIZATION.
      w_repid = sy-repid.
      PERFORM fieldcat_init USING i_fieldcat.
      PERFORM eventtab_build USING i_events.
      PERFORM comment_build USING i_list_top_of_page.
      PERFORM sp_group_build USING i_sp_group.
      PERFORM t_sort_build USING i_sort.
    Set Options: save variant userspecific or general
    'A or 'U' are for user-specific variants list
    'X' or 'space' for general
      w_save = 'A'.
      PERFORM variant_init.
    Get default variant
      i_variant1 = i_variant.
      CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
           EXPORTING
                i_save     = w_save
           CHANGING
                cs_variant = i_variant1
           EXCEPTIONS
                not_found  = 2.
      IF sy-subrc = 0.
        p_varnt = i_variant1-variant.
      ENDIF.
    Process on value request (list of possible variants)
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_varnt.
      PERFORM f4_for_variant.
    PAI
    AT SELECTION-SCREEN.
      PERFORM pai_of_selection_screen.
    START-OF-SELECTION.
      PERFORM selection.
    END-OF-SELECTION.
      PERFORM layout_build USING i_layout. "wg. Parameters
      PERFORM print_build USING i_print.  "wg. Parameters
      CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
           EXPORTING
                i_program_name         = w_repid
             i_internal_tabname     = 'I_SFLIGHT'
                i_structure_name       = 'SFLIGHT'
                i_client_never_display = 'X'
                i_inclname             = w_repid
           CHANGING
                ct_fieldcat            = i_fieldcat[]
           EXCEPTIONS
                inconsistent_interface = 1
                program_error          = 2
                OTHERS                 = 3.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    Call ABAP/4 List Viewer
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
          EXPORTING
            I_INTERFACE_CHECK           = ' '
               i_callback_program          =  w_repid
            I_CALLBACK_PF_STATUS_SET    = ' '
            I_CALLBACK_USER_COMMAND     = ' '
            I_CALLBACK_TOP_OF_PAGE      = ' '
            I_CALLBACK_HTML_TOP_OF_PAGE = ' '
            I_CALLBACK_HTML_END_OF_LIST = ' '
               i_structure_name            = 'SFLIGHT'
               i_background_id         = 'ALV_BACKGROUND'
            I_GRID_TITLE                =
            I_GRID_SETTINGS             =
               is_layout                   = i_layout
               it_fieldcat                 = i_fieldcat[]
            IT_EXCLUDING                =
               it_special_groups           = i_sp_group[]
               it_sort                     = i_sort[]
            IT_FILTER                   =
            IS_SEL_HIDE                 =
            I_DEFAULT                   = 'X'
               i_save                      = w_save
               is_variant                  = i_variant
               it_events                   = i_events[]
            IT_EVENT_EXIT               =
               is_print                    = i_print
            IS_REPREP_ID                =
            I_SCREEN_START_COLUMN       = 0
            I_SCREEN_START_LINE         = 0
            I_SCREEN_END_COLUMN         = 0
            I_SCREEN_END_LINE           = 0
       IMPORTING
            E_EXIT_CAUSED_BY_CALLER     =
            ES_EXIT_CAUSED_BY_USER      =
           TABLES
                t_outtab                    = i_sflight
          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.
    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
          EXPORTING
               i_callback_program      = w_repid
               i_structure_name        = 'SFLIGHT'
               is_layout               = i_layout
               it_fieldcat             = i_fieldcat[]
              IT_EXCLUDING            =
               it_special_groups       = i_sp_group[]
               it_sort                 = i_sort[]
              IT_FILTER               =
              IS_SEL_HIDE             =
              i_default                = W_DEFAULT
               i_save                  = w_save
               is_variant              = i_variant
               it_events               = i_events[]
              IT_EVENT_EXIT           =
               is_print                = i_print
              I_SCREEN_START_COLUMN   = 0
              I_SCREEN_START_LINE     = 0
              I_SCREEN_END_COLUMN     = 0
              I_SCREEN_END_LINE       = 0
         IMPORTING
              E_EXIT_CAUSED_BY_CALLER =
          TABLES
               t_outtab                = i_sflight.
          FORM FIELDCAT_INIT                                        *
    -->  L_FIELDCAT                                               *
    FORM fieldcat_init USING l_fieldcat TYPE slis_t_fieldcat_alv.
      DATA: ls_fieldcat TYPE slis_fieldcat_alv.
      CLEAR ls_fieldcat.
      ls_fieldcat-fieldname = 'SEATSOCC'.
    *The field is not displayed in the initial output, can be interactively
    chosen for display
      ls_fieldcat-no_out    = 'X'.
    *This field is assigned to a special group with tech. key 'A' and can be
    *displayed using the special group buttons
      ls_fieldcat-sp_group  = 'A'.
    *The field cannot be summed irrespective of its data type
      ls_fieldcat-no_sum    = 'X'.
      APPEND ls_fieldcat TO l_fieldcat.
      CLEAR ls_fieldcat.
      ls_fieldcat-fieldname = 'SEATSMAX'.
      ls_fieldcat-no_out    = 'X'.
      ls_fieldcat-sp_group  = 'A'.
      APPEND ls_fieldcat TO l_fieldcat.
      CLEAR ls_fieldcat.
      ls_fieldcat-fieldname = 'PRICE'.
      ls_fieldcat-no_out    = 'X'.
      ls_fieldcat-sp_group  = 'B'.
      APPEND ls_fieldcat TO l_fieldcat.
      CLEAR ls_fieldcat.
      ls_fieldcat-fieldname    = 'CARRID'.
      ls_fieldcat-outputlen    = 7.
      APPEND ls_fieldcat TO l_fieldcat.
    ENDFORM.
          FORM DATA_ADD                                             *
    --> L_SFLIGHT
    FORM data_add TABLES l_sflight STRUCTURE i_sflight.
      LOOP AT l_sflight.
        IF sy-tabix > 10.
          l_sflight-box  = 'X'.
          l_sflight-lights = '3'.
        ELSE.
          IF sy-tabix = 1.
            l_sflight-lights = '2'.
          ELSE.
            l_sflight-lights = '1'.
          ENDIF.
        ENDIF.
        MODIFY l_sflight.
      ENDLOOP.
    ENDFORM.
          FORM EVENTTAB_BUILD                                       *
    -->  l_EVENTS                                                 *
    FORM eventtab_build USING l_events TYPE slis_t_event.
      DATA: ls_event TYPE slis_alv_event.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
           EXPORTING
                i_list_type = 0
           IMPORTING
                et_events   = l_events.
      READ TABLE l_events WITH KEY name = slis_ev_top_of_page INTO ls_event.
      IF sy-subrc = 0.
        MOVE c_formname_top_of_page TO ls_event-form.
        APPEND ls_event TO l_events.
      ENDIF.
    ENDFORM.
          FORM COMMENT_BUILD                                        *
    -->  L_TOP_OF_PAGE                                            *
    FORM comment_build USING l_top_of_page TYPE slis_t_listheader.
      DATA: ls_line TYPE slis_listheader.
    ***Header
      CLEAR ls_line.
      ls_line-typ  = 'H'.
    LS_LINE-KEY: not used for this type
      ls_line-info = 'Heading list'.
      APPEND ls_line TO l_top_of_page.
    ***Selection
      CLEAR ls_line.
      ls_line-typ  = 'S'.
      ls_line-key  = 'Key 1'.
      ls_line-info = 'Information'.
      APPEND ls_line TO l_top_of_page.
      ls_line-key  = 'Key 2'.
      APPEND ls_line TO l_top_of_page.
    ***Action
      CLEAR ls_line.
      ls_line-typ  = 'A'.
    LS_LINE-KEY: not used for this type
      Ls_line-info = 'Status list'.
      APPEND ls_line TO l_top_of_page.
    ENDFORM.
          FORM LAYOUT_BUILD                                         *
    <->  LS_LAYOUT                                                 *
    FORM layout_build USING ls_layout TYPE slis_layout_alv.
      ls_layout-f2code            = w_f2code.
      ls_layout-zebra             = p_zebra.
      ls_layout-colwidth_optimize = p_colopt.
      IF p_chkbox = 'X'.
    *Fieldname for check box on the report output
        ls_layout-box_fieldname     = w_boxnam.
      ELSE.
        ls_layout-box_fieldname     = space.
      ENDIF.
      ls_layout-no_input          = p_noinpt.
      ls_layout-no_vline          = p_novlin.
      ls_layout-no_colhead        = p_nocolh.
      IF p_lights = 'X' OR p_lightc = 'X'.
    **Fieldname for lights on the report output
        ls_layout-lights_fieldname = w_lignam.
      ELSE.
        CLEAR ls_layout-lights_fieldname.
      ENDIF.
      ls_layout-lights_condense   = p_lightc.
      ls_layout-totals_text       = p_totext.
      ls_layout-subtotals_text    = p_sttext.
      ls_layout-totals_only       = p_totonl.
      ls_layout-key_hotspot       = p_keyhot.
      ls_layout-detail_popup      = p_detpop.
      ls_layout-group_change_edit = p_groups.
    E05_LS_LAYOUT-GROUP_BUTTONS     = P_GROUPB.
    ls_layout-group_buttons     = 'X'.
    ENDFORM.
          FORM SP_GROUP_BUILD                                       *
    -->  L_SP_GROUP                                               *
    FORM sp_group_build USING l_sp_group TYPE slis_t_sp_group_alv.
      DATA: ls_sp_group TYPE slis_sp_group_alv.
    *Fields are assigned to the special group
      CLEAR ls_sp_group.
      ls_sp_group-sp_group = 'A'.
      ls_sp_group-text     = 'Reservation status'.
      APPEND ls_sp_group TO l_sp_group.
      CLEAR ls_sp_group.
      ls_sp_group-sp_group = 'B'.
      ls_sp_group-text     = 'Flight charges'.
      APPEND ls_sp_group TO l_sp_group.
    ENDFORM.
          FORM SELECTION                                                *
    FORM selection.
      SELECT * FROM sflight INTO CORRESPONDING FIELDS OF TABLE i_sflight
               UP TO p_maxrow ROWS WHERE carrid IN s_carrid
               AND connid IN s_connid AND fldate IN s_fldate.
      PERFORM data_add TABLES i_sflight.
    ENDFORM.
          FORM TOP_OF_PAGE                                              *
    FORM top_of_page.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
           EXPORTING
                i_logo             = 'ENJOYSAP_LOGO'
                it_list_commentary = i_list_top_of_page.
    ENDFORM.
          FORM F4_FOR_VARIANT                                           *
    FORM f4_for_variant.
      CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
           EXPORTING
                is_variant          = i_variant
                i_save              = w_save
              it_default_fieldcat =
           IMPORTING
                e_exit              = w_exit
                es_variant          = i_variant1
           EXCEPTIONS
                not_found = 2.
      IF sy-subrc = 2.
        MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ELSE.
        IF w_exit = space.
          p_varnt = i_variant1-variant.
        ENDIF.
      ENDIF.
    ENDFORM.
    *&      Form  PAI_OF_SELECTION_SCREEN
          to check whether right variant is entered on the selection scr
    FORM pai_of_selection_screen.
      IF NOT p_varnt IS INITIAL.
        MOVE i_variant TO i_variant1.
        MOVE p_varnt TO i_variant1-variant.
        CALL FUNCTION 'REUSE_ALV_VARIANT_EXISTENCE'
             EXPORTING
                  i_save     = w_save
             CHANGING
                  cs_variant = i_variant1.
        i_variant = i_variant1.
      ELSE.
        PERFORM variant_init.
      ENDIF.
    ENDFORM.                               " PAI_OF_SELECTION_SCREEN
    *&      Form  VARIANT_INIT
    FORM variant_init.
      CLEAR i_variant.
      i_variant-report = w_repid.
    ENDFORM.                               " VARIANT_INIT
          FORM PRINT_BUILD                                          *
    FORM print_build USING l_print TYPE slis_print_alv.
      l_print-print              = p_print.
      l_print-no_print_selinfos  = p_nosinf.
      l_print-no_coverpage       = p_nocove.
      l_print-no_new_page        = p_nonewp.
      l_print-no_print_listinfos = p_nolinf.
      l_print-reserve_lines      = p_reserv.
      l_print-print              = p_print.
    ENDFORM.
          FORM T_SORT_BUILD                                         *
    FORM t_sort_build USING l_sort TYPE slis_t_sortinfo_alv.
      DATA: ls_sort TYPE slis_sortinfo_alv.
      ls_sort-fieldname = 'CARRID'.
      ls_sort-spos      = 1.
      ls_sort-up        = 'X'.
      ls_sort-subtot    = 'X'.
      APPEND ls_sort TO l_sort.
    ps : reward points for helpful answers and mark the post as closed..

  • Display Standard Text in ALV

    Dear Experts,
    I have a requirement where the user wants me to display the standard text in SO10 using ALV.
    The text must be displayed exactly like how the user maintaned in SO10.
    What is the best way? The user do not want the solution to have a button in the text field, and pop up screen in alv to display the text.

    The problem not related to the data retrieval.
    Its about how to display the text in ALV. I dont wantto display the text in single line in alv coz it gonna be very long and will no longer in original format.
    Edited by: Castelloz Alfonso on Sep 24, 2009 7:59 AM

  • Displaying Field Names in ALV GRID

    hi,
         I have a requirement that i have to display the type of the GL Indicators.
         Now i want the corressponding name/desc of that GL indicator to be displayed down in the ALV GRID.Can any one tell how can i solve this issue..
    For Ex.
    This is my ALV GRID.
        Comp_Code     Vendor_Id       GL_indicator 1          GL_indicator 2
                                                          ABC                         EDF                 
         1000                1000001           20000.00                    500.00
    In this ABC and EDF are the desc of GL_indicator 1 and GL_indicator 2 resp..
    How can i display such type of ALV..
    Rewards points will be given
    Thank You.

    Hi,
    Check the below test code......You will understand.
    TYPE-POOLS: SLIS.
    DATA: GT_OUTTABH TYPE SCARR OCCURS 0 WITH HEADER LINE,
          GT_OUTTAB TYPE SFLIGHT OCCURS 0 WITH HEADER LINE,
          GT_SORT TYPE SLIS_T_SORTINFO_ALV WITH HEADER LINE ,
          GS_LAYOUT TYPE SLIS_LAYOUT_ALV,
          GS_KEYINFO  TYPE SLIS_KEYINFO_ALV,
          G_REPID LIKE SY-REPID.
    DATA: GT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE .
    DATA:
        GT_EVENTS      TYPE SLIS_T_EVENT,
        GT_LIST_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER,
        G_STATUS_SET   TYPE SLIS_FORMNAME VALUE 'PF_STATUS_SET',
        G_USER_COMMAND TYPE SLIS_FORMNAME VALUE 'USER_COMMAND',
        G_TOP_OF_PAGE  TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE',
        G_TOP_OF_LIST  TYPE SLIS_FORMNAME VALUE 'TOP_OF_LIST',
        G_END_OF_LIST  TYPE SLIS_FORMNAME VALUE 'END_OF_LIST'.
    INITIALIZATION.
    define keyinfo
      CLEAR GS_KEYINFO.
      GS_KEYINFO-HEADER01 = 'CARRID'.
      GS_KEYINFO-ITEM01   = 'CARRID'.
      GS_KEYINFO-HEADER02 = SPACE.
      GS_KEYINFO-ITEM02   = 'CONNID'.
      G_REPID = SY-REPID.
      GS_LAYOUT-GROUP_CHANGE_EDIT = 'X'.
      GT_SORT-FIELDNAME = 'CURRCODE'.
      GT_SORT-tabNAME = '1'.
      GT_SORT-SPOS      = 1.
      GT_SORT-UP        = 'X'.
      GT_SORT-SUBTOT    = 'X'.
      GT_SORT-GROUP    = '*'.
      APPEND GT_SORT.
      GT_SORT-FIELDNAME = 'CARRID'.
      GT_SORT-tabNAME = '1'.
      GT_SORT-SPOS      = 2.
      GT_SORT-UP        = 'X'.
      GT_SORT-SUBTOT    = 'X'.
      GT_SORT-GROUP    = ' '.
      APPEND GT_SORT.
      GT_FIELDCAT-FIELDNAME    = 'PRICE'.
      GT_FIELDCAT-tabname    = '2'.
      GT_FIELDCAT-outputlen    = 12.
      GT_FIELDCAT-DO_SUM       = 'X'.
      APPEND GT_FIELDCAT.
      GT_FIELDCAT-FIELDNAME    = 'CARRID'.
      GT_FIELDCAT-tabname    = '1'.
      GT_FIELDCAT-outputlen    = 6.
      GT_FIELDCAT-DO_SUM       = space.
      APPEND GT_FIELDCAT.
      PERFORM EVENTTAB_BUILD USING GT_EVENTS[].
    START-OF-SELECTION.
      SELECT * FROM SCARR INTO CORRESPONDING FIELDS
           OF TABLE GT_OUTTABH.
      SELECT * FROM SFLIGHT INTO CORRESPONDING FIELDS
      OF TABLE GT_OUTTAB.
      CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
           EXPORTING
                I_CALLBACK_PROGRAM      = G_REPID
                I_STRUCTURE_NAME_HEADER = 'SCARR'
                I_STRUCTURE_NAME_ITEM   = 'SFLIGHT'
                IS_KEYINFO              = GS_KEYINFO
                IS_LAYOUT               = GS_LAYOUT
                IT_FIELDCAT             = GT_FIELDCAT[]
                I_TABNAME_HEADER        = '1'
                I_TABNAME_ITEM          = '2'
                IT_EVENTS               = GT_EVENTS[]
                IT_SORT                 = GT_SORT[]
           TABLES
                T_OUTTAB_HEADER         = GT_outtabh
                T_OUTTAB_ITEM           = GT_outtab.
          FORM EVENTTAB_BUILD                                           *
    FORM EVENTTAB_BUILD USING RT_EVENTS TYPE SLIS_T_EVENT.
    *"Registration of events to happen during list display
      DATA: LS_EVENT TYPE SLIS_ALV_EVENT.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
           EXPORTING
                I_LIST_TYPE = 0
           IMPORTING
                ET_EVENTS   = RT_EVENTS.
      READ TABLE RT_EVENTS WITH KEY NAME = SLIS_EV_TOP_OF_PAGE
                               INTO LS_EVENT.
      IF SY-SUBRC = 0.
        MOVE G_TOP_OF_PAGE TO LS_EVENT-FORM.
        APPEND LS_EVENT TO RT_EVENTS.
      ENDIF.
    ENDFORM.
          FORM TOP_OF_PAGE                                              *
    FORM TOP_OF_PAGE.
      DATA: LS_LINE TYPE SLIS_LISTHEADER.
      REFRESH GT_LIST_TOP_OF_PAGE.
      CLEAR LS_LINE.
      LS_LINE-TYP  = 'H'.
      LS_LINE-INFO = '<Header>'.
      APPEND LS_LINE TO GT_LIST_TOP_OF_PAGE.
    STATUS LINE: TYPE S
      CLEAR LS_LINE.
      LS_LINE-TYP  = 'S'.
      LS_LINE-KEY  = '<Status1>'.
      LS_LINE-INFO = GT_OUTTABH-CURRCODE.
      APPEND LS_LINE TO GT_LIST_TOP_OF_PAGE.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
           EXPORTING
                IT_LIST_COMMENTARY = GT_LIST_TOP_OF_PAGE.
    ENDFORM.
    Regards,
    Omkar.

  • Display of "Average Values Text in ALV grid"

    Hi
        I use ALV grid to display  the fields from a table. I have 15 columns.  I need to do average for four columns.
    In the field catalog i did a do_sum for those fields.
       When the ALV grid is displayed I get average values for these columns.
    Eg. Let suppose the grid looks like
    Field1           Field2           Field3             Field4     Field5         Field 6.
    vendor1       18                 22                   6            17                28
    vendor1       54                 11                  16           62                28
    vendor1       33                 21                   26          79                18
                        35             18                 16        52             24
      My requirement is I need to display the text "AVERAGE VALUES" . ( I need something like this.)
    Field1                      Field2           Field3             Field4     Field5         Field 6.
    vendor1                   18                 22                   6            17                28
    vendor1                    54                 11                  16           62                28
    vendor1                    33                 21                  26          79                18
    Average values        35             18                16        52             24
    Could someone help me in this?
    Thanks & Regards
    Kavitha

    Hello,
    you can use event subtotal_text of ALV_GRID.
    Regards,
    Pedro Santos

  • Display 80 characters of PO text in ALV grid column?

    Hi Guys,
                 I just want to display only 80 characters of PO Header text in the ALV grid column and  the rest should appear when we move the Mouse on to the each ALV grid'd POtext column. So how is it possible 1st tell me how to display 80 characters of PO text.?
      in ME23n u can see the PO  header text.
    Thanks ,
    Gopi.

    Hi Gopi,
    Are you displaying ALV in your custom report and you want to show just 80 char in output?
    If this is yes:
    You can set ALV column width as 80 CHAR while building field catalog.
    Column cell will have complete text but when ALV appears it will first show first 80 char.
    thnx,
    ags.

  • How to display sub total text in ALV grid display reporting

    Hi,
    I want to display a text 'SUB TOTAL'  in Sub total  row  of an ALV report.
    Presently I am getting the name of the field used in sorting to get sub totals. But I required to display own text. Could you please give me solution.
    Thanks
    Giridhar Karnam

    For doing this u need to simply modify the layout properties, please award points if found helpful
    DATA: L_LAYOUT TYPE SLIS_LAYOUT_ALV.
    L_LAYOUT-SUBTOTALS_TEXT = 'GEN SUBTOT'.
        CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
          EXPORTING
            I_CALLBACK_PROGRAM = SY-REPID
            IS_LAYOUT          = L_LAYOUT
            IT_FIELDCAT        = IT_FIELDCAT
          TABLES
            T_OUTTAB           = IT_FINAL
          EXCEPTIONS
            PROGRAM_ERROR      = 1
            OTHERS             = 2.

  • Subtotal Text in ALV Grid and hiding empty row

    Hello,
    ive got a ALV-Grid with a few fields .. Total on one field subtotal on VKORG, category or some other fields .
    after subtotal of one of the 2 named fields i'm reading the literal to the given fields and writing them in the table which is displayed and do a refresh.
    i can show the field literal in the alv by adding it into the field cat but than its displayed even if its not filled.
    i just want to display that column after filling it - the subtotal of the 2 columns.
    and i want to add the text of  the literal to the subtotal line. so if the alv grid is closed to display the totals. i want to see what the subtotal is for.
    for displaying i use        
    CALL METHOD lcl_alv_grid->set_table_for_first_display
          EXPORTING
            is_layout            = gs_layout
            is_variant           = gs_variant
            it_toolbar_excluding = gt_exclude
            i_save               = x_save
            i_default            = 'X'
          CHANGING
            it_outtab            = it_alvlist[]
            it_fieldcatalog      = gt_field_cat.
    for refresh 
        lv_lvc_s_stbl-row = 'X'.
        lv_lvc_s_stbl-col = 'X'.
        lv_soft_refresh = 'X'.
        CALL METHOD lcl_alv_grid->refresh_table_display
          EXPORTING
            is_stable      = lv_lvc_s_stbl
            i_soft_refresh = lv_soft_refresh
          EXCEPTIONS
            finished       = 1
            OTHERS         = 2.
    get the selected column to read literal
    CALL METHOD lcl_alv_grid->get_selected_columns
        IMPORTING
          et_index_columns = it_col_tab
        EXCEPTIONS
          OTHERS           = 1.
    Hope you can help me and understand my problem

    Hi,
    Use the No_out from Reusable types of fieldcat..For example.
    IF it_final-field is initial.
            READ TABLE IT_FIELDCAT5 WITH KEY FIELDNAME = 'BCD'.
            IF SY-SUBRC EQ 0.
              IT_FIELDCAT5-NO_OUT = 'X'.
              MODIFY IT_FIELDCAT5 INDEX SY-TABIX TRANSPORTING NO_OUT.
            ENDIF.
    else.
            READ TABLE IT_FIELDCAT5 WITH KEY FIELDNAME = 'BCD'.
            IF SY-SUBRC EQ 0.
              IT_FIELDCAT5-NO_OUT = ' '.
              MODIFY IT_FIELDCAT5 INDEX SY-TABIX TRANSPORTING NO_OUT.
            ENDIF.
    ENDIf.
    Cheers,
    Syed Maheboob.

Maybe you are looking for

  • Help if you can

    Am a newbie in Java and decompiled a class file and the following is the output of the decompiler.Please explain what it does. public static String toHex(byte decValue) return toHex(decValue, 2); public static String toHex(short decValue) return toHe

  • REPLICAT ERROR(The procedure entry point long jmp could not be located )

    Hi, I am getting the following error The procedure entry point long jmp could not be located in the dynamic link library orauts.dll Does anyone know anything about this? please help. Thanks V

  • How to select email account for sending notifications

    I have three calendars (for example, C1, C2, C3). My Mail application has 3 email accounts (A1, A2, A3). How can I make the calendar send notifications using a selected email account? For example, I want all calendar email notifications to be sent us

  • New HCM Legal Changes?

    Dear Friends, Did SAP announced any new HCM Legal Changes. If so pl do let me know and how it is going to hit International payroll. Any country specfic changes are made, Regards, Vamshi

  • The info "i" button on albums in itunes store is not showing up?

    The quick view button at the bottom right corner of every album in the itunes store is not there anymore. Is this the same for anyone else or is it a glitch in my itunes? Does anyone know how to fix it? Thank you.