ALV GRID - Handling selected rows? Sorting in OUTTAB is different from ALV

Dear Experts ,
I have a transaction with ALV grid. I have defined several application specific functions to the ALV grid tool bar. My requirement is to handle the ALV tool bar functions only for the selected rows.
Code snippet:
DATA:
LS_GRID_DS TYPE TYS_DS.
TYPES: BEGIN OF TYS_DS.
INCLUDE   TYPE TYS_ALVGRID.
TYPES: STRUCNAME LIKE DD02L-TABNAME.
TYPES: PRETAB    TYPE ZTAB_T,
       OUTTAB    TYPE ZTAB_T,
       OUTTAB_HIDDEN TYPE ZTAB_T,
       OUTTAB_SUM TYPE ZTAB_T,
       OUTTAB_ROLLBACK TYPE ZTAB_T,
       END OF TYS_DS.
  LOOP AT ls_grid_ds-marked_rows INTO ss_index_split
       WHERE rowtype IS INITIAL.
( Marked rows is correctly giving the row numbers of the highlighted rows)
READ TABLE ls_grid_ds-outtab INTO ss_sel_rows_ds_split
               INDEX ss_index_split-index.
ISSUE : Sorting in ls_grid_ds-outtab internal table is different from ALV Grid display.
Hence, though ls_grid_ds-marked_rows giving correct rows, I am not able to handle the my requirement correctly.
Why sorting in gs_grid_ds-outtab is different from ALV display? How can they made in sync?
Thank you in Advance.
Sravan.
Edited by: Raja Sravan on Jan 16, 2009 1:13 AM

Hello Raja
The OUTTAB is usually in sync with the display on the frontend grid control because it is a CHANGING parameter (of method SET_TABLE_FOR_FIRST_DISPLAY).
Question: Do you "feed" ls_grid_ds-outtab to the parameter IT_OUTTAB of method SET_TABLE_FOR_FIRST_DISPLAY?
If not then it is obvious why you get discrepancies.
Regards
  Uwe

