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.

Similar Messages

  • 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..

  • How to make a field manadatory within ALV Grid using methods and classes

    Hi,
    I am using ALV Grid using set_table_for_first_display
    inside my dialog programming. I have a field called project number inside my grid which has to be made as mandatory field.
    I have defined a method called catch_data_changed inside my class lcl_event_receiver. This method captures the changes made to one of the fields inside my ALV grid and displays all the default values of the other fields from the grid.
    Now, i have to make project number which is one of my fields inside my ALV grid as mandatory. At the field catalog level i did not find any such option for making a field as required field.
    Is there any other way, i can accomplish this within the ALV grid?

    from my understanding from ur question, i understood that u want the editable field inside alvgrid to be mandatory.
    i dont know anthing in fieldcat, but u can try the following logic.
    FORM DATA_CHANGED  USING P_ER_DATA_CHANGED TYPE REF TO
    CL_ALV_CHANGED_DATA_PROTOCOL .
      DATA: L_VALUE TYPE LVC_VALUE,
        ls_mod_cell type lvc_s_modi.
      READ TABLE P_ER_DATA_CHANGED->MT_MOD_CELLS INTO LS_MOD_CELL.
    if sy-subrc = 0.
        CALL METHOD P_ER_DATA_CHANGED->GET_CELL_VALUE
          EXPORTING
            I_ROW_ID    = LS_MOD_CELL-row_id
            I_FIELDNAME = LS_MOD_CELL-fieldname
          IMPORTING
            E_VALUE     = L_VALUE.
    IF LS_MOD_CELL-FIELDNAME <> 'fieldname what u want'
    MESSAGE 'ENTER VALUE INTO (fieldname u want) ' TYPE 'I'.
    ENDIF.
    ELSE.
    MESSAGE 'ENTER VALUE INTO (fieldname u want) ' TYPE 'I'.
    ENDIF.

  • 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

  • Validation I/P Enabled field in the ALV grid

    Hi all,
    Which method is used for validating a value entered in a reprot output field of an ALV Grid OO report.
    can some one please throw some light on this.
    with a few example programs where it has been implemented.
    Regrds

    Hi sushi,
      check this Program :  BCALV_EDIT_04
      to check out, Execute it , select the checkbox , and give any non numeric amount in the amount field , it will display an error

  • 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

  • Field Length in Alv Grid out put

    hi,
    How to increase the length of the filed in the output of alv grid,
    Actually i am getting one blank field in the alv grid out put, my requirement is to increase the length through out the column how to do that
    can anyone guide me plz
    SIRI

    in your fieldcat of the field
    wfieldcat-fieldname = '<your fieldname in caps>'
    wfieldcat-outputlen = 10 (or the length you want for the field)
    <you can define any other property also for that field>
    append wfieldcat to ifieldcat.
    now pass it in fm.
    regards
    shiba dutta

  • How can I modify the display field names on the output port of my bi query

    Hello,
    I integrate my bi query in the visual composer storyboard.
    Then I click on my output port of the query and see the output fields.
    The display field names are very strange.
    For example:
    ABZCNQMDOPWJGHS1Q5Q27090
    I have never save such a field name while I create my query in the query designer.
    Have somebody an idea, where I can modify my displayed field names??
    Thanks.
    Thomas

    Hi Thomas,
    the cryptical names are the technical names of your query components. If there is no decription available (depends also on your portal language) then the technical names are displayed. Check your portal language in your user settings and then check if you have entered a description in the query designer for this language.
    Best Regards,
    Marcel

  • How change standard field lable in alv grid display

    Hi Experts,
        How are you doing! I am having some doubts in the alv grid display, I am new to this concepts.
    I want to display field  lable manually, actually its taking from table field discription but I want to display one field name manually.
    example code.
    ls_fldcat-fieldname = 'BPKIND'.
      ls_fldcat-ref_tabname = 'BUT000'.
      ls_fldcat-ref_fieldname = 'BPKIND'.
      APPEND ls_fldcat TO lt_fldcat.
      ls_fldcat-fieldname = 'PARTNER2'.
      ls_fldcat-ref_tabname = 'BUT051'.
      ls_fldcat-ref_fieldname = 'PARTNER2'.
    Here I dont want to display 'PARTNER2' I need 'KEY ACCOUNT MANAGER'.
    Please send me how to do this.
    Surya Ramireddy.

    Hi
      Please check out this program.
    Type-pools: slis.
    Tables: likp.
    Data: Begin of i_likp occurs 0,
            vbeln like likp-vbeln,
            ernam like likp-ernam,
            erzet like likp-erzet,
            erdat like likp-erdat,
          End of i_likp.
    Data: it_fieldcat type slis_t_fieldcat_alv,
          wa_fieldcat type SLIS_FIELDCAT_ALV,
          it_events type slis_t_event.
    Selection-screen: Begin of block b1 with frame title text-001.
      select-options: s_vbeln for likp-vbeln.
    Selection-screen: End of block b1.
    start-of-selection.
    perform get_sales_header_data.
    end-of-selection.
    perform field_catalogue.
    perform modify_field_catalogue.
    perform display_alv_grid_display.
    *&      Form  get_sales_header_data
          text
    -->  p1        text
    <--  p2        text
    form get_sales_header_data .
    select vbeln
           ernam
           erzet
           erdat
           into table i_likp
           from likp
           where vbeln in s_vbeln.
    endform.                    " get_sales_header_data
    *&      Form  field_catalogue
          text
    -->  p1        text
    <--  p2        text
    form field_catalogue .
    CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
    EXPORTING
       I_PROGRAM_NAME               = sy-repid
       I_INTERNAL_TABNAME           = 'I_LIKP'
       I_INCLNAME                   = sy-repid
      CHANGING
        ct_fieldcat                  = it_fieldcat
    EXCEPTIONS
       INCONSISTENT_INTERFACE       = 1
       PROGRAM_ERROR                = 2
       OTHERS                       = 3
    endform.                    " field_catalogue
    *&      Form  modify_field_catalogue
          text
    -->  p1        text
    <--  p2        text
    form modify_field_catalogue .
    loop at it_fieldcat into wa_fieldcat.
    case wa_fieldcat-fieldname.
      when 'VBELN'.
       wa_fieldcat-col_pos = 1.
       wa_fieldcat-seltext_l = 'Sales Doc Header No'.
       wa_fieldcat-emphasize = 'C100'.
      when 'ERNAM'.
       wa_fieldcat-col_pos = 2.
       wa_fieldcat-seltext_l = 'Created By'.
       wa_fieldcat-emphasize = 'C200'.
      when 'ERZET'.
       wa_fieldcat-col_pos = 3.
       wa_fieldcat-seltext_l = 'Entry Time'.
       wa_fieldcat-emphasize = 'C300'.
      when 'ERDAT'.
       wa_fieldcat-col_pos = 4.
       wa_fieldcat-seltext_l = 'Created On'.
       wa_fieldcat-emphasize = 'C400'.
      endcase.
      modify it_fieldcat from wa_fieldcat.
    endloop.
    endform.                    " modify_field_catalogue
    *&      Form  display_alv_grid_display
          text
    -->  p1        text
    <--  p2        text
    form display_alv_grid_display .
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
       I_CALLBACK_PROGRAM                = sy-repid
       IT_FIELDCAT                       = IT_FIELDCAT
      TABLES
        t_outtab                          = i_likp
    EXCEPTIONS
       PROGRAM_ERROR                     = 1
       OTHERS                            = 2
    endform.                    " display_alv_grid_display
    Regards
    Haritha.

  • Need to display Long Text as field Name in ALV

    Hi,
    I am using an ALV Grid Display. Even though i have kept the output field length to be 30 char, the Column header that is being selected is the short name. I would like the Column header to display the long name.
    For example: Field "MAKTX"
    l_seltext_l = "Description"
    L_seltext_s = "Descr"
    I want to display "Description" as the field name but it is displaying the short length even though the field is 30 characters wide.
    Please help.
    Thanks,
    Urmila

    Hi,
    along with <b>fieldcat-SELTEXT_L  = 'long text'.</b>
       try to pass this also..
    <b>fieldcat-DDICTXT = 'L'.</b>
    so this will allow only long text.
    Regards
    vijay

  • Field Catolgue in alv grid display

    Hi Abapers,
    I need to display the percentage rows with decimals and other rows without decimal . Is their any option in field catalog to do like this. Or tell me any other alternative to achieve this.
    sno  total     col1      col2      col3
    1      220       100        20       100
    2      320      120         50        150
    tot    540       220        70         250
    per               40.74     1.87  and so on
    or ,
    I have two different internal tables how can i put it in one field catalog to pass it to alv grid display.
    Regards,
    Priya

    Don't   do  total  by your  self  in the Pogram.
    in the   Fieldcatalog  there is an Attribute which will do total  &  Average .
    Enable it so that  from one  internal  table   data   it self it will do  good.
    example program
    Below is an example ABAP program which will populate a simple internal table(it_ekpo) with data and
    display it using the basic ALV grid functionality(including column total). The example details the main
    sections of coding required to implement the ALV grid functionality:
                             Data declaration
                             Data retrieval
                             Build fieldcatalog
                             Build layout setup
    REPORT  zdemo_alvgrid                 .
    TABLES:     ekko.
    type-pools: slis.                                 "ALV Declarations
    *Data Declaration
    TYPES: BEGIN OF t_ekko,
      ebeln TYPE ekpo-ebeln,
      ebelp TYPE ekpo-ebelp,
      statu TYPE ekpo-statu,
      aedat TYPE ekpo-aedat,
      matnr TYPE ekpo-matnr,
      menge TYPE ekpo-menge,
      meins TYPE ekpo-meins,
      netpr TYPE ekpo-netpr,
      peinh TYPE ekpo-peinh,
    END OF t_ekko.
    DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
          wa_ekko TYPE t_ekko.
    *ALV data declarations
    data: fieldcatalog type slis_t_fieldcat_alv with header line,
          gd_tab_group type slis_t_sp_group_alv,
          gd_layout    type slis_layout_alv,
          gd_repid     like sy-repid.
    *Start-of-selection.
    START-OF-SELECTION.
    perform data_retrieval.
    perform build_fieldcatalog.
    perform build_layout.
    perform display_alv_report.
    *&      Form  BUILD_FIELDCATALOG
    *       Build Fieldcatalog for ALV Report
    form build_fieldcatalog.
    * There are a number of ways to create a fieldcat.
    * For the purpose of this example i will build the fieldcatalog manualy
    * by populating the internal table fields individually and then
    * appending the rows. This method can be the most time consuming but can
    * also allow you  more control of the final product.
    * Beware though, you need to ensure that all fields required are
    * populated. When using some of functionality available via ALV, such as
    * total. You may need to provide more information than if you were
    * simply displaying the result
    *               I.e. Field type may be required in-order for
    *                    the 'TOTAL' function to work.
      fieldcatalog-fieldname   = 'EBELN'.
      fieldcatalog-seltext_m   = 'Purchase Order'.
      fieldcatalog-col_pos     = 0.
      fieldcatalog-outputlen   = 10.
      fieldcatalog-emphasize   = 'X'.
      fieldcatalog-key         = 'X'.
    *  fieldcatalog-do_sum      = 'X'.
    *  fieldcatalog-no_zero     = 'X'.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'EBELP'.
      fieldcatalog-seltext_m   = 'PO Item'.
      fieldcatalog-col_pos     = 1.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'STATU'.
      fieldcatalog-seltext_m   = 'Status'.
      fieldcatalog-col_pos     = 2.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'AEDAT'.
      fieldcatalog-seltext_m   = 'Item change date'.
      fieldcatalog-col_pos     = 3.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'MATNR'.
      fieldcatalog-seltext_m   = 'Material Number'.
      fieldcatalog-col_pos     = 4.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'MENGE'.
      fieldcatalog-seltext_m   = 'PO quantity'.
      fieldcatalog-col_pos     = 5.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'MEINS'.
      fieldcatalog-seltext_m   = 'Order Unit'.
      fieldcatalog-col_pos     = 6.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'NETPR'.
      fieldcatalog-seltext_m   = 'Net Price'.
      fieldcatalog-col_pos     = 7.
      fieldcatalog-outputlen   = 15. 
      fieldcatalog-do_sum      = 'X'.        "Display column total
      fieldcatalog-datatype     = 'CURR'.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'PEINH'.
      fieldcatalog-seltext_m   = 'Price Unit'.
      fieldcatalog-col_pos     = 8.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
    endform.                    " BUILD_FIELDCATALOG
    *&      Form  BUILD_LAYOUT
    *       Build layout for ALV grid report
    form build_layout.
      gd_layout-no_input          = 'X'.
      gd_layout-colwidth_optimize = 'X'.
      gd_layout-totals_text       = 'Totals'(201).
    *  gd_layout-totals_only        = 'X'.
    *  gd_layout-f2code            = 'DISP'.  "Sets fcode for when double
    *                                         "click(press f2)
    *  gd_layout-zebra             = 'X'.
    *  gd_layout-group_change_edit = 'X'.
    *  gd_layout-header_text       = 'helllllo'.
    endform.                    " BUILD_LAYOUT
    *&      Form  DISPLAY_ALV_REPORT
    *       Display report using ALV grid
    form display_alv_report.
      gd_repid = sy-repid.
      call function 'REUSE_ALV_GRID_DISPLAY'
           exporting
                i_callback_program      = gd_repid
    *            i_callback_top_of_page   = 'TOP-OF-PAGE'  "see FORM
    *            i_callback_user_command = 'USER_COMMAND'
    *            i_grid_title           = outtext
                is_layout               = gd_layout
                it_fieldcat             = fieldcatalog[]
    *            it_special_groups       = gd_tabgroup
    *            IT_EVENTS                = GT_XEVENTS
                i_save                  = 'X'
    *            is_variant              = z_template
           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  DATA_RETRIEVAL
    *       Retrieve data form EKPO table and populate itab it_ekko
    form data_retrieval.
    select ebeln ebelp statu aedat matnr menge meins netpr peinh
    up to 10 rows
      from ekpo
      into table it_ekko.
    endform.                    " DATA_RETRIEVAL
    gowri
    Message was edited by:
            Gowri Krishna

  • Fieldcontent in field catalog in ALV GRID with leading blanks to be display

    Hello,
    I want to display the result of a report in an ALV Grid.
    There are different columns in the ALV, one of them contains text, sometimes with leading blanks.
    The ALV does not display the blanks, cut them and moves the rest to the left.
    I have used LVC_S_FCAT-JUST with 'R' but this moves the content of the field only to the right (right justified), so that it looks like there is always a lot of blnks on the left side . 
    Is there any possibility to display blanks when they appear in the text field?
    e.g.
    TEXT1 (10)
      9991-A
    9950-B
          9090-T
    9675-N
    Do´t ask, why there are leading blanks. It is always your customer or manager who determines the results!
    Thank you very much for any hint that brings happiness into the face of  this customer / manager.
    Best regards
    Dirk

    Hi Sunil,
    unfortunately this did not help!
    But what can I expect, when the forum works the same.
    e.g.
    TEXT1 (10)
    9991-A
    9950-B
    9090-T
    9675-N
    should more look like:
    e.g.
    TEXT1 (10)
    9991-A
    _9950-B
    ___9090-T
    __9675-N
    but without all the '_'.  
    Regards
    Dirk

  • Error in field catalog in ALV grid display using classes at do_sum = "X'.

    Hi,
    I'm using classes in ALV Grid display.
    the code for the field catalog is going to dump because of the statement in the field catalog for field 'netwr',do_sum = 'X'.
    that do_sum = 'X' is not working and going to dump when executed.with out that do_sum it is working fine. the error in dump analysys is showing sap standard incude LSLVCF01.
        assign component
               <ls_fieldcat>-fieldname of structure rt_data to <g_field>.
        if sy-subrc ne 0.
          message x000(0k).
        endif.
    sy-subrc is 4 when the program is being executed.
    CODE:
    FORM prepare_field_catalog CHANGING pt_fieldcat TYPE lvc_t_fcat.
      DATA ls_fcat TYPE lvc_s_fcat.
      ls_fcat-fieldname = 'VBELN1'.
      ls_fcat-ref_field = 'VBELN'.
      ls_fcat-ref_table = 'VBRK'.
      ls_fcat-coltext = 'Invoice No'.
      ls_fcat-seltext = 'Invoice No'.
      APPEND ls_fcat TO pt_fieldcat.
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'BUDAT'.
      ls_fcat-ref_table = 'BKPF'.
      ls_fcat-coltext = 'Invoice Date'.
      ls_fcat-seltext = 'Invoice Date'.
      APPEND ls_fcat TO pt_fieldcat.
      CLEAR ls_fcat.
    ls_fcat-fieldname = 'NETWR'.
      ls_fcat-ref_field = 'NETWR'.
      ls_fcat-ref_table = 'VBRK'.
      ls_fcat-coltext = 'Value of Invoice'.
      ls_fcat-seltext = 'Value of Invoice'.
      ls_fcat-datatype = 'CURR'.
      ls_fcat-do_sum = 'X'.
      APPEND ls_fcat TO pt_fieldcat.
      CLEAR ls_fcat.
    ENDFORM.
    can u please look in the code and rectify the error,
    would appeciate ur response.
    regards,
    veera.

    Hi,
    try this..
    ls_fcat-fieldname = 'NETWR'.
    ls_fcat-ref_field = 'NETWR'.
    ls_fcat-ref_table = 'VBRK'.
    ls_fcat-coltext = 'Value of Invoice'.
    ls_fcat-seltext = 'Value of Invoice'.
    ls_fcat-datatype = 'CURR'.
    ls_fcat-do_sum = 'X'.
    <b>ls_fcat-cfieldname = 'WAERS'.</b>
    APPEND ls_fcat TO pt_fieldcat.
    CLEAR ls_fcat.
    Regards
    vijay

  • FIeld headings in ALV Grid by label

    Hi
    I want disply the headings in alv grid display like this format.
    I want write my own label in the output. (not in Normal LIST DISPLAY)
    Sno |      Sname |    Marks
        |           |     M1 |  M2  | M3
    How it is possible?
    Edited by: Krishna Bommisetty on Sep 11, 2008 10:55 AM

    Hi,
      Check the below code.
    WA_FCAT-SELTEXT_M   = TEXT-073.
      WA_FCAT-DDICTXT      = 'M'.
    We can define the name of the field label as mentioned above, where texto073 is nothing but the field label you want to give to the particular field.
      DDICTXT you have to mention the length as small 'S', medium 'M' and large as 'L'.

  • Display error message in ALV grid  using OOPS

    Hi,
    I have a requirement to display report in ALV. I have created ALV grid using OOPS with three editable cells and 1 button on toolbar. When user enter values in Ediatble cell  and click on the Toolbar button, sales order item should be assigned to contract.
    When the user select  the row and click on toolbar button, a salesorder item should be assigned  to contract and i am using BAPI and fine with BAPI. All the error message should be displayed in a popup and the corresponding failed row  should change its color .
    Once the user identified the failed row, he can edit the value in the ediatble cells and should reprocess in the same screen ( without going back to selection screen).
    To display POP Up, I  am using FM BAL_LOG_CREATE, BAL_LOG_MSG_ADD, BAL_DSP_PROFILE_NO_TREE_GET, BAL_CNTL_CREATE.
    by using above 4 FM , i can display POP UP. but i cannot change the color of the failed row. 
    Once I identified the failed row and reprocess from the same screen , I am successful in processing the failed row, but my error log still has the reprocessed row as failed row because,  error log is not refreshing.
    Please suggest me how to clear error log which was created by using the above FM's and change the color of the failed row .
    Thanks in Advance

    Hi
    Please suggest me how to clear error log which was created by using the above FM's....
    U can use BAL_LOG_REFRESH
    ....and change the color of the failed row
    You need to insert a new field for Colour Attributes in your output table and input its name in the layout structure:
    IS_LAYOUT-INFO_FNAME = <field name for colour>
    The field has to be a CHAR 3 and its value can be -
    > Cxy
    C is a constant
    x is the colour number (from 1 to 9)
    y is intensified (0 = off, 1 = on)
    After changing the value of output table you need to run the method REFRESH_TABLE_DISPLAY for refreshing the output
    Max

Maybe you are looking for

  • Update rule dead lock

    I need to reload an ODS to an infocube. I've erased the whole infocube (fact table and dimensions) and then i launched init with all data from ODS to infocube. All informations are getting stuck at the level of update rules. It ends after a while wih

  • Ipod shuffle is loaded but charging indicator react for only a second

    Hi, I have an Ipod shuffle, which is still under warranty for at least 160 days. Problem is that it is charged (when I connect to the PC it shows the green light) but when I disconnect it from the PC it is only possible to press the charging check fo

  • Convert Oracle SQL query to single column output

    Hello All, I need to build the query to have multiple columns in a single column with multiple rows. select a.customer_trx_id,a.previous_customer_trx_id from ra_customer_trx_all a where a.customer_trx_id = :customer_trx_id here, a.customer_trx_id and

  • HT201272 Tranfering from one ipod to another

    I am trying to import songs from one ipod to another......songs on old ipod are from another computer I know longer have. How can I or can I even do this?

  • Scrolling with Magic Mouse in Firefox

    Occasionally, maybe once per day, when I open the Bookmarks menu in Firefox, my Magic Mouse won't scroll up or down. I close the menu, open it again, and the Magic Mouse works fine. The Firefox Bookmarks menu is the only place I've noticed this or an