cancel
Showing results for 
Search instead for 
Did you mean: 

input table element

Former Member
0 Kudos

Hi all,

I have created a element table,

the node that the table refers is not a structure instead an attribute,

i have 7 attribute in that node, each attribute is binded to column in the table,

all the attribute is of type input field,

in doint method i have initialized the table with 2 rows,

now the business process is i type in the values in the table and after i have values in the table i want to get the sum of values in each row?

the issue i am facing is when i input the values in the table i am not getting those values in the node attribute,

how do i capture the input values and how do i get the row sum of a table whose reference node does not have reference structure rather it have attributes?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Gerad,

It does not matter that your node is not based on a structure and you have added attributes individually. A structure will be generated at the view level anyway.

Say you have a node named 'example', which has 3 fields field1, field2, field3 and total. You can have a button in the table toolbar to compute the total of each row. In the event handler of this method, have your code as below:

data: lr_node type ref to if_wd_context_node,

wa type if_main=>element_example,

itab type if_main=>elements_example.

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

lr_node->get_static_attributes_table(

importing

table = itab ).

loop at itab into wa.

wa-total = wa-field1 + wa-field2 + wa-field3.

modify itab from wa.

endloop.

lr_node->bind_table( itab ).

Initially the values in the total column will be empty. Then when you compute the total, the sum will be calculated and when you do a binding again, the values will be reflected in the UI.

If you do not want the total as part of the table, but want it as a separate attribute, you can probably make an input field separately in the view and bind an attribute total to it.

Hope this helps.

Regards,

Nithya

Former Member
0 Kudos

Hi Nitya,

Thanks for the reply,

i tried to use your code, but when i use 'get_static_attributes_table'

i get error message 'GET_STATIC_ATTRIBUTE_TABLE is unknown or protected or private'

can you help me out in this, as i am new to OOP's concept.

Thanks a lot.

Former Member
0 Kudos

Hi Nitya,

I solved it.

Thanks a lot.

Answers (2)

Answers (2)

abhimanyu_lagishetti7
Active Contributor
0 Kudos

Hi

data: lr_node type ref to if_wd_context_node.

data: lr_elem type ref to if_wd_context_element.

data: lv_<attributeName> type <type of the attribute>

lr_node = wd_context->get_child_node( '<Node Name>' ).

lr_elem = lr_node->get_lead_selection( ).

lr_elem->get_attribute( exporting name = '<name of the attribute> importing value = lv_<attributeName> ).

you have the attribute value into lv_<attributeName> variable,

similarly you can get all the elements in lr_node by index and get the lr_elem then retrieve attribute value of that element.

Regards

Abhimanyu L

Message was edited by:

Abhimanyu Lagishetti

Former Member
0 Kudos

Hi Gerad,

First of all, you have to see that the table binding is correct for you to get the values entered by you in the corresponding context node.

Second, make sure that you have some event or some action on the view which triggers the summation process. You can have a button saying GET_SUM on the view. When you press this, in the ActionHandler, just acces the node, get all the attributes, calculate the sum and set this sum to another attribute. This attribute can be bound to a textview or in your case a column of another table, where you can display the sums of the rows.

Regards,

Neha

<i><b>PS:Reward if helpful</b></i>