Catching "RETURN" Key on a ALV Grid

Good Morning,
I have a ALV grid which can be updated with values. I need to trigger code after i update one field in the ALV. How can i do that?
Should i use function REUSE_ALV_EVENTS_GET?
Regards,
Pedro Gaspar

Hi
1. Things won't work if we do normal things.
2. The important things are :
a) New PF-STATUS is required , say 'ABCD'.
b) Handle user_commmand
3. First of all, from Function group SALV,
copy the STANDARD gui status to your program,
from SE80, by right clicking.
4. come to your program.
start-of-selection.
SET PF-STATUS 'ABCD'.
5. Double click ABCD and activate the gui status.
6. In gui status,
in those green buttons and yellow buton,
write BACK1 in both.
ie. buttons with fcode BACK1.
Save and activate.
6. AT USER-COMMAND.
IF sy-ucomm = 'BACK1'.
DATA : answer TYPE c.
CALL FUNCTION 'POPUP_TO_CONFIRM'
EXPORTING
titlebar = 'Do You Want To Exit ?'
text_question = 'Do You Want To Exit ?'
IMPORTING
answer = answer
EXCEPTIONS
text_not_found = 1
OTHERS = 2.
IF answer = '1'.
SET USER-COMMAND 'BACK'.
ENDIF.
ENDIF.
This will solve your problem.
I tried at my end, it works fantastic.
<b>Reward if usefull</b>

