Get selected rows using the fm REUSE_ALV_GRID_DISPLAY_LVC

FYI ... for all those developers trying to select multiple rows in an ALV report, and get the selected rows - without using the OO approach to display to ALV, and without using checkboxes in the function module approach.  First off, you need to use the function module REUSE_ALV_GRID_DISPLAY_LVC instead of the standard REUSE_ALV_GRID_DISPLAY.  This allows you to select multiple rows using the toggle, line selection buttons, at the start of each row (with 'select all' button).  See the sample code below.  If you are converting from the one fm to the other, you will have to change the type of 2 of the structures to the 'LVC' structures and make minor code changes.  The example code below was initially using the REUSE_ALV_GRID_DISPLAY fm, and was converted to use REUSE_ALV_GRID_DISPLAY_LVC  to allow for multiple row selection.  The next step is to create a custom status, with a new custom button, that will start the processing of the selected rows.  Go to tcode SE41, press Copy Status, and copy program SAPLKKBL, status STANDARD, to your custom program (same name as the custom ALV rpt) and a new status name (ie STANDARD1).  In the new STANDARD1 status for the custom ALV program/rpt (tcode SE41), add a new button ('&EXE') at the end of the std buttons (items 29-35).  Assign the new button a Text, Icon and a Function Key. Thats it!
Here's the code:
FORM display_data.
DATA:
  wa_callback_program LIKE sy-repid,
  wa_layout      TYPE lvc_s_layo,  "was  slis_layout_alv,       "D01K913690
  t_fieldcat        TYPE lvc_t_fcat,   "was  slis_t_fieldcat_alv,  "D01K913690
  wa_fieldcat    TYPE lvc_s_fcat,  "was  slis_fieldcat_alv,     "D01K913690
  t_excluding     TYPE slis_t_extab,
  wa_excluding TYPE slis_extab,
  wa_variant     LIKE disvariant.
* Setup Field Catalog
  CLEAR wa_fieldcat.
  wa_fieldcat-fieldname  = 'ZBUKR'.
  wa_fieldcat-ref_field    = 'ZBUKR'.
  wa_fieldcat-ref_table   = 'REGUT'.
  APPEND wa_fieldcat TO t_fieldcat.
  CLEAR wa_fieldcat.
  wa_fieldcat-fieldname = 'BANKS'.
  wa_fieldcat-ref_field   = 'BANKS'.
  wa_fieldcat-ref_table  = 'REGUT'.
  APPEND wa_fieldcat TO t_fieldcat.
* Setup other ALV fm parameters
  CLEAR wa_excluding.
  wa_excluding-fcode = '&F12'.
  APPEND wa_excluding TO t_excluding.
  CLEAR wa_excluding.
  wa_excluding-fcode = '&F15'.
  APPEND wa_excluding TO t_excluding.
* Callback program
  wa_callback_program = sy-repid.
* List layout
  wa_layout-zebra = 'X'.
  wa_layout-sel_mode = 'A'.
* variant
  wa_variant-variant  = p_var.
* Display the ALV report
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'                "D01K913690
       EXPORTING
            i_callback_program             = wa_callback_program
            i_callback_pf_status_set    = 'SET_PF_STATUS'              "D01K913690
            i_callback_user_command  = 'USER_COMMAND'
            is_layout_lvc                       = wa_layout                          "D01K913690
            it_fieldcat_lvc                      = t_fieldcat                            "D01K913690
            it_excluding                         = t_excluding
            i_save                                 = 'A'
            is_variant                            = wa_variant
       TABLES
            t_outtab                              = t_regut
