Teknologi

LightBlog

Breaking

LightBlog

Monday 23 April 2012

Validate E-Mail Address

 Code

*&---------------------------------------------------------------------*
*& Report  ZEMAIL
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*


REPORT  ZEMAIL.

DATAgo_regex   TYPE REF TO cl_abap_regex,
      go_matcher TYPE REF TO cl_abap_matcher,
      go_match   TYPE LENGTH 1,
      gv_msg     TYPE string.

PARAMETERS: p_email TYPE ad_smtpadr.

START-OF-SELECTION.

  CREATE OBJECT go_regex    EXPORTING
      pattern     '\w+(\.\w+)*@(\w+\.)+(\w{2,4})'
      ignore_case abap_true.

  go_matcher go_regex->create_matchertext p_email ).
  IF go_matcher->matchIS INITIAL.    gv_msg 'Email address is invalid'.
  ELSE.
    gv_msg = 'Email address is valid'.
  ENDIF.

  MESSAGE gv_msg TYPE 'I'.



Output




Previous Page
Next Page

No comments:

Post a Comment

Note: only a member of this blog may post a comment.

Adbox