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

Validate E-mail address

Former Member
0 Likes
6,643

Hi,

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

7 REPLIES 7
Read only

Former Member
0 Likes
3,664

Hi,

[validate email address |]

Read only

RichHeilman
Developer Advocate
Developer Advocate
3,664

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

Read only

0 Likes
3,664

Hi Rich,

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

Thanks a lot...

Read only

0 Likes
3,664

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})$'

Read only

0 Likes
3,664

It works perfectly!

Thanks,

Read only

Former Member
0 Likes
3,664

Hi,

Check this Fm SX_INTERNET_ADDRESS_TO_NORMAL

Read only

retired_member
Product and Topic Expert
Product and Topic Expert
3,664