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

Retriving Data from TableView with a Button Click

Hi,

I have a TableView and a Button. The requirement is that the user can select several rows in the tableview and click the button to process the selected rows. I am using the following logic in OnInputProcessing to retrive the rows selected,

DATA: TB1 TYPE REF TO CL_HTMLB_TABLEVIEW,

tlist1 TYPE REF TO OBJECT.

case event->name.

WHEN 'button'.

CALL METHOD cl_htmlb_manager=>get_data

EXPORTING

request = runtime->server->request

name = 'tableView'

id = 'tvX'

RECEIVING

data = tlist1.

TB1 = tlist1.

  • Then access TB1->data->prevselectedrowindextable to find out which row indexes the user has clicked in TableView.

However I get error that can't assign type ot tlist1 to TB1.

The return type of tlist1 is TYPE REF TO CL_HTMLB_TABLEVIEW so this assignment should be possible.

But I think the problem is only during runtime is the type of tlist1 knowm. ?

Also, is there a better way to retrive multiple rows from a tableview when a button is clicked ?

Thanks

Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • Best Answer
    Posted on Feb 04, 2005 at 03:36 PM

    Hi Anand,

    please have a look at application sbspext_table page TableViewMultiSelect.bsp. That's the example you need.

    Regards,

    Rainer

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Feb 04, 2005 at 08:34 PM

    Anand,

    <i>But I think the problem is only during runtime is the type of tlist1 knowm. ?</i>

    You are correct that ? is the character you are looking for here. In your next quiet moment, spend some time reading ABAP online docs (or in fact any OO like language) on casting.

    DATA: tb  TYPE REF TO CL_HTMLB_TABLEVIEW,
          obj TYPE REF TO OBJECT. 
    obj = tb.
    tb ?= obj.
    

    You need the ? to indicate to ABAP that are casting from an OBJECT to something bigger. Notice that in the other way this is not required.

    (If you find the relevant link onto help.sap.com, you can append it here. I don't have it handy at the moment.)

    brian

    PS: I see that you are new in our small corner of SDN, and would thus recommend that you also look at <a href="/people/brian.mckellar/blog/2004/06/11/bsp-trouble-shooting-getting-help">Getting Help</a>. It helps to keep the learning curve short.

    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.