cancel
Showing results for 
Search instead for 
Did you mean: 

How to get Table value to a single element on view

Former Member
0 Kudos

All,

The component i use, makes use of a service call to a BAPI to get the data. The table parameter within this BAPI may have more than one row of records. I need to read the 1st row all the time to map the data to the element on the view. The cardinality of the view context is set to 1..n and the selection is 0..1.

- How do i make this happen ?

- Which method should i use the code

Padma S

Accepted Solutions (0)

Answers (1)

Answers (1)

abhimanyu_lagishetti7
Active Contributor
0 Kudos

first of all, if you want the first record only to be shown why are you making the cardinality of your node to 1..n, make it 1..1.

and call the BAPI, get the data into internal table.

read the first record and code to set the values.

data: lr_node type ref to if_wd_cotnext_node.

data: l_stru type <node type>

data: lr_element type ref to if_wd_context_element.

copy the first record values into l_stru.

lr_node = wd_context->get_child_node( '<name of node>' ).

lr_node->set_static_attributes( STATIC_ATTRIBUTES = l_stru ).

Abhi

Former Member
0 Kudos

Thanks for your quick response Abhi. Which method should be used for the code ?

Padma S

abhimanyu_lagishetti7
Active Contributor
0 Kudos

where are you calling your BAPI, immediately after that.

Former Member
0 Kudos

That helps but still i have no result. I am not sure what mistake i am making. Here is the code i have,

method ONACTIONGETTRIP .

wd_Comp_Controller->Execute_Bapi_Trip_Get_Details( ).

data: lr_node type ref to if_wd_context_node.

data: l_stru type bapitrvemp.

data: lr_element type ref to if_wd_context_element.

*copy the first record values into l_stru.

lr_node = wd_context->get_child_node( 'EMPDATA' ).

lr_node->set_static_attributes( STATIC_ATTRIBUTES = l_stru ).

endmethod.

The fields within the node 'EMPDATA' is what is mapped to the UI screen elements. What i am not sure is, how does the l_stru is mapped back to the UI element....

Padma S

abhimanyu_lagishetti7
Active Contributor
0 Kudos

copy the first record values into l_stru, it is not done in the above code, you should complete it.

after calling the BAPI where are you storing the return values, you should read that internal table and put in l_stru.

l_stru is the actual data which is shown in the View, binding the context nodes and attributes are only at design time, at runtime you see the values only if the context node has some values

Abhi

Edited by: Abhimanyu Lagishetti on Aug 7, 2008 6:37 AM

Former Member
0 Kudos

Abhi,

Here's my understanding. The context elements of view are bound to the screen elements. The declaration that i make on the method source code doesnot seem to be visible at the context that i can bind with screen elements.

I think, i am missing on how to co relate Method variables with Context attributes.

I will look more into help level documentation too.

Thanks,

Padma S

abhimanyu_lagishetti7
Active Contributor
0 Kudos

In View, Context Nodes and Attributes are the only means through which you can bind data to your View.

In Methods, you have some standard methods given by framework which are called at particular time during the execution.

and some user defined methods to write your logic with more readability

In Attributes, you can create variables which has nothing to do with View, but are useful in your methods part, to store temperory data.

Hope it is clear

Former Member
0 Kudos

Thanks. I also made a mistake at the cardinality functionality. I corrected it to 1..1 to make it work,

Padma S