cancel
Showing results for 
Search instead for 
Did you mean: 

how calculate the values in column only for checked rows for ALV table

Former Member
0 Kudos

Hi, experts. I'm beginner in Web Dynpro.

I have some table ALV with checkbox column. I need calculate the values in column for that rows where checkbox is checked ( = ‘X’) and display sum in corresponding column (Price).  How its making using aggregate property of alv for column (cl_salv_wd_aggr_rule), but I need do it only for checked rows.

Thank you very much.

How can I do it ?

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Alex, instead of trying to alter the way standard aggregation work I would suggest to put a total row at the bottom which will show the total based on the check box state.

For the aggregation rule functionality available you can check this link.

http://wiki.sdn.sap.com/wiki/display/WDABAP/Aggregations+in+Web+Dynpro+ABAP 

Former Member
0 Kudos

I would suggest to put a total row at the bottom which will show the total based on the check box state.

And how do it. I am hindered to solve this problem. And this link didn't help me to solve my problem.

Thank you!

Former Member
0 Kudos

Read the node at first as a table operation.  Fallow the codes below.

i is

DATA lo_nd_alv_main TYPE REF TO if_wd_context_node.

     DATA lt_alv_main TYPE wd_this->Elements_alv_main.

     DATA ls_alv_main TYPE wd_this->Element_alv_main.

*   navigate from <CONTEXT> to <ALV_MAIN> via lead selection

     lo_nd_alv_main = wd_context->get_child_node( name = wd_this->wdctx_alv_main ).

     lo_nd_alv_main->get_static_attributes_table( importing table = lt_alv_main ).

    

    

     delete lt_alv_main where price = 'X'.

    

   

This will delete the checked box values from your internal table and  by looping that table you can do as,

loop at lt_alv_main into ls_alv_main.

CALL METHOD lv_value->if_salv_wd_field_settings~get_field

     EXPORTING

       fieldname = 'LUGGWEIGHT'

     RECEIVING

       value     = lr_field_amnt.

   CALL METHOD lr_field_amnt->if_salv_wd_aggr~create_aggr_rule

     EXPORTING

       aggregation_type = if_salv_wd_c_aggregation=>aggrtype_total

     RECEIVING

       value            = lv_aggr_rule.

endloop.

Former Member
0 Kudos

This is not right algorithm. The sum of column is calculated for all rows, not only for thats rows where checkbox is 'X'.