Similar Messages

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

  • Foreign Key check in ALV Grid

    Hi all.
    I'm trying to have data automatically validated using Foreign Keys in an (editable) ALV Grid.  I managed to get the proper values in a dropdown on F4, but i want the manual entries validated without coding every field individually.
    The field in question is LFA1-REGIO.  This field has a Foreign Key in T005S.  I'm using F.M. DDIF_TABL_GET to populate my Field Catalog.  This gives me all Foreign Key fields for my fields.
    If the user enters 'ZZ' as a Region(LFA1-REGIO), the auto-validation of CL_GUI_ALV_GRID does not recognize that this value is invalid.
    I've debugged the class methods that handle the validation, but it seems the problem is in the way i'm setting up my Foreign Key info.
    Could someone tell me how to set this up properly?  i also have access to the dependant field LAND1, and would like to integrate it in the Validation, but this is a second priority.  Thanks in advance.

    Hi Jester,
      In your ALV Grid Field Catalog (LVC_S_LAYO), for REGIO check whether field <b>checktable</b> has value T005S and <b>ref_field</b> has REGIO and <b>ref_table</b> has LFA1.
      If the above entries are fine and still the validation does not occur then try changing the ref_table to T005S and see..
      Hope this helps..
    Sri

  • Display listbox key value in ALV GRID method

    Hi All,
    I have a program in which columns are generted dynamically based on number of fields. The column name is dynamic as it depends on its text while The value in Column's can be 1, 2, 3, 4, 5.
    I am trying to display this in a list box along with the text which are maintained as fixed values at domain level.
    space Walking
    1       Archery   
    2       Boxing
    3       Cycling
    4       Rowing
    Also I am displaying by using 'DD_DOMVALUEs_GET, looping through all the fixed values and concatenate
    domvalue_l   ddtext separated by cl_abap_char_utilities=>horizontal_tab. No tab space is coming between key and value.
    Also for the 1st value which is space it is not coming properly as space is condensed.
    The point is that after I am putting values in the grid. The system event data changed is called where the value selected is  1 Archery and it is going to bad cells, error protocol display . I want only the 1st character. How to modify the content in the grid before the system event gets called.
    Regards,
    DPM

    Hi,
    try follow code to setup fieldcat of that DROP DOWN field.
    FCAT-DOMNAME = ' '.
    FCAT-CHECKTABLE= '!'.

  • ALV Grid: event for user return in ALV Grid Control

    Hi developers,
    i'm wanna do something after a user has pressed the return button in a alv grid control. For that i need probably a event. But i can not find a proper event in the documentation. Could one of you guys help me?
    Best regards christian

    Hi Christian
    ALV grid is an encapsulated object, so it seems there is no way, you ought to implement the data_changed event. So if you want to make bulk data input and after trigger the event by pressing the return key, you should make the ALV Grid get your changes after pressing the key but not after a cell change of a modified cell.
    To set this attribute:
    CALL METHOD gr_alvgrid->register_edit_event
         EXPORTING i_event_id = cl_gui_alv_grid=>mc_evt_enter .
    This way "data_changed" event will be triggered whenever you press the return key while editing.
    For some more information you can also refer to the tutorial <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/documents/a1-8-4/an%20easy%20reference%20for%20alv%20grid%20control.pdf">"An Easy Reference for ALV Grid Control"</a>.
    Regards
    *--Serdar <a href="https://www.sdn.sap.com:443http://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.sdn.businesscard.sdnbusinesscard?u=qbk%2bsag%2bjiw%3d">[ BC ]</a>

  • ALV Grid: event for return

    Hi developers,
    i'm wanna do something after a user has pressed the return button in a alv grid control. For that i need probably a event. But i can not find a proper event in the documentation. Could one of you guys help me?
    Best regards christian

    You should post your question in the ABAP forum

  • ALV grid display-my columns are multiplying.

    I have been searching for the solution for my small problem..So I hope this question hasn`t been asked before.
    I have an ALV grid in a pop up display using 'REUSE_ALV_GRID_DISPLAY'.
    I have an input field on my screen that helps me display only certain keys on my alv grid.
    When I input for example key 2 it shows all the correct products for that key 2.
    When I try to enter another key....it shows the correct products but each column is duplicated. So each time I input something and hit 'Show' each column in that table is duplicated again.
    Tried REFRESH, CLEAR my internal table....but I haven`t been able to make it work.
    Did this happen to anybody ?
    Newbie Ilinca
    my input module for that screen:
    when 'SHOW'.
           select col1 col2....
               into corresponding fields of table it_display
               from ztable
              where col1 = ztable2-col1.
    CLEAR ls_fieldcatlog.
      ls_fieldcatlog-row_pos   = '1'.
      ls_fieldcatlog-col_pos   = '1'.
      ls_fieldcatlog-fieldname = 'COL1'.
      ls_fieldcatlog-tabname   = 'IT_DISPLAY'.
      ls_fieldcatlog-seltext_m = 'Infotype'.
      APPEND ls_fieldcatlog TO lt_fieldcatlog.
      CLEAR ls_fieldcatlog.
      ls_fieldcatlog-row_pos   = '1'.
      ls_fieldcatlog-col_pos   = '2'.
      ls_fieldcatlog-fieldname = 'COL2'.
      ls_fieldcatlog-tabname   = 'IT_DISPLAY'.
      ls_fieldcatlog-seltext_m = 'Infotype'.
      APPEND ls_fieldcatlog TO lt_fieldcatlog.
    noloyo-zebra = 'X'.
    noloyo-colwidth_optimize = 'X'.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program    = sy-repid
          i_grid_title          = 'INFOTYPE DETAILS'
          is_layout             = noloyo
          it_fieldcat           = lt_fieldcatlog
          i_screen_start_column = 10
          i_screen_start_line   = 20
          i_screen_end_column   = 100
          i_screen_end_line     = 40
        TABLES
          t_outtab              = it_display
        EXCEPTIONS
          program_error         = 1
          OTHERS                = 2.
    AND MY DECL:
    TYPES: BEGIN OF type_com,
          col1TYPE ztable-col1,
          col2TYPE ztable-col2,
           END OF type_com.
    DATA : it_display TYPE STANDARD TABLE OF type_com.

    Hi ilinktrinel;
    Please try to below code
    first way;
    refresh lt_fieldcatlog. "add only this row
    CLEAR ls_fieldcatlog.
    ls_fieldcatlog-row_pos = '1'.
    ls_fieldcatlog-col_pos = '1'.
    ls_fieldcatlog-fieldname = 'COL1'.
    ls_fieldcatlog-tabname = 'IT_DISPLAY'.
    ls_fieldcatlog-seltext_m = 'Infotype'.
    APPEND ls_fieldcatlog TO lt_fieldcatlog.
    CLEAR ls_fieldcatlog.
    ls_fieldcatlog-row_pos = '1'.
    ls_fieldcatlog-col_pos = '2'.
    ls_fieldcatlog-fieldname = 'COL2'.
    ls_fieldcatlog-tabname = 'IT_DISPLAY'.
    ls_fieldcatlog-seltext_m = 'Infotype'.
    second way;
    if lt_fieldcatlog is initial. "add this row
    CLEAR ls_fieldcatlog.
    ls_fieldcatlog-row_pos = '1'.
    ls_fieldcatlog-col_pos = '1'.
    ls_fieldcatlog-fieldname = 'COL1'.
    ls_fieldcatlog-tabname = 'IT_DISPLAY'.
    ls_fieldcatlog-seltext_m = 'Infotype'.
    APPEND ls_fieldcatlog TO lt_fieldcatlog.
    CLEAR ls_fieldcatlog.
    ls_fieldcatlog-row_pos = '1'.
    ls_fieldcatlog-col_pos = '2'.
    ls_fieldcatlog-fieldname = 'COL2'.
    ls_fieldcatlog-tabname = 'IT_DISPLAY'.
    ls_fieldcatlog-seltext_m = 'Infotype'.
    endif. "add this row
    Best regards.

  • ALV Grid/Tree in Dialog Popup

    Hi,
    I have requirement whereby I display an partially filled ALV Grid.
    To populate a specific field of the ALV I need to pop-up a dialog form on which is displayed either another ALV Grid or preferably an ALV Tree.
    The data behind the Dilog ALV/Tree is a table of Parent-Child relationships.
    The user will either navigate the ALV Grid by clicking on a 'Parent' and refreshing the ALV with the Children etc or do the same by expanding nodes on the ALV Tree.
    When the user has reached the lowest level of the 'hierarchy' this value is returned to the initial ALV Grid.
    I have had a look around the ABAP and OO Demo's and in the Weblogs etc on SDN.
    However I cannot seem to 'manipulate' these into my specific requirements.
    Ideally, I need to create either a FM or Class/Method which takes as input the above table of relationships, displays the dilog and then returns the selected child.
    My questions are:
      Can this be done?
      Which is the best way for me to approach this?
    Thanks,
    Martin

    Hi,
    I have requirement whereby I display an partially filled ALV Grid.
    To populate a specific field of the ALV I need to pop-up a dialog form on which is displayed either another ALV Grid or preferably an ALV Tree.
    The data behind the Dilog ALV/Tree is a table of Parent-Child relationships.
    The user will either navigate the ALV Grid by clicking on a 'Parent' and refreshing the ALV with the Children etc or do the same by expanding nodes on the ALV Tree.
    When the user has reached the lowest level of the 'hierarchy' this value is returned to the initial ALV Grid.
    I have had a look around the ABAP and OO Demo's and in the Weblogs etc on SDN.
    However I cannot seem to 'manipulate' these into my specific requirements.
    Ideally, I need to create either a FM or Class/Method which takes as input the above table of relationships, displays the dilog and then returns the selected child.
    My questions are:
      Can this be done?
      Which is the best way for me to approach this?
    Thanks,
    Martin

  • ALV Grid and return to selection screen

    Hello
    I have an ALV Grid and when I push a buttom that I program appears another ALV Grid. In this second ALV I try to program different buttoms. When I program the BACK buttom I want to go to selection screen.
    I try with CALL SELECTION SCREEN but when I stay in selection screen and push the execute buttom the ALV that I see is the second, not the first. It seems that we don't catch the news selections.
    I put rs_selfied-refresh = 'X' after the CALL SELECTION SCREEN but is wrong again.
    What can I do????

    Hello Silvia
    There is a simple trick to return from the second ALV list directly back to the selection screen:
    *& Report  ZUS_SDN_REUSE_ALV_GRID_DISPLAY
    REPORT  zus_sdn_reuse_alv_grid_display.
    TYPE-POOLS: slis.
    DATA:
      gt_t001        TYPE STANDARD TABLE OF t001,
      gt_knb1        TYPE STANDARD TABLE OF knb1.
    DATA:
      gs_fcat        TYPE slis_fieldcat_alv,
      gt_fcat_t001   TYPE slis_t_fieldcat_alv,
      gt_fcat_knb1   TYPE slis_t_fieldcat_alv.
    PARAMETERS:
      p_bukrs        TYPE bukrs  DEFAULT '1000'.
    START-OF-SELECTION.
      SELECT * FROM  t001 INTO TABLE gt_t001.
      CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
        EXPORTING
    *     I_PROGRAM_NAME               =
    *     I_INTERNAL_TABNAME           =
          i_structure_name             = 'T001'
    *     I_CLIENT_NEVER_DISPLAY       = 'X'
    *     I_INCLNAME                   =
    *     I_BYPASSING_BUFFER           =
    *     I_BUFFER_ACTIVE              =
        CHANGING
          ct_fieldcat                  = gt_fcat_t001
        EXCEPTIONS
          inconsistent_interface       = 1
          program_error                = 2
          OTHERS                       = 3.
      IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
    *     I_INTERFACE_CHECK                 = ' '
    *     I_BYPASSING_BUFFER                = ' '
    *     I_BUFFER_ACTIVE                   = ' '
          i_callback_program                = syst-cprog
          i_callback_pf_status_set          = 'ALV_SET_PF_STATUS'
          i_callback_user_command           = 'ALV_USER_COMMAND'
    *     I_CALLBACK_TOP_OF_PAGE            = ' '
    *     I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
    *     I_CALLBACK_HTML_END_OF_LIST       = ' '
    *     I_STRUCTURE_NAME                  = ' '
    *     I_BACKGROUND_ID                   = ' '
    *     I_GRID_TITLE                      =
    *     I_GRID_SETTINGS                   =
    *     IS_LAYOUT                         =
          it_fieldcat                       = gt_fcat_t001
    *   IMPORTING
    *     E_EXIT_CAUSED_BY_CALLER           =
    *     ES_EXIT_CAUSED_BY_USER            =
        TABLES
          t_outtab                          = gt_t001
    *   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.
    END-OF-SELECTION.
    *&      Form  set_pf_status
    *       text
    *      -->RT_EXTAB   text
    FORM alv_set_pf_status USING rt_extab TYPE slis_t_extab.
    * NOTE: identical to STANDARD_FULLSCREEN with additional button
    *       for detail list ('DETAILLIST')
      SET PF-STATUS 'STANDARD_FULLSCREEN'.
    ENDFORM.                    "set_pf_status
    *&      Form  alv_user_command
    *       text
    *      -->R_UCOMM    text
    *      -->RS_SELFIELDtext
    FORM alv_user_command  USING r_ucomm LIKE sy-ucomm
                             rs_selfield TYPE slis_selfield.
      CASE r_ucomm.
    *   Display detail list: all customers for selected company code
        WHEN 'DETAILLIST'.
          IF ( rs_selfield-fieldname = 'BUKRS' ).
            SELECT        * FROM  knb1 INTO TABLE gt_knb1
                   WHERE  bukrs  = rs_selfield-value.
            CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
              EXPORTING
    *         I_INTERFACE_CHECK                 = ' '
    *         I_BYPASSING_BUFFER                = ' '
    *         I_BUFFER_ACTIVE                   = ' '
                i_callback_program                = syst-cprog
                i_callback_pf_status_set          = 'ALV_SET_PF_STATUS'
                i_callback_user_command           = 'ALV_USER_COMMAND'
    *         I_CALLBACK_TOP_OF_PAGE            = ' '
    *         I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
    *         I_CALLBACK_HTML_END_OF_LIST       = ' '
                i_structure_name                  = 'KNB1'
    *       IMPORTING
    *         E_EXIT_CAUSED_BY_CALLER           =
    *         ES_EXIT_CAUSED_BY_USER            =
              TABLES
                t_outtab                          = gt_knb1
              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.
    <b>*       NOTE: when the program logic returns from the 2nd ALV list
    *             and exit = 'X' then the program leaves the
    *       1st ALV list, too, and returns to the selection screen.</b>
            rs_selfield-exit = 'X'.
          ENDIF.
        WHEN OTHERS.
      ENDCASE.
    ENDFORM.                    "alv_user_command
    Regards
      Uwe

  • 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

  • ALV GRID Problem when delete key is pressed from keyboard

    I have created a ALV Grid using cl_gui_alv_grid class
    I this I made one field editable based on some conditions
    and used SEL_MODE as 'A' ( i tried 'D' too) in the LAYOUT Settings
    When I select the records and press the DELETE key from keyboard
    the records are getting deleted, and i am not able to catch this action
    in the debug mode
    (FYI: I have written my own set of code for delete row in the USER COMMAND EVENT which is not getting triggered in this case )
    Can any body help me with this

    have you used this to trigger the event
    SET HANDLER W_EVENT_RECEIVER->HANDLE_USER_COMMAND FOR W_GRID

  • ALV-Grid:  Is it possible to catch "LOCAL Function Codes" in any Event ??

    Hi,
    is it possible that i can catch a "Local Function Code" in ALV Grid with an Event??
    For example if you click to an Grid Button on the toolbar than it must call an Event!
    ..........BUTTON: Local APPEND (existing in ALV Toolbar)
    Function Code: '&LOCAL&APPEND'
    My Idea is:
    --- IF i click to the Button "Local APPEND" in the ALV toolbar, than it must after this command give me an Message( "It was Successfull" ).
    But the "Local Function Codes" dont called the Event "User_command" OR "After_user_command" is there any other Event for this "Local Function Codes"???
    Have anyone an idea?
    Thanks in forward.
    Ersin

    Hi,
    See following thread.
    http://scn.sap.com/thread/715996
    Thanks
    Santosh

  • ALV grid, prevent return to line 1 column 1 after using filter button

    How can I prevent the ALV grid display from returning to line 1, column 1, after a user has modified the display using the filter or sort button ?  I know this is possible using the is_stable field when control is passed to my ALV code, but when the automatic on-screen buttons are used I can't find a way of controlling how the screen is displayed.

    Max,
    Thanks, the AFTER_USER_COMMAND event allows me access after the filter or sort button has bee npressed, but I am unable to prevent the grid from reverting to column1 line1.  By using the method GET_CURRENT_CELL I can find out the column, but it does not return me the row.   I have tried putting this column id into  SET_CURRENT_CELL_VIA_ID, as suggested by Naimesh above, and calling this from the AFTER_USER_COMMAND method, but it does not effect how the grid displays.    
    Any further advice would be very welcome.

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

  • ALV grid refresh problem when I return from list-processing

    hi,
    I have made alv grid with f4 help features and i'm using row select feature.
    When i click on a button in Application toolbar, the program leaves to list processing and then return to alv gridscreen.
    Now the problem arises.
    (1)Even if i select rows and press F8, the program does not identify the rows selected and does not give me desired output.
    (2)Also, when i press F4, the selected value does not appear in the text field.
    Both the cases are working fine, if i dont press button and go to list processing.
    Please help!!

    You can use the function module as stated below -
    FORM user_command USING r_ucomm TYPE sy-ucomm
                            rs_selfield TYPE slis_selfield.
      CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
      IMPORTING
    ET_EXCLUDING =
    E_FLG_NO_HTML =
    E_CALLBACK_PROGRAM =
    E_REPID =
      e_grid = ref1
    ES_LAYOUT_KKBLO =
    ES_SEL_HIDE =
      CALL METHOD ref1->check_changed_data.
    This helps to get the data in the internal table refreshed as well as that on the screen so that both are in sync.
    this is generally used on some event, you can also use it otherwise.
    <b>
    Reward if useful.</b>
    Regards,
    Pritha

