Skip to Content
avatar image
Former Member

SUM OF COLUMNS IN INTERNAL TABLE...

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.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • avatar image
    Former Member
    Mar 06, 2017 at 10:31 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded