cancel
Showing results for 
Search instead for 
Did you mean: 

Add total to web dynpro table

Former Member
0 Kudos

Hi all,

I have created a table on my abap web dynpro for ABAP but need to add a total to one of the columns. Does anyone know how i can do this?

Regards

Mart

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

hi,

As you are displaying data in Table , you must have binded internal table having all data to the Context Node which is binded to Table UI Element.

NOw Lets assume you have Table with three Columns, C1,C2,C3. YOu want to add details of C1.

As you are displaying data in Table, you have internal table itab having all three fields.

lo_nd->bind_table(itab). lo_nd is node binded with table.

in the wddo init method, write following code :

data: wa like line of itab.

data : sum type I.

sum = 0.

loop at itab into wa.

sum = sum + wa-C1.

endloop.

NOw you have total of Column1 in sum.

Set the value of sum with the Context Attribute of TextView UI Element in your Layout.

DATA lo_el_context TYPE REF TO if_wd_context_element.

lo_el_context->set_attribute(

name = `FOR_TEXTVIEW`

value = sum ).

Here For_textview is Context Attribute binded to TextView UI Element in Layout and this will display the total.

Thanx.

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Mart,

are you using general table or ALV Table?

Regards,

Ravi

Former Member
0 Kudos

Hi Ravi,

I am just using the general table an not ALV!

Regards

Mart

vivekananthan_sellavel
Active Participant
0 Kudos

hi

follow this code it will work

assume in a table mark column to be sum.

DATA: node_table_out TYPE REF TO if_wd_context_node, sum TYPE i , wa_table_out TYPE if_v_sv_ovstest=>element_table_out . it_table_out TYPE if_v_sv_ovstest=>elements_table_out . node_table_out = wd_context->get_child_node( name = if_v_sv_ovstest=>wdctx_table_out ). "To read node node_table_out->get_static_attribute_table( it_table_out ). "_________ to sum the particullar column LOOP AT it_table_out INTO wa_table_out. sum = sum + wa_table_out-mark . ENDLOOP. wa_table_out-mark = sum. APPEND wa_table_out to it_table_out. " __________ to append in last line node_table_out->bind_table( it_table_out ).

if ur using the ALV

there is default method.

l_table->if_salv_wd_std_functions~set_aggregation_allowed( abap_true ).

Former Member
0 Kudos

Hi mart,

I suspect that.... are you going to change the table values dynamically so that total values to displayed on total colum. is this your scenario.?

If yes. there should be action to be perform after each user input happen to the table colums..like push button or input field action. So in that action method you can very well read the current record of that internal table and make the changes to that internal table and bind it finally.

You can reply me if you need more info.

Regards,

Sreenivasa Sarma k.

former_member402443
Contributor
0 Kudos

Hi Mart,

Check the standard component - WDR_TEST_TABLE regarding your problem to add total to a table column.

Hopes this will helps you.

Regard

Manoj Kumar