*      EXCEPTIONS
*           PROGRAM_ERROR            = 1
*           OTHERS                             = 2
ENDFORM.                               " DISPLAY_DATA
FORM user_command
  USING
    r_ucomm     LIKE sy-ucomm
    rs_selfield TYPE slis_selfield.
  DATA: wa_text(80) TYPE c.
  CASE r_ucomm.
    WHEN '&EXE'.   "User pressed custom Execute button
      DATA ref1 TYPE REF TO cl_gui_alv_grid.
      CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
        IMPORTING
          e_grid = ref1.
      DATA: lt_index_rows TYPE lvc_t_row,
                 lt_row_no TYPE lvc_t_roid,
                 lw_row_no TYPE lvc_s_roid.
      CALL METHOD ref1->get_selected_rows
        IMPORTING
          et_index_rows = lt_index_rows
          et_row_no     = lt_row_no.
      LOOP AT lt_row_no
         INTO lw_row_no.
         *** CODE TO PROCESS EACH RECORD FROM MULTIPLE SELECTED***
      ENDLOOP.  "loop at lt_row_no
    WHEN '&IC1'.  "User double-clicked on row
      *** CODE TO PROCESS SINGLE RECORD SELECTED ***
    WHEN '&F03' .          " back
      SET SCREEN 0. LEAVE SCREEN.
    WHEN '&F15' .          " exit
      SET SCREEN 0. LEAVE SCREEN.
    WHEN '&F12' .          " cancel
      SET SCREEN 0. LEAVE SCREEN.
  ENDCASE.
ENDFORM.                               " USER_COMMAND
FORM set_pf_status USING rt_extab TYPE slis_t_extab.
  SET PF-STATUS 'STANDARD1'.
ENDFORM. " set_pf_status
Hope this helps ...
Regards,
Kevin
Moderator message - Welcome to SCN.
However, as you can see, the forum software was unable to format this because of the 2,500 character posting limit. since this looks interesting, would you please try to edit to conform to that limitation? You may try to split it into an initial post and a response.
Edited by: Rob Burbank on Jul 8, 2009 1:39 PM

Hi ,
     Make it use in your code and let me know if u have any concerns...
    Use "Subtotal_text" in events table.
here GTOTAL is field in itab on which we sortindf data, and use your own field on which field u want to sort...
refresh gt_event.
clear gw_event.
call function 'REUSE_ALV_EVENTS_GET'
   EXPORTING
     i_list_type = 0
   IMPORTING
     et_events   = gt_event.
Subtotal
read table gt_event with key name = slis_ev_subtotal_text into gw_event.
if sy-subrc = 0.
   move 'SUBTOTAL_TEXT' to gw_event-form.
   append gw_event to gt_event.
endif.
     form subtotal_text using uw_subtot_line type ty_main
                uv_subtottxt type slis_subtot_text.  "#EC CALLED
if uv_subtottxt-criteria = 'GTOTAL'.
   uv_subtottxt-display_text_for_subtotal = 'TOTAL'.
endif.
     *FORM build_sort .
refresh gt_sort.
gw_sort-spos      = 1.
gw_sort-fieldname = 'GTOTAL'.
gw_sort-tabname   = 'GT_MAIN'.
gw_sort-up        = 'X'.
gw_sort-subtot    = 'X'.
APPEND gw_sort TO gt_sort.
CLEAR gw_sort.
Reward points once its useful..

