Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Problem in capturing Tableview Selectedrow contents

Hi I am experiencing problem in capturing the contents of the selected row in the tableview. My Code looks like as follows:

<b>Layout</b>

<%@page language="abap" %>
<%@extension name="htmlb" prefix="htmlb" %>
<htmlb:content design="design2003" >
<%--  <%@include file="head.htm" %> --%>

  <htmlb:page title="Company Code Search " >
    <htmlb:form>
      <htmlb:label for      = "l_CCODE"
                   text     = "Field"
                   tooltip  = "User ID"
                   required = "X"
                   width    = "100px"
                   design   = "EMPHASIZED" />
      <htmlb:dropdownListBox id = "ddname">
        <htmlb:listBoxItem key   = "li_bukrs"
                           value = "Company Code" />
        <htmlb:listBoxItem key   = "li_butxt"
                           value = "Company Code Description" />
      </htmlb:dropdownListBox>
      <htmlb:inputField id    = "i_search"
                        value = "Search term" />
      <htmlb:button id      = "b_search"
                    text    = "Search"
                    tooltip = "click here to start the search"
                    onClick = "onInputProcessing(select)" />
      <br>

      <htmlb:tableView id              = "tv_tabid"
                       table           = "<%= gt_t001 %>"
                       design          = "STANDARD"
                       designMode      = "HTMLB"
                       allRowsEditable = "TRUE"
                       tableLayout     = "AUTO"
                       width           = "75%"
                       visibleFirstRow = "1"
                       visibleRowCount = "10"
                       headerVisible   = "TRUE"
                       headerText      = "Company Code Selection Table"
                       onRowSelection  = "onInputProcessing(select)"
                       selectionMode   = "SINGLESELECT"
                       selectedRowKey  = "wa-BUKRS"
                       navigationMode  = "BYPAGE"
                       footerVisible   = "TRUE" >
        <htmlb:tableViewColumn columnName="BUKRS"
                                    title= "Company Code">
        </htmlb:tableViewColumn>
        <htmlb:tableViewColumn columnName="BUTXT"
                                    title= "Description">
        </htmlb:tableViewColumn>
      </htmlb:tableView>
    </htmlb:form>
  </htmlb:page>
</htmlb:content>

<b>OnInputProcessing</b>

event = cl_htmlb_manager=>get_event( request ).

CASE event->id.
  WHEN 'b_search'.
    DATA: l_ccode TYPE REF TO cl_htmlb_inputfield.
    DATA: l_id TYPE REF TO cl_htmlb_dropdownlistbox.

    l_ccode ?= cl_htmlb_manager=>get_data( request = runtime->server->request
                                          name    = 'inputField'
                                          id      = 'i_search' ).

    l_id ?= cl_htmlb_manager=>get_data( request = runtime->server->request
                                        name    = 'dropdownListBox'
                                        id      = 'ddname' ).

    ls_listvalue = l_id->selection.
    IF NOT  l_ccode->value IS INITIAL.
      IF ls_listvalue = 'li_bukrs'.
        ls_name = l_ccode->value.
      ENDIF.
* Read Data into internal table by search term
   Select * from T001 into table gt_t001 where bukrs = ls_name.
    ENDIF.

  WHEN 'tv_tabid'.
    DATA: tv_table TYPE REF TO cl_htmlb_tableview.
    DATA: table_event TYPE REF TO cl_htmlb_event_tableview.
    DATA: selectedrowindex TYPE i.

    tv_table ?= cl_htmlb_manager=>get_data( request = runtime->server->request
                                         name    = 'tableView'
                                         id      = 'tv_tabid' ).
    IF tv_table IS NOT INITIAL.
      table_event = tv_table->data.
      selectedrowindex = table_event->selectedrowindex.
* Read Table gt_t001 into Work Area and Pass the selected value through Navigator
      READ TABLE gt_t001 INTO wa_t001 INDEX selectedrowindex.
      navigation->set_parameter( name = 'nv_bukrs' value = 'samp').
      navigation->goto_page( 'FormRequest.bsp' ).


    ENDIF.

ENDCASE.

When I selected a row in the tableview, I am getting the selectedrow Index (selectedrowindex = table_event->selectedrowindex.). But the Values in the table gt_t001 are disapperiaring to read the contents by selectedrowindex.

Is there a way of capturing the contents of selected row or if I am doing any wrong in loosing the data from internal table.

Please help.

Former Member
Not what you were looking for? View more on this topic or Ask a question