Maybe you are looking for

  • Opening a URL from an application

    Hi everyone, am not quiet skilled with java but i would really appreciate your help with this, as i couldn't find a solution which made me doubt my whole basic knowledge of java. Now am doing this for my school project, it's a speech recognition appl

  • How to persist user changes in porlet in portal

    hi, when i login with particular id and i made some changes in look and feel of portlets in portal page. can any body tell how to persist those changes for particular user in portal . Thanks in advance

  • SmartCSS FW3 Extension - Install?

    Has anyone installed the free, SmartCSS extension for Fireworks CS3. I was going to install it until the error message below displayed, and then I decided not to. I'm not sure if the extension will cause problems in FW3 or not. Has anyone else see th

  • Embedded jar files decrease performance

    Hi. When deploying a project using the SAP BAPI eWay we get this warning: [#|2008-07-24T17:07:59.687+0200|WARNING|IS5.1.3|javax.enterprise.system.tools.deployment|_ThreadID=18; ThreadName=http35000-Processor1;|Component svc_BAPItest_ISH_out.jar conta

  • SYSAUX for XML Repository?

    Hi, I'm new in the xml db oracle (10g). With the command "create or replace directory XML_DIR as '/home/foo/xml';" I've created a DIRECTORY object that points where I saved the XML files. Now some questions worry me... Is it a correct way to store xm