[ABAP] Email-Adresse validieren

DATA: lv_address_normal TYPE sx_address.
DATA: lv_local TYPE sx_addr.
DATA: lv_domain TYPE sx_addr.
DATA: lv_comment TYPE sx_addr.
DATA: lv_addr_normal_no_upper TYPE sx_address.
DATA: lv_addr_normal_no_up TYPE sx_address.

* Type
* FAX	Faxnummer
* INT	Internet Mail Adresse
* X40	X.400 Mail Adresse
* RML	SAPoffice Adresse
* PAG	Pager(SMS) Nummer
* PRT	Druckername
* *	Alle
DATA(lv_address_unstruct) = value sx_address( address = 'email (Test)@email.com'
                                              type    = 'INT' ).

WRITE: / lv_address_unstruct-type, lv_address_unstruct-address.

CALL FUNCTION 'SX_INTERNET_ADDRESS_TO_NORMAL'
  EXPORTING
    address_unstruct               = lv_address_unstruct
  IMPORTING
    address_normal                 = lv_address_normal        " Normalform: Local@DOMAIN
    local                          = lv_local                 " Lokaler Teil der Adresse
    domain                         = lv_domain                " Domäne (konvertiert zu Großbuchstaben)
    comment                        = lv_comment               " Kommentar der Adresse
    addr_normal_no_upper           = lv_addr_normal_no_upper  " Adresse: Local@Domain (Domäne unkonvertiert)
    addr_normal_no_up_with_comment = lv_addr_normal_no_up     " Normalform mit Kommentar
  EXCEPTIONS
    error_address_type             = 1
    error_address                  = 2
    error_group_address            = 3
    OTHERS                         = 4.

IF sy-subrc = 0.
  WRITE: / '                    Normalform:', lv_address_normal-type, lv_address_normal-address.
  WRITE: / '                  Lokaler Teil:', lv_local.
  WRITE: / '                        Domäne:', lv_domain.
  WRITE: / '                     Kommentar:', lv_comment.
  WRITE: / 'Adresse (Domäne unkonvertiert):', lv_addr_normal_no_upper-type, lv_addr_normal_no_upper-address.
  WRITE: / '      Normalform mit Kommentar:', lv_addr_normal_no_up-type, lv_addr_normal_no_up-address.
ELSE.
  WRITE: / 'Error:', sy-subrc.
ENDIF.