cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with get_cell_value

alberto_colonna
Participant
0 Kudos

Hi all,

I have written this application, consists of 2 bsp-sites.

The .1 site includes an inputfield with the f4-help. The page-attribute is called

abc type string. the 2. site contains a tableview object with selectionmode "lineEdit". In the table I display the entries from table SPFLI from column CARRID.

If the user clicks on the f4-help of the inputfield (site 1), a Javascript Function is called, which opens the 2. site into a new window.

When a row of the tableview is selected, the value of the column shall be passed to site 1.

To test this, I created the pageattribute abc. The value of the cell shall be stored in abc and this value has to bo displayed into the inputfield of site 1.

Here is my code, but it doesn't work:

I assume, that there is an error in onInputProcessing.

<b>2. Site - Layout</b>

<%@page language="abap" %>
<%@extension name="htmlb" prefix="htmlb" %>
<htmlb:content design="design2003" >
  <htmlb:page title="Display Table " >

    <%
      TYPES: begin of line_spfli,
               carrid type spfli-carrid,
             end of line_spfli.

      DATA: itab_spfli type standard table of line_spfli,
            wa like line of itab_spfli.

      select distinct carrid from spfli into table itab_spfli.
    %>

    <script>
      function pass_values(id)
      {
         window.close()
         opener.document.getElementById('asset').value = id
      }
    </script>

    <br>

    <htmlb:form id = "main_form">

      <htmlb:tableView  id = "table_Entries"
             headerVisible = "TRUE"
             selectionMode = "lineEdit"
                     table = "<%= itab_spfli %>" >

             <htmlb:tableViewColumns>

             <htmlb:tableViewColumn  columnName = "carrid"
                                       wrapping = "true"
                                          width = "100"
                            horizontalAlignment = "center" >
             </htmlb:tableViewColumn>

             </htmlb:tableViewColumns>

      </htmlb:tableView>

    </htmlb:form>

  </htmlb:page>
</htmlb:content>

<b>OnInputProcessing (Site 2)</b>

* event handler for checking and processing user input and
* for defining navigation

DATA: event TYPE REF TO cl_htmlb_event,
      tv TYPE REF TO cl_htmlb_tableview,
      table_event TYPE REF TO cl_htmlb_event_tableview,
      selected_row_index TYPE selectedrow-index,
      cell_value TYPE string.

IF event_id = 'htmlb'.
  event = cl_htmlb_manager=>get_event( runtime->server->request ).
  CASE event->server_event.
    WHEN 'button_go'.
      tv ?= cl_htmlb_manager=>get_data( request = request
                                        name    = 'tableView'
                                        id      = 'table_Entries' ).
      IF tv IS NOT INITIAL.
        table_event = tv->data.
        selected_row_index = table_event->selectedrowindex.

        cell_value = table_event->get_cell_value(
            row_index    = selected_row_index
            column_index = 1 ).
      ENDIF.
  ENDCASE.
ENDIF.

navigation->set_parameter( name = 'abc' value = cell_value ).
navigation->next_page( 'TOINDEX' ).

Message was edited by:

Alberto Colonna

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi ALbert,

Try debugging and check if selectedrowindex is getting populated.

If not you try this code in oninputprocessing :


  DATA: tv          TYPE REF TO   CL_HTMLB_TABLEVIEW,
        table_event TYPE REF TO   CL_HTMLB_EVENT_TABLEVIEW.
  DATA: event       TYPE REF TO   IF_HTMLB_DATA.

DATA : selectedrowindextable type INT4_TABLE,
lw_index type string.


  tv ?= cl_htmlb_manager=>get_data( request = request
                                    name    = 'tableView'
                                    id      = 'table_Entries' ).
  IF tv IS NOT INITIAL.
    table_event = tv->data.
    CLEAR selectedrowindextable.
    selectedrowindextable = table_event->prevselectedrowindextable.
    IF table_event->event_type EQ cl_htmlb_event_tableview=>co_row_selection.
      READ TABLE selectedrowindextable WITH KEY table_line =
    table_event->row_index
          TRANSPORTING NO FIELDS.
      IF sy-subrc EQ 0.
        DELETE selectedrowindextable INDEX sy-tabix.
      ELSE.
        APPEND INITIAL LINE TO selectedrowindextable ASSIGNING <i>.
        <i> = table_event->row_index.
        lw_index = table_event->row_index.
      ENDIF.
    ENDIF.
  ENDIF.
  event = cl_htmlb_manager=>get_event( request ).
  IF event IS NOT INITIAL .
