Skip to Content

Validate email and phone number

Hi guys

There are a function to validate phone number types bt user ?

And i need a function to validate email too.

Thanks

I try search in sdn but i didnt find.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Oct 26, 2015 at 01:49 PM

    HI, Email u can check it by using.

    PARAMETERS : P_MAIL   TYPE C  AS CHECKBOX

       IF P_MAIL IS  NOT INITIAL.

         IF P_MAILID EQ '<enter email address>' OR

            P_MAILID EQ ' '.

           MESSAGE 'Please Enter valid E-mailid' TYPE 'E'.

         ELSE.

           MATCHER = CL_ABAP_MATCHER=>CREATE(

                        PATTERN = `\w+(\.\w+)*@(\w+\.)+(\w{2,4})`

                        IGNORE_CASE = 'X'

                        TEXT = P_MAILID ).

           IF MATCHER->MATCH( ) IS INITIAL.

             MESSAGE 'Please Enter valid E-mailid'  TYPE 'E'.

    *      ELSE.

    *        MESSAGE 'Format OK' TYPE 'I'.

           ENDIF.

         ENDIF.

       ENDIF.

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 26, 2015 at 01:50 PM

    Hi Ronaldo Aparecido,

    try this FM

    SX_INTERNET_ADDRESS_TO_NORMAL

    Thanks,

    Vijay SR

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 26, 2015 at 02:01 PM

    Try this.

    Email id validation.

    data : lr_matcher type ref to CL_ABAP_MATCHER.

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

    lr_matcher = cl_abap_matcher=> create (pattern = v_pattern

    Text = ’test@gmail.com’).

    CALL METHOD lr_matcher->match

    RECEIVING

    success = v_sucess.

    IF v_sucess = abap_false.

    Message 'Invalid email id' TYPE 'I'.

    ENDIF.

    Add comment
    10|10000 characters needed characters exceeded