ABAP WD ALV  set cursor /focus to ALV cell

G'day guys,
We have a requirement to position/focus the cursor to a cell in the WD ALV.
example: the user inserts a new line into the ALV and wants to immediately start typing in the first cell (column) of the new row in the ALV. Currently, the user must use the mouse and click, or tab, to that first cell before typing.
Any help/suggestions is appreciated
Cheers,
Mick.

I need a solution for this too.... Can anyone help?

Similar Messages

  • How to set Cursor position in ALV

    Hi,
    i have an issue that how can i set cursor in alv grid.
    i am using alv function modules.
    if user enters wrong info (i have one input enabled filed) then i must show this row as first row and place the cursor in that wrong entry column.
    does anybody worked on this kind of issue..?if so,plz send me the example code
    Thanks

    I think that you have to use OO ALV and use
    CALL METHOD <ref.var. to CL_GUI_ALV_GRID > ->set_current_cell_via_id
       EXPORTING
          IS_ROW_ID    =   <structure of type LVC_S_ROW > ( obsolete )
          IS_COLUMN_ID =   <structure of type LVC_S_COL >
          IS_ROW_NO    =   <structure of type LVC_S_ROID >.
    Hopefully, you can find the object reference of you REUSE ALV by using FM 'GET_GLOBALS_FROM_SLVC_FULLSCR'
    (But i never try it)
    Regards.

  • Set cursor alv grid (not using objects)

    I got a question on ALV GRID (not using objects), please let me know if you have pointers. Thanks.
    Output has 2 screens both has different contents. The output is generated using internal table1 and 2 and using FM  'REUSE_ALV_GRID_DISPLAY_LVC'  (both screen use same FM).
    First screen has multiple pages of output (say 10 pages). User scrolled page 5 and line 10 of first screen and then double clicked it takes to screen #2. After completion of screen #2, the back arrow should get back to page 5 and line 10 of screen #1. Currently the back arrow gets to screen#1 page 1 and line 1. How to remember the cursor position in alv grid and instruct the cursor to go there?
    Appreciate the input.
    Note: I tried "set cursor line n" with "Scroll" command but no luck. http://help.sap.com/saphelp_nw70/helpdata/EN/9f/dba47e35c111d1829f0000e829fbfe/content.htm

    Thanks for the inputs.
    FYI, I got it implemented using method  CALL METHOD <ref.var. to CL_GUI_ALV_GRID > ->set_current_cell_via_id
    The method is called by 'REUSE_ALV_GRID_DISPLAY_LVC' form 'PF_STATUS_SET' when the ALV grid output is presented each time.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
        EXPORTING
          i_bypassing_buffer       = 'X'
          i_callback_program       = gc_repid
          i_callback_pf_status_set = 'PF_STATUS_SET'
          i_callback_user_command  = 'USER_COMMAND'
          is_layout_lvc            = lwa_layout
          it_fieldcat_lvc          = git_fc_lvc
          i_default                = ' '
        TABLES
          t_outtab                 = git_data
        EXCEPTIONS
          program_error            = 1
          OTHERS                   = 2.
      FORM alv_event_pf_status_set USING rt_extab                
                                 TYPE slis_t_extab.
      DATA lo_ref1 TYPE REF TO cl_gui_alv_grid.
    *Get the reference to class "lo_ref1" for the ALV report
      CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
        IMPORTING
          e_grid = lo_ref1.
    *set the focus of cursor in ALV
      CALL METHOD lo_ref1->set_current_cell_via_id
        EXPORTING
          is_row_no = gv_row. "row number where you want to focus the cursor
      ENDFORM.

  • Set Cursor on ALV Grid

    i am trying to set the cursor on an ALV Grid display so that the field can be editted....
    LOOP AT lt_fieldnames INTO ls_fieldnames.
        IF NOT ls_fieldnames-colortab IS INITIAL.
          ls_row_no-row_id       = sy-tabix.
          ls_column_id-fieldname = 'VALUE'.
          EXIT.
        ENDIF.
      ENDLOOP.
    *--- Set focus to cell that contains error
    CALL METHOD grid_editmsg->set_current_cell_via_id
      EXPORTING
           is_column_id = ls_column_id
           is_row_no    = ls_row_no 
    the field is highlighted but i still have to click in the field to edit the contents....
    is there a method/fm i can use that makes the field directly editable????

    I also searched for this and i find a solution.
    CALL METHOD cl_gui_control=>set_focus
         EXPORTING
           control = gref_grid_menge.
    So even if this post is very old, probably it can help other devs to go further!

  • Set cursor in ALV grid output

    Hi guys,
    I generated a report which gives out put in ALV grid.
    In the ALV grid output, I have some editable fields.
    Lets suppose, there are some editable fields with no data in it.
    I have userdefined pushbutton in Application toolbar, when I press the pushbutton the cursor should go to the empty field in the ALV grid output.
    Can this be possible through SET CURSOR statement?
    Thanks,
    Shivaa......

    Hi,
        You can set the cursor field on the output list that too for the output fields which are vissible on the screen only.
    syntax
    SET CURSOR 11 3.   ---> 11Coloumn and 3 line
    for dynamically setting cursor, first you have to search for the empty fields then set the cursor dynamically.
    look at this help document it might be helpful
    http://help.sap.com/saphelp_nw70/helpdata/EN/9f/dba47e35c111d1829f0000e829fbfe/content.htm
    Regards
    Bala KRishna

  • How to set the focus on the new added line in ALV list (OO)

    Dear Friends,
    I have an ALV list based on OO(using alv_grid->set_table_for_first_display), when I click the 'new' button to add a new line, the mouse arrow is always pointing to the first line - not the new created line for user to input!!.
    So how to set the focus (mouse arrow) on the new added line in ALV list for user to input it friendly?
    Thanks a lot!!

    Hello,
    To get the selected line row first we have get all the rows in the internal table.
    When u click on the button when it is creating the new line we have to pass the row number to the call method
    CALL METHOD <ref.var. to CL_GUI_ALV_GRID > ->get_selected_rows
       IMPORTING
          ET_INDEX_ROWS  =   <internal table of type LVC_T_ROW > (obsolete)
          ET_ROW_NO      =   <internal table of type LVC_T_ROID > .
    CALL METHOD<ref.var. to CL_GUI_ALV_GRID>->set_selected_rows
       EXPORTING
          IT_ROW_NO  =  <internal table of type LVC_T_ROID>
       or alternatively
       IT_INDEX_ROWS  =  <internal table of type LVC_T_ROW>
          IS_KEEP_OTHER_SELECTIONS  =  <type CHAR01>.
    http://help.sap.com/saphelp_erp2004/helpdata/EN/22/a3f5ecd2fe11d2b467006094192fe3/content.htm

  • Refresh ALV & set focus

    Hi,
       I have a refresh option on my screen. It will bring latest data from database. After displaying data in ALV and scrolling down (lets assume scrolled down 10 records). if I select refresh, I am reloading data to ALV. But focus is going to first record. I have again scrool down to 11th record to check the data. How I can set focus to 11th record after repopulating data on ALV. I am using classes for ALV.
    I will appriciate any inputs.
    Regards,
    Venkat.

    Hi,
    Check this example of using the method set_current_cell_via_id.
        DATA: ROWNO TYPE LVC_S_ROID.
        ROWNO-ROW_ID = 25.
    Set the focus on the row number 25.
        CALL METHOD <b>grid1->set_current_cell_via_id</b>
          EXPORTING
            IS_ROW_NO    = rowno.
    Hope this helps..
    THanks,
    Naren

  • Remove / set focus on ALV using objects

    I have a screen with 6 subscreen and 6 customercontainers with each 1 ALV, I have 6 ALV's on the same screen, some of the ALV's are only display, and some are for input, my problem is that each alv have fokus on the first cell I want to remove the fokus in all display alv's, I am using the method "set_current_cell_via_id" to place the fokus in edit cell for the alv's with editable cell's, but how to remove fokus in alv, where only display ?
    Best regards Jørgen Jensen INIT A/S

    Hello Jørgen
    This is one of the rare occasion where I believe that something is NOT possible with SAP.
    You may have a look at my sample report
    ZUS_SDN_SPLITTER_CONTAINER and play around with various methods yet I doubt you will be successful. 
    *& Report  ZUS_SDN_SPLITTER_CONTAINER
    REPORT  zus_sdn_splitter_container.
    **type-pools:  abap.
    TYPES: ty_t_knb1    TYPE STANDARD TABLE OF knb1
                        WITH DEFAULT KEY.
    TYPES: BEGIN OF ty_s_control.
    TYPES: cell    TYPE REF TO cl_gui_container.
    TYPES: grid    TYPE REF TO cl_gui_alv_grid.
    TYPES: data    TYPE ty_t_knb1.
    TYPES: row     TYPE lvc_s_row.
    TYPES: layout  TYPE lvc_s_layo.
    TYPES: variant TYPE disvariant.
    TYPES: END OF ty_s_control.
    TYPES: ty_t_control  TYPE STANDARD TABLE OF ty_s_control
                         WITH DEFAULT KEY.
    DATA:
      gs_control       TYPE ty_s_control,
      gt_controls      TYPE ty_t_control.
    DATA:
      gd_repid         TYPE syst-repid,
      gd_okcode        TYPE ui_func,
      go_docking       TYPE REF TO cl_gui_docking_container,
      go_splitter      TYPE REF TO cl_gui_splitter_container,
    **  go_cell          TYPE REF TO cl_gui_container,
    **  go_grid          TYPE REF TO cl_gui_alv_grid,
      gs_layout        TYPE lvc_s_layo.
    DATA:
      gd_msg           TYPE bapi_msg,
      gd_perc          TYPE i,
      gd_lines         TYPE i,
      gd_idx           TYPE i,
      gd_cnt           TYPE i,
      gt_knb1          TYPE STANDARD TABLE OF knb1.
    PARAMETERS:
      p_row    TYPE i  DEFAULT '3',
      p_col    TYPE i  DEFAULT '3'.
    START-OF-SELECTION.
      PERFORM init_controls.
      DESCRIBE TABLE gt_controls.
      gd_lines = syst-tfill.
      SELECT * FROM knb1 INTO TABLE gt_knb1 UP TO 100 ROWS
        WHERE bukrs = '1000'.
      LOOP AT gt_controls INTO gs_control.
        gd_idx = syst-tabix.
        gd_cnt = syst-tabix * 5.
        gd_perc = ( syst-tabix * 100 ) / gd_lines.
        CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
          EXPORTING
            percentage       = gd_perc
    *       TEXT             = ' '
        gs_control-data = gt_knb1.
        DELETE gt_knb1 INDEX 1.
        "   Set individual layout and variant
        gs_control-layout-cwidth_opt = abap_true.
        gs_control-layout-zebra      = abap_true.
        gs_control-layout-no_toolbar = abap_true.
        gs_control-layout-smalltitle = abap_true.
        gs_control-row-index = gd_idx.
        WRITE gd_idx TO gs_control-layout-grid_title NO-ZERO.
        CONDENSE gs_control-layout-grid_title NO-GAPS.
        CONCATENATE gs_control-layout-grid_title
                    '. Customer'
          INTO gs_control-layout-grid_title.
        CALL METHOD gs_control-grid->set_table_for_first_display
          EXPORTING
            i_structure_name = 'KNB1'
            is_layout        = gs_control-layout
            i_save           = 'A'
            is_variant       = gs_control-variant
          CHANGING
            it_outtab        = gs_control-data
          EXCEPTIONS
            OTHERS           = 4.
        IF sy-subrc <> 0.
    *     MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *                WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
        IF ( gd_idx > 1 ).
          CALL METHOD gs_control-grid->set_current_cell_via_id
            EXPORTING
              is_row_id = gs_control-row.
          CALL METHOD gs_control-grid->refresh_table_display
    *        EXPORTING
    *          IS_STABLE      =
    *          I_SOFT_REFRESH =
    *        EXCEPTIONS
    *          FINISHED       = 1
    *          others         = 2
          IF sy-subrc <> 0.
    *       MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *                  WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
          ENDIF.
        ENDIF.
        MODIFY gt_controls FROM gs_control INDEX gd_idx.
      ENDLOOP.
      gd_msg = gd_lines.
      CONDENSE gd_msg NO-GAPS.
      CONCATENATE gd_msg 'grids displayed on single screen.'
        INTO gd_msg
        SEPARATED BY space.
      MESSAGE gd_msg  TYPE 'S'.
    * Link the docking container to the target dynpro
      gd_repid = syst-repid.
      CALL METHOD go_docking->link
        EXPORTING
          repid                       = gd_repid
          dynnr                       = '0100'
    *      CONTAINER                   =
        EXCEPTIONS
          OTHERS                      = 4.
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    * NOTE: dynpro does not contain any elements
      CALL SCREEN '0100'.
    * Flow logic of dynpro (does not contain any dynpro elements):
    *PROCESS BEFORE OUTPUT.
    *  MODULE STATUS_0100.
    *PROCESS AFTER INPUT.
    *  MODULE USER_COMMAND_0100.
    END-OF-SELECTION.
    *&      Module  STATUS_0100  OUTPUT
    *       text
    MODULE status_0100 OUTPUT.
      SET PF-STATUS 'STATUS_0100'.  " contains push button "DETAIL"
    *  SET TITLEBAR 'xxx'.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
    *       text
    MODULE user_command_0100 INPUT.
      CASE gd_okcode.
        WHEN 'BACK' OR
             'END'  OR
             'CANC'.
          SET SCREEN 0. LEAVE SCREEN.
        WHEN OTHERS.
      ENDCASE.
      CLEAR: gd_okcode.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    *&      Form  INIT_CONTROLS
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM init_controls .
    * define local data
      DATA:
        ld_column  TYPE i,
        ls_control TYPE ty_s_control.
      REFRESH: gt_controls.
    * Create docking container
      CREATE OBJECT go_docking
        EXPORTING
          parent                      = cl_gui_container=>screen0
          ratio                       = 90
        EXCEPTIONS
          OTHERS                      = 6.
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      CALL METHOD go_docking->set_extension( 99999 ).
    * Create splitter container
      CREATE OBJECT go_splitter
        EXPORTING
          parent            = go_docking
          rows              = p_row
          columns           = p_col
    *      NO_AUTODEF_PROGID_DYNNR =
    *      NAME              =
        EXCEPTIONS
          cntl_error        = 1
          cntl_system_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.
      DO p_col TIMES.
        ld_column = syst-index.
        DO p_row TIMES.
    * Get cell container
          CLEAR: ls_control.
          CALL METHOD go_splitter->get_container
            EXPORTING
              row       = syst-index
              column    = ld_column
            RECEIVING
              container = ls_control-cell.
    *   Create ALV grid
          CREATE OBJECT ls_control-grid
            EXPORTING
              i_parent          = ls_control-cell
            EXCEPTIONS
              OTHERS            = 5.
          IF sy-subrc <> 0.
    *     MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *                WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
          ENDIF.
          APPEND ls_control TO gt_controls.
        ENDDO.  " rows
      ENDDO.  " columns
    ENDFORM.                    " INIT_CONTROLS
    Regards
      Uwe

  • Set default focus on pushbutton (dynpro not ALV)

    Dear all
    I created a popup showing a table control and 2 buttons (confirm / abort).
    The user simply wants to push the confirm button to proceed by pressing enter but unfortunatly I see no way to set the focus on that element by default.
    Any help is appreciated.
    Thank's in advance and best regards
    Benno

    Use this in PBO:
    * BUT_CONF is the button for the Confirm
    SET CURSOR FIELD 'BUT_CONF'
    Regards,
    Naimesh Patel

  • Cursor position in alv grid

    Hi,
    How can control cursor posiotion in alv grid,
    plz help me.
    Regards,
    venkat.

    hiiii
    you can use SET or GET cursor statement of ABAP.that will help you to get cursor position & to set cursor position also
    regards
    twinkal

  • Focus in ALV

    Hi,
    Is there a way to put a focus like "SET CURSOR" on a specific field ?
    Thanks.
    PS : ALV created with CL_GUI_ALV_GRID.

    Refresh ALV & set focus
    Scroll to row with CL_GUI_ALV_GRID (ALVGRID)
    (Just in case anybody is reading this thread after the years:)

  • ALV report Cursor problem

    Hi All,
             I am working on ALV report. In that I am displying 20 columns. I am taking the first column for selecting row.
    Suppose I have field1, 2 ,3 etc.
    when i click on any field it will display the field description popup. It is working fine.After that in that popup, when i cancel it, the cursor is still on the selected field. I need the cursor to goto first column. Can anybody please help me out in this?
    Thanks,
    Ravi

    Hi,
    Use the following syntax,
    SET CURSOR FIELD <fname>.
    Thanks,
    Bhanu
    Edited by: Bhanu  P on Feb 3, 2008 6:17 AM

  • ALV set row and column position

    Hi Experts,
    I have editable ALV, after edit I refresh ALV, but problem is, that position is set to position 1.1. I need to keep cursor at edited position.
    I use ALV through function module REUSE_ALV_GRID_DISPLAY.
    Thansk&regards,
    Jirka

    In order to refresh the ALV and keep the scroll position, you have to read the scroll posiition before refresh and set the scroll position after the refresh..
    Below code will help,.. Whenever you want to refresh the alv use these in your coding...
    FORM refresh_alv_display.
    DATA: li_rows    TYPE lvc_s_roid,
             li_col     TYPE lvc_s_col,
             lws_row_id TYPE lvc_s_roid,
             lws_col_id TYPE lvc_s_col,
             ls_col     TYPE lvc_s_col,
             ls_num     TYPE lvc_s_roid.
       CALL METHOD c_grid->get_current_cell
         IMPORTING
           es_col_id = li_col
           es_row_no = li_rows.
       CALL METHOD c_grid->get_scroll_info_via_id
         IMPORTING
           es_col_info = ls_col
           es_row_no   = ls_num.
       CALL METHOD c_grid->refresh_table_display.
       CALL METHOD c_grid->set_scroll_info_via_id
         EXPORTING
           is_col_info = ls_col
           is_row_no   = ls_num.
       lws_row_id-row_id    = li_rows-row_id.
       lws_col_id-fieldname = li_col-fieldname.
       CALL METHOD c_grid->set_current_cell_via_id
         EXPORTING
           is_column_id = lws_col_id
           is_row_no    = lws_row_id.
    ENDFORM.

  • Unable to set the Cursor focus on a particular field in OA Page

    Hi,
    I have a custom page with 3 controllers . Now when i delete a row from the Advance table, the focus of the cursor goes to the top of the page. My requirement is that, the focus should remain in the Advance table region itself.
    I tried to set the focus using the below code. It dosent work. Could there be an issue since iam using more than one controller for the page?
    OABodyBean bodyBean = (OABodyBean)pageContext.getRootWebBean();
    bodyBean.setInitialFocusId("item164"); // item164 is the messageTextInput field in the Advance table region.
    I tried to get the Initialfocus value after its set. The value shows as 'item164'. However , it doesnt focus on that item.
    Please help me out in fixing this issue.
    Thanks
    AG

    Hi,
    Thanks for the Info. Can you help me with this java script or if you can provide me any reference it would be hepful.
    Basically the focus has to stay in that particular AdvanceTable region where the row is deleted. Not required that the focus has to point to the next row after the delete.
    Thanks
    AG
    Edited by: 928445 on Apr 26, 2012 12:06 AM

  • Get cursor field in ALV Tree

    Hello all,
    How do I get a cursor field on ALV Tree report? I have output with po number, vendor no etc. When I double click PO, i shuold display ME23N and on vendor no 'XK03' etc. Double click event is triggered, but how do I check which field is clicked? Anybody pls suggest me.
    Thanks,
    Chandni

    Hi,
    you can use method to get the select lines:
      CALL METHOD TREE->GET_SELECTED_NODES
       CHANGING
         CT_INDEX_OUTTAB   = SELECTED_NODES
        EXCEPTIONS
          CNTL_SYSTEM_ERROR = 1
          DP_ERROR          = 2
          FAILED            = 3
          OTHERS            = 4.
    or in double click:
        METHODS HANDLE_DOUBLE_CLICK
          FOR EVENT ITEM_DOUBLE_CLICK OF CL_GUI_ALV_TREE_SIMPLE
          IMPORTING FIELDNAME INDEX_OUTTAB GROUPLEVEL.
    just read tables with index_outttab
    READ TABLE GT_TAB INTO IGT_TAB INDEX INDEX_OUTTAB.
    to check which  field is clicked use the FIELDNAME field.
    regards

Maybe you are looking for