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

scripting

Former Member
0 Likes
621

Hi all,

i have to write code for email validations in scripting . but they didn't give any input i.e how many Characters include in that email?

i have to check is there '@ 'and '.' symbols are exist or not ?

but my doubt is after how many char the @ symbol is exist and after @ how many chars are exists before dot symbol and after dot symbol how many chars are exist .in this way i wnat to write code for validations

plz suggest me with sample code how can i follow this.

Thanks in advance

Rambabu.A

2 REPLIES 2
Read only

Former Member
0 Likes
543

Hi Rambabu.

Look at the following code. You can easily extract the positions of a special character

and calculate the length of the pieces in between.

PARAMETERS: p_mail     TYPE char80.
DATA: mail       TYPE char80,
      atoff      TYPE i,
      pointoff   TYPE i,
      endlen     TYPE i.

mail = p_mail.
FIND FIRST OCCURRENCE OF '@' IN mail MATCH OFFSET atoff.
ADD 1 TO atoff.
SHIFT mail BY atoff PLACES LEFT.
FIND FIRST OCCURRENCE OF '.' IN mail MATCH OFFSET pointoff.
ADD 1 TO pointoff.
SHIFT mail BY pointoff PLACES LEFT.
endlen = STRLEN( mail ).
WRITE: / 'Length of pieces in ', p_mail,
       / 'Before @   : ', atoff,
       / 'Btw @ and .: ', pointoff,
       / 'After .    : ', endlen.

The output of this little programm for a mail like First.LastName@SomeCompany.Country would look like

Length of pieces in  FIRST.LASTNAME@SOMECOMPANY.COUNTRY     
Before @   :          15                                       
Btw @ and .:          12                                    
After .    :           7    

Regards,

Timo

Read only

Former Member
0 Likes
543

Hi Ram,

Upto my knowledge I want to say the following conditions for validation purpose.

1. There must be only one symbol @

2. After @ atleast one symbol . must be there

3.Mail shold start with characters not with numbers

4.-,+like that symbols are not allowed.

check wheather these conditions are useful or not.

Thanks,

Suma.