Single row select in ALV Grid

HI,
I want to make my ALV Grid only single row select enabled, can some one guide me which variable should be set for the same.
Thanks and Regards,
Harsh

If you are using OO for alv then
  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.
* Info message : Please select a row
    message i176.                        " Please select a row'.
  endif.
  if v_dbcnt gt 1.
* Info message : Multiple Row Selection not  possible
    message i177.                        " Multiple Row Selection not
    " possible'
  endif.
or if your using REUSE then
form user_command using p_ucomm type sy-ucomm
                     rs_selfield type  slis_selfield.
" Check the rs_selfield-tabindex value here
" you may get some clue here
endform.

Similar Messages

  • Row Selection in ALV Grid created using CL_GUI_ALV_GRID

    Hi,
    I have ALV grid using cl_gui_alv_grid. I want to capture the row selection and display the selected rows in 2nd ALV grid (using cl_gui_alv_grid).
    Method CALL METHOD Grid->get_selected_rows giving right no. of selected records first time and process these records by POST button and hence shows these records in next alv grid. but when i came back to 1st ALV by pressing BACK button on 2nd ALV then if I again select records on the same 1st ALV grid the same Method CALL METHOD Grid->get_selected_rows fires again. but this times it wouldn't give the selected records. I mean first time this gives me correct no. of selected records but 2nd time wouldn't.
    how do I capture the row selection.?
    Kindly suggest me. helpful answer will be appreciated.
    Thanx in Advance.
    Robin

    Hi,
    Write this code, you have to free the container.
    MODULE user_command_0101 INPUT.
      CASE sy-ucomm.
        WHEN 'BACK'.
           c_container->free( ).
           c_container1->free( ). " this is the container of secondary list.
           clear: r_grid,  r_grid1, c_container, c_container1.
          LEAVE TO SCREEN 100.
      ENDCASE.
    Regards and Best wishes.

  • How to set only one row selection  in ALV GRID DISPLAY

    How to set single row selection in grid display
    not multiselection.

    Hi,
    In the USER COMMAND, build the code to check the REFRESHED Data & then check the number of records with SEL  = 'X'.
    If more than single entry found, then raise an error message.
    Best regards,
    Prashant

  • Default row selected in alv grid

    Hi Everyone,
    I have couple of alv screens. By default the topmost cell is highlighted in the first grid, the data of second grid is dependant on the first one. So if the topmost record is selected by default in first grid, i want to highlight its corresponding records in the second grid.
    How do I achieve this.
    Any help on this will be of great use to me.
    Thanks in advance,
    Prashant.

    In PAI,
    MODULE user_command_9001 INPUT.
      REFRESH i_fieldrows.
    <b>CALL METHOD o_alvgrid->get_selected_rows
                  IMPORTING
                  et_index_rows = i_fieldrows.</b>  LOOP AT i_fieldrows INTO w_fieldrows.
        READ TABLE i_output INTO w_output INDEX w_fieldrows-index.
      ENDLOOP.
      CASE sy-ucomm.
        WHEN 'EXIT' OR  'CANC'.
    WHEN 'MD04'.
          IF w_output-matnr IS INITIAL.
            MESSAGE i001 WITH text-e07.
          ELSE.
            SET PARAMETER ID 'MAT' FIELD w_output-matnr.
            SET PARAMETER ID 'WRK' FIELD w_output-werks.
            CALL TRANSACTION 'md04' AND SKIP FIRST SCREEN .
          ENDIF.
        WHEN OTHERS.
      ENDCASE.
    ENDMODULE.                 " USER_COMMAND_9001  INPUT
    Similarly in the next screen PAI,
    use
    CALL METHOD o_alvgrid->set_selected_rows
                  IMPORTING
                  et_index_rows = i_fieldrows.

  • ALV Grid Single Row Selection Only

    Hi,
    I have a requirement to select a single row in an ALV grid using class
    I tried with   layout-sel_mode   = 'B'  its not working, and don't want to use
      call method g_grid->get_selected_rows
        importing
          et_row_no = lt_row_no.
    and check for number of rows and giving error message " select only one row".
    Is there any other way to tackle this issue
    Thanks
    aRs

    Hi,
    DATA:
    * Internal table for indexes of selected rows
    gi_index_rows TYPE lvc_t_row,
    * Information about 1 row
    g_selected_row LIKE lvc_s_row.
      CALL METHOD go_grid->get_selected_rows
        IMPORTING
          et_index_rows = gi_index_rows.
      DESCRIBE TABLE gi_index_rows LINES l_lines.
    Here the L_Lines will contain the number of rows selected
    Regards
    Sudheer

  • Single selection in ALV Grid Control

    hi,
    I want to enable single row selection only in the alv grid displayed.
    attribute sel_mode of layout doesnt help.
    Can anybody provide me a solution.
    Regards,
    Auro

    Hello,
    Try this:
    DATA:gs_layout type lvc_s_layo.
    gs_layout-NO_ROWMARK = 'X'.
    call method g_grid->set_table_for_first_display
           exporting is_layout             = gs_layout
    Regards,
    Beejal
    **reward if this helps

  • Urgent :  how to select the rows in the ALV Grid Control

    How to select the rows in the ALV Grid control,
    I am facing the situation where i need to select the row/rows in the Grid control and then to lock the entries,
    If anyone have the solution please help me out
    <b>Its very Urgent</b>

    Hi Bharath,
    Go through this hope u can understand.
    SEL_MODE. Selection mode, determines how rows can be selected. Can have the following values:
    A Multiple columns, multiple rows with selection buttons.
    B Simple selection, listbox, Single row/column
    C Multiple rows without buttons
    D Multiple rows with buttons and select all ICON
    Setting and getting selected rows (Columns) and read line contents
    You can read which rows of the grid that has been selected, and dynamic select rows of the grid using methods get_selected_rows and set_selected_rows. There are similar methods for columns.
    Note that the grid table always has the rows in the same sequence as displayed in the grid, thus you can use the index of the selected row(s) to read the information in the rows from the table. In the examples below the grid table is named gi_sflight.
    Data declaration:
    DATA:
    Internal table for indexes of selected rows
    gi_index_rows TYPE lvc_t_row,
    Information about 1 row
    g_selected_row LIKE lvc_s_row.
    Example 1: Reading index of selected row(s) and using it to read the grid table
      CALL METHOD go_grid->get_selected_rows
        IMPORTING
          et_index_rows = gi_index_rows.
      DESCRIBE TABLE gi_index_rows LINES l_lines.
      IF l_lines = 0.
        CALL FUNCTION 'POPUP_TO_DISPLAY_TEXT'
             EXPORTING
                  textline1 = 'You must choose a valid line'.
        EXIT.
      ENDIF.
      LOOP AT gi_index_rows INTO g_selected_row.
         READ TABLE gi_sflight INDEX g_selected_row-index INTO g_wa_sflight.
        ENDIF.
      ENDLOOP.
    Example 2: Set selected row(s).
      DESCRIBE TABLE gi_index_rows LINES l_lines.
      IF l_lines > 0.
        CALL METHOD go_grid->set_selected_rows
            exporting
              it_index_rows = gi_index_rows.
      ENDIF.
    Reward points if helpful.
    Thanks
    Naveen khan

  • Single click event in alv grid.

    Hi Experts,
    i have done will my code..everything is working perfectly, but having an issue..pls help me...
    in my output screen i have 2 check-boxes,when i select both of them i shuld get a message saying select only one..this is done when am using double click. Is single click possible in alv-grid...
    please help me.
    thanks.
    anusha

    Hi Anusha,
    Did you Try by using get_selected_rows(Method)?
    If the selected rows are 2 display a message such that 'Select only One record'.
    data t_roid type lvc_t_roid.
    CALL METHOD r_grid->get_selected_rows
            IMPORTING
              et_row_no = t_roid.
    READ TABLE t_roid INDEX 1 TRANSPORTING NO FIELDS."to know how many No.Of records selected
    if sy-tfill > 1.
    Message 'Please Select only one record' type 'I'.
    Exit.
    endif.

  • How do I find an event which is triggered on line selection for ALV grid?

    Hi,
    I'm trying to find an event which is triggered when a user selects a row in the ALV grid. I want to add my own code in to add up the total values of selected lines, but can't find any event which will trigger my method.
    I found CLICK_ROW_COL but it's protected so when I try and add a method for it:
      PROTECTED SECTION.
        METHODS:
        select_row
            FOR EVENT click_row_col OF cl_gui_alv_grid.
    I get the syntax error:
    Access to protected event "CLICK_ROW_COL" is not allowed.
    Am I using the right event? Am I implementing it correctly?
    Any help appreciated. Thanks in advance.
    Gill

    I chose to solve this by removing the line select buttons from the ALV and replacing them with a checkbox defined as a hotspot.  I then used EVENT hotspot_click FROM cl_gui_alv_grid to highlight the line and change my totals on a single click.

  • Adding a color to row of a alv grid using function modules

    Can anybody clearly explains me how to add a color to a row to an alv grid using function module reuse_alv_grid_display.
    thanks in advance
    regards
    anil.

    hi,
    chk this ample pgm
    report zxyz_0004
           no standard page heading.
    type-pools slis.
    data: fieldcat type slis_t_fieldcat_alv.
    data: begin of imara occurs 0,
          matnr type mara-matnr,
          mtart type mara-mtart,
          maktx type makt-maktx,
          color_line(4) type c,
          tcolor type slis_t_specialcol_alv,  "cell
          end of imara.
    data: xcolor type slis_specialcol_alv.
    start-of-selection.
      perform get_data.
      perform write_report.
    Get_Data
    form get_data.
      imara-matnr = 'ABC'.
      imara-mtart = 'ZCFG'.
      imara-maktx = 'This is description for ABC'.
      append imara.
      imara-matnr = 'DEF'.
      imara-mtart = 'ZCFG'.
      imara-maktx = 'This is description for DEF'.
      append imara.
      imara-matnr = 'GHI'.
      imara-mtart = 'ZCFG'.
      imara-maktx = 'This is description for GHI'.
      append imara.
      loop at imara.
        if sy-tabix = 1.
          imara-color_line = 'C410'.   " color line
        endif.
        if sy-tabix = 2.          "color CELL
          clear xcolor.
          xcolor-fieldname = 'MTART'.
          xcolor-color-col = '3'.
          xcolor-color-int = '1'. "Intensified on/off
          xcolor-color-inv = '0'.
          append xcolor to imara-tcolor.
        endif.
        modify imara.
      endloop.
    endform.
    WRITE_REPORT
    form write_report.
      data: layout type  slis_layout_alv.
      layout-coltab_fieldname = 'TCOLOR'.
      layout-info_fieldname = 'COLOR_LINE'.
      perform build_field_catalog.
    CALL ABAP LIST VIEWER (ALV)
      call function 'REUSE_ALV_GRID_DISPLAY'
           exporting
                is_layout   = layout
                it_fieldcat = fieldcat
           tables
                t_outtab    = imara.
    endform.
    BUILD_FIELD_CATALOG
    form build_field_catalog.
      data: fc_tmp type slis_t_fieldcat_alv with header line.
      clear: fieldcat. refresh: fieldcat.
      clear: fc_tmp.
      fc_tmp-reptext_ddic    = 'Material Number'.
      fc_tmp-fieldname  = 'MATNR'.
      fc_tmp-tabname   = 'IMARA'.
      fc_tmp-outputlen  = '18'.
      append fc_tmp to fieldcat.
      clear: fc_tmp.
      fc_tmp-reptext_ddic    = 'Material Type'.
      fc_tmp-fieldname  = 'MTART'.
      fc_tmp-tabname   = 'IMARA'.
      fc_tmp-outputlen  = '4'.
      append fc_tmp to fieldcat.
      clear: fc_tmp.
      fc_tmp-reptext_ddic    = 'Material'.
      fc_tmp-fieldname  = 'MAKTX'.
      fc_tmp-tabname   = 'IMARA'.
      fc_tmp-outputlen  = '40'.
      fc_tmp-emphasize = 'C610'.   " color column
      append fc_tmp to fieldcat.
    endform.
    <b>anil , pls chk this link also.
    http://www.sapdevelopment.co.uk/reporting/alv/alvgrid_color.htm
    very hlpful.</b>
    rgds
    anver
    <b>pls mark points if ur issue solved</b>
    Message was edited by: Anversha s
    Message was edited by: Anversha s

  • Interactive report with single row select

    Hi,
    Is it possible to create an interactive report that has a single row select column i.e. you can only select one row and when you select another row it deselects any row selected before, simular to a list of values but with the functionionality of an IR report.
    Thanks in advance

    Hi,
    Try adding this to the query of your report:
    select ...
           apex_item.radiogroup(1, some_unique_column) sel
    from ...You didn't say how you want to use this, but when the page is submitted the array apex_application.g_f01 may contain either none or exactly one element, which will be the some_unique_column value of the selected row.
    Luis

  • OGG-00665  OCI Error executing single row select (status = 4060-ORA-04060:

    Unable to start Replica. Is it Oracle user permission issue ?
    ERROR OGG-00665 OCI Error executing single row select (status = 4060-ORA-04060: insufficient privileges to execute DBMS_STREAMS.SET_TAG
    ORA-06512: at "SYS.DBMS_STREAMS", line 16
    ORA-06512: at line 1), SQL<BEGIN dbms_streams.set_tag(:1); END;>.
    ERROR OGG-01668 PROCESS ABENDING.

    Operating System Version:
    Linux
    Version #1 SMP Sat Feb 25 16:26:29 EST 2012, Release 2.6.18-308.0.0.0.1.el5xen
    Node:
    Machine: x86_64
    soft limit hard limit
    Address Space Size : unlimited unlimited
    Heap Size : unlimited unlimited
    File Size : unlimited unlimited
    CPU Time : unlimited unlimited
    23,0-1 Top
    Process id: 7662
    Description:
    ** Running with the following parameters **
    2013-05-01 10:06:13 INFO OGG-03059 Operating system character set identified as UTF-8.
    2013-05-01 10:06:13 INFO OGG-02695 ANSI SQL parameter syntax is used for parameter parsing.
    replicat robey
    userid test12, password ********
    Source Context :
    SourceModule : [ggdb.ora.sess]
    SourceID : [*/aime1/adestore/views/aime1_*/oggcore/OpenSys/src/gglib/ggdbora/ocisess.c]
    SourceFunction : [oci_try]
    SourceLine : [790]
    ThreadBacktrace : [18] elements
    : [*/*/OGGCOREMAINBACKTEST/libgglog.so(CMessageContext::AddThreadContext()+0x26) [0x2af5c09b67f6]]
    : [*/*/OGGCOREMAINBACKTEST/libgglog.so(CMessageFactory::CreateMessage(CSourceContext*, unsigned int, ...)+0x28f) [0x2af5c09ae90f]]
    : [/*/*/OGGCOREMAINBACKTEST/libgglog.so(_MSG_ERR_ORACLE_OCI_ERROR_WITH_DESC_SQL(CSourceContext*, int, char const*, char const*, char const*,
    CMessageFactory::MessageDisposition)+0x64) [0x2af5c09787d4]]
    : [*/*/OGGCOREMAINBACKTEST/replicat(OCISESS_context_def::oci_try(int, char const*, ...)+0x3ee) [0x788aae]]
    : [*/*/OGGCOREMAINBACKTEST/replicat(query_handle::exec_stmt(bool, int)+0x19a) [0x79664a]]
    : [*/*/OGGCOREMAINBACKTEST/replicat(OCISESS_context_def::setTag(ggs::gglib::ggunicode::UString const&, bool)+0x25a) [0x787d5a]]
    : [*/*/OGGCOREMAINBACKTEST/replicat(OCISESS_context_def::init_context(int, int)+0x410) [0x78f230]]
    : [/*/*/OGGCOREMAINBACKTEST/replicat(DBOCI_init_connection_logon(ggs::gglib::ggapp::CLoginName const&, ggs::gglib::ggapp::CDBObjName<(DBObjType)12>
    const&, char const*, int, int, int, char*)+0x136) [0x76c566]]
    : [*/*/OGGCOREMAINBACKTEST/replicat [0x740479]]
    : [*/*/OGGCOREMAINBACKTEST/replicat [0x746f91]]
    : [*/*/OGGCOREMAINBACKTEST/replicat(odbc_param(char*, char*)+0x364) [0x74a5f4]]
    : [*/*/OGGCOREMAINBACKTEST/replicat(get_infile_params(time_elt_def*, time_elt_def*, char**)+0x959f) [0x57af1f]]
    : [*/*/OGGCOREMAINBACKTEST/replicat(replicat_main(int, char**)+0x152) [0x5de8c2]]
    : [*/*/OGGCOREMAINBACKTEST/replicat(ggs::gglib::MultiThreading::MainThread::ExecMain()+0x6f) [0x7249af]]
    : [*/*/OGGCOREMAINBACKTEST/replicat(ggs::gglib::MultiThreading::MainThread::Run(int, char**)+0x127) [0x724d57]]
    : [*/*/OGGCOREMAINBACKTEST/replicat(main+0x4a) [0x5dafba]]
    : [lib64/libc.so.6(__libc_start_main+0xf4) [0x3f4da1d994]]
    : [*/*/OGGCOREMAINBACKTEST/replicat [0x4c70a9]]
    2013-05-01 10:06:13 ERROR OGG-00665 OCI Error executing single row select (status = 439-ORA-00439: feature not enabled: Streams Capture
    ORA-06512: at "SYS.DBMS_STREAMS", line 7
    ORA-06512: at line 1), SQL<BEGIN dbms_streams.set_tag(:1); END;>.
    2013-05-01 10:06:13 ERROR OGG-01668 PROCESS ABENDING.

  • How can I get the selected rows from two ALV grids at the same time?

    I have a program that uses two ALV grids in one dialog screen. I'm using the OO ALV model (SALV* classes).
    The user can select any number of rows from each grid. Then, when a toolbar pushbutton is pressed, I'd have to retrieve the selected rows from both grids and start some processing with these rows.
    It is no problem to assign event handlers to both grids, and use the CL_SALV_TABLE->GET_SELECTIONS and CL_SALV_SELECTIONS->GET_SELECTED_ROWS methods to find out which rows were marked by the user. Trouble is, this only works when I raise an event in each grid separately, for instance via an own function that I added to the grid's toolbar. So, I can only see the selected rows of the same grid where such an event was raised.
    If I try to do this in the PBO of the dialog screen (that contains the two grids), the result of CL_SALV_SELECTIONS->GET_SELECTED_ROWS will be empty, as the program does not recognize the marked entries in the grids. Also, an event for grid1 does not see the selected rows from grid2 either.
    As it is right now, I can have an own button in both grid's toolbar, select the rows, click on the extra button in each grid (this will tell me what entries were selected per grid). Then, I'd have to click on a third button (the one in the dialog screen's toolbar), and process the selected rows from both grids.
    How can I select the rows, then click on just one button, and process the marked entries from both grids?
    Is it somehow possible to raise an event belonging to each grid programmatically, so that then the corresponding CL_SALV_SELECTIONS->GET_SELECTED_ROWS will work?
    Thanks.

    Hello Tamas ,
    If I try to do this in the PBO of the dialog screen (that contains the two grids), the result of CL_SALV_SELECTIONS->GET_SELECTED_ROWS will be empty, as the program does not recognize the marked entries in the grids. Also, an event for grid1 does not see the selected rows from grid2 either.--->
    is it possible to  have a check box in each grid  & get the selected lines in PAI of the screen ?
    regards
    prabhu

  • Get Row Data from a selected Row in an ALV Grid

    Hello,
    I create a Custom Control from an intern table. When i do a double click on a row, i call another dynpro. The data of the marked line should be written into an internal table.
    How i implement this?
    I tried things like:
    Call method alv_list->GET_SELECTED_ROWS_BASE
    or
    Call method alv_list->GET_SELECTED_ROWS

    Hi Sebastian,
        For a double click event we need to register the double click event which goes the following way.
    data: lref_alv type ref to cl_gui_alv_grid.
    * after initializing ALV
    SET HANDLER gref_application->handle_alv_dblclik FOR lref_alv.
    Now this double click event needs to be handled in the local class.
    eg:
    CLASS lcl_application DEFINITION.
      PUBLIC SECTION.
        METHODS:
    * Method to handle double click on ALV grid.............................
          handle_alv_dblclik
                        FOR EVENT double_click
                               OF cl_gui_alv_grid
                        IMPORTING e_row
                                  e_column
                                  es_row_no.
    endclass.
    CLASS lcl_application IMPLEMENTATION.
    *           Method: HANDLE_ALV_DBLCLICK                                *
    *           Text: Event triggers when ALV grid is double clicked       *
    *    -->e_row                                                          *
    *    -->e_column                                                       *
    *    -->es_row_no,                                                     *
      METHOD handle_alv_dblclik.
        data:  lv_value(40) TYPE c.
       * Get the value of the current cell double clicked......................
        CALL METHOD gref_alv->get_current_cell
          IMPORTING
            e_value   = lv_value
    *  here you can insert the values in the internal table
      endmethod.
    endclass.
    hope this helps.
    Regards,
    Kinshuk

  • Row Selection in ALV on Single click

    Hi
    Can we read the row in ALV on row selection ?  i set  gs_layout-sel_mode = 'D'.
    My Scenario is as under
    there is an ALV on the screen in which i have displayed the data . there is a push button on the screen. User will select the row and then click the push button. on click of that push button selected row should move to the work area.
    I am using  following method
    CALL METHOD g_Grid->SET_TABLE_FOR_FIRST_DISPLAY
    Regards
    Ammad

    If the method [g_grid->get_selected_rows|http://help.sap.com/saphelp_erp2004/helpdata/en/0a/b55312d30911d2b467006094192fe3/frameset.htm] returns no row, then try a [g_grid->get_current_cell|http://help.sap.com/saphelp_erp2004/helpdata/en/0a/b552fad30911d2b467006094192fe3/frameset.htm]  (Don't forget the [cl_gui_cfw=>flush|http://help.sap.com/saphelp_erp2004/helpdata/en/06/3fa1879f2811d2bd68080009b4534c/frameset.htm] to synchronize the automation queue.)
    Regards,
    Raymond

Maybe you are looking for

  • How do I get rid of this "Norton" pop up window that pops up frequently?

    For some reason, every time I pop in a blank dvd to burn or any NON movie dvd, I get this "computer cant find Norton blah blah blah" window error type thing ... how the heck do I get rid of that or keep it from popping up in the future?

  • Non-transactional datastores

    In the WebLogic 5.1 documentation it mentions that for non-transactional           datastores in a cluster that you can use a custom "dictionary" object to           keep track of which webLogic server instance is currently hosting a given           

  • How to install your applications on your i pod touch

    I have the applications downloaded to my computer and my i pod is the version 3.1 and the apps are compatible with the i pod but when i am in my i tunes it dose not let me add new apps or move the ones i had. So i deleted all the apps manually from m

  • How to query for content type in plumtree?

    Hi, I am able to browse through the documents in knowledge directory and their properties programmatically using IDK. Here I am getting document property ids and their values, but not property name? Can anybody suggest me how to get property names fo

  • I need to put an image up that looks like tv turned on

    I need to put an image up of a television and have a video of something looping in the center the image of the tv would be just that and a player would really be under the image playing the video. I am a newbiie and would b very greatful if someone w