Similar Messages

  • How to obtain the selected rows in the model with af:Table using selectMany

    Hi ,
    I am using multi select af:Table and it is based on a programmatically populated view. When the table is single select I can use the getCurrentRow at the view implementation. I wonder whether there is a way to get list of selected rows within the view implementation for the multi-select scenario.
    I saw some ways of doing it in the page's backing bean but it will be more appropriate if I could do it at the model project.
    Thanks
    My environment is JDeveloper 10.1.3.3 and jdk 1.4

    Thanks for your reply.
    What you say makes sense. I thought there might be way of setting the selected rows in the model also as we do woth the current row.
    But looks like these two different things.
    Anyway I am doing it by passing the values through the backing bean.
    Thanks

  • When I select "Convert" using the Adobe PDF conversion - I get "Error signing in"

    When I select "Convert" using the Adobe PDF conversion - I get "Error signing in"

    You need the CreatePDF forum

  • Get selected row from grid

    Hi
    I use JDev 11.1 with ADF, i have grid, i need to get selected row of grid when i press buttom, how can i do that?
    Thanks

    Hi,
    You have a table in your page that is based on a viewObject iterator and you need to get the selected row in your backing bean when you click on a button.
    Did I get this right?
    If so then you need to add an actionListener on this button that executes a method in the backing bean.
    the button code:
    <af:commandButton text="commandButton 1" id="cb1"
                                        actionListener="#{myBean.buttonActionListener}"/>In this method you need to add code like this:
      public void buttonActionListener(ActionEvent actionEvent) {
        BindingContext bindingctx=BindingContext.getCurrent();
        DCBindingContainer bindings=(DCBindingContainer)bindingctx;
        DCIteratorBinding iter= bindings.findIteratorBinding("iteratorName");
        Row currentRow=iter.getCurrentRow();
      }If this is not what you need give some more details.
    Gabriel

  • How to get selected  row index  of a Table ?

    hi gurus,I'm new  to Webdynpro for abap
    I'm displaying    just Flight details in a Table  so
    how to get selected  row index  of a  Table  and need  to be display in Message manager.

    Hi,
    For getting the row index use the following code.
    DATA lo_nd_node TYPE REF TO if_wd_context_node.
      DATA lo_el_node TYPE REF TO if_wd_context_element.
      DATA index TYPE i.
    * navigate from <CONTEXT> to <NODE> via lead selection
      lo_nd_node = wd_context->get_child_node( name = wd_this->wdctx_node ).
      lo_el_node = lo_nd_node->get_lead_selection(  ).
      index = lo_el_node->get_index( ).
    node is the name of the node which is binded to the table.
    For printing the message u can use code wizard.
    Press ctrl-F7. Now Select generate message.
    IN this select the method  REPORT_SUCCESS
    In the code now u can give index to Message text Exporting parameter. Comment receiving parameter.
    Write the whole code in onLeadSelect of the table.
    Regards,
    Pankaj Aggarwal

  • How to get selected Row Index in a table based ona  VO?

    Hi All,
    I'm writing an ADF form wherein I use a VO based on a SQL query. I'd like to know how to get the index of a selected row. I havea selection Listener in place where I can print the selected Row's data using getSelectedRowData().toString() on the table.
    How can I get certain Attributes from this selected row.
    One solution I thought of is to get the row index and then read attributes. But I cant seem to figure out how to get rowIndex for a selected row. Any sugestions?
    Using JDeveloper 11g.
    Thanks
    P.

    If your selected row is marked as current row you can use
    // Get a attribute value of the current row of iterator
    DCIteratorBinding iterBind= (DCIteratorBinding)dcBindings.get("testIterator");
    String attribute = (String)iterBind.getCurrentRow().getAttribute("field1");Where 'testIterator' is the name of the iterator you use for the table and 'field1' is the name of an attribute you want to get.
    Or you can iterate over the selected row keys (even if it's only one):
    // get  selected Rows of a table 2
    for (Object facesRowKey : table.getSelectedRowKeys()) {
    table.setRowKey(facesRowKey);
    Object o = table.getRowData();
    JUCtrlHierNodeBinding rowData = (JUCtrlHierNodeBinding)o;
    Row row = rowData.getRow();
    TestRow testRow = (TestRow)((DCDataRow)row).getDataProvider() ;
    }Where TestRow is the row type of the VO of your table.
    Timo

  • Getting selected rows in ALV grid output

    Hi All,
    As per my requirement, in the ALV output i have 3 push buttons (Display, Edit and Print).
    Using the below code, I am trying to get the selected rows from the output.
        CALL METHOD ob_grid->check_changed_data
          CHANGING
            c_refresh = w_x.
        CALL METHOD ob_grid->get_selected_rows
          IMPORTING
            et_index_rows = is_rows.
    When I execute the code wid Display/Edit push buttons it is working fine as long as Print button is not used.
    If I use the Print button and then try to select any other push button, I am not getting the entries in is_rows internal table.
    Kindly help me.
    Thanks in Advance.

    Would your user actually select a row if they wanted simply to print?   I don't see that you're checking to see if the user actually selected a row ( after et_index_rows = is_rows, need to be sure is_rows is not initial (zero)).    Debug should show you exactly what is happening in the situation you described.

  • WEB DYNPRO ALV GRID  GET SELECTED ROWS...

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

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

  • Getting selected row for command link in af:table

    Hi
    I have a h:commandLink in a column of my af:table. When it is clicked, I need to get the selected row data.
    I know the documentation says use setCurrentRowValue method, but I am not using the Data Control Palette - I get the data fromt the database using code in the BackingBean.
    Is there any other way? Pls help.

    Yes, I got it. But my method gets the data in the selected row, not the rowKey
    First I used af:commandLink instead of h:commandLink and then used af:setActionListener based on an example in the jDeveloper Help. I had to change it a bit since I am not using DCP or bindings.
    This is the sample from Help, hope it helps!
    SF Page Code for a Command Link Using a setActionListener Component <af:commandLink actionListener="#{bindings.setCurrentRowWithKey.execute}"
    action="edit"
    text="#{row.svrId}"
    disabled="#{!bindings.setCurrentRowWithKey.enabled}"
    id="commandLink1">
    <af:setActionListener from="#{row.svrId}"
    to="#{userState.currentSvrId}">
    </af:commandLink>

  • When iam selecting row of the table i got the exception

    Hi ,
    When iam selecting row in the table at that time iam getting below exceptions
    <21/02/2013 1:31:35 PM EST> <Warning> <oracle.adf.view.rich.component.fragment.UIXRegion> <ADF_FACES-00009> <Error processing viewId: /InventoryPropertiesViewTF/InventoryPropertiesView URI: /com/avocent/trellis/apps/mainUi/inventory/pages/fragments/InventoryPropertiesView.jsff actual-URI: /com/avocent/trellis/apps/mainUi/inventory/pages/fragments/InventoryPropertiesView.jsff.
    javax.el.PropertyNotFoundException: Target Unreachable, 'BracketSuffix' returned null
    <21/02/2013 1:31:35 PM EST> <Warning> <oracle.adf.view.rich.component.fragment.UIXRegion> <ADF_FACES-00009> <Error processing viewId: /PropertyDisplayTF/PropertyDisplay URI: /com/avocent/trellis/apps/coreapps/ui/fragments/PropertyDisplay.jsff actual-URI: /com/avocent/trellis/apps/coreapps/ui/fragments/PropertyDisplay.jsff.
    javax.el.PropertyNotFoundException: Target Unreachable, 'BracketSuffix' returned null
         at com.sun.el.parser.AstValue.getTarget(Unknown Source)
    Please Let me know why its getting this type exception only some time interemitten issue,
    Please provide me any solution for these,
    jdeveloper 1.1.1.4

    Check your page code for an EL that uses 'BracketSuffix'. This is the point of error as the 'BracketSuffix' can't be evaluated at the given point.
    Timo

  • To get selected rows from alv output which is prepared with funciton module

    Hi ,
    I have a program which is prepared ALV with funciton modules.
    Now i have to get selected rows(more than one).
    Can i use method CL_GUI_ALV_GRID -> get_selected_rows.
    or any other way to get selected rows.
    thanks,
    shyla

    Under the callback subroutine ( u have passed them in I_CALLBACK_USER_COMMAND of ur function module) - u do like this -
    DATA : ref1 TYPE REF TO cl_gui_alv_grid,
               t_selcted_rows type LVC_T_ROID.
    CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
    IMPORTING e_grid = ref1.
    call method ref1->get_selected_rows
    importing ET_ROW_NO = t_selected_rows.
    Hope this solves ur problem.

  • How to get selected row keys from RichSelectManyCheckbox

    Adf Table has getSelectedRowKeys but SelectManyChekcbox does not has anything similar. Can you tell me how to get selected row keys programmatically for RichSelectManyCheckbox?

    Hi User,
    selectManyCheckbox component's value property holds the selected items values. Bind this property to some bean variable(of type list) so that you can get the selected values by accessing the bean property.
    Sireesha

  • How to get selected row from table(FacesCtrlHierBinding ).

    I'am trying to get selected row data from table:
    FacesCtrlHierBinding rowBinding = (FacesCtrlHierBinding) tab.getSelectedRow();
    Row rw = rowBinding.getRow();
    But import for oracle.adfinternal.view.faces.model.binding.FacesCtrlHierBinding cannot be found from my JDev 11.
    What is correct package for FacesCtrlHierBinding?

    Hi, another problem.
    I fill table with data manualy from source:
    <af:table var="row" value="#{getCompanyData.com}"
    rowSelection="single" columnSelection="single"
    editingMode="clickToEdit"
    binding="#{getCompanyData.tab}"
    selectionListener="#{getCompanyData.GetSelectedCompany}">
    <af:column sortable="false" headerText="col1">
    <af:outputText value="#{row.id}"/>
    </af:column>
    <af:column sortable="false" headerText="col2">
    <af:outputText value="#{row.name}"/>
    </af:column>
    <af:column sortable="false" headerText="col3">
    <af:outputText value="#{row.phone}"/>
    </af:column>
    </af:table>
    and when I'am trying to use method to get selected row:
    RichTable table = this.getTab(); //get table bound to UI Table
    RowKeySet rowKeys = table.getSelectedRowKeys();
    Iterator selection = table.getSelectedRowKeys().iterator();
    while (selection.hasNext())
    Object key = selection.next();
    table.setRowKey(key);
    Object selCompany = table.getRowData();
    JUCtrlHierNodeBinding rowData = (JUCtrlHierNodeBinding) selCompany;
    row = rowData.getRow();
    I got an error:
    SEVERE: Server Exception during PPR, #1
    javax.el.ELException: java.lang.ClassCastException: data.COMPANY cannot be cast to oracle.jbo.uicli.binding.JUCtrlHierNodeBinding
    When I created tables by dragging data from date control, all worked fine.
    What could be a problem?

  • How to select rows in the inner JTable rendered in an outer JTable cell

    I have wrriten the following code for creating cell specific renderer - JTable rendered in a cell of a JTable.
    table=new JTable(data,columnNames)
    public TableCellRenderer getCellRenderer(int row, int column)
    if ((row == 0) && (column == 0))
    return new ColorRenderer();
    else if((row == 1) && (column == 0))
    return new ColorRenderer1();
    else
    return super.getCellRenderer(row, column);
    ColorRenderer and ColorRenderer1 are two inner classes, which implement TableCellRenderer to draw inner JTable on the outer JTable cell, having 2 rows and 1 column each.
    Now what is happening the above code keeps executing continously, that is the classes are being initialised continously, inner JTables are rendered (drawn) continously, and this makes the application slow after some time. It throws java.lang.OutOfMemoryException.
    WHY IS IT SO??? I can't understand where's the bug..
    Any advice please???
    Moreover i want selections in inner tables and not on outer table, how can this be possible.
    I am working on this since a long time but have not yet found a way out...

    With your help i have overcome the problem of continous repeatition.
    The major problem which I am facing is, in selecting rows in the inner rendered JTables.
    I have added listener on outer JTable which select rows on the outer JTable, hence the complete inner JTable which being treated as a row, gets selected.
    The thing is i need to select the rows of inner rendered JTables,not the outer JTable.
    How to go about it??
    I have even added listener to inner rendered JTables, but only first row of every table gets selected.
    Please help....
    Thanks in advance.

  • Can't Select Rows in the Microsoft Edge F12 Network Inspector

    Applies To: Microsoft Edge F12 Developer Tools
    Release: Windows 10 Insider Preview SDK and tools, April 2015 release
    Issue:
    Can’t select rows in the network inspector with mouse to see body, timings etc.

    Workaround
    Use arrow keys. The initially selected row, when focus is on the network data grid, will be the last row so you may need to press up arrow several times to reach a displayed row.

Maybe you are looking for

  • How can i add the songs in ringtone

    How can i add the my fav songs in rintone gallery top play a custom wise songs on contact numbers

  • Walkman Performance on Z3 Compact

    Hi, currently I own the Z1 Compact but I plan to "upgrade" to the Z3 Compact very soon. View questions please: Sound quality in Walkman App BETTER than Z3 Compact? High Res Audio: Is it worth?  Sound Volume: Quite low on the Z1 Compact ... I would li

  • Regarding Jobs in PLSQL

    Hi everyone i am finding jobs as a ORACLE PLSQL DEVELOPER. Can anyone help me what are the main points/topics to study regarding interviews. . .I am totally lost what to study what not? As PLSQL is vast thats why i am facing difficulty what to study

  • Web DVD subtitle default

    Does anyone know of a way to set the subtitle language from javascript with a web DVD exported from Encore? I have managed to sort of hack around it by creating duplicates of the title display items and appending their id with the language code (like

  • Using Powershell to create Pervasive database

    In my quest to replace a bunch of old scripts and programs (blend of VB, bat files, manual intervention) to automate some processes, I'm trying to create a pervasive.sql database with Powershell. They currently use an old VB script to do this, and th