ALV grid Enter event

Hi
I have a grid view where I can insert a new line and enter values in 2 of its columns. I wish to update other columns based on the values that the user enters in the 2 columns.
I have tried both of the following but neither gives me exactly what I want :-
        i_event_id = cl_gui_alv_grid=>mc_evt_modified.     " and
     i_event_id = cl_gui_alv_grid=>mc_evt_enter.
I want the user to be able to TAB (or mouse) between the 2 columns. After entering a value and TABing away from the column then the other columns in the row should be updated. When the user is finished experimenting with values, he hits ENTER then the 2 columns should cease to be editable (I know how to enable/disable edit on cells).
If I use mc_evt_modified then TABing between the 2 columns updates the other columns nicely. However I cannot distinguish between TAB and ENTER and so cannot switch of EDIT when the user hits ENTER.
If I use mc_evt_enter then the other columns are not updated when I TAB away. This is of course correct, but not what I want. When the user hits ENTER then everything is updated and I could switch of Edit at this point.
It looks like I need a different event to DATA_CHANGED and DATA_CHANGED_FINISH. This event should be invoked when the user hits ENTER even if nothing has changed in the Grid. I have tested DOUBLE_CLICK but it does not work.
So what I really want is for the user to see the results of his changes imeadiately (using the TAB) and then to finish the insert by hitting ENTER. Remember that since the user TABed away to see the updated columns, a subsequent ENTER will not result in a DATA_CHANGED event since the Grid is unchanged.
Perhaps I am designing a bad GUI. When does one normaly switch off EDIT on cells in a newly inserted line.
Peter

can't you add a button instead of enter to switch off EDIT ?

