Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

how to add different numeric fields

Former Member
0 Kudos

hai,

How to sum the different numeric fields like eno,esal and dno for a table EMP between eno= 51 to 57 of 100 records.

Please provide the code for this.

regards,

bhargav.

5 REPLIES 5

andreas_mann3
Active Contributor
0 Kudos

Hi,

to avoid a dump you can try sth like this:

DATA pval TYPE p DECIMALS 0.

data cval(8).

DATA n TYPE n.

DATA i TYPE i.

CATCH SYSTEM-EXCEPTIONS conversion_errors = 1.

MOVE cval TO pval.

ENDCATCH.

if sy-subrc = 0.

sum = cval + n + i.

endif.

Andreas

0 Kudos

hai,

I think ur solution is very typical one i cant get your solution.

please explain it clearly as iam new to abap.

0 Kudos

hi,

let us assume all the values in the internal table.

in the loop we get get values one by one then we need to check if the eno is greter than 50 and less than 57 you do the sum and keep it into separate variable, that's it.

cheers,

sasi

Former Member
0 Kudos

hi,

loop at itab_emp.

if itab_emp-eno ge 51 and itab_emp-eno le 57

esal = esal + itab_emp-esal.

endif

endloop.

is this you want.

sasi

Former Member
0 Kudos

You can use

sort itab by empno.

Loop at itab where empno ge '51'

and empno le '57' .

<You adding logic here >.

Endloop.

Cheers