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

validations

Former Member
0 Likes
448

Hi all,

i have to check email validations by using function module

input email (char70).

in this email i hev to check @ and dot symbols.

in this @ symbol is exist after 2nd character onwards.

dot symbol is exist after @ symbol but between @ and dot symbols atleast one character and after dot symbol at least one character should be exist.

this is how can i achieve

here i mention my code, this is working fine upto checking @ and dot symbols .

but in this i heve incorporate the logic for findout the postions of @ and dot symbols

plz help me

Constants: c_patt1 TYPE c VALUE `@`,

c_patt2 TYPE c VALUE `.`.

data: str1 type string value 'abcdefghijklmnopqrstuvwxyz',

str2 type string,

str3 type string,

str4 type string,

str5 type string,

str6 type string,

str7 type string.

data : atoff type i,

moff type c.

if not email is initial.

str2 = email.

translate str1 to upper case.

if str2(1) ca str1.

find c_patt1 in section offset atoff of str2 match offset moff.

if sy-subrc <> 0 .

return-message = ' no @ symbol'.

exit.

else.

split str2 at c_patt1 into str3 str4.

find c_patt1 in section offset atoff of str4.

if sy-subrc = 0.

return-message = ' 2 times @ symbol'.

exit.

else.

find c_patt2 in section offset atoff of str2.

if sy-subrc <> 0.

return-message = ' no dot symbol'.

exit.

else.

str5 = email.

split str5 at c_patt2 into str6 str7.

find c_patt2 in section offset atoff of str7.

if sy-subrc = 0.

return-message = '2 times dot symbol'.

exit.

endif.

endif.

endif.

endif.

else.

return-message = 'enter email start with alphabets'.

exit.

endif.

else.

return-message = ' enter email id'.

exit.

endif.

if any misatke in this code plz correct this .

Thanks in advance

Rambabu.A

2 REPLIES 2
Read only

Former Member
0 Likes
416

hi,

U can validate an email ID with this FM.

no need for any lengthy codings.

Try with FM - > <b>SX_INTERNET_ADDRESS_TO_NORMAL</b> to validate the email address.

TYP ADDRESS

INT xyz@yahoo.com

Now run the FM and see...

Regards

Reshma

Read only

Former Member
0 Likes
416

CHECK THIS SAMPLE

DATA : TEXT(70) VALUE 'ABC@DEF.COM',

VAR1(20),

VAR2(50),

VAR3(25),

VAR4(25).

SPLIT TEXT AT '@' INTO VAR1 VAR2.

IF VAR2 CA '@'.

MESSAGE 'INCORRECT ID' TYPE 'E'.

ELSEIF VAR2 CA '.'.

SPLIT VAR2 AT '.' INTO VAR3 VAR4.

ENDIF.

IF VAR3 IS INITIAL.

MESSAGE 'INCORRECT ID' TYPE 'E'.

ELSEIF VAR4 CA '.'.

MESSAGE 'INCORRECT ID' TYPE 'E'.

ENDIF.

REGARDS

SHIBA DUTTA