Application Development and Automation 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: 
Read only

how to add different numeric fields

Former Member
0 Likes
752

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
Read only

andreas_mann3
Active Contributor
0 Likes
723

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

Read only

0 Likes
723

hai,

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

please explain it clearly as iam new to abap.

Read only

0 Likes
723

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

Read only

Former Member
0 Likes
723

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

Read only

Former Member
0 Likes
723

You can use

sort itab by empno.

Loop at itab where empno ge '51'

and empno le '57' .

<You adding logic here >.

Endloop.

Cheers