Similar Messages

  • How can I call functionality of ALV Grid by event of button outside grid?

    Hello,
    How can I call functionality of ALV Grid by event of button located outside ALV Grid? For example how to fire printing of this ALV Grid by button click elsewhere on the screen (not in toolbar of ALV Grid).
    Best regards,
    Josef Motl

    hi Motl,
    these are steps to create a button in ALV and trigger an event from it..
    1.Use the parameter i_callback_pf_status_set in the function module REUSE_ALV_GRID_DISPLAY
    i_callback_program = gd_repid
    i_callback_pf_status_set = 'SET_PF_STATUS'
    form set_pf_status using rt_extab type slis_t_extab.
    set pf-status 'NEWALVSTATUS'.
    endform.
    You have to copy the standard ALV pf stauts to 'NEWALVSTATUS' and add your button.
    2.You have to do the following to process the new button click.
    i_callback_user_command = 'USER_COMMAND'
    form user_command using i_ucomm like sy-ucomm
    is_selfield type slis_selfield.
    case i_ucomm.
    3. to copy the standard pf status to a new one.go to the ALV screen and take the menu System -> Status.  Then look for the standard pf status. Copy this to Z range and then add your new button.
    reward points if helpful
    regards
    satesh

  • Issue with ALV Grid and events

    Hi,
    I am creating an ALV Grid with fields Matnr,Charg,Labst,Meins. The first three fields are editable and the last (MEINS) is read only.
    Now I am trying to fill the MEINS field programmaticly after entering the MATNR and confirm with enter/return.
    I think that I have to "overload" the enter event of the alv grid to fill the MEINS everytime when a MATNR was entered. But I don't know how I could implementing this. Could you give me a hint how I could solve this problem?
    (The behavior should look like in transaction MIGO)
    Thanks

    Hi Alex
    When you press enter an event is triggerd and function code is filled in sy-ucoom or you can say in ok_code. At that time PAI event occurs. In PAI of that screen you need to check ok_code and load new data in table which you passed to ALV and also refresh the ALV.
    data: ok_code like sy-ucomm.
    PAI----screen 100
    case ok_code.
    when 'ENTER'.
    select data
    and refresh ALV
    then again call
    funtion to display ALV
    Regards
    Aditya

  • ALV Grid-- "DOUBLECLICK EVENT" doesnt work with "DATA_CHANGED_FINISHED" ??

    Hello at all,
    i have an ALV-Grid with 2 different Events.
    .....First Event: "Doubleclick"
    Second Event: "data_changed_finished"
    If i click to a column than it should be trigger the Doubleclick Event.
    And if i write some text in the column and "Press" Enter than it should be trigger the Event data_changed_finished.
    But the Problem is:
    If i click double to any column it will allways trigger the Event datachanged_finished_
    But if i replace the Event data_changed_finished with Event data_change, than it will be work.
    What can I do to resolve the Problem??
    Please give me some ideas, what i can do!!!
    With kind regards
    Ersin

    Hi,
    Try to do SET HANDLER first for Hanld_Double_Click Event then Handle Data Changed
    Thanks,
    Pramod

  • Know alv grid on event click

    Hi,
    Is it possible to know the alv grid (TYPE REF TO cl_gui_alv_grid) on the event click? In fact, on a screen, I have 2 alv grids and I would like to store the alv grid name for a process at click moment.
    Thanks.
    Edited by: Xavier Couloumies on Sep 12, 2008 2:07 PM

    you might declare two differents methods for the two grids
    PUBLIC SECTION.
      METHODS:
        HANDLE_DOUBLE_CLICK
          FOR EVENT DOUBLE_CLICK OF CL_GUI_ALV_GRID
            IMPORTING E_ROW
                      E_COLUMN,
        HANDLE_DOUBLE_CLICK2
          FOR EVENT DOUBLE_CLICK OF CL_GUI_ALV_GRID
            IMPORTING E_ROW
                      E_COLUMN.
    something like that
    then , in the implementations do something like this
    METHOD HANDLE_DOUBLE_CLICK.
         PERFORM X USING GRID = '1'.
    ENDMETHOD.
    METHOD HANDLE_DOUBLE_CLICK2.
         PERFORM X USING GRID = '2'.
    ENDMETHOD.
    and do the respective validations on that form
    hope this help

  • ALV Grid Click Event Handler

    Haw can i handle the single-click mouse event in a ALV Grid class implementation...???
    The LEFT_CLICK_RUN and RIGHT_CLICK don't help's me....
    Someone can update me...???
    Thank's...

    hi,
    you can just set all the field as hotspot , and implement the event hotspot_click.
    check the code below:
    pay attention the words in red
    REPORT  ZDAVID_ALV1.
    CLASS ZCL_EVENT_RECEIVER DEFINITION DEFERRED." Declear a custom class
    tables zemployee.
    data: ls_fcat type lvc_s_fcat,
          li_fcat type lvc_t_fcat,
          ls_layo type lvc_s_layo,
          ls_color type lvc_s_scol,
          LO_EVENT TYPE REF TO ZCL_EVENT_RECEIVER.
    data: container type ref to cl_gui_custom_container,
          grid type ref to cl_gui_alv_grid.
    types: begin of ty_emp,
      emp_x type c,
      zemp_id type zemp_id,
      zemp_name type zemp_name,
      zemp_salary type zemp_salary,
      zemp_dpart type zemp_dpart,
      rowcolor(4) type c,
      cellcolor type lvc_t_scol,
      end of ty_emp.
    data: emp type table of ty_emp,
          wa_emp type ty_emp,
          wcellcolor type lvc_s_scol.
    call screen 9000.
    CLASS ZCL_EVENT_RECEIVER DEFINITION." class definition
      PUBLIC SECTION.
        methods:
          handle_single_click
             for event hotspot_click of cl_gui_alv_grid
               importing
                 e_row_id es_row_no e_column_id.
      PRIVATE SECTION.
    ENDCLASS.                    "LCL_EVENT_RECEIVER DEFINITION
    *   LCL_EVENT_RECEIVER (DEFINITION)
    *  ===============================================================
    *   LOCAL CLASSES: IMPLEMENTATION
    *  ===============================================================
    *   CLASS LCL_EVENT_RECEIVER (IMPLEMENTATION)
    *   IN THIS EXAMPLE, ONLY EVENT DOUBLE_CLICK IS CAUGHT
    CLASS ZCL_EVENT_RECEIVER IMPLEMENTATION." implementation
    method handle_single_click.
         message e_column_id-fieldname type 'I'.
       endmethod.
    ENDCLASS.                    "LCL_EVENT_RECEIVER IMPLEMENTATION
    form sub_get_data.
      select * from zemployee into corresponding fields of wa_emp.
        wa_emp-emp_x = 'X'.
        if wa_emp-zemp_id = '171184'.
    "        wa_emp-rowcolor = 'C610'.
           wcellcolor-fname = 'ZEMP_ID'.
           wcellcolor-color-col = '7'.
           wcellcolor-color-int = '1'.
           append wcellcolor to wa_emp-cellcolor.
          ENDIF.
        append wa_emp to emp.
        CLEAR WA_EMP. clear wcellcolor.
        endselect.
      endform.
    form sub_create_obj.
      if container is initial.
        create object container
         exporting
           container_name = 'MYCONT'.
       endif.
       if grid is initial.
         create object grid
          exporting
            i_parent = container.
        endif.
      endform.
    form sub_call_alv.
        call method grid->set_table_for_first_display
        exporting
          is_layout                     = ls_layo
        changing
          it_outtab                     = emp
          it_fieldcatalog               = li_fcat
          "it_sort                       = i_sort2
        exceptions
          invalid_parameter_combination = 1
          program_error                 = 2
          too_many_lines                = 3
          others                        = 4.
        if sy-subrc <> 0.
          endif.
        create object lo_event.
        set handler lo_event->handle_single_click for grid." set handler
      endform.
    form sub_fcat.
      clear ls_fcat.
      ls_fcat-fieldname = 'EMP_X'.
      ls_fcat-coltext = 'Check'.
      ls_fcat-checkbox = 'X'.
      ls_fcat-edit = 'X'.
      ls_fcat-hotspot = 'X'." hotspot
      append ls_fcat to li_fcat.
      clear ls_fcat.
      ls_fcat-fieldname = 'ZEMP_ID'.
      ls_fcat-coltext = 'ID'.
      append ls_fcat to li_fcat.
      clear ls_fcat.
      ls_fcat-fieldname = 'ZEMP_NAME'.
      ls_fcat-coltext = 'Name'.
      append ls_fcat to li_fcat.
      clear ls_fcat.
      ls_fcat-fieldname = 'ZEMP_SALARY'.
      ls_fcat-coltext = 'Salary'.
      ls_fcat-do_sum = 'X'.
      append ls_fcat to li_fcat.
      clear ls_fcat.
      ls_fcat-fieldname = 'ZEMP_DPART'.
      ls_fcat-coltext = 'Department'.
      ls_fcat-drdn_hndl = '1'.
      ls_fcat-edit = 'X'.
      append ls_fcat to li_fcat.
      clear ls_fcat.
      endform.
    form sub_layout.
      ls_layo-zebra = 'X'.
      ls_layo-INFO_FNAME = 'ROWCOLOR'.
      endform.
    module pbo output.
       perform sub_get_data.
       perform sub_fcat.
       perform sub_layout.
       perform sub_create_obj.
       perform sub_drop.
       perform sub_call_alv.
      endmodule.
    module pai input.
      data: ok_code type sy-ucomm.
      case ok_code.
        when 'SHOW'.
          MESSAGE 'D' TYPE 'I'.
        WHEN 'EXIT'.
          leave program.
        WHEN OTHERS.
          ENDCASE.
      clear ok_code.
      endmodule.
    form sub_drop.
      data: wa_drop type lvc_s_drop,
            drop type lvc_t_drop.
      wa_drop-handle = '1'.
      wa_drop-value = 'Dev'.
      append wa_drop to drop.
      clear wa_drop.
      wa_drop-handle = '1'.
      wa_drop-value = 'Testing'.
      append wa_drop to drop.
      clear wa_drop.
      wa_drop-handle = '1'.
      wa_drop-value = 'Admin'.
      append wa_drop to drop.
      clear wa_drop.
      wa_drop-handle = '1'.
      wa_drop-value = 'NSS'.
      append wa_drop to drop.
      clear wa_drop.
      wa_drop-handle = '1'.
      wa_drop-value = 'Finance'.
      append wa_drop to drop.
      clear wa_drop.
      call method grid->set_drop_down_table
        EXPORTING
          it_drop_down = drop.
      endform.
    *&      Module  set_gui  OUTPUT
    *       text
    MODULE set_gui OUTPUT.
      set pf-status 'PF_GUI'.
    ENDMODULE.                 " set_gui  OUTPUT

  • Alv grid key event

    Hi,
    is it possible to register key press event in alv grid ? I want to detect ctrl button was pressed than call same action.
    help
    thx
    Message was edited by:
            mk kn

    Hi,
    did you find a solution? I have the same question.

  • Check_changed_data method on editable ALV Grid ( class cl_gui_alv_grid)

    Hi guys,
    I use the following method (register_edit_event) in the PBO soon after first display of an editable ALV grid to register enter as an event to do validations on fields like qty. If user enters some character like 'abc' for qty and hits enter on keyboard, ALV grid pop's up a standard message ( I haven't coded for this.Since I use DDIC structure in field catalog, the Std. ALV program takes care of it. ). THis takes care of the validation before I click on save.
    call method alv_grid->register_edit_event
                            exporting
                               i_event_id = cl_gui_alv_grid=>mc_evt_enter.
    This works fine. But I want this validation to run when I also click the SAVE button of the screen. Is it possible to run this standard validation in my PAI event eg. SAVE ? I thought I will be, by calling the method check_changed_data in my PAI event. But this is doing nothing. Does this method conflict with register_edit_event or something ? So , basically what I am looking for is to trigger the event or call the method which does the same work as the "check" button on ALV grid.
    Any advice or tips or sample code is greatly appreciated.
    Thanks,
    Shareen

    Hi Shareen,
    Handle the data_changed event in the grid.
    Whenever you make changes in the data in ALV Grid this event would be triggered. Here you can perform additional validations that you may need to perform.
        METHODS handle_data_changed
          FOR EVENT data_changed OF cl_gui_alv_grid
          IMPORTING er_data_changed.
    Implementation:
      METHOD handle_data_changed.
        PERFORM validations USING er_data_changed.
      ENDMETHOD.
    FORM validations USING er_data_changed TYPE REF TO cl_alv_changed_data_protocol.
      DATA: ls_good TYPE lvc_s_modi.
      DATA  wa LIKE LINE OF lt_good_cells.
      CALL METHOD g_grid->register_edit_event
        EXPORTING
          i_event_id = cl_gui_alv_grid=>mc_evt_modified.
      LOOP AT er_data_changed->mt_good_cells INTO ls_good.
        CASE ls_good-fieldname.
        WHEN 'FIELDNAME'. "Your fieldname
            CALL METHOD er_data_changed->get_cell_value "Get the changed value
              EXPORTING
                i_row_id    = ls_good-row_id
                i_fieldname = ls_good-fieldname
              IMPORTING
                e_value     = temp. "Your temp variable
            "Make your validations here.
        ENDCASE.
    Ps: Reward points if helpful.
    Regards,
    Wenceslaus.

  • ALV Grid - Add/Delete/Change Values

    Hi,
    I have an ALV Grid with editable fields. I know want to process the changed, deleted and added lines.
    Is it not possible to get the shown ALV table back?
    In the event DATA CHANGED I have only attributes and methods of CL_ALV_CHANGED_DATA_PROTOCOL. So I have a method to get deleted, changed and added rows. But this event is only thrown, when I press enter or something else, but not when I´m pressing the icon for "add" or "delete".
    End when the event is thrown, i´m only getting the changed data. In some case it´s not possible to react in the right way.
    For example:
    I have an internal table with 5 lines. I now build the alv grid with that table. When I´m now adding a line with the "add" Icon, the event is not thrown. But if I press enter, I can handle the event. In the event methods I now have one line in added data. But when I´m deleting and adding again, it sometimes "forget" some actions I have done. Isn´t there a better way to compare the changed data in ALV with my "real" internal table?
    Next example:
    If I´m adding a new line to the alv, I can compare the key of that line with the exisiting keys of my internal table. If the user has typed in a line with the same key, I can throw and error message.
    But when the user is changing a line it should be possible to update that line. But how to compare, if the line is a new addewd line or a changed line?
    I hope it´s not too complicated to understand!
    Reward points guaranteed!

    As we can now make our ALV Grid editable we may require controlling input data. 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. Here are some of those methods:
    get_cell_value: Gets the cell value. You pass the address of the cell to the interface.
    modify_cell : Modifies the cell value addressed via parameters.
    add_protocol_entry : Add a log entry. You make use of standard message interface with message type, message id, etc…
    protocol_is_visible : Make the error table visible or not.
    refresh_protocol : Refreshing log entries.
    Table 16 – Methods to use for controlling data changes
    With the reference of the instance, you can reach information about modifications. These useful attribute tables are:
    MT_MOD_CELLS
    Contains addresses of modified cells with “row_id”s and “fieldname”s.
    MP_MOD_ROWS
    Contains modified rows. Its type is generic.
    MT_GOOD_CELLS
    Contains cells having proper values
    MT_DELETED_ROWS
    Contains rows deleted from the list
    MT_INSERTED_ROWS
    Contains rows inserted to the list
    Rgds
    Mohit

  • Displaying items in a single line in ALV grid using  ALV_TOP_OF_PAGE.

    Hello Guys,
    I am having a problem in displaying items in a single line in the ALV Grid using event ALV_TOP_OF_PAGE.
    My requirement is to group items on a single line i.e. in the example below, Vendor code and posting date are on the same line. The next line the prints Vendor Name and Document no.
    Vendor Code: 123123                               Posting Date : 01.01.2011
    Vendor Name: ABCD                                 Document No: 152246598.
    Here is my code in subroutine 'ALV_TOP_OF_PAGE', 
      wa_list_comments-typ = 'S'. 
      wa_list_comments-key = ''.
      wa_list_comments-info = 'Vendor Code'.
      APPEND wa_list_comments TO it_list_comments.
      wa_list_comments-typ = 'S'. 
      wa_list_comments-key = ''.
      wa_list_comments-info = 'Posting Date'.
      APPEND wa_list_comments TO it_list_comments.
    The above code prints in the following format i.e one below the other,
    Vendor Code: 123123                              
    Posting Date : 01.01.2011.
    I also tried using HTML_TOP_OF_PAGE, but it didn't work.
    Can anybody please help me out with this.
    Regards,
    Danish.

    Hi Danish,
    Your problem is with the alignment and you need some fix positions .
    The solution i feel is u can use as below :
    In CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    use 
    i_callback_html_top_of_page       = 'HTML_TOP_OF_PAGE'.
    Now on calling routine call use cl_dd_document class :
    FORM html_top_of_page USING document TYPE REF TO cl_dd_document .
    data : doctable TYPE REF TO cl_dd_table_element,
              col1_t1 TYPE REF TO cl_dd_area,
              col2_t1 TYPE REF TO cl_dd_area,
              col1_t2 TYPE REF TO cl_dd_area,
              col2_t2 TYPE REF TO cl_dd_area.
    add quick table with five columns
        CALL METHOD lw_document->add_table
          EXPORTING
            no_of_columns               = 2
            border                      = '0'
         cell_background_transparent = ' '
            width                       = '100%'
          IMPORTING
            table                       = doctable.
    Filling columns in row
        CALL METHOD doctable->add_column
          EXPORTING
            width  = '40%'
          IMPORTING
            column = col1_t1.
    Filling columns in row
        CALL METHOD doctable->add_column
          EXPORTING
            width  = '60%'
          IMPORTING
            column = col2_t1.* Filling columns in row
    Call method doctable->new_row.
        CALL METHOD doctable->add_column
          EXPORTING
            width  = '40%'
          IMPORTING
            column = col1_t2.
    Filling columns in row
        CALL METHOD doctable->add_column
          EXPORTING
            width  = '60%'
          IMPORTING
            column = col2_t2.
    *Now adding the texts
    lw_text1 = 'your first text'
    CALL METHOD col1_t1->add_text
          EXPORTING
            text = lw_text.
    *Similarly add text for other columns
    *Adujust % in width to adjust the column as required
    Endform.
    Hope this will solve your problem .

  • 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

  • How to trigger ENTER event in oo ALV grid

    Hi,
    Can anybody help me out in catching the ENTER event in the oo ALV Grid. My requirement is as follows,
    I have oo ALV Grid displaying hell lot of columns, in that vendor number column is an editable field so when the user enters the vendor number the immediate next cell showing the vendor name should be populated with the corresponding name as soon as he press enter button, I have search help also for vendor field.
    Please give me some sample program which i can just do the copy+paste sort of as today is the deadline for the object.
    Regards,
    Suman

    Hi,
    This example is working. Please try this one.
    CLASS lcl_event_receiver DEFINITION.
       PUBLIC SECTION.
         CLASS-METHODS:
          handle_data_changed
          FOR EVENT data_changed OF cl_gui_alv_grid
          IMPORTING er_data_changed e_onf4 e_ucomm.
    ENDCLASS. "lcl_event_receiver DEFINITION
    *       CLASS lcl_event_receiver IMPLEMENTATION
    CLASS lcl_event_receiver IMPLEMENTATION.
       METHOD handle_data_changed.
         DATA : modi TYPE TABLE OF lvc_s_modi  ,
               modis TYPE lvc_s_modi,
               wa LIKE LINE OF git_alv_items,
               lv_matnr TYPE matnr.
         modi = er_data_changed->mt_mod_cells .
         LOOP AT modi INTO modis WHERE fieldname = 'MATNR'.
           MOVE modis-value TO lv_matnr.
           CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
             EXPORTING
               input        = lv_matnr
             IMPORTING
               output       = lv_matnr
             EXCEPTIONS
               length_error = 1
               OTHERS       = 2.
           READ TABLE git_alv_items INTO wa INDEX modis-row_id .
           IF sy-subrc = 0.
             SELECT SINGLE maktx FROM makt
               INTO wa-maktx
              WHERE matnr = lv_matnr
                AND spras = sy-langu.
             MODIFY git_alv_items FROM wa INDEX modis-row_id.
           ENDIF.
         ENDLOOP.
         IF sy-subrc = 0.
           CALL METHOD alv_grid->refresh_table_display
             EXPORTING
               is_stable = gs_stbl.
         ENDIF.
       ENDMETHOD.                    "handle_data_changed
    ENDCLASS. "lcl_event_receiver IMPLEMENTATION
    DATA : eventreceiver TYPE REF TO lcl_event_receiver.
    SET HANDLER eventreceiver->handle_data_changed FOR alv_grid.
           CALL METHOD alv_grid->set_table_for_first_display
             EXPORTING
               i_save                        = 'A'
               is_layout                     = layo_alv
               i_bypassing_buffer            = 'X'
               i_buffer_active               = ''
             CHANGING
               it_outtab                     = git_alv_items
               it_fieldcatalog               = fcat_alv
             EXCEPTIONS
               invalid_parameter_combination = 1
               program_error                 = 2
               too_many_lines                = 3
               OTHERS                        = 4.
           CALL METHOD alv_grid->register_edit_event
             EXPORTING
               i_event_id = cl_gui_alv_grid=>mc_evt_enter.

  • 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

  • How to capture the event in ALV grid display?

    Hi experts,
      How to capture the event in an ALV grid display which is editable. I have to capture the TAB key or ENTER key.
    regards,
    Arul Jothi.

    Hi Arul,
    Take a look at sample program BCALV_EDIT_03. (Find string "register ENTER" in the program to see how to register)
    Basically you have to Register edit events using method call REGISTER_EDIT_EVENT and then write a handler method for event DATA_CHANGED..
    If you are using a REUSE..GRID fm then first get the grid reference using function module GET_GLOBALS_FROM_SLVC_FULLSCR and then repeat the above procedure..
    Hope this helps..
    Sri
    Message was edited by: Srikanth Pinnamaneni

  • Handling events in ALV grid

    hi,
    Hi,
    I am displaying some fields from VBAP in ALV gid and have give drop down check box to storage location making it editable  so  if the user changes Storage location  of
    some entries and clicks SAVE button, when we click save button i need to capture all the rows that were been changed and update VA02 using these records through bapi.
    but iam not able to capture this SAVE event but iam able to capture Enter and cursor event.
    i have written following code for this
    LOCAL CLASSES: Definition
    class lcl_event_receiver: local class to handle event CLASS lcl_event_receiver DEFINITION.
      PUBLIC SECTION.
        METHODS:
          handle_data_changed
             FOR EVENT data_changed OF cl_gui_alv_grid
                 IMPORTING er_data_changed.
      PRIVATE SECTION.
    ENDCLASS.                    "lcl_event_receiver DEFINITION
    LOCAL CLASSES: Implementation
    class lcl_event_receiver (Implementation)
    CLASS lcl_event_receiver IMPLEMENTATION.
        METHOD handle_data_changed.
        DATA: l_error_in_data TYPE c.
        PERFORM handle_data_changed USING er_data_changed l_error_in_data.
    *§7.Display application log if an error has occured.
        IF l_error_in_data EQ 'X'.
          CALL METHOD er_data_changed->display_protocol.
        ENDIF.
      ENDMETHOD.                    "handle_data_changed
    ENDCLASS.                    "lcl_event_receiver IMPLEMENTATION
    *&      Form  handle_data_changed
         Identify columns which were changed and check input
         -->P_ER_DATA_CHANGED  text
    FORM handle_data_changed  USING  p_er_data_changed
                              TYPE REF TO cl_alv_changed_data_protocol
                              p_error_in_data TYPE c.
      DATA : lw_mod_cell TYPE lvc_s_modi ,
             l_value TYPE lvc_value ,
             l_lgort TYPE lgort_d.
      SORT p_er_data_changed->mt_mod_cells BY row_id .
      LOOP AT p_er_data_changed->mt_mod_cells INTO lw_mod_cell
                              WHERE fieldname = 'LGORT'.
        CALL METHOD p_er_data_changed->get_cell_value
          EXPORTING
            i_row_id    = lw_mod_cell-row_id
            i_fieldname = 'LGORT'
          IMPORTING
            e_value     = l_value.
        SELECT SINGLE lgort FROM t001l INTO l_lgort WHERE werks = p_werks
                                                    AND   lgort = l_value.
        IF sy-subrc NE 0.
    In case of error, create a protocol entry in the *application log.
          CALL METHOD p_er_data_changed->add_protocol_entry
            EXPORTING
              i_msgid     = '0K'
              i_msgno     = '000'
              i_msgty     = 'E'
              i_msgv1     = text-003
              i_msgv2     = l_value
              i_msgv3     = text-004
              i_fieldname = lw_mod_cell-fieldname
              i_row_id    = lw_mod_cell-row_id.
          p_error_in_data  = 'X'.
          EXIT.
        ELSE.
    *§5b.If the value is valid change values of
       cells.
          CALL METHOD p_er_data_changed->modify_cell
            EXPORTING
              i_row_id    = lw_mod_cell-row_id
              i_fieldname = lw_mod_cell-fieldname
              i_value     = l_value.
          READ TABLE t_list1 INTO w_list1 INDEX lw_mod_cell-row_id.
          IF sy-subrc EQ 0.
    *comparing old value with the changed value
            IF w_list1-lgort <> l_value.
              MOVE:      w_list1-werks  TO w_list3-werks,
                         w_list1-matnr  TO w_list3-matnr,
                         w_list1-arktx  TO w_list3-arktx,
                         w_list1-vbeln  TO w_list3-vbeln,
                         w_list1-posnr  TO w_list3-posnr,
                         w_list1-pstyv  TO w_list3-pstyv,
                         w_list1-vstel  TO w_list3-vstel,
                         w_list1-auart  TO w_list3-auart,
                         w_list1-kwmeng TO w_list3-kwmeng,
                         w_list1-vrkme  TO w_list3-vrkme,
                         w_list1-mbdat  TO w_list3-mbdat,
                         l_value        TO w_list3-lgort.
              APPEND w_list3 TO t_list3.
    *t_list3 will contain all the records that are changed
              CLEAR w_list3.
            ENDIF.
          ENDIF.
        ENDIF.
      ENDLOOP.
    *&      Module  STATUS_0100  OUTPUT
          text
    MODULE status_0100 OUTPUT.
      SET PF-STATUS 'MAIN100'.
      SET TITLEBAR 'MAIN100'.
      IF go_custom_container IS INITIAL.
    create a custom container control for our ALV Control
        CREATE OBJECT go_custom_container
          EXPORTING
            container_name              = g_cont_on_main
                EXCEPTIONS
                    cntl_error = 1
                    cntl_system_error = 2
                    create_error = 3
                    lifetime_error = 4
                    lifetime_dynpro_dynpro_link = 5.
        IF sy-subrc NE 0.
    Display error message.
          CALL FUNCTION 'POPUP_TO_INFORM'
            EXPORTING
              titel = sy-repid
              txt2  = sy-subrc
              txt1  = 'The control could not be created'.
        ENDIF.
    create an instance of alv control
        CREATE OBJECT go_grid
          EXPORTING
            i_parent          = go_custom_container.
    *If display or change radio button is cheked
        IF ( p_chng = 'X' OR p_disp = 'X' ) .
    Set a titlebar for the grid control
          g_layout-grid_title = 'Sales Orders'.
          g_layout-excp_fname = 'TRAFFIC_LIGHT'.
    Define a drop down table.
          PERFORM set_drdn_table.
          CALL METHOD go_grid->set_table_for_first_display
            EXPORTING
              is_layout                     = g_layout
            CHANGING
              it_outtab                     = t_list1
              it_fieldcatalog               = t_fieldcat1
            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.
        ENDIF.
    register ENTER and CURSOR 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.
        CALL METHOD go_grid->register_edit_event
          EXPORTING
            i_event_id = cl_gui_alv_grid=>mc_evt_modified.
        CREATE OBJECT g_event_receiver.
        SET HANDLER g_event_receiver->handle_double_click  FOR go_grid.
        SET HANDLER g_event_receiver->handle_hotspot_click FOR  go_grid .
        SET HANDLER g_event_receiver->handle_data_changed  FOR  go_grid .
      ENDIF.
      CALL METHOD cl_gui_control=>set_focus
        EXPORTING
          control = go_grid.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
          text
    MODULE user_command_0100 INPUT.
      ok_code = sy-ucomm.
      CASE ok_code.
        WHEN 'EXIT'.
          PERFORM exit_program.
        WHEN 'SAVE'.
          PERFORM update_sales_order using t_list3[].
    endcase.
    Thanks in Advance,
    Siri

    Hi Sirisha,
              You can get the event code for Enter because you have regitered in the event reciever .
    But for the SAVE you will have to set in the PF-status of the screen and not the ALV-grid save .
    Please award if helpful.

