Skip to Content
0

SUM OF COLUMNS IN INTERNAL TABLE...

Mar 03, 2017 at 02:36 AM

32

avatar image

HI ALL,

I have an internal table with 3 columns but the data here is duplicated and i m gonna add the camount which is at 3rd column. below is the code and the sum is not happening please help on this.

regards,

jithendra.

TYPES : BEGIN OF T_SUM,

CNO(4) TYPE C,

CNAME(20) TYPE C,

CAMOUNT(7) TYPE P DECIMALS 2 DECIMALS,

END OF T_SUM.

DATA : ITAB TYPE TABLE OF T_SUM,

WA TYPE T_SUM.

WA-CNO = 'C001'.

WA-CNAME = 'MIKE'

WA-CMOUNT = '2000'

APPEND WA TO ITAB.

WA-CNO = 'C002'.

WA-CNAME = 'JOHN'

WA-CMOUNT = '5000'

APPEND WA TO ITAB.

WA-CNO = 'C003'.

WA-CNAME = 'ARNOLD'

WA-CMOUNT = '6000'

APPEND WA TO ITAB.

WA-CNO = 'C002'.

WA-CNAME = 'JOHN'

WA-CMOUNT = '6000'

APPEND WA TO ITAB.

WA-CNO = 'C001'.

WA-CNAME = 'MIKE'

WA-CMOUNT = '4000'

APPEND WA TO ITAB.

WA-CNO = 'C003'.

WA-CNAME = 'ARNOLD'

WA-CMOUNT = '7000'

APPEND WA TO ITAB.

SORT ITAB BY CNO ASSENDING.

LOOP AT ITAB INTO WA.

AT NEW CNO.

SUM.

ENDAT.

WRITE : / WA-CNO, WA-CNAME, WA-CAMOUNT.

ENDLOOP.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Prasad Patil Mar 06, 2017 at 10:31 AM
0

Hello Jithendra,

Make the following correction in your code to get the sum.

LOOP AT ITAB INTO WA.

AT NEW CNO.

SUM .
WRITE : / WA-CNO, WA-CNAME, WA-CAMOUNT.
ENDAT.

Share
10 |10000 characters needed characters left characters exceeded