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: 

Function Module

Former Member
0 Kudos

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

4 REPLIES 4

Former Member
0 Kudos

no there isn't any fm of this kind, u have to create u'r own.

S@meer

Former Member
0 Kudos

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

Former Member
0 Kudos

Hello,

Just one question, I#m quite interested why you want to do it 😃

Former Member
0 Kudos

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.............