Maybe you are looking for

  • FCP 5 RT sequences now have to be rendered in FCP 6?

    Hi: We upgraded from Final Cut Studio 1 to FCS 2 a week ago to upgrade Final Cut Pro to 6.0.4 to be able to read XDCAM EX clips a client sent us. That all worked fine. But I'm encountering problems when I open older projects and sequences. Our main f

  • BI same as BW

    Hi, I am new in SAP area and have a very simple questions for experts out there.  Is BI same as BW?  It seems like BI covers all the BW area? I am actually looking to take a class offered in my area.  They are marketing it as BW/BI class.  I want to

  • Using weblogic as web server for Enterprise Manager can someone pls help?

    hello, can i have your help on this? i want to use Weblogic as web server instead of apache in the structure of Enterprise Manager 10g R3? have any of you try this? can someone please provide me some link related to how to configure Weblogic as web s

  • HT3302 Ipod nano 5th gen not responding

    Can someone please let me know what should I do. I have the Ipod freeze actually. I already hold menu and center botton for more than 6 sec and still not responding...I have the nano 5th generation and so many music in it that I am worry. Thank you!

  • Airport/G4 Disconnect

    Since upgrading to System 10.4 my PowerMac G4 disconnects from Airport anytime the computer goes to sleep. I must always go to the Airport icon at the top of my screen to reconnect. Is this normal for 10.4? PowerMac G4   Mac OS X (10.4.5)   Airport 2