cancel
Showing results for 
Search instead for 
Did you mean: 

Reading UI Tables in events

Former Member
0 Kudos

Hi

just a simple question I am sure for most of you.. but could someone tell me how to read data from a Table UI within an event controller method I have created for a button. I wish to identify which row was selected in a table and from that make further selections on the database prior to populating a new detailed table in the View.

I am populating the header table with data from select-options input from the user OK so I understand about binding contents of an internal table to the View Controller Context Element of the table defined at design time, but I need to be able to read that table in a different event than the one originally called by the selection process (by the user).

Please help.. I think this is so basic, that I cannot find it in help anywhere.

ps. sample code would be nice.

Thanks

Mark

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

you can select the node with the table data:

into a table with all the selected lines:

lt_selected_elements = node_table->get_selected_elements( ).

or to context element of your node

lo_selected_element = node_table->get_lead_selection( ).

grtz

Koen

Former Member
0 Kudos

Hi Koen

I have tried this and I think I am missing something.. I dont think I am declaring my variables correctly.

<u>CONTEXT</u>

My View Context Element (0:n) named COMPONENT_HEADER which is bound to a type ZCONTRACT_HEADER_STR.

<u>METHOD</u>

DATA: node_component_header TYPE REF TO if_wd_context_node.

DATA: lt_component_header TYPE TABLE OF zcontract_header_str.

lt_component_header = node_component_header->get_selected_elements( ).

Former Member
0 Kudos

Hi,

the selected elements function has a returning parameter of type

wdr_context_element_set

if you use a single select of your table, the second option is the way to go

grtz

Koen

Former Member
0 Kudos

Hi Koen

Thanks..for your help.

Using both methods, I am getting the following error when trying to compile

'The result type of the function method cannot be converted into the type of

LT_COMPONENT_HEADER type of LT_COMPONENT_HEADER.

Just to remind you.. this is the way I have implemented both of your options and I feel its something simple like the object types I am trying to map when assigning.

Option 1.

DATA: node_component_header TYPE REF TO if_wd_context_node.

DATA: lt_component_header TYPE TABLE OF zcontract_header_str.

lt_component_header = node_component_header->get_selected_elements( ).

Option 2.

DATA: node_component_header TYPE REF TO if_wd_context_node.

DATA: lt_component_header TYPE TABLE OF zcontract_header_str.

lt_component_header = node_component_header->get_lead_selection( ).

Thanks again..

Mark

Former Member
0 Kudos

Hi,

you are not receiving a table of your structure but in case of the first option

you receive a table of context elements so lt_component_header type wdr_context_element_set

this way you receive a table with references to the selected elements.

option1

DATA: node_component_header TYPE REF TO if_wd_context_node.

DATA: lt_component_header TYPE TABLE OF zcontract_header_str.

DATA: lo_element TYPE REF TO if_wd_context_node_element.

DATA: lt_selected_elements TYPE wdr_context_element_set.

lt_selected_elements = node_component_header->get_selected_elements( ).

loop at lt_selected_elements into lo_element.

lo_element->get_static_attributes( importing static_attributes = ls_component_header ).

...perform actions on structure...

endloop.

option 2

DATA: node_component_header TYPE REF TO if_wd_context_node.

DATA: lo_element TYPE REF TO if_wd_context_node_element.

DATA: ls_component_header TYPE zcontract_header_str

lo_element = node_component_header->get_lead_selection( ).

lo_element->get_static_attributes( importing static_attributes = ls_component_header ).

grtz

Koen

Former Member
0 Kudos

Thats got it..

Thanks Koen

Former Member
0 Kudos

Hi Koen,

Another problem moving on..

I am getting a short dump due to the selection being initial when the assignment to lt_selected_elements is called: i.e.

lt_selected_elements = node_component_header->get_selected_elements( ).

I have rechecked and I had selected two lines of the table prior to calling the event method where the code is.

The short dum is: OBJECTS_OBJREF_NOT_ASSIGNED raised by the exception CX_SY_REF_IS_INITIAL.

This error occurs no matter which one of the two options I implement.

Thanks for your help with this..

Mark

Former Member
0 Kudos

Hi Marc,

have you set your table into a specific selection mode?

which way did you use to set up your dynamic programmed context node?

grtz

Koen

Former Member
0 Kudos

Hi

It was set to auto, but I have now tried it on Muti and the same thing occurs.

All the other attributes are default with the exception of the dataSource which points to the COMPONENT_HEADER structure

Any other ideas?

Mark

Former Member
0 Kudos

Hi,

is your node defined on design time or at runtime?

grtz

Koen

Former Member
0 Kudos

Could you explain what you mean by the dynamic programmed context node? I implemented the event method by a button on the UI View in the same way I did with the select-options input where I use a button to go and populate the first table.

Is there something special I should be doing then?

Thanks

Mark

Former Member
0 Kudos

How can I tell if its Design or Runtime and what should it be ?

Former Member
0 Kudos

Hi,

if the node with all your table values is added dynamically, then you won't be

able to get the structure with these functions

Is it visible in you context menu

grtz

Koen

Former Member
0 Kudos

Hi

yes it is visible in the context menu... should I make it dynamic then and declare it as programatically?

Mark

Former Member
0 Kudos

Hi,

it's good like it is now,

your table should have the parameters:

enabled yes

selectionmode auto

row selectable true

datasource the name of the context node (the same for every column)

this way it works over here

grtz

Koen

Former Member
0 Kudos

Hi Koen

I have all these. I will try on an ECC6 system rather than CRM5 (may be a simpler table to start with)

As long as I understand what I need to do to get the data out of the context objects and you say I have it correct, then I am happy to try again / afresh.

Thanks for all your help.

Mark

Former Member
0 Kudos

Hi MArc.

You missed to get the reference to the context node:

DATA: node_component_header TYPE REF TO if_wd_context_node.

DATA: lt_component_header TYPE TABLE OF zcontract_header_str.

DATA: lo_element TYPE REF TO if_wd_context_node_element.

DATA: lt_selected_elements TYPE wdr_context_element_set.

<b>node_component_header = wd_context->get_child_node( 'NAME OF THE NODE' ).</b>

lt_selected_elements = node_component_header->get_selected_elements( ).

Thats why you get the shortdump.

Cheers,

Sascha

Former Member
0 Kudos

Thanks Sascha..

Works now.

have added points to you and to Koen for your help

Answers (0)