2022 Dec 27 2:39 PM
Hi experts, I wants to display the sum of particular column present in my internal table.
I tried to use at first. Sum.
But not works, attached my code.
Help to solve this..20221227-195731.jpg
2022 Dec 27 3:37 PM
Hello,
My guess is that status_msg_no is not a numeric type, this code works for me:
TYPES: BEGIN OF ty_data,
value TYPE i,
END OF ty_data.
DATA: lt_data TYPE STANDARD TABLE OF ty_data,
lw_data TYPE ty_data,
lv_sum TYPE i.
lt_data = VALUE #(
( value = 1 )
( value = 2 )
( value = 3 )
( value = 4 )
( value = 5 )
).
LOOP AT lt_data INTO lw_data.
AT LAST.
SUM.
lv_sum = lw_data-value.
ENDAT.
ENDLOOP.
WRITE lv_sum.
2022 Dec 27 3:37 PM
Hello,
My guess is that status_msg_no is not a numeric type, this code works for me:
TYPES: BEGIN OF ty_data,
value TYPE i,
END OF ty_data.
DATA: lt_data TYPE STANDARD TABLE OF ty_data,
lw_data TYPE ty_data,
lv_sum TYPE i.
lt_data = VALUE #(
( value = 1 )
( value = 2 )
( value = 3 )
( value = 4 )
( value = 5 )
).
LOOP AT lt_data INTO lw_data.
AT LAST.
SUM.
lv_sum = lw_data-value.
ENDAT.
ENDLOOP.
WRITE lv_sum.
2023 Jan 03 9:00 AM
2022 Dec 27 3:38 PM
Hello,
My guess is that status_msg_no is not a numeric data type, this code works for me:
TYPES: BEGIN OF ty_data,
value TYPE i,
END OF ty_data.
DATA: lt_data TYPE STANDARD TABLE OF ty_data,
lw_data TYPE ty_data,
lv_sum TYPE i.
lt_data = VALUE #(
( value = 1 )
( value = 2 )
( value = 3 )
( value = 4 )
( value = 5 )
).
LOOP AT lt_data INTO lw_data.
AT LAST.
SUM.
lv_sum = lw_data-value.
ENDAT.
ENDLOOP.
WRITE lv_sum.
Regards,
Eduardo.
2022 Dec 28 2:51 PM
It appears you posted the same answer twice. I have removed the duplicate.
Kind regards,
--Jerry
2022 Dec 28 10:44 AM
Please, better post code as text so that people who want to answer don't have to type the code manually.
If in future questions you have to show something which is not text, please embed the images instead of proposing hyperlinks, it's more user-friendly (allows reading without need of clicking and seeing images on separate screens).
2022 Dec 28 10:45 AM
gv_total = 0.
LOOP AT itab INTO line.
gv_total = gv_total + line-number.
ENDLOOP.