Similar Messages

  • WEB DYNPRO ALV GRID  GET SELECTED ROWS...

    I'm reusing component ALV Grid ...
    How can i get selected rows...

    Hi Stephan,
    In order to get the multiple rows which were selected by the user you will just have to call the get_selected_elements method of if_wd_context_node. So as you can see its no different from how you would get the multiple rows selected by the user in a table ui element. First get the reference of the node which you have used to bind to the ALV & then call this method on it.
    METHOD get_selected_rows .
      DATA: temp TYPE string.
      DATA: lr_node TYPE REF TO if_wd_context_node,
                wa_temp  TYPE REF TO if_wd_context_element,
                ls_node1 TYPE wd_this->element_node_flighttab,
                lt_node1 TYPE wd_this->elements_node_flighttab.
      lr_node = wd_context->get_child_node( name = 'NODE_FLIGHTTAB' ).
    " This would now contain the references of all the selected rows
      lt_temp = lr_node->get_selected_elements( ).
        LOOP AT lt_temp INTO wa_temp.
    " Use the references to get the exact row data
          CALL METHOD wa_temp->get_static_attributes
            IMPORTING
              static_attributes = ls_node1.
          APPEND ls_node1 TO lt_node1.
          CLEAR ls_node1.
        ENDLOOP.
    ENDMETHOD.
    Hope this helps resolve your problem.
    Regards,
    Uday

  • Return from ALV  Grid to Selection screen

    hi,
    I want to go back from ALV grid to selection screen.
    I am using the following code:
    WHEN 'BACK'.
    CALL METHOD grid1->refresh_table_display.
    CALL METHOD grid1->free.
    CALL METHOD custom_container1->free.
    CALL SELECTION-SCREEN 1000.
    it is working,but when i press BACK button from selection screen to program it is showing ERROR IN FLUSH 4 Error.
    Also I tried with method FLUSH
    WHEN 'BACK'.
    CALL METHOD grid1->refresh_table_display.
    CALL METHOD grid1->free.
    CALL METHOD custom_container1->free.
    CALL METHOD cl_gui_cfw=>flush.
    it's still showing same Error.
    Please help on this.
    Regards,
    Sankar

    Hi,
    My grid name is grid1.
    I tried with :
    DATA grid1 TYPE REF TO cl_gui_alv_grid.
    CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
    IMPORTING
    e_grid = grid1.
    CALL METHOD grid1->check_changed_data.
    CALL METHOD grid1->refresh_table_display.
    LEAVE TO SCREEN 0.
    Even, I tried with declaring another grid : grid2
    DATA grid1 TYPE REF TO cl_gui_alv_grid.
    CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
    IMPORTING
    e_grid = grid1.
    CALL METHOD grid1->check_changed_data.
    CALL METHOD grid1->refresh_table_display.
    LEAVE TO SCREEN 0.
    In both cases, I am getting the following Error : OBJECTS_OBJREF_NOT_ASSIGNED

  • Display alv grids in selection screen based on the user event

    Hi All,
    I am workign on displaying ALV in same selection screen.I am able to display the ALV in selection screen.
    But i have 2 buttons in my selection screen 'Create' and 'change'.
    When i click on create i need  with some type of data and when i click on 'change' my alv grid another type of data.Ex: if i click on crate mara data should be dispalyed when i click on change makt table data should be dispalyed and also i have user defined buttons are in my grids.
    So i have used 2 containers to dispaly to different data.I am able to display the perfectly but the problem is first time when i click on create the grid is displaying when i click on change button  the create alv grid is displaying down and change data is dispalying up.
    I need only one alv grid at a time.Can anybody please let me know how can i do this.
    Thanks,
    Taragini

    Hello,
    Also I would suggest if it is relevant data maintain in one interntal table and show/hide based on condition
    through fieldcatalog (NO_OUT) parameter.
    Thanks

  • Help req : alv grid with multiple row selection

    Hi all sap gurus,
    i have a alv list display program , in which i can select the o/p rows(multiple rows)
    and perform some actiom based on some icons .
    now i have to convert this in to grid display
    this is initial code i.e for list
    DATA :  BEGIN OF itab OCCURS 0.
            INCLUDE STRUCTURE ztest.
    DATA :  checkbox type c.
    DATA : END OF itab.
    s_layout-box_fieldname = 'CHECKBOX'.
      ty_events-name = slis_ev_top_of_page.
      ty_events-form =  'TOP_OF_PAGE'.
      APPEND ty_events TO it_events.
    ALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
           EXPORTING
                i_program_name     = v_repid
                i_internal_tabname = 'ITAB'
                i_inclname         = v_repid
           CHANGING
                ct_fieldcat        = build_fieldcatalog.
    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
         EXPORTING
       I_INTERFACE_CHECK              = ' '
       I_BUFFER_ACTIVE                = ' '
         i_callback_program             = v_repid
         i_callback_pf_status_set       = 'SET_PF_STATUS'
         i_callback_user_command        = 'USER_COMMAND'
         i_structure_name               = 'ITAB'
         is_layout                      = s_layout
         it_fieldcat                    = build_fieldcatalog[]
       IT_EXCLUDING                   =
       IT_SPECIAL_GROUPS              =
       IT_SORT                        =
       IT_FILTER                      =
       IS_SEL_HIDE                    =
       I_DEFAULT                      = 'X'
       I_SAVE                         = ' '
       IS_VARIANT                     =
         it_events                      = it_events
       IT_EVENT_EXIT                  =
       IS_PRINT                       =
       IS_REPREP_ID                   =
       I_SCREEN_START_COLUMN          = 0
       I_SCREEN_START_LINE            = 0
       I_SCREEN_END_COLUMN            = 0
       I_SCREEN_END_LINE              = 0
    IMPORTING
       E_EXIT_CAUSED_BY_CALLER        =
       ES_EXIT_CAUSED_BY_USER         =
          TABLES
            t_outtab                    = itab
         EXCEPTIONS
           program_error                = 1
           OTHERS                       = 2
      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    FORM user_command USING ucomm LIKE sy-ucomm
    selfield TYPE slis_selfield.
      IF ucomm = 'DELE'.
        LOOP AT iTAB WHERE CHECKbox = 'X' .
        ENDLOOP.
        MODIFY  ztEST FROM TABLE itAB.
      ENDIF.
      selfield-refresh = 'X'.
    ENDFORM.
    NOW I HAVE A LIST O/P WHERE I CAN SELECT THE BOX AND CLICK DELETE ICON.
    NOW I WANT TO CHANGE TO GRID, SO I KEPT EVERYTHING SAMRE AND I CHANGED  " LIST" TO "GRID"
    NOW TWO THINGS HAPPEND
    1) I SEE A EMPTY COLUMN IN THE O/P , I GUESS THATS BECAUSE CHECKBOSX IN INTERNAL TABLE , SO I REMOVED IT
    SO THIS MADE ME TO REMOVE
    IF ucomm = 'DELE'.
        LOOP AT iTAB." WHERE CHECKbox = 'X' .------PROBLEM
        ENDLOOP.
        MODIFY  ztEST FROM TABLE itAB.
      ENDIF.
      selfield-refresh = 'X'.
    NOW I DON'T SEE THE EMPTY COLUMN , BUT NOW PROBLEM  IS I CANNNOT DISTINGUISH AS TO WHICH IS SELECTED AND AT ANY POINT OF TIME I CANSELECT ONLY ROW.
    ALL I WANT IS
    1) I WANT TO SELECT MULTIPLE ROWS AND SHOULD BE ABLE TO KNOW WHICH ROWS WERE SELECTED IN THE O/P SCREEN.
    IN THE LIST DISPLAY I HAD CHECKBOX = 'X' FOR ALL THE ROWS THAT WERE SELECTED , I WANT THE SIMILAR THING in grid display
    LET ME KNOW whether this can be done without USING 00 LANG.
    thanks

    Hi Swati,
    Below code might help full for you. Description: is It selects multiple rows from ALV and display it on the next ALV.
    *************************Reward Point If help full********************************************
    *& Report   z7cc_alv_oops_show_next_alv                                *
    *&          DEVELOPERS NAME : CHIDANAND CHAUHAN
    *&          DATE: SATURDAY 08-07-2006
    *&          DESCRIPTION: TO CREATE AN OBJECT ORIENTED ALV
    REPORT      z7cc_alv_oops_show_next_alv MESSAGE-ID  z5hs .
    DATA : BEGIN OF it_mara OCCURS 0,
      mark  TYPE flag,
      matnr TYPE matnr,
      mtart TYPE mtart,
      meins TYPE meins,
    END OF it_mara.
    DATA : BEGIN OF it_mara1 OCCURS 0,
    *  mark  type flag,
      matnr TYPE matnr,
      mtart TYPE mtart,
      meins TYPE meins,
    END OF it_mara1.
    DATA : BEGIN OF it_mara2 OCCURS 0,
    *  mark  type flag,
      matnr TYPE matnr,
      mtart TYPE mtart,
      meins TYPE meins,
    END OF it_mara2.
    DATA : t_fieldcat TYPE lvc_t_fcat,
             t_fieldcat1 TYPE lvc_t_fcat,
          s_fieldcat LIKE LINE OF t_fieldcat.
    DATA : s_layout TYPE lvc_s_layo.
    DATA : control TYPE REF TO cl_gui_custom_container,
           grid  TYPE REF TO cl_gui_alv_grid.
    DATA: BEGIN OF wa ,
      mark  TYPE flag,
      matnr TYPE matnr,
      mtart TYPE mtart,
      meins TYPE meins,
    END OF wa.
    *       CLASS lcl_events_box DEFINITION
    CLASS lcl_events_box DEFINITION.
      PUBLIC SECTION.
        METHODS :
    *Handler_Data_Changed for event Data_Changed of cl_gui_alv_grid
    *imporTing er_data_changed,
        handler_user_command FOR EVENT user_command OF cl_gui_alv_grid
        IMPORTING e_ucomm,
        handler_toolbar FOR EVENT toolbar OF cl_gui_alv_grid
        IMPORTING e_object e_interactive.
    ENDCLASS.                    "lcl_events_box DEFINITION
    *       CLASS lcl_events_box IMPLEMENTATION
    CLASS lcl_events_box IMPLEMENTATION.
    * method to handle the user command.
      METHOD handler_user_command.
        PERFORM form_usercommand CHANGING e_ucomm.
      ENDMETHOD.                    "Handler_user_command
    *& Mehod to handle the toolbar.
      METHOD handler_toolbar.
        PERFORM form_toolbar CHANGING e_object e_interactive
        e_object->mt_toolbar.
      ENDMETHOD.                    "Handler_ToolBar
    ENDCLASS.                    "lcl_events_box IMPLEMENTATION
    START-OF-SELECTION.
      DATA : w_events TYPE REF TO lcl_events_box.
      SELECT matnr mtart meins FROM mara INTO CORRESPONDING FIELDS OF TABLE
      it_mara.
      CALL SCREEN 100.
    *&      Module  pbo_module  OUTPUT
    *       text
    MODULE pbo_module OUTPUT.
      IF grid IS INITIAL.
        CREATE OBJECT control
          EXPORTING
            container_name     = 'CUST_CTRL'.
        CREATE OBJECT grid
          EXPORTING
            i_parent          = control.
        PERFORM build_catalog.
        PERFORM build_catalog1.
        PERFORM build_layout.
        CALL METHOD grid->set_table_for_first_display
          EXPORTING
            is_layout       = s_layout
          CHANGING
            it_outtab       = it_mara[]
            it_fieldcatalog = t_fieldcat.
        CREATE OBJECT w_events.
        SET HANDLER : w_events->handler_toolbar FOR grid,
                      w_events->handler_user_command FOR grid.
        CALL METHOD grid->set_toolbar_interactive.
      ELSE.
        CALL METHOD grid->refresh_table_display.
      ENDIF.
    ENDMODULE.                 " pbo_module  OUTPUT
    *&      Form  BUILD_CATALOG
    FORM build_catalog .
      s_fieldcat-col_pos = '1'.
      s_fieldcat-fieldname = 'MARK'.
      s_fieldcat-checkbox = 'X'.
      s_fieldcat-edit = 'X'.
      APPEND s_fieldcat TO t_fieldcat.
      CLEAR s_fieldcat.
      s_fieldcat-col_pos = '2'.
      s_fieldcat-fieldname = 'MATNR'.
      s_fieldcat-scrtext_m = 'MATERIAL'.
      APPEND s_fieldcat TO t_fieldcat.
      s_fieldcat-col_pos = '3'.
      s_fieldcat-fieldname = 'MTART'.
      s_fieldcat-scrtext_m = 'MATERL TYPE'.
      APPEND s_fieldcat TO t_fieldcat.
      s_fieldcat-col_pos = '4'.
      s_fieldcat-fieldname = 'MEINS'.
      s_fieldcat-scrtext_m = 'UOM'.
      APPEND s_fieldcat TO t_fieldcat.
    ENDFORM.                    " BUILD_CATALOG
    *&      Form  BUILD_LAYOUT
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM build_layout .
      s_layout-zebra = 'X'.
    * S_LAYOUT-CWIDTH_OPT = 'X'.
      s_layout-grid_title = 'Material Details'.
    ENDFORM.                    "BUILD_LAYOUT
    " BUILD_LAYOUT////////////////////////////////////
    " USER_COMMAND_0100  INPUT
    *&      Form  FORM_USERCOMMAND
    *       text
    *      <--P_E_UCOMM  text
    FORM form_usercommand  CHANGING p_e_ucomm.
      CASE p_e_ucomm.
        WHEN 'INT1'.
          DO.
            READ TABLE it_mara INDEX sy-index TRANSPORTING mark matnr.
            IF sy-subrc <> 0.
              EXIT.
            ENDIF.
            IF it_mara-mark = 'X'.
              READ TABLE it_mara INTO wa TRANSPORTING matnr mtart meins .
              MOVE-CORRESPONDING wa TO it_mara1.
              READ TABLE it_mara1 TRANSPORTING matnr mtart meins .
              MOVE-CORRESPONDING it_mara1  TO it_mara2.
              APPEND it_mara2.
              CALL METHOD grid->set_table_for_first_display
                EXPORTING
                  is_layout       = s_layout
                CHANGING
                  it_outtab       = it_mara2[]
                  it_fieldcatalog = t_fieldcat1.
    *       SET PARAMETER ID 'MAT' FIELD IT_MARA-MATNR.
    *       CALL TRANSACTION 'MM02'.
            ENDIF.
    *      ENDIF.
          ENDDO.
      ENDCASE.
    ENDFORM.                    " FORM_USERCOMMAND
    *&      Form  FORM_TOOLBAR
    *       text
    *      <--P_E_OBJECT  text
    *      <--P_E_INTERACTIVE  text
    *      <--P_E_OBJECT_>MT_TOOLBAR  text
    FORM form_toolbar  CHANGING p_e_object TYPE REF TO
    cl_alv_event_toolbar_set
    p_e_interactive
    mt_toolbar TYPE ttb_button.
      DATA wal_button TYPE stb_button.
    *WAL_BUTTON-ICON = ICON_status_reverse.
      wal_button-text = 'GO'.
      wal_button-quickinfo = 'PROCEED'.
      wal_button-function = 'INT1'.
      wal_button-butn_type = 0.
      wal_button-disabled = space.
      INSERT wal_button  INTO p_e_object->mt_toolbar INDEX 1.
    ENDFORM.                    " FORM_TOOLBAR
    *&      Module  PF-STATUS  OUTPUT
    *       text
    MODULE pf-status OUTPUT.
      SET PF-STATUS 'Z7CCSTAT'.
    ENDMODULE.                 " PF-STATUS  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
    *       text
    MODULE user_command_0100 INPUT.
      CASE sy-ucomm.
        WHEN 'BACK'.
          LEAVE PROGRAM.
        WHEN 'CANCEL'.
          LEAVE PROGRAM.
      ENDCASE.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    *&      Form  BUILD_CATALOG1
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM build_catalog1 .
      s_fieldcat-col_pos = '1'.
      s_fieldcat-fieldname = 'MATNR'.
      s_fieldcat-scrtext_m = 'MATERIAL'.
      APPEND s_fieldcat TO t_fieldcat1.
      s_fieldcat-col_pos = '2'.
      s_fieldcat-fieldname = 'MTART'.
      s_fieldcat-scrtext_m = 'MATERL TYPE'.
      APPEND s_fieldcat TO t_fieldcat1.
      s_fieldcat-col_pos = '3'.
      s_fieldcat-fieldname = 'MEINS'.
      s_fieldcat-scrtext_m = 'UOM'.
      APPEND s_fieldcat TO t_fieldcat1.
    ENDFORM.                    " BUILD_CATALOG1

  • ALV grid oo delete rows and update to table

    Hi all
      How can I delete one row and update to the db table?
    thanks

    Hi,
    Refer:-
    The ALV Grid has events data_changed and data_changed_finished. The former method is
    triggered just after the change at an editable field is perceived. Here you can make checks for
    the input. And the second event is triggered after the change is committed.
    You can select the way how the control perceives data changes by using the method
    register_edit_event. You have two choices:
    1. After return key is pressed: To select this way, to the parameter i_event_id pass cl_gui_alv_grid=>mc_evt_enter.
    2. After the field is modified and the cursor is moved to another field: For this, pass cl_gui_alv_grid=>mc_evt_modifies to the same parameter.
    To make events controlling data changes be triggered, you must select either way by
    calling this method. Otherwise, these events will not be triggered.
    To control field data changes, ALV Grid uses an instance of the class
    CL_ALV_CHANGED_DATA_PROTOCOL and passes this via the event data_changed.
    Using methods of this class, you can get and modify cell values and produce error messages.
    Hope this helps you.
    Regards,
    Tarun

  • Editable ALV Grid: Append new rows

    Hi All,
    I have developed a report which will displays output in editable ALV grid list. Users can modify the values in output and save. These values will be stored in one custom table.
    My requirement is whenever user clicks on '+' mark (Create entries or Append or Copy: Standard toolbar) report should allow to enter new entries and save. How do I capture the selected function code? why becuase i need to display one value from the custom table in that added new row...
    Regards,
    Ramesh.

    Hi Ramesh,
    please check changed data event.....
    please go through the reference link......
    https://wiki.sdn.sap.com/wiki/display/Snippets/UpdatingtheInternalTable-AfterEditinALVusingFunctionModules
    Regards,
    Venkat

  • To capture the selected rows along with edited field contents in alv report

    Dear All,
             I do have requirement where, in alv report output one field is editable and need to save the content of the edited field along with the selected rows.
             For example If there are 10 records displayed in the alv output with 20 fields.
    Out of this 20 fields one field (say XYZ) is editable. Also i have already created a new pushbutton (say ABC) on alv output. Now in the alv output if we maintain some value in the field (XYZ ) for the 2nd and 4th record and select this two records, and when clicked on the pushbutton (ABC) it has to update the DB table.
          I am using the Func Module  'REUSE_ALV_GRID_DISPLAY'. 
          Your early reply with sample code would be appreciated.
    Thanks in Advance.

    HI Naveen ,
    There is an import parameter "i_callback_program" in the function module,
    plz pass the program name to it.
    Capture the command by passing a field of type sy-ucomm to "I_CALLBACK_USER_COMMAND ".  Check the returned command and
    and program a functionality as desired.
    u can try the event double_click or at line selection. there u can use READLINE command to c if the line has been selected.
    In case it is , process the code segment.
    Regards
    Pankaj

  • Web dynpro ALV table copy selected row

    How to copy a selected row into new row with same values.
    Thanks

    Hi,
    I assume that there is a COPY buttonand there is a single lead seecltion for your alv table.
    Now,
    data:
      lr_node type ref to if_wd_context_node,
      lr_element type ref to if_wd_context_element,
      lr_element1 type ref to if_wd_context_element,
      ls_table type vbak,
    ls_table1 type vbak.
    lr_node = wd_context->get_chaild_node ( 'FLIGHT ' ).
    if lr_node is not initial.
    lr_element = lr_node->get_lead_selection ( ).
    lr_elemnet1 = lr_node->get_element( index = 4). "supose the index of new row is 4
    * you can use the get_element_count to know the record number
    endif.
    if lr_element is not initial.
    lr_element->get_statitc_attributes
    importing
    static_attributes = ls_table
    endif.
    if lr_element1 is not initial.
    lr_element1->set_staitc_attributes
    exporting
    STATIC_ATTRIBUTES = ls_table.
    endif.
    Assume that you have already created a new row...
    use code wizard.
    Regards,
    Lekha.

  • ALV grid checkbox at row level

    Hi Experts,
                        I have  a requirement to make check box in ALV grid as non-editable for some rows, according to  certain conditions.
    How can I achieve this ?
    Thanks in advance
                       Sanu

    refer below demo program
    BCALV_EDIT_05
    in above demo program  find the folloing code...
    ls_celltab-fieldname = 'CHECKBOX'.
      ls_celltab-style = cl_gui_alv_grid=>mc_style_enabled.
      loop at gt_outtab.
        l_index = sy-tabix.
        refresh lt_celltab.
    here as per the condition u make the checkbox disable cl_gui_alv_grid=>mc_style_enabled
        ls_celltab-fieldname = 'CHECKBOX'.
        ls_celltab-style = cl_gui_alv_grid=>mc_style_enabled.
        insert ls_celltab into table lt_celltab.
        insert lines of lt_celltab into table gt_outtab-celltab.
        modify gt_outtab index l_index.
      endloop.
    Edited by: shan palani on Dec 16, 2008 11:48 AM

  • 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

  • ALV Grid Handle Edit Event (Lost Focus)

    Hi all,
    I have some problems with the ALV Grid.
    Target:
    I have an ALV Grid with editable Column. If the user insert, update or delete the content of the column and leave the column (column lost focus) i'd like to do somthing - this means I need a event for this action. Can anybody help me to solve this problem?
    Thanks Stefan

    Use Event data_changed and data_changed_finished of the cl_gui_alv_grid.Then all you have to do is registering your event to the ALV and fill the methods with what you want to do.In ALV Grid, There is no event to capture the lost focus of a column if you don't modify it.
    CLASS lcl_event_receiver DEFINITION.
        METHODS:
    *$ Check the change
           handle_data_changed FOR EVENT data_changed
                                   OF cl_gui_alv_grid
                               IMPORTING er_data_changed
                                         e_ucomm
                                         e_onf4
                                         e_onf4_before
                                         e_onf4_after,
           handle_data_changed_finished
                               FOR EVENT data_changed_finished
                                   OF cl_gui_alv_grid
                                IMPORTING e_modified
                                         et_good_cells
                                         sender,
    ENDCLASS.                    "LCL_EVENT_RECEIVER DEFINITION

  • Alv grid - call transaction 'ME22N' and reflect the change made in alv grid

    Hi,
    <u>Scenario</u>
    I have an alv list which has fields Purchase document no. (EBELN) and Item delivery date (EINDT). EBELN field is hot spot enabled. when i click on that transaction 'ME22' is called. I have done this using USER_COMMAND subroutine.the code is given.
          FORM USER_COMMAND                                             *
    Call transaction ME22N on clicking Document number                 *
    FORM USER_COMMAND USING F_UCOMM LIKE SY-UCOMM
                    I_SELFIELD TYPE SLIS_SELFIELD.
      DATA: F_SUBRC LIKE SY-SUBRC,
            s_arseg like G_T_PORD. "the internal table used is G_T_PORD
      CASE F_UCOMM.
        WHEN '&IC1'.
          IF i_selfield-fieldname = 'EBELN'.
            READ TABLE G_T_PORD INDEX i_selfield-tabindex INTO s_arseg.
            SET PARAMETER ID 'BES' FIELD s_arseg-ebeln.
            CALL TRANSACTION 'ME22N' AND SKIP FIRST SCREEN.
          ENDIF.
      ENDCASE.
    endform.
    <u>Requirement</u>
    After calling the transaction, If the user changes the Item delivery date (EINDT) at the ME22 transaction screen, the new date needs to be reflected in the ALV grid.
    Plz help it is very urgent.

    The first method (using selfield-refresh = 'X'.) didn't work as the internal table doesnt get modified when the user make changes in Item delivery date(EINDT) at ME22 transaction screen. The 2nd method is OO,which can't be used in my case.
    I tried calling the subroutine for populating the itab (G_T_PORD) and the subroutine for displaying the alv grid immediately after calling ME22N transaction. Still it is not reflecting the new date in the output alv. The code is given below.
          FORM USER_COMMAND                                             *
    Call transaction ME22N on clicking Document number                 *
    FORM USER_COMMAND USING F_UCOMM LIKE SY-UCOMM
                    I_SELFIELD TYPE SLIS_SELFIELD.
      DATA: F_SUBRC LIKE SY-SUBRC,
            s_arseg like G_T_PORD.
      CASE F_UCOMM.
        WHEN '&IC1'.
          IF i_selfield-fieldname = 'EBELN'.
            READ TABLE G_T_PORD INDEX i_selfield-tabindex INTO s_arseg.
            SET PARAMETER ID 'BES' FIELD s_arseg-ebeln.
            CALL TRANSACTION 'ME22N' AND SKIP FIRST SCREEN.
          ENDIF.
      ENDCASE.
            refresh G_T_PORD.
            perform F1000_POPULATE_PO.
            perform F2000_DISPLAY_PO .
    endform.

  • OO ALV grid refresh problem on sort

    I have an editable OO ALV where I over ride the standard functionality for append, insert, Delete etc to handle condition that when a new row is inserted/appended its status which is in a non-editable cell  is defaulted to some value. Now the logic is as follows
    1.User clicks on append button(which we have overridden)  I capture it in user command and append a blank row at end with default status in itab and do a grid->refresh_table_display()
    2.User enters values in all cells and presses ENTER , control goes to handle_data_changed method I validate and check the modified rows from ER_DATA_CHANGED->MOD_ROWS or ER_DATA_CHANGED->MOD_CELLS and update my itab with the values entered on screen and again do a grid->refresh_table_display() so the values are displayed again on the screen.
    Problem is when I give a SORT criteria or press sort say according to Year (descending) if grid already contains 2 rows and we add 3rd row with year 2009 at bottom
    Amount Year Status
    100        2007  Old
    200        2006  Old
    300        2009 New
    Then on ENTER the 3rd row goes to 1st place as it should  but the values on the 3rd row do not change!!! eg see below
    Amount Year Status
    300        2009 New
    100        2007  Old
    300        2009 New
    The problem is only when the ALV is sorted & I have a unique row index in my itab to keep track of records. I feel this is a mismatch in the frontend and backend update. Any body else have a clue why is this happening only on sort ?

    Don't do your refresh_table_display( ) until the data_changed_finished event.
    Cheers,
    Phil

  • Object ALV Grid - Line selection

    Hi all.
    Is there a way to force my grid to have allways a selected line.
    If possible I would like to see the row marker and I don't want users to be able to select more than one line.
    I tried all layout sel_mode... but I didn't find the result I desire...
    Do you have an idea ?
    Thanks a lot

    Hi,
    check this
        call method grid1->set_table_for_first_display
          exporting
            is_layout                     = gs_layout
            is_variant                    = gs_variant
            i_save                        = v_save
            i_default                     = v_default
            it_toolbar_excluding          = i_exclude[]
          changing
            it_outtab                     = i_output[]
            it_fieldcatalog               = i_fieldcat[]
          exceptions
            invalid_parameter_combination = 1
            program_error                 = 2
            too_many_lines                = 3
            others                        = 4.
        if sy-subrc ne 0.
          message id sy-msgid type sy-msgty number sy-msgno
                      with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        endif.
        call method grid1->refresh_table_display.
    * Creating object for the single clickevents
        if event_receiver_grid is initial.
          create object event_receiver_grid.
        endif.
        set handler event_receiver_grid->handle_toolbar_200 for grid1.
        call method grid1->set_toolbar_interactive.
        set handler event_receiver_grid->user_command_200 for grid1.
    module user_command_0200 input.
      call method cl_gui_cfw=>dispatch.
      case ok_code.
        when c_ddno.
          perform f__display.
        when c_exit.
          perform f_exit_program.
        when c_back.
          perform f_exit_program.
        when c_canc.
          perform f_exit_program.
        when others.
      endcase.
      clear ok_code.
    endmodule.                               " User_command_0200 INPUT
    form f_display.
      refresh: i_sel_alvrows,
               i_dblclk.
      clear :  i_sel_alvrows,
               i_dblclk,
               wa_dblclk.
      v_dbcnt = c_0.
      call method grid1->get_selected_rows
        importing
          et_index_rows = i_sel_alvrows[].
      call method cl_gui_cfw=>flush.
      describe table i_sel_alvrows lines v_dbcnt.
      if i_sel_alvrows[] is initial.
        message i176.
      endif.
      if v_dbcnt gt 1.
        message i177.         " You cannot select more that one row
      else.
        loop at i_sel_alvrows into wa_sel_alvrows.
          read table i_output into wa_output index wa_sel_alvrows-index.
          if sy-subrc eq c_0.
            move-corresponding wa_output to wa_dblclk.
            append wa_dblclk to i_dblclk.
            clear: wa_dblclk.
          endif.
        endloop.
      endif.
    endform.                                 
    aRs

Maybe you are looking for