08-21-2007 8:35 AM
hello friends,
i want to sepearte out even and odd digits from a given number and want to do addition of them.
Eg. suppose i have number 12345 now i want to seperate out even numbers and odd numbers which are 2,4 and 1,3,5 respectively.after that i want to do addition of these number which is 24 and 13+5 and final result is 6 and 9
is there is any function module available for this.
thanks in advance.
regards,
bhaskar
08-21-2007 8:42 AM
no there isn't any fm of this kind, u have to create u'r own.
S@meer
08-21-2007 8:43 AM
Hi Patil
i dont think there is a fm exist for u r req.
use this logic
find the string length
len = strlen (str) . len= 5.
do len times.
var1 = str + count(1). var1 = 1.
count = count + 1. count = 1.
if var1 % 2 eq 0.
even = even + var1.
else.
odd = odd+ var1.
endif.
enddo.
reward points to all helpful answers
kiran.M
08-21-2007 9:43 AM
Hello,
Just one question, I#m quite interested why you want to do it 😃
08-21-2007 11:37 AM
hi bhaskar
There are no function modules for your requirement in SAP so you need to create a function module...
Goto to<b> se37</b>,<b>Goto-> function groups->create group</b>then give the <b>function module name</b> and create it...
then a screen appears,goto <b>source code tab</b>...
in dat type the code
data : a type i,
b type i,
c type i.
selection-screen : begin of block blk1 with frame title text-001.
parameters : a type i,
b type i.
selection-screen : end of block blk1.
len = strlen (str) . len= 5.
do len times.
var1 = count + 1(str). var1 = 1.
count = count + 1. count = 1.
if var1 % 2 eq 0.
even = even + var1.
else.
odd = odd+ var1.
endif.
enddo.
in import n export parameters give a,b as export n c as import parameter.
reward if useful.............