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

Similar Messages

  • Possible to have vertical scroll bar for a cell in ALV Grid (using methods)

    Hi All,
    I have a field with length 100 characters on a ALV Grid (using methods)..User doesn't want to scroll all the 100 characters horizontally to see the whole text rather he wants to have a vertical scroll bar for the cell so that he can scroll vertically.
    Is it possible to have split the cell text into lines and have a vertical scroll bar for a cell in ALV Grid?
    Regards
    Jaker.

    Thanks for the suggestion Balu.I tried this , but while scrolling,headers also getting scrolled.
    Becoz of this , if i scroll down to the last row,headers are getting hidden.
    Headers should always be static.only the data should scroll.
    Since h:datatable is being rendered as one table , i can div tag for this table alone.
    If i have seperate datatable for headers alone i can do this .But i should not use two datatables.

  • One editable cell in alv grid using function module

    Hello all,
    Any one have an idea how to make a single editable cell in alv grid using function module, i mean to say
    with out using object oriented programming.
    Regards,
    Prakash

    Hi,
    Using ALV List display it is possible.
    Try this.
    TYPE-POOLS:SLIS.
    DATA: X_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
    DATA: IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
    DATA:IT_EVENTS TYPE SLIS_T_EVENT.
    data: begin of it_chg occurs 0,
          index type sy-tabix,
          end of it_chg.
    DATA:  X_EVENTS    TYPE SLIS_ALV_EVENT.
    DATA: BEGIN OF ITAB OCCURS 0,
          NAME(10) TYPE C,
          ZTERM TYPE C,
          END OF ITAB.
    PERFORM FILL_TABLE.
    loop at itab where zterm = 'A'.
    it_chg-index = sy-tabix + 3.
    " addition 3 IS FOR FIELD LABELS
    append it_chg.
    clear it_chg.
    endloop.
    DATA:L_POS TYPE I VALUE 1.
    CLEAR: L_POS.
    L_POS = L_POS + 1.
    **fieldcatalog
    X_FIELDCAT-FIELDNAME = 'NAME'.
    X_FIELDCAT-TABNAME = 'ITAB'.
    X_FIELDCAT-COL_POS    = L_POS.
    X_FIELDCAT-OUTPUTLEN = '10'.
    APPEND X_FIELDCAT TO IT_FIELDCAT.
    CLEAR X_FIELDCAT.
    L_POS = L_POS + 1.
    X_FIELDCAT-FIELDNAME = 'ZTERM'.
    X_FIELDCAT-TABNAME = 'ITAB'.
    X_FIELDCAT-COL_POS    = L_POS.
    X_FIELDCAT-OUTPUTLEN = '10'.
    APPEND X_FIELDCAT TO IT_FIELDCAT.
    CLEAR X_FIELDCAT.
    **events
    REFRESH:IT_EVENTS.
    CLEAR:X_EVENTS,IT_EVENTS.
    X_EVENTS-NAME = SLIS_EV_END_OF_LIST.
    X_EVENTS-FORM = 'MODIFY_LIST'.
    APPEND X_EVENTS TO IT_EVENTS.
    CLEAR X_EVENTS.
    END-OF-SELECTION.
    data lv_repid type sy-repid.
    lv_repid = sy-repid.
      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
        EXPORTING
          I_CALLBACK_PROGRAM = lv_REPID
          IT_FIELDCAT        = IT_FIELDCAT
          IT_EVENTS          = IT_EVENTS
        TABLES
          T_OUTTAB           = ITAB
        EXCEPTIONS
          PROGRAM_ERROR      = 1
          OTHERS             = 2.
      IF SY-SUBRC <> 0.
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    *&      Form FILL_TABLE
          text
    FORM FILL_TABLE.
      ITAB-NAME = 'AAA'.
      ITAB-ZTERM = 'A'.
      APPEND ITAB.
      clear itab.
      ITAB-NAME = 'ABC'.
      ITAB-ZTERM = 'B'.
      APPEND ITAB.
      clear itab.
      ITAB-NAME = 'TEST'.
      ITAB-ZTERM = 'C'.
      APPEND ITAB.
      clear itab.
      ITAB-NAME = 'BBB'.
      ITAB-ZTERM = 'D'.
      APPEND ITAB.
      clear itab.
      ITAB-NAME = '123'.
      ITAB-ZTERM = 'E'.
      APPEND ITAB.
      clear itab.
      ITAB-NAME = 'GEN'.
      ITAB-ZTERM = 'A'.
      APPEND ITAB.
      clear itab.
      ITAB-NAME = 'ALV'.
      ITAB-ZTERM = 'F'.
      APPEND ITAB.
      clear itab.
      ITAB-NAME = 'ALVTEST'.
      ITAB-ZTERM = 'A'.
      APPEND ITAB.
      clear itab.
    ENDFORM.                    "FILL_TABLE
    *&      Form  MODIFY_LIST
          text
    FORM MODIFY_LIST.
    data: l_lines type i.
    describe table itab lines l_lines.
      L_LINES  = L_LINES + 3.
    "because we have 3 lines extra occupied by lables.
    "if we have header,i mean top of page add the no.of lines
    "how many ever top of page have + 3 for labels.
      DO L_LINES TIMES.
        read table it_chg with key INDEX = sy-index.
        if sy-subrc = 0.
    **This code is for reading the out put line
    **and modify accordinlg to our requiremnet.
    **don't chnage this.
          READ LINE SY-INDEX INDEX SY-LSIND.
          IF SY-SUBRC = 0.
            MODIFY LINE SY-INDEX INDEX SY-LSIND
                       FIELD FORMAT ITAB-NAME INPUT.
          ENDIF.
        ENDIF.
      ENDDO.
    ENDFORM.                    "MODIFY_LIST

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

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

  • How to focus a cell on ALV grid display

    hi,
    I need to set the focus to the first cell on the first row in the ALV grid.I am using object oriented ALV grid control.Can anyone help me out in this regard.
    Regards,
    Anil.

    Re: simple Grid display
    Have a look at below links. It contains sample code for alv grid.
    http://www.erpgenie.com/abap/controls/alvgrid.htm#Complete%20code%20for%20the%20ALV%20grid%20example
    http://www.sap-img.com/abap/sample-programs-on-alv-grid.htm
    http://sap.niraj.tripod.com/id64.html
    Also have a look at below for OO alv grid:
    http://help.sap.com/saphelp_erp2004/helpdata/en/0a/b5533cd30911d2b467006094192fe3/frameset.htm
    -->
    ABAP List Viewer
    The common features of report are column alignment, sorting, filtering, subtotals, totals etc. To implement these, a lot of coding and logic is to be put. To avoid that we can use a concept called ABAP List Viewer (ALV).
    This helps us to implement all the features mentioned very effectively.
    Using ALV, We can have three types of reports:
    1. Simple Report
    2. Block Report
    3. Hierarchical Sequential Report
    There are some function modules which will enable to produce the above reports without much effort.
    All the definitions of internal tables, structures and constants are declared in a type-pool called SLIS.
    1. SIMPLE REPORT.
    The important function modules are
    a. Reuse_alv_list_display
    b. Reuse_alv_fieldcatalog_merge
    c. Reuse_alv_events_get
    d. Reuse_alv_commentary_write
    e. Reuse_alv_grid_display
    A. REUSE_ALV_LIST_DISPLAY : This is the function module which prints the data.
    The important parameters are :
    I. Export :
    i. I_callback_program : report id
    ii. I_callback_pf_status_set : routine where a user can set his own pf status or change the functionality of the existing pf status iii. I_callback_user_command : routine where the function codes are handled iv. I_structure name : name of the dictionary table v. Is_layout : structure to set the layout of the report vi. It_fieldcat : internal table with the list of all fields and their attributes which are to be printed (this table can be populated automatically by the function module REUSE_ALV_FIELDCATALOG_MERGE vii. It_events : internal table with a list of all possible events of ALV and their corresponding form names.
    II. Tables :
    i. t_outtab : internal table with the data to be output
    B. REUSE_ALV_FIELDCATALOG_MERGE : This function module is used to populate a fieldcatalog which is essential to display the data in ALV. If the output data is from a single dictionary table and all the columns are selected, then we need not exclusively create the field catalog. Its enough to mention the table name as a parameter(I_structure name) in the REUSE_ALV_LIST_DISPLAY. But in other cases we need to create it.
    The Important Parameters are :
    I. Export :
    i. I_program_name : report id
    ii. I_internal_tabname : the internal output table iii. I_inclname : include or the report name where all the dynamic forms are handled.
    II Changing
    ct_fieldcat : an internal table with the type SLIS_T_FIELDCAT_ALV which is declared in the type pool SLIS.
    C. REUSE_ALV_EVENTS_GET : Returns table of possible events for a list type
    Parameters :
    I. Import :
    Et_Events : The event table is returned with all possible CALLBACK events for the specified list type (column 'NAME'). For events to be processed by Callback, their 'FORM' field must be filled. If the field is initialized, the event is ignored. The entry can be read from the event table, the field 'FORM' filled and the entry modified using constants from the type pool SALV.
    II. Export :
    I_List_type :
    0 = simple list REUSE_ALV_LIST_DISPLAY
    1 = hierarchcal-sequential list REUSE_ALV_HIERSEQ_LIST_DISPLAY
    2 = simple block list REUSE_ALV_BLOCK_LIST_APPEND
    3 = hierarchical-sequential block list
    REUSE_ALV_BLOCK_LIST_HS_APPEND
    D. REUSE_ALV_COMMENTARY_WRITE : This is used in the Top-of-page event to print the headings and other comments for the list.
    Parameters :
    I. it_list_commentary : internal table with the headings of the type slis_t_listheader.
    This internal table has three fields :
    Typ : ‘H’ – header, ‘S’ – selection , ‘A’ - action Key : only when typ is ‘S’.
    Info : the text to be printed
    E. REUSE_ALV_GRID_DISPLAY : A new function in 4.6 version, to display the results in grid rather than as a preview.
    Parameters : same as reuse_alv_list_display
    This is an example for simple list.
    2. BLOCK REPORT
    This is used to have multiple lists continuously.
    The important functions used in this report are:
    A. REUSE_ALV_BLOCK_LIST_INIT
    B. REUSE_ALV_BLOCK_LIST_APPEND
    C. REUSE_ALV_BLOCK_LIST_HS_APPEND
    D. REUSE_ALV_BLOCK_LIST_DISPLAY
    A. REUSE_ALV_BLOCK_LIST_INIT
    Parameters:
    I. I_CALLBACK_PROGRAM
    II. I_CALLBACK_PF_STATUS_SET
    III. I_CALLBACK_USER_COMMAND
    This function module is used to set the default gui status etc.
    B. REUSE_ALV_BLOCK_LIST_APPEND
    Parameters :
    Export :
    I. is_layout : layout settings for block II. it_fieldcat : field catalog III. i_tabname : internal table name with output data IV. it_events : internal table with all possible events
    Tables :
    i. t_outtab : internal table with output data.
    This function module adds the data to the block.
    Repeat this function for all the different blocks to be displayed one after the other.
    C. REUSE_ALV_BLOCK_LIST_HS_APPEND
    This function module is used for hierarchical sequential blocks.
    D. REUSE_ALV_BLOCK_LIST_DISPLAY
    Parameters : All the parameters are optional.
    This function module display the list with data appended by the above function.
    Here the functions REUSE_ALV_FIELDCATALOG_MERGE, REUSE_ALV_EVENTS_GET, REUSE_ALV_COMMENTARY_WRITE can be used.
    3. Hierarchical reports :
    Hierarchical sequential list output.
    The function module is
    A. REUSE_ALV_HIERSEQ_LIST_DISPLAY
    Parameters:
    I. Export:
    i. I_CALLBACK_PROGRAM
    ii. I_CALLBACK_PF_STATUS_SET
    iii. I_CALLBACK_USER_COMMAND
    iv. IS_LAYOUT
    v. IT_FIELDCAT
    vi. IT_EVENTS
    vii. i_tabname_header : Name of the internal table in the program containing the output data of the highest hierarchy level.
    viii. i_tabname_item : Name of the internal table in the program containing the output data of the lowest hierarchy level.
    ix. is_keyinfo : This structure contains the header and item table field names which link the two tables (shared key).
    II. Tables
    i. t_outtab_header : Header table with data to be output ii. t_outtab_item : Name of the internal table in the program containing the output data of the lowest hierarchy level.
    slis_t_fieldcat_alv : This internal table contains the field attributes. This internal table can be populated automatically by using ‘REUSE_ALV_FIELDCATALOG_MERGE’.
    Important Attributes :
    A. col_pos : position of the column
    B. fieldname : internal fieldname
    C. tabname : internal table name
    D. ref_fieldname : fieldname (dictionary) E. ref_tabname : table (dictionary) F. key(1) : column with key-color G. icon(1) : icon H. symbol(1) : symbol I. checkbox(1) : checkbox J. just(1) : (R)ight (L)eft (C)ent.
    K. do_sum(1) : sum up
    L. no_out(1) : (O)blig.(X)no out
    M. outputlen : output length
    N. seltext_l : long key word
    O. seltext_m : middle key word
    P. seltext_s : short key word
    Q. reptext_ddic : heading (ddic)
    R. ddictxt(1) : (S)hort (M)iddle (L)ong
    S. datatype : datatype
    T. hotspot(1) : hotspot
    Simple ALV report
    http://www.sapgenie.com/abap/controls/alvgrid.htm
    http://wiki.ittoolbox.com/index.php/Code:Ultimate_ALV_table_toolbox
    ALV
    1. Please give me general info on ALV.
    http://www.sapfans.com/forums/viewtopic.php?t=58286
    http://www.sapfans.com/forums/viewtopic.php?t=76490
    http://www.sapfans.com/forums/viewtopic.php?t=20591
    http://www.sapfans.com/forums/viewtopic.php?t=66305 - this one discusses which way should you use - ABAP Objects calls or simple function modules.
    2. How do I program double click in ALV?
    http://www.sapfans.com/forums/viewtopic.php?t=11601
    http://www.sapfans.com/forums/viewtopic.php?t=23010
    3. How do I add subtotals (I have problem to add them)...
    http://www.sapfans.com/forums/viewtopic.php?t=20386
    http://www.sapfans.com/forums/viewtopic.php?t=85191
    http://www.sapfans.com/forums/viewtopic.php?t=88401
    http://www.sapfans.com/forums/viewtopic.php?t=17335
    4. How to add list heading like top-of-page in ABAP lists?
    http://www.sapfans.com/forums/viewtopic.php?t=58775
    http://www.sapfans.com/forums/viewtopic.php?t=60550
    http://www.sapfans.com/forums/viewtopic.php?t=16629
    5. How to print page number / total number of pages X/XX in ALV?
    http://www.sapfans.com/forums/viewtopic.php?t=29597 (no direct solution)
    6. ALV printing problems. The favourite is: The first page shows the number of records selected but I don't need this.
    http://www.sapfans.com/forums/viewtopic.php?t=64320
    http://www.sapfans.com/forums/viewtopic.php?t=44477
    7. How can I set the cell color in ALV?
    http://www.sapfans.com/forums/viewtopic.php?t=52107
    8. How do I print a logo/graphics in ALV?
    http://www.sapfans.com/forums/viewtopic.php?t=81149
    http://www.sapfans.com/forums/viewtopic.php?t=35498
    http://www.sapfans.com/forums/viewtopic.php?t=5013
    9. How do I create and use input-enabled fields in ALV?
    http://www.sapfans.com/forums/viewtopic.php?t=84933
    http://www.sapfans.com/forums/viewtopic.php?t=69878
    10. How can I use ALV for reports that are going to be run in background?
    http://www.sapfans.com/forums/viewtopic.php?t=83243
    http://www.sapfans.com/forums/viewtopic.php?t=19224
    11. How can I display an icon in ALV? (Common requirement is traffic light icon).
    http://www.sapfans.com/forums/viewtopic.php?t=79424
    http://www.sapfans.com/forums/viewtopic.php?t=24512
    12. How can I display a checkbox in ALV?
    http://www.sapfans.com/forums/viewtopic.php?t=88376
    http://www.sapfans.com/forums/viewtopic.php?t=40968
    http://www.sapfans.com/forums/viewtopic.php?t=6919
    Go thru these programs they may help u to try on some hands on
    ALV Demo program
    BCALV_DEMO_HTML
    BCALV_FULLSCREEN_DEMO ALV Demo: Fullscreen Mode BCALV_FULLSCREEN_DEMO_CLASSIC ALV demo: Fullscreen mode BCALV_GRID_DEMO Simple ALV Control Call Demo Program BCALV_TREE_DEMO Demo for ALV tree control BCALV_TREE_SIMPLE_DEMO BC_ALV_DEMO_HTML_D0100
    Reward If useful

  • HOW TO GET VALUE OF A PARTICULAR CELL IN ALV GRID

    I HAVE 2 ALV GRID. IWANT WHEN I DOUBLE CLICK ON ANY PARTICULAR CELL OF FIRST GRID I WILL GET THE VALUE DISPLAYED ON THAT PARTICULAR CELL.
    THANKS IN ADVANCE

    Hi,
    If you are using a class alv, you only need to create a local class to control event and, before setting the screen to present the alv, you need to assign the class as a handler, like this:
        CREATE OBJECT event_handler.
        SET HANDLER event_handler->double_click FOR alv_grid.
    This event handler was defined before like below and a object was created for it:
    CLASS cl_event_handler DEFINITION.
      PUBLIC SECTION.
        METHODS double_click FOR EVENT double_click OF cl_gui_alv_grid
          IMPORTING e_row e_column.
    ENDCLASS.                    "cl_event_handler DEFINITION
    Then you need to implement this class, creating the method double click and do a READ TABLE to the itab you presented in the alv to recover the data, like this:
        READ TABLE itab INTO wk_itab
          INDEX e_row-index.
    The e_row structure was sent to the method by the handler, setting it with the line index that you double clicked in the alv. After that, you can manipulate the data that you selected in your internal table to generate the data to the other ALV.
    Best Regards,
    -h

  • Hide cell in alv-grid on certain rows

    Hi all,
    I wonder if it is possible to hide certain cells in an ALV-grid ?
    e.g the data in cell1 row1 is visible, but the data in cell1 on row2 has to be invisible...

    Hi
    I don't believe it can do it for only certain cells and I don't believe it's possible to hide anything in alv-grid.
    Your program decides what  can be displayed so if something data doesn't has to be shown it shouldn't be loaded in output table.
    Max

  • Modifying single cell in ALV Grid via OO

    Hi All,
    Got a problem I hope someone can assist me with.  I have a custom program generating an editable ALV grid.  The users want to update a single cell in a row with value from a custom drop down.  I've got the dropdown working, but I can't work out how to get the value back into the field.  My attempts result in a 'GETWA_NOT_ASSIGNED' short dump.
    I'm using the CL_GUI_ALV_GRID->get_selected_cells_id method to get the reference for the field to be modified, but I don't know where to go from here. 
    Any thoughts would be greatly appreciated.  Btw, my knowledge of OO is passable, but not great, so any explanations of what the code is doing in a proposed solution would be greatly appreciated.
    points will be rewarded.
    Cheers,
    Stephen

    Hello Stephen
    Since your dropdown list restrict the already allowed values there should be no special need to validate the selected values.
    Simply "grab" the data from the editable ALV into your internal itab in the ABAP report.
    I have copied sample report BCALV_EDIT_07 into ZUS_SDN_BCALV_EDIT_07 and modified the report to show how to retrieve the dropdown values (which is simple). Please note that I added the GUI-function 'SAVE' to the GUI-status MAIN100.
    *       MODULE PAI INPUT                                              *
    MODULE pai INPUT.
      save_ok = ok_code.
      CLEAR ok_code.
      "$TMP
      g_grid->check_changed_data( ). " retrieve changes from editable grid
      CASE save_ok.
        WHEN 'EXIT'.
          PERFORM exit_program.
        "$TMP
        WHEN 'SAVE'.
          PERFORM save_data.
        WHEN OTHERS.
    *     do nothing
      ENDCASE.
    ENDMODULE.                    "pai INPUT
    *&      Form  SAVE_DATA
    *       text
    FORM save_data.  "$TMP
    * define local data
      data: ls_fcat   type lvc_s_fcat,
            lt_fcat   type lvc_t_fcat.
      lt_fcat = gt_fieldcat.
      ls_fcat-edit = ' '.
      modify lt_fcat from ls_fcat
          TRANSPORTING edit
        where ( edit = 'X' ).  " display ALV should be not editable
      " Simulate saving of data
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
        EXPORTING
    *     I_INTERFACE_CHECK                 = ' '
    *     I_BYPASSING_BUFFER                =
    *     I_BUFFER_ACTIVE                   =
    *     I_CALLBACK_PROGRAM                = ' '
    *     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                  =
    *     I_BACKGROUND_ID                   = ' '
          I_GRID_TITLE                      = 'Display modified list data'
    *     I_GRID_SETTINGS                   =
    *     IS_LAYOUT_LVC                     =
          IT_FIELDCAT_LVC                   = lt_fcat
    *     IT_EXCLUDING                      =
    *     IT_SPECIAL_GROUPS_LVC             =
    *     IT_SORT_LVC                       =
    *     IT_FILTER_LVC                     =
    *     IT_HYPERLINK                      =
    *     IS_SEL_HIDE                       =
    *     I_DEFAULT                         = 'X'
    *     I_SAVE                            = ' '
    *     IS_VARIANT                        =
    *     IT_EVENTS                         =
    *     IT_EVENT_EXIT                     =
    *     IS_PRINT_LVC                      =
    *     IS_REPREP_ID_LVC                  =
          I_SCREEN_START_COLUMN             = 5
          I_SCREEN_START_LINE               = 5
          I_SCREEN_END_COLUMN               = 120
          I_SCREEN_END_LINE                 = 20
    *     I_HTML_HEIGHT_TOP                 =
    *     I_HTML_HEIGHT_END                 =
    *     IT_EXCEPT_QINFO_LVC               =
    *     IR_SALV_FULLSCREEN_ADAPTER        =
        TABLES
          t_outtab                          = gt_outtab
        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.                    "SAVE_DATA
    And here is the entire coding: In order to find the modified parts of the coding simply search for $TMP.
    PROGRAM zus_sdn_bcalv_edit_07.
    * Purpose:
    * ~~~~~~~~
    * This example shows how to define dropdown listboxes for
    * particular cells of your output table.
    * To check program behavior
    * ~~~~~~~~~~~~~~~~~~~~~~~~~
    * Conceive that customers are only allowed to smoke in the
    * first class. For this reason, if the customer is a smoker
    * only the first class (F) can be chosen in column 'CLASS',
    * otherwise all classes.
    * Essential steps (search for '§')
    * ~~~~~~~~~~~~~~~
    * 1.Define an extra field in your output table
    * 2.Define a dropdown table and pass it to ALV.
    * 3.Set your dropdown field editable and assign the fieldname of the
    *   corresponding additional field to DRDN_FIELD of the fieldcatalog.
    * 4.Set the handle of your additional field of your output
    *   table according to the listbox that shall be displayed.
    DATA: ok_code LIKE sy-ucomm,
          save_ok LIKE sy-ucomm,
          g_container TYPE scrfname VALUE 'BCALV_GRID_DEMO_0100_CONT1',
          g_grid  TYPE REF TO cl_gui_alv_grid,
          g_custom_container TYPE REF TO cl_gui_custom_container,
          gt_fieldcat TYPE lvc_t_fcat,
          gs_layout TYPE lvc_s_layo,
          g_max TYPE i VALUE 100.
    *§1.Define an extra field in your output table
    *   for each column where you want to use drop down listboxes.
    *   (One additional field refers to cells of one column).
    DATA: BEGIN OF gt_outtab OCCURS 0.
            INCLUDE STRUCTURE sbook.
    DATA: drop_down_handle TYPE int4.
    DATA: END OF gt_outtab.
    *       MAIN                                                          *
    END-OF-SELECTION.
      CALL SCREEN 100.
    *       MODULE PBO OUTPUT                                             *
    MODULE pbo OUTPUT.
      SET PF-STATUS 'MAIN100'.
      SET TITLEBAR 'MAIN100'.
      IF g_custom_container IS INITIAL.
        PERFORM create_and_init_alv CHANGING gt_outtab[]
                                             gt_fieldcat.
      ENDIF.
    ENDMODULE.                    "pbo OUTPUT
    *       MODULE PAI INPUT                                              *
    MODULE pai INPUT.
      save_ok = ok_code.
      CLEAR ok_code.
      "$TMP
      g_grid->check_changed_data( ). " retrieve changes from editable grid
      CASE save_ok.
        WHEN 'EXIT'.
          PERFORM exit_program.
        "$TMP
        WHEN 'SAVE'.
          PERFORM save_data.
        WHEN OTHERS.
    *     do nothing
      ENDCASE.
    ENDMODULE.                    "pai INPUT
    *       FORM EXIT_PROGRAM                                             *
    FORM exit_program.
      LEAVE PROGRAM.
    ENDFORM.                    "exit_program
    *&      Form  SAVE_DATA
    *       text
    FORM save_data.  "$TMP
    * define local data
      data: ls_fcat   type lvc_s_fcat,
            lt_fcat   type lvc_t_fcat.
      lt_fcat = gt_fieldcat.
      ls_fcat-edit = ' '.
      modify lt_fcat from ls_fcat
          TRANSPORTING edit
        where ( edit = 'X' ).  " display ALV should be not editable
      " Simulate saving of data
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
        EXPORTING
    *     I_INTERFACE_CHECK                 = ' '
    *     I_BYPASSING_BUFFER                =
    *     I_BUFFER_ACTIVE                   =
    *     I_CALLBACK_PROGRAM                = ' '
    *     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                  =
    *     I_BACKGROUND_ID                   = ' '
          I_GRID_TITLE                      = 'Display modified list data'
    *     I_GRID_SETTINGS                   =
    *     IS_LAYOUT_LVC                     =
          IT_FIELDCAT_LVC                   = lt_fcat
    *     IT_EXCLUDING                      =
    *     IT_SPECIAL_GROUPS_LVC             =
    *     IT_SORT_LVC                       =
    *     IT_FILTER_LVC                     =
    *     IT_HYPERLINK                      =
    *     IS_SEL_HIDE                       =
    *     I_DEFAULT                         = 'X'
    *     I_SAVE                            = ' '
    *     IS_VARIANT                        =
    *     IT_EVENTS                         =
    *     IT_EVENT_EXIT                     =
    *     IS_PRINT_LVC                      =
    *     IS_REPREP_ID_LVC                  =
          I_SCREEN_START_COLUMN             = 5
          I_SCREEN_START_LINE               = 5
          I_SCREEN_END_COLUMN               = 120
          I_SCREEN_END_LINE                 = 20
    *     I_HTML_HEIGHT_TOP                 =
    *     I_HTML_HEIGHT_END                 =
    *     IT_EXCEPT_QINFO_LVC               =
    *     IR_SALV_FULLSCREEN_ADAPTER        =
        TABLES
          t_outtab                          = gt_outtab
        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.                    "SAVE_DATA
    *&      Form  BUILD_FIELDCAT
    *       text
    *      <--P_GT_FIELDCAT  text
    FORM build_fieldcat CHANGING pt_fieldcat TYPE lvc_t_fcat.
      DATA ls_fcat TYPE lvc_s_fcat.
      CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
        EXPORTING
          i_structure_name = 'SBOOK'
        CHANGING
          ct_fieldcat      = pt_fieldcat.
      LOOP AT pt_fieldcat INTO ls_fcat.
    * Exchange smoker field with invoice field - just to
    * make the dependance between SMOKER and CLASS more transparent
    * (Smoking is only allowed in the first class).
        IF ls_fcat-fieldname EQ 'SMOKER'.
          ls_fcat-col_pos = 11.
          ls_fcat-outputlen = 10.
          MODIFY pt_fieldcat FROM ls_fcat.
        ELSEIF ls_fcat-fieldname EQ 'INVOICE'.
          ls_fcat-col_pos = 7.
          MODIFY pt_fieldcat FROM ls_fcat.
        ELSEIF    ls_fcat-fieldname EQ 'CLASS'.
    *§3.Set your dropdown field editable and assign the fieldname of the
    *   corresponding additional field to DRDN_FIELD of the fieldcatalog.
          ls_fcat-edit = 'X'.
          ls_fcat-drdn_field = 'DROP_DOWN_HANDLE'.
          ls_fcat-outputlen = 5.
    * Field 'checktable' is set to avoid shortdumps that are caused
    * by inconsistend data in check tables. You may comment this out
    * when the test data of the flight model is consistent in your system.
          ls_fcat-checktable = '!'.        "do not check foreign keys
          MODIFY pt_fieldcat FROM ls_fcat.
        ENDIF.
      ENDLOOP.
    ENDFORM.                    "build_fieldcat
    *&      Form  CREATE_AND_INIT_ALV
    *       text
    *      <--P_GT_OUTTAB  text
    *      <--P_GT_FIELDCAT  text
    *      <--P_GS_LAYOUT  text
    FORM create_and_init_alv CHANGING pt_outtab TYPE STANDARD TABLE
                                      pt_fieldcat TYPE lvc_t_fcat.
      DATA: lt_exclude TYPE ui_functions.
      CREATE OBJECT g_custom_container
        EXPORTING
          container_name = g_container.
      CREATE OBJECT g_grid
        EXPORTING
          i_parent = g_custom_container.
      PERFORM build_fieldcat CHANGING pt_fieldcat.
    * Optionally restrict generic functions to 'change only'.
    *   (The user shall not be able to add new lines).
      PERFORM exclude_tb_functions CHANGING lt_exclude.
      PERFORM set_drdn_table.
      PERFORM build_data CHANGING pt_outtab.
      CALL METHOD g_grid->set_table_for_first_display
        EXPORTING
          it_toolbar_excluding = lt_exclude
        CHANGING
          it_fieldcatalog      = pt_fieldcat
          it_outtab            = pt_outtab[].
    * Set editable cells to ready for input initially
      CALL METHOD g_grid->set_ready_for_input
        EXPORTING
          i_ready_for_input = 1.
    ENDFORM.                               "CREATE_AND_INIT_ALV
    *&      Form  EXCLUDE_TB_FUNCTIONS
    *       text
    *      <--P_LT_EXCLUDE  text
    FORM exclude_tb_functions CHANGING pt_exclude TYPE ui_functions.
    * Only allow to change data not to create new entries (exclude
    * generic functions).
      DATA ls_exclude TYPE ui_func.
      ls_exclude = cl_gui_alv_grid=>mc_fc_loc_copy_row.
      APPEND ls_exclude TO pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_loc_delete_row.
      APPEND ls_exclude TO pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_loc_append_row.
      APPEND ls_exclude TO pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_loc_insert_row.
      APPEND ls_exclude TO pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_loc_move_row.
      APPEND ls_exclude TO pt_exclude.
    ENDFORM.                               " EXCLUDE_TB_FUNCTIONS
    *&      Form  set_drdn_table
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM set_drdn_table.
    *§2.Define a dropdown table and pass it to ALV.
    *   One listbox is referenced by a handle, e.g., '1'.
    *   For each entry that shall appear in this listbox
    *   you have to append a line to the dropdown table
    *   with handle '1'.
    *   This handle can be assigned to several columns
    *   of the output table using the field catalog.
      DATA: lt_dropdown TYPE lvc_t_drop,
            ls_dropdown TYPE lvc_s_drop.
      ls_dropdown-handle = '1'.
      ls_dropdown-value = 'F'.
      APPEND ls_dropdown TO lt_dropdown.
      ls_dropdown-handle = '2'.
      ls_dropdown-value = 'F'.
      APPEND ls_dropdown TO lt_dropdown.
      ls_dropdown-handle = '2'.
      ls_dropdown-value = 'C'.
      APPEND ls_dropdown TO lt_dropdown.
      ls_dropdown-handle = '2'.
      ls_dropdown-value = 'Y'.
      APPEND ls_dropdown TO lt_dropdown.
      CALL METHOD g_grid->set_drop_down_table
        EXPORTING
          it_drop_down = lt_dropdown.
    ENDFORM.                               " set_drdn_table
    *&      Form  build_data
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM build_data CHANGING pt_outtab TYPE STANDARD TABLE.
      DATA: lt_sbook TYPE TABLE OF sbook,
            ls_sbook TYPE sbook,
            l_index TYPE i,
            ls_outtab LIKE LINE OF gt_outtab.
      SELECT * FROM sbook INTO TABLE lt_sbook UP TO g_max ROWS."#EC CI_NOWHERE
      IF sy-subrc NE 0.
        PERFORM generate_entries CHANGING lt_sbook.
      ENDIF.
    *§4.Set the handle of your additional field of your output
    *   table according to the listbox that shall be displayed.
      LOOP AT lt_sbook INTO ls_sbook.
        l_index = sy-tabix.
        MOVE-CORRESPONDING ls_sbook TO ls_outtab.
        CLEAR ls_outtab-class.
    * Alternate between smoker and non smoker to make
    * it more obvious what this example is about
        l_index = l_index MOD 2.
        IF l_index EQ 1.
          ls_outtab-smoker = 'X'.
        ELSE.
          ls_outtab-smoker = ' '.
        ENDIF.
        IF ls_outtab-smoker EQ 'X'.
          ls_outtab-drop_down_handle = '1'.
        ELSE.
          ls_outtab-drop_down_handle = '2'.
        ENDIF.
        APPEND ls_outtab TO pt_outtab.
      ENDLOOP.
    ENDFORM.                               " build_data
    *&      Form  generate_entries
    *       text
    *      <--P_LT_SLFIGHT  text
    FORM generate_entries CHANGING pt_sbook TYPE STANDARD TABLE.
      DATA: ls_sbook TYPE sbook,
            l_month(2) TYPE c,
            l_day(2) TYPE c,
            l_date(8) TYPE c,
      l_prebookid TYPE i.
      ls_sbook-carrid = 'LH'.
      ls_sbook-connid = '0400'.
      ls_sbook-forcurkey = 'DEM'.
      ls_sbook-loccurkey = 'USD'.
      ls_sbook-custtype = 'B'.
      DO 110 TIMES.
        l_prebookid = sy-index.
        ls_sbook-forcuram = sy-index * 10.
        ls_sbook-loccuram = ls_sbook-loccuram * 2.
        ls_sbook-customid = sy-index.
        ls_sbook-counter = 18.
        ls_sbook-agencynum = 11.
        l_month = sy-index / 10 + 1.
        DO 2 TIMES.
          l_day = 3 + l_month + sy-index * 2.
          l_date+0(4) = '2000'.
          l_date+4(2) = l_month.
          l_date+6(2) = l_day.
          ls_sbook-fldate = l_date.
          SUBTRACT 3 FROM l_day.
          ls_sbook-order_date+0(6) = l_date+0(6).
          ls_sbook-order_date+6(2) = l_day.
          ls_sbook-bookid = l_prebookid * 2 + sy-index.
          IF sy-index EQ 1.
            ls_sbook-smoker = 'X'.
          ELSE.
            ls_sbook-smoker = space.
          ENDIF.
          ls_sbook-luggweight = l_prebookid * 10.
          IF ls_sbook-luggweight GE 1000.
            ls_sbook-wunit = 'G'.
            ls_sbook-class = 'C'.
          ELSE.
            ls_sbook-wunit = 'KG'.
            ls_sbook-class = 'Y'.
          ENDIF.
          IF ls_sbook-bookid > 40 AND ls_sbook-wunit EQ 'KG'.
            ls_sbook-invoice = 'X'.
          ENDIF.
          IF ls_sbook-bookid EQ 2.
            ls_sbook-cancelled = 'X'.
            ls_sbook-class = 'F'.
          ENDIF.
          APPEND ls_sbook TO pt_sbook.
        ENDDO.
      ENDDO.
    ENDFORM.                               " generate_entries
    Regards
      Uwe

  • Display a cell in ALV report as Pushbutton

    Hi,
    I am having an ALV report. I want to display one cell of the ALV report as a Pushbutton. How is it possible ?
    Thanks and regards.

    Hi WTM,
      To display a cell as pushbutton in container display of a simple, two-dimensional table, use the cell type BUTTON.
    cell type -->
    In the content of your ALV output, you are able to display various elements in place of text. Some of these elements can be treated as a click area for the user. You are able to display the following elements:
    ·        Checkbox
    In list-type ALV ouputs, the checkbox is disabled. With the content of the column, you are only to display whether the checkbox is set or not.
    In the tree structure, however, you are able to handle users actions on this element using an event.
    ·        Pushbutton
    You are able to handle user actions on this element with an event.
    ·        Hyperlink
    You specify the Internet addresses (URLs). Users can then call up the corresponding page in the Internet browser by clicking on one of these Internet addresses.
    ·        Click Area
    You are able to handle user actions on this element with an event.
    Hope this helps u,
    Regards,
    Nagarajan.

  • Value of the previous cell when I double click a cell in ALV Grid.

    Hi !
    Suppose I have an internal table GT_ITAB and I use ALV Grid to print it on the screen. The colums are as below:
    Invoice No       Invoice Data        Customer No     Amount
      90001231        15.01.2009            100024             5
    Customer No Fields is Hot Spot and when I click it uses Call Transaction 'FD10N' and Skip First Screen.
    But the Problem is that :
    Callback subroutine that is defined for  "i_callback_user_command" receives the input and
    p_selfield type slis_selfield structure has the value by means of  p_selfield-value.
    Problem : How can I get also the value of Invoice Data Cell. I need "15.01.2009" to set the Year field of FD10n.
    I know that it is possible because SAP has examples of it.
    Please advice.
    Erkan VAROL.

    Hi ,
      In teh structure slis_selfield  there is a field tabindex , you can get the index of the record selected from this field and use this to read the internal table being displayed in the alv to get the entrired row.
    Regards
    Arun

  • 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

  • Displaying traffic lights in alv grid report?

    Hi everyone,
    I have an alv grid report.I m using the FM reuse_alv_grod_display to display my alv report.I am passing the fieldcatalogue automatically.I m getting the output perfectly.Now i have to add traffic lights to that alv report.
    Since i m passing the fieldcatalogue automatically i m confused to display the traffic lights?
    any suggestions please?
    Thank you.

    hi dp,
    look at the program i made... se the bold part you will be able to impelment lights easily,
    DECLARING TYPES POOL *
    All the definitions of internal tables, structures and constants
    are declared in a type-pool called SLIS.
    type-pools: slis.
    TABLES *
    tables: vbak,vbap,kna1.
    TYPES *
    *&--defining types for TABLE VBAK
    types: begin of t_vbak,
    vbeln type vbeln_va, "sales document
    kunnr type kunag,
    erdat type erdat,
    auart type auart,
    netwr type netwr_ak,
    waerk type waerk,
    vkorg type vkorg,
    vtweg type vtweg,
    spart type spart,
    name1 type name1_gp,
    stras type stras_gp,
    ort01 type ort01_gp,
    pstlz type pstlz,
    regio type regio,
    land1 type land1_gp,
    telf1 type telf1,
    end of t_vbak.
    *&--Defining types for TABLE VBAP
    types: begin of t_vbap,
    vbeln type vbeln_va,
    posnr type posnr_va,
    matnr type matnr,
    maktx type maktx,
    end of t_vbap.
    *&--MERGED FINAL SALES TABLE
    types: begin of t_sales_final,
    vbeln type vbeln_va,
    kunnr type kunag,
    posnr type posnr_va,
    erdat type erdat, "date of creation
    auart type auart,
    netwr type netwr_ak,
    waerk type waerk,
    vkorg type vkorg,
    vtweg type vtweg,
    spart type spart,
    name1 type name1_gp,
    v_lights type c,
    stras type stras_gp,
    ort01 type ort01_gp,
    pstlz type pstlz,
    regio type regio,
    land1 type land1_gp,
    telf1 type telf1,
    matnr type matnr,
    maktx type maktx,
    end of t_sales_final.
    defining wrokarea and IT.
    WORK AREA DECLARATION *
    *&---work area for Internal Tables
    data: wa_vbak type t_vbak.
    data: wa_vbap type t_vbap.
    data: wa_sales_final type t_sales_final.
    *&--work area for layout
    data: wa_layout type slis_layout_alv.
    INTERNAL TABLES DECLARATION *
    *&---Internal tables without Header Line.
    data : i_vbak type standard table of t_vbak,
    i_vbap type standard table of t_vbap,
    i_sales_final type standard table of t_sales_final.
    *&---Internal table for field catalog
    data : i_fieldcat type slis_t_fieldcat_alv,
    *&---Internal table for the sorting sequence.
    i_sortinfo type slis_t_sortinfo_alv,
    *&---Internal table for the event catalog.
    i_eventcat type slis_t_event,
    *&---Internal table for the top of page event
    i_listheader type slis_t_listheader.
    VARIABLE DECLARATION *
    data : v_progname like sy-repid, "Program name(system defined)
    v_gridtitle type lvc_title. "Grid Title
    INITIALIZATION EVENT *
    initialization.
    v_progname = sy-repid.
    refresh:i_vbak,
    i_vbap,
    i_sales_final,
    i_fieldcat,
    i_sortinfo,
    i_eventcat,
    i_listheader.
    clear: wa_vbak,
    wa_vbap,
    wa_sales_final,
    wa_layout.
    SELECTION SCREEN *
    SCREEN FOR ENTERING INFORMATION
    selection-screen begin of block b1 with frame title text-001.
    select-options: r_vbeln for wa_vbak-vbeln obligatory.
    select-options: r_erdat for wa_vbak-erdat obligatory.
    selection-screen end of block b1 .
    AT SELECTION SCREEN *
    at selection-screen.
    perform zf_validate_sales_doc_no.
    perform zf_validate_date.
    START OF SELECTION EVENT
    start-of-selection.
    perform zf_populate_header.
    perform zf_populate_detail.
    perform zf_append_sales_final.
    END OF SELECTION EVENT
    end-of-selection.
    *If Internal Table Is Populated Then Only Display Alv Report.
    if i_sales_final is not initial.
    Prepare fieldcatalog .
    perform zf_build_fieldcat using i_fieldcat.
    MODIFY the records IN the internal TABLE for the traffic lights.
    perform zf_modify_final.
    build event catalogue
    perform zf_eventcat using i_eventcat.
    build sorting
    perform zf_sorting using i_sortinfo.
    &---Build Listheader for TOP OF PAGE EVENT.
    perform zf_build_listheader using i_listheader.
    &---Build layout.
    perform zf_layout.
    &---Initializating Grid Title
    perform zf_build_grid_title.
    &---Display alv grid.
    perform zf_display_alv_grid.
    else.
    *If Table is not Populated ie Records Does not exist
    message 'Record Does Not Exist' type 'S'.
    endif.
    *& Form zf_validate_sales_doc_no
    text
    --> p1 text
    <-- p2 text
    form zf_validate_sales_doc_no .
    select single vbeln into wa_vbak-vbeln from vbak where vbeln in r_vbeln .
    if sy-subrc <> 0.
    message i101.
    endif.
    endform. " zf_validate_sales_doc_no
    *& Form zf_validate_date
    text
    --> p1 text
    <-- p2 text
    form zf_validate_date .
    if date is future
    if r_erdat-low >= sy-datum.
    message e102.
    elseif r_erdat-high >= sy-datum.
    message e103.
    endif.
    endform. " zf_validate_date
    *& Form zf_populate_header
    text
    --> p1 text
    <-- p2 text
    form zf_populate_header .
    select vbeln
    kunnr
    erdat
    auart
    netwr
    waerk
    vkorg
    vtweg
    spart
    into table i_vbak from vbak where vbeln in r_vbeln.
    if sy-subrc <> 0.
    message 'RECORD DOES NOT EXIST' type 'E'.
    endif.
    sort i_vbak by vbeln.
    *&--LOGIC TO GET FIELDS FROM TABLE KNA1 INTO INTERNAL TABLE I_VBAK
    loop at i_vbak into wa_vbak.
    select single name1 stras ort01 pstlz regio land1 telf1 into (wa_vbak-name1,
    wa_vbak-stras,
    wa_vbak-ort01,
    wa_vbak-pstlz,
    wa_vbak-regio,
    wa_vbak-land1,
    wa_vbak-telf1)
    from kna1
    where kunnr = wa_vbak-kunnr.
    modifying it_header.
    modify i_vbak from wa_vbak.
    clear wa_vbak.
    endloop.
    endform. " zf_populate_header
    *& Form zf_populate_detail
    text
    --> p1 text
    <-- p2 text
    form zf_populate_detail .
    if i_vbak[] is not initial.
    select vbeln
    posnr
    matnr
    into table i_vbap from vbap
    for all entries in i_vbak where vbeln = i_vbak-vbeln.
    endif.
    sort i_vbap by vbeln.
    sort i_vbap by posnr.
    *&--LOGIC TO GET FIELDS FROM TABLE MAKT INTO INTERNAL TABLE I_VBAP
    loop at i_vbap into wa_vbap.
    select single maktx into (wa_vbap-maktx)
    from makt where matnr = wa_vbap-matnr and spras = sy-langu.
    modifying it_header.
    modify i_vbap from wa_vbap.
    clear wa_vbap.
    endloop.
    endform. " zf_populate_detail
    *& Form zf_append_sales_final
    text
    --> p1 text
    <-- p2 text
    form zf_append_sales_final .
    sort i_vbak by vbeln.
    sort i_vbap by vbeln posnr.
    loop at i_vbak into wa_vbak.
    move-corresponding wa_vbak to wa_sales_final.
    read table i_vbap with key vbeln = wa_vbak-vbeln
    binary search transporting no fields.
    loop at i_vbap into wa_vbap from sy-tabix.
    if wa_vbap-vbeln <> wa_vbak-vbeln.
    exit.
    endif.
    move-corresponding wa_vbap to wa_sales_final.
    append wa_sales_final to i_sales_final.
    endloop.
    endloop.
    endform. " zf_append_sales_final
    *& Form zf_build_fieldcat
    text
    -->P_I_FIELDCAT text
    form zf_build_fieldcat using p_i_fieldcat type slis_t_fieldcat_alv.
    data: l_fieldcat type slis_fieldcat_alv. "local Workarea used
    clear l_fieldcat.
    FOR LIGHT IN COLUMN
    clear l_fieldcat.
    l_fieldcat-col_pos = '1'. " POSITION OF THE COLUMN.
    l_fieldcat-fieldname = 'V_LIGHTS'.
    " FIELD FOR WHICH CATALOG ID FILLED.
    *We are passing final internal table 'I_FINAL' to l_fieldcat(local
    *variable
    l_fieldcat-tabname = 'I_SALES_FINAL'.
    " INTERNAL TABLE TO WHICH THE FIELD BELONGS TO.
    l_fieldcat-just = 'C'. " FOR JUSTIFICATION.
    l_fieldcat-outputlen = 20.
    " TO DEFINE OUTPUT LENGTH OF THE COLUMN.
    append l_fieldcat to p_i_fieldcat.
    FIRST COLUMN ********************************
    l_fieldcat-col_pos = '2'. " POSITION OF THE COLUMN
    l_fieldcat-fieldname = 'VBELN'. " FIELD FOR WHICH CATALOG ID FILLED
    l_fieldcat-tabname = 'I_SALES_FINAL'. " INTERNAL TABLE BELONGS TO
    l_fieldcat-key = 'X'. " SO THAT this field is not scrollable hiddable.
    l_fieldcat-just = 'L'. " FOR JUSTIFICATION
    *l_fieldcat-hotspot = 'X'. " MARK THIS field as hotsopt
    l_fieldcat-lzero = 'X'. " OUTPUT WITH leading zeros.
    l_fieldcat-seltext_l = 'Sales Document'. " long text for header.
    l_fieldcat-seltext_m = 'Sales Doc'. " medium text for header.
    l_fieldcat-seltext_s = 'Sales Doc'. " sort text for header.
    l_fieldcat-outputlen = 20. " SET THE output length.
    l_fieldcat-ref_tabname = 'VBAK'. " FOR F1 & F4 help as
    append l_fieldcat to p_i_fieldcat.
    clear l_fieldcat.
    **************************SECOND COLUMN ********************************
    *l_fieldcat-col_pos = '3'. " POSITION OF THE COLUMN
    l_fieldcat-row_pos = '2'. " POSITION OF THE COLUMN
    l_fieldcat-fieldname = 'POSNR'. " FIELD FOR WHICH CATALOG ID FILLED
    l_fieldcat-tabname = 'I_SALES_FINAL'. " INTERNAL TABLE BELONGS TO
    l_fieldcat-key = 'X'. " SO THAT this field is not scrollable hiddable.
    l_fieldcat-just = 'L'. " FOR JUSTIFICATION
    l_fieldcat-hotspot = 'X'. " MARK THIS field as hotsopt
    l_fieldcat-lzero = 'x'. " OUTPUT WITH leading zeros.
    l_fieldcat-seltext_l = 'Sales Document Item'. " long text for header.
    l_fieldcat-seltext_m = 'Sales Document Item'. " medium text for header.
    l_fieldcat-seltext_s = 'Sales Document Item'. " sort text for header.
    l_fieldcat-outputlen = 20. " SET THE output length.
    l_fieldcat-ref_tabname = 'VBAP'. " FOR F1 & F4 help as
    append l_fieldcat to p_i_fieldcat.
    clear l_fieldcat.
    endform. " zf_build_fieldcat
    *& Form zf_eventcat
    text
    -->P_I_EVENTCAT text
    form zf_eventcat using p_i_eventcat type slis_t_event.
    data: l_eventcat type slis_alv_event.
    clear l_eventcat.
    call function 'REUSE_ALV_EVENTS_GET'
    exporting
    i_list_type = 0
    importing
    et_events = p_i_eventcat
    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.
    TOP OF PAGE FORM
    clear l_eventcat.
    read table p_i_eventcat into l_eventcat with key
    name = slis_ev_top_of_page.
    "(COMPONENT "NAME"of structure)
    if sy-subrc = 0. "if success
    move 'ZF_TOP_OF_PAGE' to l_eventcat-form.
    "matches name and moves form to workarea and modifies table
    modify p_i_eventcat from l_eventcat index sy-tabix
    transporting form.
    endif.
    PF_STATUS_SET FORM
    clear l_eventcat.
    read table p_i_eventcat into l_eventcat with key
    name = slis_ev_pf_status_set.
    if sy-subrc = 0.
    move 'ZF_PF_STATUS_SET' to l_eventcat-form.
    modify p_i_eventcat from l_eventcat index sy-tabix
    transporting form.
    endif.
    USER_COMMAND FORM
    clear l_eventcat.
    read table p_i_eventcat into l_eventcat with key
    name = slis_ev_user_command.
    if sy-subrc = 0.
    move 'ZF_USER_COMMAND' to l_eventcat-form.
    modify p_i_eventcat from l_eventcat index sy-tabix
    transporting form.
    endif.
    endform. " zf_eventcat
    *& Form zf_sorting
    text
    -->P_I_SORTINFO text
    form zf_sorting using p_i_sortinfo.
    endform. " zf_sorting
    *& Form zf_build_listheader
    text
    -->P_I_LISTHEADER text
    form zf_build_listheader using p_i_listheader type slis_t_listheader.
    data: l_listheader type slis_listheader.
    refresh p_i_listheader.
    clear l_listheader.
    HEADER
    l_listheader-typ = 'H'.
    l_listheader-info = 'FUJITSU CONSULTING INDIA LTD.'.
    append l_listheader to p_i_listheader.
    SELECTION
    l_listheader-typ = 'S'.
    l_listheader-key = 'Date:'.
    l_listheader-info = sy-datum.
    append l_listheader to p_i_listheader.
    ACTION
    l_listheader-typ = 'A'.
    *l_listheader-key =
    l_listheader-info = 'SALES ORDER ALV REPORT By Rohan Malik'.
    append l_listheader to p_i_listheader.
    endform. " zf_build_listheader
    *& Form zf_build_grid_title
    text
    --> p1 text
    <-- p2 text
    form zf_build_grid_title .
    v_gridtitle = 'List of Purchase Order'.
    endform. " zf_build_grid_title
    *& Form zf_display_alv_grid
    text
    --> p1 text
    <-- p2 text
    form zf_display_alv_grid .
    call function 'REUSE_ALV_GRID_DISPLAY'
    exporting
    i_callback_program = v_progname
    i_grid_title = v_gridtitle
    is_layout = wa_layout
    it_fieldcat = i_fieldcat
    it_sort = i_sortinfo
    it_events = i_eventcat
    IMPORTING
    E_EXIT_CAUSED_BY_CALLER =
    ES_EXIT_CAUSED_BY_USER =
    tables
    t_outtab = i_sales_final
    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. " zf_display_alv_grid
    *& Form zf_top_of_page
    text
    --> p1 text
    <-- p2 text
    form zf_top_of_page .
    call function 'REUSE_ALV_COMMENTARY_WRITE'
    exporting
    it_list_commentary = i_listheader
    i_logo = 'ENJOYSAP_LOGO'
    I_END_OF_LIST_GRID =
    endform. " zf_top_of_page
    *& Form zf_user_command
    text
    --> p1 text
    <-- p2 text
    form zf_user_command using r_ucomm like sy-ucomm
    rs_selfield type slis_selfield .
    case r_ucomm. "FCODE
    when 'VA03'.
    read table i_sales_final into wa_sales_final index rs_selfield-tabindex.
    set parameter id 'AUN' field rs_selfield-value.
    call transaction 'VA03' and skip first screen .
    message i102 with rs_selfield-value .
    when '&IC1'. "for hotspot with VBELN, POSNR, MATNR, KUNNR.
    if rs_selfield-fieldname = 'MATNR'.
    set parameter id 'MAT' field rs_selfield-value.
    call transaction 'MM03' and skip first screen.
    return.
    message i103 with rs_selfield-value .
    endif.
    if rs_selfield-fieldname = 'VBELN'.
    set parameter id 'AUN' field rs_selfield-value.
    call transaction 'VA03' and skip first screen.
    return.
    message i104 with rs_selfield-value .
    endif.
    endcase.
    endform. " zf_user_command
    *& Form ZF_PF_STATUS_SET
    text
    --> p1 text
    <-- p2 text
    form zf_pf_status_set using rt_extab type slis_t_extab.
    set pf-status 'Z11_RM_ALV_SO'.
    endform. " ZF_PF_STATUS_SET
    *& Form zf_layout
    text
    --> p1 text
    <-- p2 text
    form zf_layout .
    wa_layout-zebra = 'X'.
    wa_layout-lights_fieldname = 'V_LIGHTS'.
    wa_layout-lights_tabname = 'I_SALES_FINAL'.
    " 1, 2 or 3 for red, yellow and green respectively.
    endform. " zf_layout
    *& Form zf_modify_final
    text
    --> p1 text
    <-- p2 text
    form zf_modify_final .
    CODE TO EXECUTE LIGHTS
    *start of loop
    loop at i_sales_final into wa_sales_final.
    *giving conditions and modifying as we want to change many rows
    if wa_sales_final-netwr <= 10000.
    wa_sales_final-v_lights = '1'.
    modify i_sales_final from wa_sales_final transporting v_lights.
    elseif wa_sales_final-netwr > 10000 and wa_sales_final-netwr <= 100000.
    wa_sales_final-v_lights = '2'. " Exception.
    modify i_sales_final from wa_sales_final transporting v_lights.
    else.
    wa_sales_final-v_lights = '3'. " Exception.
    modify i_sales_final from wa_sales_final transporting v_lights.
    endif.
    endloop.
    reward point s if helpful
    rohan malik

  • Disabling push button column cell on alv grid control (OOABAP)

    Hello All,
    I have a requirement where I need to add one column as pushbutton in alv grid display. I have done that and it's triggering button_click event also. The problem here is that I want the few <b>push button cells</b> of that column to be disbaled (depending on my requirement). I tried using a internal table lvc_t_styl and adding a field of same lvc_t_styl in my main internal table. This works for all other fields (e.g disbaling checkbox in alv grid and other editable fields) but not for push buttons. My exact requirement is that I want some of the <b>cells of pushbutton column to be grayed out (made inactive)</b>. Can anyone tell me how to do that. Thanks.
    Note:Helpful answers will be duly rewarded.
    null

    Hi,
    I had the same problem.
    what I did I just added the  cl_gui_alv_grid=>mc_style_button at each row of the data table instead of adding it at the field catalog level.
    Hope this solve your problem.
    Thanks,
    Harish

Maybe you are looking for