Editable ALV-Grid  Using Class

Hi experts.....
I like to know How to create Editable ALV Grid using Class...
Also i like to to know how to add The contains to Z-Table...
Whether we can delete ALV grid contents........
...Thanks
..Ashish

Hello Ashish
You may want to have a look at thread Select Row in OO-ALV programmatically
Regards
  Uwe

Similar Messages

  • Header in alv grid using class

    Hello All,
        I developed alv grid using class method.
    First I created CREATE OBJECT GR_CCONTAINER
    then  CREATE OBJECT GR_ALVGRID
    then  PERFORM FIELD_CATALOG TABLES GT_FIELDCAT----
    for field catalog
        PERFORM LAYOUT CHANGING GS_LAYOUT.----
    for header
        p_gs_layout-grid_title = 'class method'.
      p_gs_layout-sel_mode = 'D'.
      APPEND P_GS_LAYOUT TO IT_LAYOUT.
    and finally CALL METHOD GR_ALVGRID->SET_TABLE_FOR_FIRST_DISPLAY
    the report is cooming fine but in header it comes only "class method".
    but i need also
    1. reporting date
    2. reporting time.
       can any body tell me how i can i put 2 more heading line
    Thanks,
    Rakesh

    Hi Dude,
    Please refer the below link how to handle  the header in alv using abap oo
    https://www.sdn.sap.com/irj/scn/wiki?path=/display/snippets/abapObjects-ALVModel-UsingHeaderand+Footer
    Hope it clears,..............
    Thanks & Regards
    Ramakrishna Pathi

  • Is it possbile to create ALV Grid using Class &  without using SE51

    Is it possible to create a alv grid using Class, with out using the screen painter(SE51).

    Hi Preethi,
    It is possible to creat ALV grid using class, provided u have to create a custom control in the screen dialog.
    Try with the foll code. This is an example for flight detail.
    DATA: container TYPE REF TO cl_gui_custom_container,
          alv_con TYPE REF TO cl_gui_alv_grid.
    data : it_sflight like table of wa with header line,
           g_fieldcat type lvc_t_fcat.
    /* Paste the code the PBO
        CREATE OBJECT container
          EXPORTING
            container_name              = 'C_SPFLI'. "Specify the container name which u created in the dialog screen.
        CREATE OBJECT alv_con
          EXPORTING
            i_parent          = container.
    /* Use the foll. to dislay the report
    CALL METHOD cl_grid->set_table_for_first_display
            EXPORTING
             I_STRUCTURE_NAME              = 'SFLIGHT'
            CHANGING
              it_outtab                     = it_sflight[]
              IT_FIELDCATALOG               = g_fieldcat.
    First create the container and then place the ALV in the container and for dislaying pass the necessary table.
    Hope this will useful for u.
    Get back if u r unable to do it.
    Regards
    Router

  • Doubt regarding editable ALV report using Classes

    I need to create an ALV report and make few fields editable
    and i need to update the changes  to the corresponding database tables
    for that please suggest me some idea or provide me sample code for that
    urgent

    Hi ramesh,
    Please check this example program. I think it will help for some extent.
    [code]&----
    *& Report  ZSUMA_INTERACTIVEREPORT                                     *
    report zsuma_interactivereport.
    tables: vbak.
    data :gr_alvgrid type ref to cl_gui_alv_grid,
          gr_cc_name type scrfname value 'CC_ALV',
          gr_ccontainer type ref to cl_gui_custom_container,
          gr_fieldcat type lvc_t_fcat,
          gr_layout type lvc_s_layo,
          gr_sort type lvc_t_sort,
          gr_get_cell type lvc_t_cell,
          gr_set_cell type lvc_t_cell,
          gr_hyper type lvc_t_hype,
          gr_drop_down type lvc_t_drop,
          is_variant type disvariant,
          line_number type lvc_s_roid-row_id,
          line(5) type c ,
          cell_value type lvc_value.
    data: begin of it_vbak occurs 0,
          vbeln type vbak-vbeln,
          erdat like vbak-erdat,
          erzet like vbak-erzet,
          netwr like vbak-netwr,
          waerk like vbak-waerk,
    *Below field is useful for making the entire row with different colors.
    it must be a char of 4.and layout-info_fname should populate with
    *this field.
          rowcolor(4) type c,
    *Below field is useful for making the INDIVIDUAL CELL with different
    *colors.for this we have to include structure of type lvc_t_scol.
    *layout-ctab_fname should be populate with this field.
          cellcolor type lvc_t_scol,
    *below field is added for for providing the hyperlinks to perticular
    *field. at the time of field catalog , it_fcatalog-web_field should be
    *populate with this field.
          vbeln_hyper type int4,
    *For displaying one cell as button.we have to declare one styles
    *internal table .it has to be populate.at layout structure this table
    *name has to be populate at layout-stylename.
         cellstyle type lvc_t_styl,
          end of it_vbak.
    *&   SELECTION SCREEN
    selection-screen begin of block b1 with frame title text-001.
    select-options s_vbeln for vbak-vbeln.
    selection-screen end of block b1.
    start-of-selection.
    select vbeln
           erdat
           erzet
           netwr
           waerk
           from vbak
           into corresponding fields of table it_vbak
           where vbeln in s_vbeln.
    data: wa_cellcolor type lvc_s_scol,
          wa_style type lvc_s_styl.
    loop at it_vbak.
    FOR ROW COLORING
    if sy-tabix = 1.
    it_vbak-rowcolor = 'C511'.
    FOR PUTTING THE HYPERLINKS ON VBELN FIELD
    it_vbak-vbeln_hyper = '1'.
    modify it_vbak.
    endif.
    FOR CELL COLORING
    if sy-tabix = 2.
    wa_cellcolor-fname = 'ERZET'.
    wa_cellcolor-color-col = '6'.
    wa_cellcolor-color-int = '1'.
    wa_cellcolor-color-inv = '1'.
    append wa_cellcolor to it_vbak-cellcolor.
    modify it_vbak index 2.
    endif.
    FOR DISPLAYING THE CELL AS A BUTTON
    clear it_vbak-cellstyle.
    at last.
    read table it_vbak index sy-tabix.
    wa_style-fieldname = 'NETWR'.
    wa_style-style = cl_gui_alv_grid=>mc_style_button.
    append wa_style to it_vbak-cellstyle .
    modify it_vbak .
    endat.
    endloop.
    if not it_vbak[] is initial.
      call screen 100.
    endif.
    *CLASS DEFINITION FOR HANDLING THE EVENTS IN ALV GRID
    class gr_event_handler definition.
    public section.
    methods:handle_hotspot_click
                  for event hotspot_click of cl_gui_alv_grid
                   importing e_row_id e_column_id es_row_no.
    endclass.
    *CLASS IMPLEMENTATIONFOR HANDLING THE EVENTS IN ALV GRID
    class gr_event_handler implementation.
    method handle_hotspot_click.
    perform handle_hotspot_click using e_row_id e_column_id es_row_no.
    endmethod.
    endclass.
    *&      Form  BUILDING_FIELDCATALOG
          text
         <--P_GR_FIELDCAT  text
    form building_fieldcatalog  changing p_gr_fieldcat type lvc_t_fcat.
    data s_fieldcat type lvc_s_fcat.
    s_fieldcat-fieldname = 'VBELN'.
    s_fieldcat-outputlen = '15'.
    s_fieldcat-col_pos   = '1'.
    s_fieldcat-coltext   = 'DOCCUMENT NO.'.
    s_fieldcat-key   = ' '.
    s_fieldcat-emphasize = 'C511'.
    s_fieldcat-web_field = 'VBELN_HYPER'.
    append s_fieldcat to p_gr_fieldcat .
    clear s_fieldcat.
    s_fieldcat-fieldname = 'ERDAT'.
    s_fieldcat-outputlen = '15'.
    s_fieldcat-col_pos   = '2'.
    s_fieldcat-coltext   = 'REC CREATE DATE.'.
    s_fieldcat-emphasize = 'C311'.
    s_fieldcat-hotspot = 'X'.
    append s_fieldcat to p_gr_fieldcat .
    clear s_fieldcat.
    s_fieldcat-fieldname = 'ERZET'.
    s_fieldcat-outputlen = '15'.
    s_fieldcat-col_pos   = '3'.
    s_fieldcat-coltext   = 'TIME ENTRY.'.
    *S_FIELDCAT-EMPHASIZE = 'C311'.
    append s_fieldcat to p_gr_fieldcat .
    clear s_fieldcat.
    s_fieldcat-fieldname = 'NETWR'.
    s_fieldcat-outputlen = '15'.
    s_fieldcat-col_pos   = '4'.
    s_fieldcat-emphasize = 'C311'.
    s_fieldcat-coltext   = 'NET WEIGHT.'.
    s_fieldcat-do_sum   = 'X'.
    append s_fieldcat to p_gr_fieldcat .
    clear s_fieldcat.
    s_fieldcat-fieldname = 'WAERK'.
    s_fieldcat-outputlen = '5'.
    s_fieldcat-col_pos   = '5'.
    s_fieldcat-emphasize = 'C511'.
    s_fieldcat-coltext   = 'CURR.'.
    FOR PUTTING THE DROP DOWN BOX.
    s_fieldcat-drdn_hndl = '1'.
    s_fieldcat-edit = 'X'.
    append s_fieldcat to p_gr_fieldcat .
    clear s_fieldcat.
    endform.                    " BUILDING_FIELDCATALOG
    *&      Form  CREATE_CCONTAINER_INSTANCE
          text
    -->  p1        text
    <--  p2        text
    form create_ccontainer_instance .
    create object gr_ccontainer
    exporting
    container_name              = gr_cc_name
    exceptions
    cntl_error                  = 1
    cntl_system_error           = 2
    create_error                = 3
    lifetime_error              = 4
    lifetime_dynpro_dynpro_link = 5
    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.
    endform.                    " CREATE_CCONTAINER_INSTANCE
    *&      Form  CREATE_ALVGRID_INSTANCE
          text
    -->  p1        text
    <--  p2        text
    form create_alvgrid_instance .
    create object gr_alvgrid
      exporting
        i_parent          = gr_ccontainer
      exceptions
        error_cntl_create = 1
        error_cntl_init   = 2
        error_cntl_link   = 3
        error_dp_create   = 4
        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.
    endform.                    " CREATE_ALVGRID_INSTANCE
    *&      Form  DISPLAYING_ALVGRID
          text
    -->  p1        text
    <--  p2        text
    form displaying_alvgrid .
    call method gr_alvgrid->set_table_for_first_display
      exporting
       I_BUFFER_ACTIVE               =
       I_BYPASSING_BUFFER            =
       I_CONSISTENCY_CHECK           =
       I_STRUCTURE_NAME              =
        is_variant                    = is_variant
        i_save                        = 'A'
       I_DEFAULT                     = 'X'
        is_layout                     = gr_layout
       IS_PRINT                      =
       IT_SPECIAL_GROUPS             =
       IT_TOOLBAR_EXCLUDING          =
        it_hyperlink                  = gr_hyper
       IT_ALV_GRAPHICS               =
       IT_EXCEPT_QINFO               =
      changing
        it_outtab                     = it_vbak[]
        it_fieldcatalog               = gr_fieldcat
       it_sort                       = gr_sort
       IT_FILTER                     =
    EXCEPTIONS
       INVALID_PARAMETER_COMBINATION = 1
       PROGRAM_ERROR                 = 2
       TOO_MANY_LINES                = 3
       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.
    *CALL METHOD GR_ALVGRID->GET_FRONTEND_LAYOUT
    IMPORTING
       ES_LAYOUT = GR_LAYOUT
    *GR_LAYOUT-GRID_TITLE = 'HAI ALV'.
    *CALL METHOD GR_ALVGRID->SET_FRONTEND_LAYOUT
    EXPORTING
       IS_LAYOUT = GR_LAYOUT
    endform.                    " DISPLAYING_ALVGRID
    *&      Form  REFRESH_DISPLAY_TABLE
          text
    -->  p1        text
    <--  p2        text
    form refresh_display_table .
    call method gr_alvgrid->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.
    endform.                    " REFRESH_DISPLAY_TABLE
    *&      Form  SETTING_LAYOUT
          text
         <--P_GR_LAYOUT  text
    form setting_layout  changing p_gr_layout type lvc_s_layo.
    p_gr_layout-grid_title = 'ALV GRID USING ABAP OBJECTS'.
    p_gr_layout-zebra = 'X'.
    p_gr_layout-no_toolbar = ''.
    p_gr_layout-sel_mode = 'D'.
    p_gr_layout-info_fname = 'ROWCOLOR'.
    p_gr_layout-ctab_fname = 'CELLCOLOR'.
    p_gr_layout-stylefname = 'CELLSTYLE'.
    endform.                    " SETTING_LAYOUT
    *&      Module  STATUS_0100  OUTPUT
          text
    module status_0100 output.
    SET PF-STATUS 'xxxxxxxx'.
    SET TITLEBAR 'xxx'.
    set pf-status 'MENU'.
    if gr_alvgrid is initial.
    *CREATING THE CONTAINER INSTANCE BY SENDING THE CONTAINER NAME( IT HAS
    *TO COINSIDE WITH COSTUM CONTROL NAME OF TRANSACTION SCREEN
    perform create_ccontainer_instance.
    perform create_alvgrid_instance.
    *VARIANT POPULATION.
    perform setting_variants changing is_variant.
    *BELOW FORM IS USEFUL TO FILL THE HYPER LINK TABLE AND WE PASS THAT
    *TABLE TO 'IT_HYPERLINK' PARAMETER IN FIRST DISPLAY METHOD.
    perform setting_hyperlinks_field changing gr_hyper.
    *TO MAKE THE COLOUMN AS DROP DOWN.
    perform setting_dropdown_column changing gr_drop_down.
    perform building_fieldcatalog changing gr_fieldcat.
    perform setting_layout changing gr_layout.
    perform setting_sorting changing gr_sort.
    perform setting_cells changing gr_set_cell.
    perform displaying_alvgrid.
    *PERFORM GETTING_CELL_DETAILS CHANGING GR_GET_CELL. " IT IS NOT WORKING
                                                 FOR ME AND I HAVE DOUBT .
    perform creating_event_object.
    *PERFORM REFRESH_DISPLAY_TABLE.
    endif.
    endmodule.                 " STATUS_0100  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
          text
    module user_command_0100 input.
    case sy-ucomm.
      when 'BACK'.
      leave to screen 000.
      endcase.
    endmodule.                 " USER_COMMAND_0100  INPUT
    *&      Form  SETTING_SORTING
          text
         <--P_GR_SORT  text
    form setting_sorting  changing p_gr_sort type lvc_t_sort.
    data: lr_sort type lvc_s_sort.
    lr_sort-spos = '1'.
    lr_sort-fieldname = 'VBELN'.
    lr_sort-up = 'X'.
    append lr_sort to p_gr_sort.
    lr_sort-spos = '2'.
    lr_sort-fieldname = 'ERDAT'.
    lr_sort-up = 'X'.
    append lr_sort to p_gr_sort.
    endform.                    " SETTING_SORTING
    *&      Form  GETTING_CELL_DETAILS
          text
         <--P_GR_GET_CELL  text
    form getting_cell_details  changing p_gr_get_cell.
    call method gr_alvgrid->get_selected_cells
      importing
        et_cell = p_gr_get_cell
    *CELL_VALUE = P_GR_GET_CELL-VALUE.
    endform.                    " GETTING_CELL_DETAILS
    *&      Form  SETTING_CELLS
          text
         <--P_GR_SET_CELL  text
    form setting_cells  changing p_gr_set_cell type lvc_t_cell.
    data:s_gr_set_cell type lvc_s_cell.
    s_gr_set_cell-col_id-fieldname = 'NETWR'.
    s_gr_set_cell-row_id-index = '3'.
    append s_gr_set_cell to p_gr_set_cell.
    call method gr_alvgrid->set_selected_cells
      exporting
        it_cells = p_gr_set_cell.
    endform.                    " SETTING_CELLS
    *&      Form  SETTING_HYPERLINKS_FIELD
          text
         <--P_GR_HYPER  text
    form setting_hyperlinks_field  changing p_gr_hyper type lvc_t_hype.
    data: is_hype type lvc_s_hype.
    is_hype-handle = '1'.
    is_hype-href = 'HTTP://WWW.GOOGLE.CO.IN'.
    append is_hype to p_gr_hyper.
    is_hype-handle = '2'.
    is_hype-href = 'HTTP://SDN.SAP.COM'.
    append is_hype to p_gr_hyper.
    endform.                    " SETTING_HYPERLINKS_FIELD
    *&      Form  SETTING_DROPDOWN_COLUMN
          text
         <--P_GR_DROP_DOWN  text
    form setting_dropdown_column  changing p_gr_drop_down type lvc_t_drop.
    data: wa_drop type lvc_s_drop.
    wa_drop-handle = '1'.
    wa_drop-value = '$'.
    append wa_drop to p_gr_drop_down.
    wa_drop-handle = '1'.
    wa_drop-value = 'Rs'.
    append wa_drop to p_gr_drop_down.
    wa_drop-handle = '1'.
    wa_drop-value = 'CUR'.
    append wa_drop to p_gr_drop_down.
    call method gr_alvgrid->set_drop_down_table
      exporting
        it_drop_down       = p_gr_drop_down
       IT_DROP_DOWN_ALIAS =
    endform.                    " SETTING_DROPDOWN_COLUMN
    *&      Form  SETTING_VARIANTS
          text
         <--P_IS_VARIANT  text
    form setting_variants  changing p_is_variant type disvariant.
    p_is_variant-report = sy-repid.
    endform.                    " SETTING_VARIANTS
    *&      Form  HANDLE_HOTSPOT_CLICK
          text
         -->P_E_ROW  text
         -->P_E_COLUMN  text
         -->P_E_ROW_NO  text
    form handle_hotspot_click  using    p_e_row_id type lvc_s_row
                                        p_e_column_id type lvc_s_col
                                        p_es_row_no type lvc_s_roid.
    read table it_vbak index p_es_row_no-row_id.
    if sy-subrc = 0 and p_e_column_id-fieldname = 'ERDAT'.
    line = p_es_row_no-row_id.
    line_number = p_es_row_no-row_id.
    leave to screen 200.
    endif.
    endform.                    " HANDLE_HOTSPOT_CLICK
    *&      Form  CREATING_EVENT_OBJECT
          text
    -->  p1        text
    <--  p2        text
    form creating_event_object .
    data event_handle type ref to gr_event_handler.
    create object event_handle.
    set handler event_handle->handle_hotspot_click for gr_alvgrid.
    endform.                    " CREATING_EVENT_OBJECT
    *&      Module  STATUS_0200  OUTPUT
          text
    module status_0200 output.
      set pf-status 'BB'.
    SET TITLEBAR 'xxx'.
    *LINE = LINE_NUMBER.
    endmodule.                 " STATUS_0200  OUTPUT
    *&      Module  USER_COMMAND_0200  INPUT
          text
    module user_command_0200 input.
    if sy-ucomm = 'BACK'.
    leave to screen 100.
    endif.
    endmodule.                 " USER_COMMAND_0200  INPUT[/code]
    Reward points if helpful
    Thanks,
    Suma.

  • Coulmn validation on ALV Grid (using Classes)

    Hi All,
       I'm creating a ALV Grid using calsses. I want to check the column value of Grid and raise some errror message. How to do this.
    Regards
    Jaker.

    have a look at sample report BCALV_EDIT_03

  • ALV Grid using classes

    Hi gurus,
               can anyone send me sample code to develop a repot using classes with all possibilities i.e, using events and interactive, pop-up.
    Best answers wil be rewarded.
    Regards,
    alson

    REPORT zex35 MESSAGE-ID zsmg NO STANDARD PAGE HEADING.
    INCLUDE <icon>.
    CLASS myclass DEFINITION DEFERRED.
    TABLES: vbak,kna1.
    TYPE-POOLS: slis,sdydo.
    DATA: BEGIN OF jtab OCCURS 0,
          ch(1),
          vbeln LIKE vbak-vbeln,
          erdat LIKE vbak-erdat,
          kunnr LIKE vbak-kunnr,
          ernam LIKE vbak-ernam,
          netwr LIKE vbak-netwr,
          knumv LIKE vbak-knumv,
          bstnk LIKE vbak-bstnk,
          ktext LIKE vbak-ktext,
          styletable TYPE lvc_t_styl,
          rowcolor(4),
          cellcolor TYPE lvc_t_scol,
          ptype_dd_hndl TYPE int4 ,
          END OF jtab.
    DATA : ejtab LIKE jtab OCCURS 0 WITH HEADER LINE.
    DATA: BEGIN OF vjtab OCCURS 0,
          vbeln LIKE vbak-vbeln,
          erdat LIKE vbak-erdat,
          kunnr LIKE vbak-kunnr,
          ernam LIKE vbak-ernam,
          netwr LIKE vbak-netwr,
          knumv LIKE vbak-knumv,
          bstnk LIKE vbak-bstnk,
          ktext LIKE vbak-ktext,
          END OF vjtab.
    DATA: alv TYPE scrfname VALUE 'ALV',
          obj_c_container_alv TYPE REF TO cl_gui_custom_container,
          obj_grid TYPE REF TO cl_gui_alv_grid,
          obj_myclass TYPE REF TO myclass,
          i_fieldcat TYPE lvc_t_fcat,
          wa_fieldcat LIKE LINE OF i_fieldcat,
          ei_fieldcat TYPE lvc_t_fcat,
          ewa_fieldcat LIKE LINE OF i_fieldcat,
          gs_layout   TYPE lvc_s_layo.
    DATA:   l_rows TYPE lvc_t_row.
    DATA :  modi TYPE  lvc_s_modi ,
            rowid TYPE i,
            ind TYPE i,
            wjtab LIKE jtab,
            it_exclude TYPE ui_functions,
            it_sort TYPE lvc_t_sort,
            it_filt TYPE lvc_t_filt,
            gi_index_rows TYPE lvc_t_row,
            g_selected_row LIKE lvc_s_row.
    DATA: ls_edit TYPE lvc_s_styl,
          lt_edit TYPE lvc_t_styl.
    DATA: ls_outtab LIKE LINE OF jtab.
    CALL SCREEN 100.
          CLASS MYCLASS DEFINITION
    CLASS myclass DEFINITION.
      PUBLIC SECTION.
        METHODS:
        toolbar FOR EVENT toolbar OF cl_gui_alv_grid IMPORTING e_object
                 e_interactive,
        user_command FOR EVENT user_command OF cl_gui_alv_grid IMPORTING
                 e_ucomm.
       after_user_command FOR EVENT BEFORE_user_command OF cl_gui_alv_grid
             IMPORTING
                e_ucomm,
       handle_change_click
        FOR EVENT data_changed OF cl_gui_alv_grid IMPORTING
             er_data_changed.
       handle_change_click
        FOR EVENT data_changed OF cl_gui_alv_grid IMPORTING
             er_data_changed.
    ENDCLASS.
          CLASS MYCLASS IMPLEMENTATION
    CLASS myclass IMPLEMENTATION.
      METHOD toolbar.
        DATA: ls_toolbar  TYPE stb_button.
        CLEAR ls_toolbar.
        MOVE 3 TO ls_toolbar-butn_type.
        APPEND ls_toolbar TO e_object->mt_toolbar.
        CLEAR ls_toolbar.
        MOVE 'BACK' TO ls_toolbar-function.
       MOVE icon_previous_object TO ls_toolbar-icon.
        MOVE 'BACK' TO ls_toolbar-text.
        MOVE ' ' TO ls_toolbar-disabled.
        APPEND ls_toolbar TO e_object->mt_toolbar.
        CLEAR ls_toolbar.
        MOVE 'CLEA' TO ls_toolbar-function.
       MOVE icon_refresh TO ls_toolbar-icon.
        MOVE 'CLEAR' TO ls_toolbar-text.
        MOVE ' ' TO ls_toolbar-disabled.
        APPEND ls_toolbar TO e_object->mt_toolbar.
        CLEAR ls_toolbar.
        MOVE 'TEXT' TO ls_toolbar-function.
       MOVE icon_display TO ls_toolbar-icon.
        MOVE 'READ' TO ls_toolbar-text.
        MOVE ' ' TO ls_toolbar-disabled.
        APPEND ls_toolbar TO e_object->mt_toolbar.
        CLEAR ls_toolbar.
        MOVE 'INSERT' TO ls_toolbar-function.
       MOVE icon_display TO ls_toolbar-icon.
        MOVE 'INSERT' TO ls_toolbar-text.
        MOVE ' ' TO ls_toolbar-disabled.
        APPEND ls_toolbar TO e_object->mt_toolbar.
        CLEAR ls_toolbar.
        MOVE 'FCAT' TO ls_toolbar-function.
       MOVE icon_display TO ls_toolbar-icon.
        MOVE 'FCAT' TO ls_toolbar-text.
        MOVE ' ' TO ls_toolbar-disabled.
        APPEND ls_toolbar TO e_object->mt_toolbar.
      ENDMETHOD.
    METHOD after_user_command.
       CASE e_ucomm.
         WHEN '&LOCAL&INSERT_ROW'.
           PERFORM insert_data.
       ENDCASE.
    ENDMETHOD.
      METHOD user_command.
        CASE e_ucomm.
          WHEN 'BACK'.
            LEAVE PROGRAM.
          WHEN 'INSERT'.
            PERFORM insert_data.
          WHEN 'FCAT'.
            PERFORM fcat_change.
        ENDCASE.
      ENDMETHOD.
    METHOD handle_change_click.
       LOOP AT er_data_changed->mt_mod_cells INTO modi.
         rowid = modi-row_id.
         READ TABLE jtab INTO wjtab INDEX rowid.
      WJTAB-VBELN = MODI-VALUE.
         MODIFY jtab FROM wjtab INDEX rowid.
       ENDLOOP.
    ENDMETHOD.
    ENDCLASS.
    *&      Module  STATUS_0100  OUTPUT
    MODULE status_0100 OUTPUT.
      CASE sy-ucomm.
        WHEN 'EXIT'.
          LEAVE PROGRAM.
        WHEN 'DISPLAY'.
          SELECT  vbeln erdat kunnr ernam netwr knumv bstnk ktext
              FROM vbak INTO CORRESPONDING FIELDS OF TABLE vjtab
              WHERE vbeln LT  '0000000500'.
          PERFORM display1.
        WHEN 'EXIT'.
          LEAVE PROGRAM.
      ENDCASE.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&      Form  display1
    FORM display1.
      CREATE OBJECT obj_c_container_alv
        EXPORTING
          container_name              = alv.
      IF obj_grid IS INITIAL.
        CREATE OBJECT obj_grid
              EXPORTING
                i_parent          = obj_c_container_alv.
        CREATE OBJECT obj_myclass.
        SET HANDLER obj_myclass->toolbar FOR obj_grid.
        SET HANDLER obj_myclass->user_command FOR obj_grid.
       SET HANDLER obj_myclass->handle_change_click FOR obj_grid.
       gs_layout-sel_mode = 'C'.
       gs_layout-cwidth_opt = 'X'.
       gs_layout-smalltitle = 'X'.
        gs_layout-grid_title = 'ALV TITLE'.
       gs_layout-no_headers = 'X'.
        gs_layout-stylefname = 'STYLETABLE'.
       gs_layout-no_hgridln = 'X'.
       gs_layout-no_vgridln = 'X'.
       gs_layout-NO_ROWMARK = 'X'.
       gs_layout-no_toolbar = 'X'.
        gs_layout-info_fname = 'ROWCOLOR'.
        gs_layout-ctab_fname = 'CELLCOLOR'.
        LOOP AT vjtab.
          jtab-vbeln = vjtab-vbeln.
          jtab-erdat = vjtab-erdat.
          jtab-kunnr = vjtab-kunnr.
          jtab-ernam = vjtab-ernam.
          jtab-netwr = vjtab-netwr.
          jtab-knumv = vjtab-knumv.
          jtab-bstnk = vjtab-bstnk.
          jtab-ktext = vjtab-ktext.
          APPEND jtab.
          CLEAR jtab.
        ENDLOOP.
        PERFORM build_fieldcat.
        PERFORM exclude_toolbaricons CHANGING it_exclude.
        PERFORM sort_table CHANGING it_sort.
        PERFORM filter_table CHANGING it_filt.
        PERFORM rowcolor.
        PERFORM colcolor.
        PERFORM drilldown_values.
        CALL METHOD obj_grid->set_table_for_first_display
          EXPORTING
            i_structure_name              = 'JTAB'
            is_layout                     = gs_layout
            it_toolbar_excluding          = it_exclude
          CHANGING
            it_outtab                     = jtab[]
           it_sort                       = it_sort
            it_filter                     = it_filt
            it_fieldcatalog               = i_fieldcat.
      ELSE .
        CALL METHOD obj_grid->refresh_table_display.
      ENDIF.
    ENDFORM.                                                    " display1
    *&      Form  SAVE_DATA
    FORM save_data.
    ENDFORM.                    " SAVE_DATA
    *&      Form  INSERT_DATA
    FORM insert_data.
      DATA:l_lines TYPE i.
      REFRESH gi_index_rows.
      CLEAR   g_selected_row.
      DATA ls_listrow LIKE LINE OF jtab .
      CALL METHOD obj_grid->get_selected_rows
        IMPORTING
          et_index_rows = gi_index_rows.
      READ TABLE gi_index_rows INTO g_selected_row INDEX 1.
      ind = g_selected_row-index + 1.
      INSERT INITIAL LINE INTO jtab INDEX ind.
      READ TABLE jtab INDEX ind.
      CLEAR ls_edit.
      ls_edit-fieldname = 'VBELN'.
      ls_edit-style = cl_gui_alv_grid=>mc_style_disabled.
      INSERT ls_edit INTO TABLE lt_edit.
    CLEAR ls_edit.
    ls_edit-fieldname = 'ERDAT'.
    ls_edit-style = cl_gui_alv_grid=>mc_style_enabled.
    INSERT ls_edit INTO TABLE lt_edit.
      CLEAR ls_edit.
      ls_edit-fieldname = 'KUNNR'.
      ls_edit-style = cl_gui_alv_grid=>mc_style_enabled.
      INSERT ls_edit INTO TABLE lt_edit.
      CLEAR ls_edit.
      ls_edit-fieldname = 'ERNAM'.
      ls_edit-style = cl_gui_alv_grid=>mc_style_enabled.
      INSERT ls_edit INTO TABLE lt_edit.
    CLEAR ls_edit.
    ls_edit-fieldname = 'NETWR'.
    ls_edit-style = cl_gui_alv_grid=>mc_style_enabled.
    INSERT ls_edit INTO TABLE lt_edit.
      CLEAR ls_edit.
      ls_edit-fieldname = 'KNUMV'.
      ls_edit-style = cl_gui_alv_grid=>mc_style_enabled.
      INSERT ls_edit INTO TABLE lt_edit.
      CLEAR ls_edit.
      ls_edit-fieldname = 'BSTNK'.
      ls_edit-style = cl_gui_alv_grid=>mc_style_enabled.
      INSERT ls_edit INTO TABLE lt_edit.
    CLEAR ls_edit.
    ls_edit-fieldname = 'KTEXT'.
    ls_edit-style = cl_gui_alv_grid=>mc_style_enabled.
    INSERT ls_edit INTO TABLE lt_edit.
      CLEAR : ls_outtab.
      INSERT LINES OF lt_edit INTO TABLE ls_outtab-styletable.
      MODIFY jtab INDEX ind FROM ls_outtab  TRANSPORTING
                                      styletable .
      CALL METHOD obj_grid->refresh_table_display.
    GS_LAYOUT-STYLEFNAME = 'STYLETABLE'.
      REFRESH : lt_edit.
    ENDFORM.                    " INSERT_DATA
    *&      Form  FCAT_CHANGE
    FORM fcat_change.
    DATA ls_fcat TYPE lvc_s_fcat .
    DATA lt_fcat TYPE lvc_t_fcat .
    DATA ls_layout TYPE lvc_s_layo .
    CALL METHOD obj_grid->get_frontend_fieldcatalog
    IMPORTING
    et_fieldcatalog = lt_fcat[] .
    LOOP AT lt_fcat INTO ls_fcat .
       IF ls_fcat-fieldname = 'ERNAM' .
         ls_fcat-coltext = 'MYNAME'.
         ls_fcat-no_out = 'X'.
         MODIFY lt_fcat FROM ls_fcat .
       ENDIF .
    ENDLOOP .
    CALL METHOD obj_grid->set_frontend_fieldcatalog
    EXPORTING
    it_fieldcatalog = lt_fcat[] .
    CALL METHOD obj_grid->get_frontend_layout
    IMPORTING
    es_layout = ls_layout .
    ls_layout-grid_title = 'Changed ALV Grid Title' .
    ls_layout-zebra = 'X' .
    CALL METHOD obj_grid->set_frontend_layout
    EXPORTING
    is_layout = ls_layout .
    LOOP AT jtab.
       IF jtab-netwr > '400.00'.
         CLEAR ls_edit.
         ls_edit-fieldname = 'ERDAT'.
         ls_edit-style = cl_gui_alv_grid=>mc_style_disabled.
         INSERT ls_edit INTO TABLE lt_edit.
         CLEAR : ls_outtab.
         INSERT LINES OF lt_edit INTO TABLE ls_outtab-styletable.
         MODIFY jtab INDEX sy-tabix FROM ls_outtab  TRANSPORTING
                                         styletable .
       ENDIF.
    ENDLOOP.
      LOOP AT jtab.
        IF jtab-netwr LE '400.00'.
          ejtab-vbeln = jtab-vbeln.
          ejtab-erdat = jtab-erdat.
          ejtab-kunnr = jtab-kunnr.
          ejtab-ernam = jtab-ernam.
          ejtab-netwr = jtab-netwr.
          ejtab-knumv = jtab-knumv.
          ejtab-bstnk = jtab-bstnk.
          ejtab-ktext = jtab-ktext.
          APPEND ejtab.
          CLEAR ejtab.
        ENDIF.
      ENDLOOP.
      PERFORM ebuild_fieldcat.
      CALL METHOD obj_grid->set_table_for_first_display
           EXPORTING
             i_structure_name              = 'EJTAB'
             is_layout                     = gs_layout
             it_toolbar_excluding          = it_exclude
           CHANGING
             it_outtab                     = ejtab[]
           it_sort                       = it_sort
             it_filter                     = it_filt
             it_fieldcatalog               = ei_fieldcat.
    ENDFORM.                    " FCAT_CHANGE
    *&      Form  exclude_toolbaricons
    FORM exclude_toolbaricons CHANGING   pt_exclude TYPE ui_functions.
      DATA ls_exclude TYPE ui_func.
      ls_exclude = cl_gui_alv_grid=>mc_fc_maximum .
      APPEND ls_exclude TO pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_minimum .
      APPEND ls_exclude TO pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_subtot .
      APPEND ls_exclude TO pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_find .
      APPEND ls_exclude TO pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_sum .
      APPEND ls_exclude TO pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_average .
      APPEND ls_exclude TO pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_mb_sum .
      APPEND ls_exclude TO pt_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_mb_subtot.
      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_delete_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_toolbaricons
    *&      Form  sort_table
    FORM sort_table CHANGING pt_sort TYPE lvc_t_sort.
      DATA ls_sort TYPE lvc_s_sort .
      ls_sort-spos = '1' .
      ls_sort-fieldname = 'VBELN' .
      ls_sort-up = 'X' .
      ls_sort-down = space .
      APPEND ls_sort TO pt_sort .
      ls_sort-spos = '2' .
      ls_sort-fieldname = 'KUNNR' .
      ls_sort-up = space .
      ls_sort-down = 'X' .
      APPEND ls_sort TO pt_sort .
    ENDFORM.                    " sort_table
    *&      Form  filter_table
    FORM filter_table CHANGING pt_filt TYPE lvc_t_filt.
      DATA ls_filt TYPE lvc_s_filt .
      ls_filt-fieldname = 'VBELN' .
      ls_filt-sign = 'E' .
      ls_filt-option = 'BT' .
      ls_filt-low = '0000000010' .
      ls_filt-high = '0000000100' .
      APPEND ls_filt TO pt_filt .
    ENDFORM.                    " filter_table
    *&      Form  ROWCOLOR
    FORM rowcolor.
      CLEAR wjtab.
      LOOP AT jtab INTO wjtab.
        IF wjtab-netwr LE '400.00'.
          wjtab-rowcolor    = 'C611'.
        ENDIF.
        MODIFY jtab FROM wjtab.
      ENDLOOP.
    ENDFORM.                    " ROWCOLOR
    *&      Form  colcolor
    FORM colcolor.
      DATA ls_cellcolor TYPE lvc_s_scol .
      CLEAR ls_cellcolor.
      READ TABLE jtab INDEX 8 .
      ls_cellcolor-fname = 'KUNNR' .
      ls_cellcolor-color-col = '0' .
      ls_cellcolor-color-int = '0' .
      APPEND ls_cellcolor TO jtab-cellcolor .
      MODIFY jtab INDEX 8 .
      CLEAR ls_cellcolor.
      READ TABLE jtab INDEX 13 .
      ls_cellcolor-fname = 'NETWR' .
      ls_cellcolor-color-col = '5' .
      ls_cellcolor-color-int = '1' .
      APPEND ls_cellcolor TO jtab-cellcolor .
      MODIFY jtab INDEX 13 .
    ENDFORM.                    " colcolor
    *&      Form  DRILLDOWN_VALUES
    FORM drilldown_values.
      DATA lt_ddval TYPE lvc_t_drop .
      DATA ls_ddval TYPE lvc_s_drop .
      ls_ddval-handle = '1' .
      ls_ddval-value = 'JFK-12' .
      APPEND ls_ddval TO lt_ddval .
      ls_ddval-handle = '1' .
      ls_ddval-value = 'JSF-44' .
      APPEND ls_ddval TO lt_ddval .
      ls_ddval-handle = '1' .
      ls_ddval-value = 'KMDA-53' .
      APPEND ls_ddval TO lt_ddval .
      ls_ddval-handle = '1' .
      ls_ddval-value = 'SS3O/N' .
      APPEND ls_ddval TO lt_ddval .
      CALL METHOD obj_grid->set_drop_down_table
      EXPORTING
      it_drop_down = lt_ddval .
    ENDFORM.                    " DRILLDOWN_VALUES
    *&      Form  BUILD_FIELDCAT
          text
    -->  p1        text
    <--  p2        text
    FORM build_fieldcat.
      CLEAR i_fieldcat[].
    *CLEAR wa_fieldcat.
    *wa_fieldcat-col_pos = 1.
    *wa_fieldcat-fieldname = 'CH'.
    **wa_fieldcat-tabname = 'JTAB'.
    *wa_fieldcat-outputlen = '2'.
    **wa_fieldcat-coltext = 'CHECKBOX'.
    *wa_fieldcat-checkbox = 'X'.
    *wa_fieldcat-edit        = 'X'.
    *APPEND wa_fieldcat TO i_fieldcat.
      CLEAR wa_fieldcat.
      wa_fieldcat-col_pos = 2.
      wa_fieldcat-fieldname = 'VBELN'.
      wa_fieldcat-tabname = 'JTAB'.
    *wa_fieldcat-outputlen = '10'.
      wa_fieldcat-coltext = 'SALES ORDER'.
    *wa_fieldcat-CHECKBOX = 'X'.
      APPEND wa_fieldcat TO i_fieldcat.
      CLEAR wa_fieldcat.
      wa_fieldcat-col_pos = 4.
      wa_fieldcat-fieldname = 'KUNNR'.
      wa_fieldcat-tabname = 'JTAB'.
      wa_fieldcat-outputlen = '20'.
      wa_fieldcat-coltext = 'CUSTOMER NO'.
      APPEND wa_fieldcat TO i_fieldcat.
      CLEAR wa_fieldcat.
      wa_fieldcat-col_pos = 3.
      wa_fieldcat-fieldname = 'ERDAT'.
      wa_fieldcat-tabname = 'JTAB'.
    *wa_fieldcat-outputlen = '8'.
      wa_fieldcat-coltext = 'DATE'.
      wa_fieldcat-edit        = 'X'.
      APPEND wa_fieldcat TO i_fieldcat.
      CLEAR wa_fieldcat.
      wa_fieldcat-col_pos = 5.
      wa_fieldcat-fieldname = 'ERNAM'.
      wa_fieldcat-tabname = 'JTAB'.
    *wa_fieldcat-outputlen = '12'.
      wa_fieldcat-coltext = 'NAME'.
      APPEND wa_fieldcat TO i_fieldcat.
      CLEAR wa_fieldcat.
      wa_fieldcat-col_pos = 6.
      wa_fieldcat-fieldname = 'NETWR'.
      wa_fieldcat-tabname = 'JTAB'.
    *wa_fieldcat-outputlen = '15'.
      wa_fieldcat-coltext = 'NET WEIGHT'.
      wa_fieldcat-edit        = 'X'.
      APPEND wa_fieldcat TO i_fieldcat.
      CLEAR wa_fieldcat.
      wa_fieldcat-col_pos = 7.
      wa_fieldcat-fieldname = 'KNUMV'.
      wa_fieldcat-tabname = 'JTAB'.
    *wa_fieldcat-outputlen = '10'.
      wa_fieldcat-coltext = 'DOC COND'.
      APPEND wa_fieldcat TO i_fieldcat.
      CLEAR wa_fieldcat.
      wa_fieldcat-col_pos = 8.
      wa_fieldcat-fieldname = 'BSTNK'.
      wa_fieldcat-tabname = 'JTAB'.
    *wa_fieldcat-outputlen = '20'.
      wa_fieldcat-coltext = 'CUST PO'.
      APPEND wa_fieldcat TO i_fieldcat.
      CLEAR wa_fieldcat.
      wa_fieldcat-col_pos = 9.
      wa_fieldcat-fieldname = 'KTEXT'.
      wa_fieldcat-tabname = 'JTAB'.
    *wa_fieldcat-outputlen = '40'.
      wa_fieldcat-coltext = 'SEARCH TERM FOR PRODUCT PROPOSAL'.
      wa_fieldcat-edit        = 'X'.
      wa_fieldcat-drdn_field = 'PTYP_DD_HNDL'.
      APPEND wa_fieldcat TO i_fieldcat.
    ENDFORM.                    " BUILD_FIELDCAT
    *&      Form  ebuild_fieldcat
          text
    -->  p1        text
    <--  p2        text
    FORM ebuild_fieldcat.
      CLEAR ei_fieldcat[].
      CLEAR ewa_fieldcat.
      ewa_fieldcat-col_pos = 1.
      ewa_fieldcat-fieldname = 'CH'.
    *ewa_fieldcat-tabname = 'JTAB'.
      ewa_fieldcat-outputlen = '2'.
    *ewa_fieldcat-coltext = 'CHECKBOX'.
      ewa_fieldcat-checkbox = 'X'.
      ewa_fieldcat-edit        = 'X'.
      APPEND ewa_fieldcat TO ei_fieldcat.
      CLEAR ewa_fieldcat.
      ewa_fieldcat-col_pos = 2.
      ewa_fieldcat-fieldname = 'VBELN'.
      ewa_fieldcat-tabname = 'JTAB'.
    *ewa_fieldcat-outputlen = '10'.
      ewa_fieldcat-coltext = 'SALES ORDER'.
    *ewa_fieldcat-CHECKBOX = 'X'.
      APPEND ewa_fieldcat TO ei_fieldcat.
      CLEAR ewa_fieldcat.
      ewa_fieldcat-col_pos = 4.
      ewa_fieldcat-fieldname = 'KUNNR'.
      ewa_fieldcat-tabname = 'JTAB'.
      ewa_fieldcat-outputlen = '20'.
      ewa_fieldcat-coltext = 'CUSTOMER NO'.
      APPEND ewa_fieldcat TO ei_fieldcat.
      CLEAR ewa_fieldcat.
      ewa_fieldcat-col_pos = 3.
      ewa_fieldcat-fieldname = 'ERDAT'.
      ewa_fieldcat-tabname = 'JTAB'.
    *ewa_fieldcat-outputlen = '8'.
      ewa_fieldcat-coltext = 'DATE'.
      ewa_fieldcat-edit        = 'X'.
      APPEND ewa_fieldcat TO ei_fieldcat.
      CLEAR ewa_fieldcat.
      ewa_fieldcat-col_pos = 5.
      ewa_fieldcat-fieldname = 'ERNAM'.
      ewa_fieldcat-tabname = 'JTAB'.
    *ewa_fieldcat-outputlen = '12'.
      ewa_fieldcat-coltext = 'NAME'.
      ewa_fieldcat-edit        = 'X'.
      APPEND ewa_fieldcat TO ei_fieldcat.
      CLEAR ewa_fieldcat.
      ewa_fieldcat-col_pos = 6.
      ewa_fieldcat-fieldname = 'NETWR'.
      ewa_fieldcat-tabname = 'JTAB'.
    *ewa_fieldcat-outputlen = '15'.
      ewa_fieldcat-coltext = 'NET WEIGHT'.
      ewa_fieldcat-edit        = 'X'.
      APPEND ewa_fieldcat TO ei_fieldcat.
      CLEAR ewa_fieldcat.
      ewa_fieldcat-col_pos = 7.
      ewa_fieldcat-fieldname = 'KNUMV'.
      ewa_fieldcat-tabname = 'JTAB'.
    *ewa_fieldcat-outputlen = '10'.
      ewa_fieldcat-coltext = 'DOC COND'.
      ewa_fieldcat-edit        = 'X'.
      APPEND ewa_fieldcat TO ei_fieldcat.
      CLEAR ewa_fieldcat.
      ewa_fieldcat-col_pos = 8.
      ewa_fieldcat-fieldname = 'BSTNK'.
      ewa_fieldcat-tabname = 'JTAB'.
    *ewa_fieldcat-outputlen = '20'.
      ewa_fieldcat-coltext = 'CUST PO'.
      APPEND ewa_fieldcat TO ei_fieldcat.
      CLEAR ewa_fieldcat.
      ewa_fieldcat-col_pos = 9.
      ewa_fieldcat-fieldname = 'KTEXT'.
      ewa_fieldcat-tabname = 'JTAB'.
    *ewa_fieldcat-outputlen = '40'.
      ewa_fieldcat-coltext = 'SEARCH TERM FOR PRODUCT PROPOSAL'.
      ewa_fieldcat-edit        = 'X'.
      ewa_fieldcat-drdn_field = 'PTYP_DD_HNDL'.
      APPEND ewa_fieldcat TO ei_fieldcat.
    ENDFORM.                    " ebuild_fieldcat

  • ALV grid using classes(displaying subtotals groupwise in ALV grid control)

    Hello ,
      please can any body help me its urgent tome.
    displaying subtotals groupwise ..say for ex..
    cost group  costelement         amount     
    10          101         100.00
    10                            102          200.00
    10                            103          300.00
    20                            104          400.00
    20                            105          500.00
    20                            106          600.00
                    101         100.00
                    102         200.00
                    103         300.00
    10                          600.00
              104         400.00
              105         500.00
              106         600.00
    20                         1500.00
    In ALV grid control using classes.
    Thanks in Advance

    Hi alson,
    MODULE pbo OUTPUT.
    SET PF-STATUS 'MAIN100'.
    IF g_custom_container IS INITIAL.
    CREATE OBJECT g_custom_container
    EXPORTING container_name = g_container.
    CREATE OBJECT grid1
    EXPORTING i_parent = g_custom_container.
    <b>CALL METHOD grid1->set_table_for_first_display
    EXPORTING IS_LAYOUT = it_LAY
    CHANGING it_fieldcatalog = fieldcat
    it_sort = it_sort
    it_outtab = itab[].</b>
    ENDIF.
    ENDMODULE. " PBO OUTPUT
    keep the below code
    <b>CALL METHOD grid1->set_table_for_first_display
    EXPORTING IS_LAYOUT = it_LAY
    CHANGING it_fieldcatalog = fieldcat
    it_sort = it_sort
    it_outtab = itab[].</b>
    here
    IF pdel = 'X'.
    *BEGIN OF CHANGES BY VINAY DASARI
    PERFORM get_data.
    <b>CALL METHOD grid1->set_table_for_first_display
    EXPORTING IS_LAYOUT = it_LAY
    CHANGING it_fieldcatalog = fieldcat
    it_sort = it_sort
    it_outtab = itab[].</b>
    ENDIF.

  • Enable User Defined toolbar button on click -  editable alv grid using oops

    Hi all,
    I  have created editable alv using  oops concept.
    created 2 user defined toolbar button save and print using method toolbar
      ls_toolbar-text      = 'Print'.                         "#EC NOTEXT
        ls_toolbar-quickinfo = space.
        ls_toolbar-checked   = space.
        APPEND ls_toolbar TO e_object->mt_toolbar.
    requirement is
    initially print button should be disabled, and save enabled
    when i click save button, print button should be enabled.
    I want coding in editable alv oops concept
    kindly help
    regards
    senthil kumar

    Halo Senthil,
    You should call set_toolbar_interactive method of cl_gui_alv_grid in the on_user_command( ie the event handler for event user command) .
    method on_user_command.
    case e_ucomm.
    when 'SAVE'. or whatever your function code is .
    my_save_flag = 'X'.
    call method grid->set_toolbar_interactive.
    endmethod.
    This triggers the toolbar event of the
    cl_gui_alv_grid. Inside the eventhandler method ( ie the on_toolbar method ) you should set the toolbar.
    if my_save_flag = 'X'.
    read table e_object->mt_toolbar
    clear l_toolbar-disabled.
    modify e_object->mt_toolbar.
    endif.
    e_ucomm will not have  the function code if the save button is not in the toolbar area.
    then you can set the my_save_flag in the data_changed event handler of the Cl_gui_alv_grid.
    Regards
    Arshad

  • Refreshing of ALV Grid(using class)

    Hi all,
      In my program, i found that the ALV grid is displaying the same data for different criteria's. when debugging i found that the data is populated correctly in the output table that is passed to the method SET_TABLE_FOR_FIRST_DISPLAY according to the criteria's, yet i could only see the grid with the previous data.Please suggest on what could be done to correct this.
    Thanks,
    saran

    Hi Saran,
    There is a lifetime attribute that you have to set .
    Set this when you create object container at the first time .
    Here is the sample syntax :
    Variable definition
    DATA: grid_pr1 TYPE REF TO cl_gui_alv_grid,
          g_cconth TYPE REF TO cl_gui_custom_container,
          gs_layout2 TYPE lvc_s_layo,
          it_alv TYPE lvc_t_fcat .
    DATA: it_pr1 type table of ZP119H. " custom structure
    Create the object
    IF g_cconth is INITIAL.
        CREATE OBJECT g_cconth
           EXPORTING
              container_name = 'CCONTH'
              lifetime = g_cconth->lifetime_dynpro.
        CREATE OBJECT grid_pr1
           EXPORTING
             i_parent = g_cconth .
        CALL METHOD grid_pr1->set_table_for_first_display
          EXPORTING
            is_layout            = gs_layout2
          CHANGING
            it_outtab            = it_pr1
            it_fieldcatalog      = it_alv.
    ENDIF. " g_cconth
    Message was edited by:
            TUWUHSIH WINEDYA

  • Handling Enter Key in Editable ALV Grid using REUSE_ALV_GRID_DISPLAY

    Hello All,
    I have seen a number of threads on captioned issue and everyone of them say to create FCODE for Enter in the Screen's PF Status and then handle the event.
    But the catch is when you hit Enter key in ALV Grid, it will not trigger any FCODE at all because the FCODE Enter you have created is for the screen and not for the GRID. Can anyone please let me know if SAP has given any standard utility in REUSE_ALV_GRID_DISPLAY FM for handling the Enter key event.
    Thanks and regards,
    Mahesh

    Hi,
    Set the PF-status for OK key and use the FCODE or u can usethe dynamic ok_code generated .
    Also try 'ENTE' .
    Hope thishelps.

  • Changing Values on ALV Grid (using Classes)

    Hi all,
        I have ALV Grid output, on which ZMENG (Target Qty) column is editable. So user will enter in value in ZMENG column and press ENTER. Then TOTAL column should be populated with ZMENG * NETWR columns. I have tried with changing/ entering values with char data type columns like MAKTX etc.. Its working fine with them. But when I entered in value in ZMENG, the actual value which I have entered is not flowing into LS_GOOD-VALUE. For char data types its been populated with user entered values.
          Can anyone please tell why its not happening with Quantity or Currency fields.
      method handle_data_changed.
        DATA: ls_good TYPE lvc_s_modi,
              l_netwr TYPE vbap-netwr,
              l_total TYPE vbap-netwr,
              l_zmeng TYPE vbap-zmeng.
        LOOP AT er_data_changed->mt_good_cells INTO ls_good.
          CASE ls_good-fieldname.
            WHEN 'ZMENG'.
              <<<<l_zmeng = ls_good-value.>>>>
              call method er_data_changed->get_cell_value
                             exporting i_row_id = ls_good-row_id
                                       i_fieldname = 'NETWR'
                             importing e_value = l_netwr.
              l_total = l_zmeng * l_netwr.
              call method er_data_changed->modify_cell
                        exporting i_row_id = ls_good-row_id
                                  i_fieldname = 'TOTAL'
                                  i_value     = l_total.
          ENDCASE.
      ENDLOOP.
    ENDMETHOD.
    Fieldcatlog for Quantity field:
      l_fcat-tabname = 'IT_VBAP'.
      l_fcat-fieldname = 'ZMENG'.
      l_fcat-coltext = 'Qty'.
      l_fcat-outputlen = 17.
      l_fcat-edit = 'X'.
      APPEND l_fcat TO ct_fcat.
      CLEAR l_fcat.

    Hi Jaker 
    Try calling cl_gui_alv_Grid->refresh_table_display.
    refresh table display when ever the qty is changed.
    It should work.
    Venkat.

  • Selecting rows in ALV Grid using Classes

    I am displaying the output in ALV grid format.
    Now i am using cl_gui_alv_grid->Get_selected_ROWS to get the row index selected by User and on clicking a button it will take us to another screen which will hold the values of the selected row.
    Problem Faced: But when we again go back to the first screen and select another row  or same rows and click this button the selected rows index remains initial, that value is not getting captured.
    I cleared the parameters and refershed grid also.
    But the problem is not yet solved.
    Please Give me the solution.
    Regards,
    Balaji.

    Hi Lavanya,
    I did debugging also.
    First time Get_Selected_rows is working fine.
    But Second time it is failed.

  • &RNT_PREV ( ALV GRID USING Classes )

    Hi,
    I am using the above function code to display print preview . I am able to display that successfully, but the 'Question' I have here is Can i customize the Print Preview.
    For Example if i have 10 rows in the Data and i select a Few rows and display only those rows in Print Preview.
    Please suggest.
    Thanks in Advance.
    Tarun

    Yes
    You can look at the code post by this SDN user and study it.
    http://forums.sdn.sap.com/post!reply.jspa?messageID=10986911

  • Abt alv grid using classes for tree structure

    hi to all,
    please giv me reply asap.
    thanks n regards
    satya

    Hi,
    Please check the link below :
    <a href="http://www.sapdev.co.uk/reporting/alv/alvtree.htm">http://www.sapdev.co.uk/reporting/alv/alvtree.htm</a>
    Thanks,
    Sriram Ponna.

  • Enter Key Event in Editable ALV Grid

    Hi all,
    I am trying to create and editable ALV grid using the REUSE ALV FM.
    On the grid after changing a value, if I press enter key the pai is not triggered. I have tried the various example programs (BCALV*) but could not find anything relevant.
    Basically I need similar functionality to normal module pool programming as in validations on screen done when enter key is pressed after screen entry.
    Is it possible to capture the Enter keypress on the ALV grid?

    Hello Preet
    I can only tell you how I would solve this using the ALV grid control (CL_GUI_ALV_GRID) because I have abandoned using ALV function modules.
    The problem with running through PAI is whether the focus (i.e. the cursor) is still on the control or already on the (surrounding) main program. If the control has the focus, you do not run through PAI.
    I would add a "Refresh" button to the toolbar of the ALV list. Normally, this button is already there or you only have to make it visible.
    When the user pushes this button you catch the corresponding user-command and call the CHECK_DATA_CHANGED method to see if values have been changed on the editable grid. If so, the previous method will fire event DATA_CHANGED.
    Now, in the event handler method (e.g. HANDLE_DATA_CHANGED) you receive as input a data change object (CL_ALV_CHANGED_DATA_PROTOCOL). This object contains all changed values. These values you will need to make your checks.
    I assume that the logic will be similar using ALV function modules.
    Regards
       Uwe

Maybe you are looking for

  • Does the 'default where clause' query select the ROWID by default ?

    Hi , The query in default where property of a data block is as follows: global.prim_lang = :global.user_lang and upper(group_name) like upper('%' || :B_apply_inclusions.TI_group_desc || '%') UNION ALL select g.rowid, g.group_no from table1 t, table 2

  • OP Passing methods

    Soz, the other post seemed to be getting a bit long. Everything is working great now guys, just 1 little problem, I will post all the code so that you can see. And just in case this makes a difference but all three of these classes are on seperate pa

  • After Backup In iTunes - All Media Content Is Deleted - iPhone 3G 16GB/8GB

    I have the latest iPhone Update 3.1 on my wife's 8GB 3G & my iPhone 16GB 3G - We are running the latest iTunes on a 2008 intel iMac. Using separate Logins on iMac. Strange things have happened since backing iPhone up in iTunes 9 today. (Previous Back

  • ORA-942 in Export

    I'm trying to do an export of a database (8.1.7) from one server to another (9.0.1) I can connect through sqlplus fine but when I try to run the export on the command line, I get the ORA-942 error. We also have a script that we run at night to do the

  • Load balancing /Clustring Xservers

    I am totally new to load balancing/clustering in X servers. This is my scenario, we need all the designers to start work from the server not on their systems. Only for rendering they would copy the file and throw back them to server. For this kind of