on 03-02-2007 10:48 AM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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( ).
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
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
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
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
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
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
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.