cancel
Showing results for 
Search instead for 
Did you mean: 

displaying listbox on Multiple selections

former_member198064
Participant
0 Kudos

Hi All,

I am displaying the data in the table according to the multiple selection in listbox.

I am getting the data in Item listbox but i am not able to fill the data in the table.

My code is to get the data in listbox as:

* data declaration

   DATA lt_airline TYPE wd_this->Elements_airline.

   DATA ls_airline LIKE LINE OF lt_airline.

select DISTINCT carrid from sflight into TABLE lt_airline.

* bind all the elements

   node->bind_table(

     new_items            =  lt_airline

     set_initial_elements = abap_true ).

here i am getting the data in list box.

According to the selection in listbox i need to fill data in table.

method ONACTIONGET_DATA .

   DATA lo_nd_airline TYPE REF TO if_wd_context_node.

   DATA lo_el_airline TYPE REF TO if_wd_context_element.

   DATA ls_airline TYPE wd_this->element_airline.

   DATA lt_airline TYPE wd_this->elements_airline.

   DATA lt_elements TYPE wdr_context_element_set.

   DATA lv_id LIKE ls_airline-id.

   DATA lo_nd_sflight TYPE REF TO if_wd_context_node.

   DATA lo_el_sflight TYPE REF TO if_wd_context_element.

   DATA ls_sflight TYPE wd_this->element_sflight.

   DATA lt_sflight TYPE wd_this->elements_sflight.

   DATA lt_sflight2 TYPE wd_this->elements_sflight.

* navigate from <CONTEXT> to <AIRLINE> via lead selection

   lo_nd_airline = wd_context->get_child_node( name = wd_this->wdctx_airline ).

   lo_nd_airline->get_static_attributes_table(

       importing

         table = lt_airline ).

*lt_elements   = context_node->get_lead_selection( ).

   lt_elements = lo_nd_airline->get_selected_elements( ).

   LOOP AT lt_elements INTO lo_el_airline.

     call METHOD lo_el_airline->get_static_attributes( IMPORTING static_attributes = ls_airline ).

     APPEND ls_airline TO lt_airline.

   ENDLOOP.

* navigate from <CONTEXT> to <SFLIGHT> via lead selection

   lo_nd_sflight = wd_context->get_child_node( name = wd_this->wdctx_sflight ).

   SELECT  carrid

              connid

              fldate

              currency

              planetype

        FROM  sflight

   INTO TABLE lt_sflight.

   LOOP AT lt_airline INTO ls_airline.

     LOOP AT lt_sflight INTO ls_sflight WHERE carrid = ls_airline-id.

       APPEND ls_sflight TO lt_sflight2.

     ENDLOOP.                         

   ENDLOOP.                           

* Bind Internal table with Table Element

   lo_nd_sflight->bind_table( lt_sflight2 ).

endmethod.

When i am executing i am not able to fill the data.Can you please any one help me on this.

Thanks,

Venkatesh.

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hello Venkatesh

I did the same example a while ago. I had the exact same issue. When I tried to fill the Web Dynpro table from the database  it would not fill .The component would activate fine. In the application the listbox would get filled but when I tried to select data from the listbox  and fill the table it would instead show me an error. I  have followed the same steps as on the SAP Technical website with the normal database table that I have created myself . With one exception. When it came to the select statement in the ONACTIONGET_DATA method I did the  following.

The code that is in the example is :

SELECT carrid connid fldate currency planetype FROM sflight INTO TABLE lt_sflight.

What I did is:

SELECT (Then I listed all the fields I had in the database table) FROM sflight INTO TABLE lt_sflight.

That was my solution . Otherwise I would get a warning like: The work area "lt_sflight" has more fields than selected. So this solution  worked out fine for me.  I hope my reply will help you . Otherwise I really don't know what else could be wrong. 

Greetings

Črt Košak

amy_king
Active Contributor
0 Kudos

Hi Venkatesh,

i am not able to fill the data

It's not clear to me at what point in your code you are having an issue.

To read the selected elements of the ItemListBox, read from the context the ItemListBox's dataSource node then call the node's get_selected_elements method.

DATA lo_nd_datasource TYPE REF TO if_wd_context_node.

DATA lt_selected             TYPE wdr_context_element_set.

lo_nd_datasource = wd_context->get_child_node( name = wd_this->wdctx_datasource ).

lt_selected = lo_nd_datasource->get_selected_elements( ).

As Jitendra suggests, you could step through the debugger at this point to see if your code is doing what you expect.

Cheers,

Amy

Former Member
0 Kudos

in debugger check are you getting all selcted data after below statement

LOOP AT lt_elements INTO lo_el_airline. 

     call METHOD lo_el_airline->get_static_attributes( IMPORTING static_attributes = ls_airline ).

     APPEND ls_airline TO lt_airline.

   ENDLOOP.

former_member198064
Participant
0 Kudos

Hi Jitendra,

I checked in debugging no selected data is coming so it is not filing the table.

  lt_elements = lo_nd_airline->get_selected_elements( ).

   LOOP AT lt_elements INTO lo_el_airline.

     lo_el_airline->get_static_attributes( IMPORTING static_attributes = ls_airline ).

     APPEND ls_airline TO lt_airline.

   ENDLOOP.

can you please guide how to fill the selected data

former_member198064
Participant
0 Kudos

Hi Jithendra,

I am trying to do the same example like:

http://www.saptechnical.com/Tutorials/WebDynproABAP/Listbox/page1.htm

i tried this but i am not able to get the selected data.

Can you try and tell me.

Thanks,

Venkatesh

Former Member
0 Kudos

example is working fine you need to take care below points

1. each  node have cardinality 0.n

2.when you create list_box multiple selection is checked , datasource and text are bind properly

3. select statement use into corresponding fields of table instead of into table

hope it help