Skip to Content
author's profile photo Former Member
Former Member

Inputfield values while using tableview & iterator

Hi,

I'm using the MVC pattern for my BSP application.

I'm displaying data obtained from a DB table in a tableview. 2 columns need to have editable fields for user input which will then be saved in a custom table.

I managed to display the table data and get the 2 columns as editable using an iterator and overwriting the IF_HTMLB_TABLEVIEW_ITERATOR~GET_COLUMN_DEFINITIONS method.

I'm also able to get data about which row that was selected in the tableview event on do_handle_event.

However, I'm unable to access the data that is entered in the 2 editable fields.

I have gone through Brian's blog on tableview but couldn't find info on how to read data from the editable columns (especially in the MVC scenario).

I have tried every possible way I could think of but I guess I'm missing something very basic.

Could someone please help?

Add a comment
10|10000 characters needed characters exceeded

Related questions

4 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Feb 09, 2005 at 06:08 AM

    This is a bit tricky the first time around.

    1 of the easiest ways is to read the form field value like a normal form field on your page, the key is to know how the field is called.

    [controller name]_[tableview name]_[row index]_[cell]

    I have a View called data and in that view I have a tableview called flighttab and I want to read the value for the selected row which 5 and the cell 7 and 8

      data: lt_1 type string,
            lt_2 type string.
      lt_1 = request->get_form_field( name = 'data_flighttab_5_7' ).
    
      lt_2 = request->get_form_field( name = 'data_flighttab_5_8' ).
    
    

    So a quick CONCATENATE command with the selectedRowIndex value and you are all set to go 😊

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Feb 09, 2005 at 09:29 AM

    Hi Vivek,

    as you are using MVC you might also consider using <b>Data Binding</b>, this simplifies your life a lot!

    Have a look at the documentation, try it, if you have questions left come back again 😊

    Model" target="_blank">http://help.sap.com/saphelp_webas620/helpdata/en/0f/ab3a3c9ca75402e10000000a114084/frameset.htm">Model View Controller (MVC)

    Data" target="_blank">http://help.sap.com/saphelp_webas620/helpdata/en/fb/fbb84c20df274aa52a0b0833769057/frameset.htm">Data Binding

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 09, 2005 at 01:20 PM

    Hi,

    Thanks Craig for your answer, I was able to get that working. Maximilian, I agree using a model might simplify things but unfortunately I'm at a point where there's no going back 😊

    Thanks a lot for the quick response, it was a great help!

    I have another logic issue here that I could use some help with. My tableview is a MULTILINEEDIT and finally on submitting the form, I insert details of only those rows that were selected in the tableview.

    The user can select each row, making the 2 fields editable, enter values and move on either to the next row or click the submit.

    Using the code below, i can read the 2 inputfields for all previously selected rows. Even if I get the currently selected row, the user has not yet entered values for the inputfields. Hence, I am unable to get values from the last selected row.

    IF htmlb_event IS BOUND AND htmlb_event->name = 'tableView'.

    table_event ?= htmlb_event.

    IF table_event->selectedrowindex IS NOT INITIAL.

    rowselection = table_event->selectedrowindex.

    srit = table_event->prevselectedrowindextable.

    • Append current row to selection if previously not included

    READ TABLE srit WITH TABLE KEY TABLE_LINE = rowselection

    TRANSPORTING NO FIELDS.

    IF sy-subrc <> 0.

    APPEND rowselection TO srit.

    ENDIF.

    LOOP AT srit INTO ls_row.

    READ TABLE salineitem INDEX ls_row INTO wa_salineitem.

    ...concatenate row no.

    ...get data

    ...and process

    ENDLOOP.

    ENDIF.

    ENDIF.

    ENDIF.

    Could you please let me know if you'll have any other suggestion for this. Thanks once again!

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 09, 2005 at 05:55 PM

    I finally got that done as well.

    I read the values for tableview fields using the form field only during submit of my form. That way, even if just one line was edited by the user, I get the data even after tableview event was called.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.