[ABAP] SMTP-Email-Adresse von Benutzer (User) lesen

Variante 1 (Select)

PARAMETERS: p_uname TYPE usr21-bname.

SELECT u~bname,
       u~persnumber,
       u~addrnumber,
       a~smtp_addr
  FROM usr21 AS u
  INNER JOIN adr6 AS a  ON ( a~persnumber = u~persnumber AND a~addrnumber = u~addrnumber )
  INTO TABLE @DATA(it_userdata)
  WHERE u~bname = @p_uname.

LOOP AT it_userdata ASSIGNING FIELD-SYMBOL(<u>).
  WRITE:/ <u>-bname, <u>-smtp_addr.
ENDLOOP.

Variante 2 (Funktionsbaustein)

DATA: rc    TYPE                   sy-subrc,
      email TYPE                   string,
      err   TYPE STANDARD TABLE OF rpbenerr.

CALL FUNCTION 'HR_FBN_GET_USER_EMAIL_ADDRESS'
  EXPORTING
    user_id       = sy-uname
    reaction      = sy-msgty
  IMPORTING
    subrc         = rc
    email_address = email
  TABLES
    error_table   = err.

WRITE: / sy-uname, email.