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: 

Validate E-mail address

Former Member
0 Kudos
3,486

Hi,

Is anyone familiar with function module that helps validate E-mail address ?

7 REPLIES 7

Former Member
0 Kudos
507

Hi,

[validate email address |]

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos
507

You can use a RegEx for this. Here is an example program.

PARAMETERS email TYPE c LENGTH 30 LOWER CASE DEFAULT '<enter email address>'.
DATA matcher TYPE REF TO cl_abap_matcher.

matcher = cl_abap_matcher=>create(
             pattern = `\w+(\.\w+)*@(\w+\.)+(\w{2,4})`
             ignore_case = 'X'
             text = email ).
IF matcher->match( ) is INITIAL.
  MESSAGE 'Wrong Format' TYPE 'I'.
ELSE.
  MESSAGE 'Format OK' TYPE 'I'.
ENDIF.

Regards,

Rich Heilman

0 Kudos
507

Hi Rich,

You code works exactly what I need in my program to do..

Thanks a lot...

0 Kudos
507

this code doesn't validate this type of email address

abc.efg-xyz@domain.com

I used this code and I get error of 'Invalid email address'

instead try this regex

'^([0-9a-zA-Z]([-.w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-w]*[0-9a-zA-Z].)+[azA-Z]{2,9})$'

0 Kudos
507

It works perfectly!

Thanks,

Former Member
0 Kudos
507

Hi,

Check this Fm SX_INTERNET_ADDRESS_TO_NORMAL

horst_keller
Product and Topic Expert
Product and Topic Expert
507