on 2024 Aug 08 3:34 AM
Hi Experts,
Name's Dio, I have a need to add a new line after the group data, that new line is the subtotal of the 'WRBTR' field. I've been looking for a way for 3 days and haven't found a way. Please help me to solved this, I appreciate any help.
Regards,
Dio
cl_salv_table=>factory( IMPORTING r_salv_table = DATA(lo_salv)
CHANGING t_table = lt_table ).
lo_salv->get_sorts( )->add_sort( columnname = 'LIFNR' subtotal = abap_true sequence = if_salv_c_sort=>sort_up ).
lo_salv->get_aggregations( )->add_aggregation( columnname = 'WRBTR' aggregation = if_salv_c_aggregation=>total ).
lo_salv->display( ).
Quick solution to display the table with subtotals in an ALV...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Thank you for your answer friend, I got another way to do this. here's the code :
READ TABLE it_data INTO DATA(work_area2) INDEX 1.
IF sy-subrc IS INITIAL.
old_val = work_area2-znme1.
ENDIF.
LOOP AT it_data INTO work_area.
IF work_area-znme1 <> old_val.
new_line-znme1 = 'SUBTOTAL'.
new_line-wrbtr = sum.
INSERT new_line INTO it_data INDEX sy-tabix.
CLEAR sum.
old_val = work_area-znme1.
ENDIF.
sum = sum + work_area-wrbtr.
ENDLOOP.
data: v_lin type i.
DESCRIBE TABLE it_data lines v_lin.
READ TABLE it_data into data(work_area3) index v_lin.
new_line-payment = 'GRAND TOTAL'.
new_line-wrbtr = sum.
INSERT new_line INTO it_data INDEX v_lin.
Regards,
Dio
User | Count |
---|---|
81 | |
11 | |
10 | |
10 | |
10 | |
8 | |
7 | |
7 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.