IF event->EVENT_NAME = 'button' and event->EVENT_TYPE = 'click'.
      but_event ?= event.
      CASE event->EVENT_ID.
when 'your_button_id'.
navigation->set_parameter( name = 'abc' value = cell_value ).
navigation->next_page( 'TOINDEX' ).

ENDCASE.
ENDIF.

There might be missing ENDIf's...!!

Hope this helps.

<b><i>Do reward each useful answer..!</i></b>

Thanks,

Tatvagna.

alberto_colonna
Participant
0 Kudos

I tried to debug the application but I dind't find an error.

I think there is an error in onInputProcessing.

If I select a row in the tableview, the application navigates to the 1. page

but the selected value is not displayed in the inputfield.

Former Member
0 Kudos

Hi Albert,

Have you put the button code in the Layout section....

I don't see a button code...!!

Hope this helps.

<b><i>Do reward each useful answer..!</i></b>

Thanks,

Tatvagna.

alberto_colonna
Participant
0 Kudos

Hi,

sorryI made a mistake in my code. There is no button.

Now I have modified the code, but it still doesn't work.

Here the code:

* event handler for checking and processing user input and
* for defining navigation

DATA: event TYPE REF TO cl_htmlb_event,
      tv TYPE REF TO cl_htmlb_tableview,
      table_event TYPE REF TO cl_htmlb_event_tableview,
      selected_row_index TYPE selectedrow-index,
      cell_value TYPE string.

IF event_id = 'htmlb'.
  event = cl_htmlb_manager=>get_event( runtime->server->request ).

      tv ?= cl_htmlb_manager=>get_data( request = request
                                        name    = 'tableView'
                                        id      = 'table_Entries' ).
      IF tv IS NOT INITIAL.
        table_event = tv->data.
        selected_row_index = table_event->selectedrowindex.

        cell_value = table_event->get_cell_value(
            row_index    = selected_row_index
            column_index = 0 ).
      ENDIF.
endif.

navigation->set_parameter( name = 'abc' value = cell_value ).
navigation->next_page( 'TOINDEX' ).

Message was edited by:

Alberto Colonna

Former Member
0 Kudos

Ok,

No probs.

Try this...in your code, replace

      IF tv IS NOT INITIAL.
        table_event = tv->data.
        selected_row_index = table_event->selectedrowindex.

with

      IF tv IS NOT INITIAL.
        table_event = tv->data.
        selected_row_index = table_event->prevselectedrowindextable.

Also try this....

change the data-type of

selected_row_index TYPE selectedrow-index,

to

selected_row_index TYPE int4_table.

Hope this helps.

<b><i>Do reward each useful answer..!</i></b>

Thanks,

Tatvagna.

alberto_colonna
Participant
0 Kudos

Hi Tatvagna,

thanks for your help.

when I use your code, I get following error message:

"selected_row_index" is not compatible to the parameter "row_index"

Best regards

Alberto

Former Member
0 Kudos

right...that because this is a table....

try reading this into a line/wa and then pass it to row_index of get_cell_value.

Hope this helps.

<b><i>Do reward each useful answer..!</i></b>

Thanks,

Tatvagna.

alberto_colonna
Participant
0 Kudos

Hi,

I have done this, but it still doesn't work.

Here is the code:

* event handler for checking and processing user input and
* for defining navigation

DATA: event TYPE REF TO cl_htmlb_event,
      tv TYPE REF TO cl_htmlb_tableview,
      table_event TYPE REF TO cl_htmlb_event_tableview,
      selected_row_index TYPE int4_table,
      wa_test like line of selected_row_index,
      cell_value TYPE string.

IF event_id = 'htmlb'.
  event = cl_htmlb_manager=>get_event( request ).

  tv ?= cl_htmlb_manager=>get_data( request =  request
                                    name    = 'tableView'
                                    id      = 'table_Entries' ).


      IF tv IS NOT INITIAL.
        table_event = tv->data.
        selected_row_index = table_event->prevselectedrowindextable.

    loop at selected_row_index into wa_test.

      cell_value = table_event->get_cell_value(
          row_index    = wa_test
          column_index = '0' ).
    endloop.
  ENDIF.

ENDIF.

navigation->set_parameter( name = 'abc' value = cell_value ).
navigation->next_page( 'TOINDEX' ).