Obiettivo

Ricavare l’indirizzo email di default, SMTP_ADDR, del cliente, KUNNR.

Modalità

*&---------------------------------------------------------------------*
*&      Form  get_email_address
*&---------------------------------------------------------------------*
*       text Returns in SMTP_ADDR the customer, KUNNR, default email address.
*       (by N4N)
*----------------------------------------------------------------------*
*      -->KUNNR      text
*      -->SMTP_ADDR  text
*----------------------------------------------------------------------*
FORM get_email_address USING kunnr smtp_addr.

  DATA: t_adrnr TYPE adrnr,
        t_smtp_addr TYPE ad_smtpadr.

  SELECT SINGLE adrnr FROM kna1 INTO t_adrnr
                         WHERE kunnr = kunnr.

  IF sy-subrc EQ 0.
    SELECT SINGLE smtp_addr FROM adr6 INTO t_smtp_addr
      WHERE addrnumber = t_adrnr and flgdefault = 'X'.
    IF sy-subrc EQ 0.
      smtp_addr =  t_smtp_addr.
    ENDIF.
  ENDIF.

*  IF sy-subrc EQ 0.
*    SELECT SINGLE flagcomm6 FROM adrc INTO t_flagcomm6
*      WHERE addrnumber = t_adrnr.
*    IF sy-subrc EQ 0 AND t_flagcomm6 IS NOT INITIAL.
*      SELECT SINGLE prsnr FROM knvk INTO t_pernr
*        WHERE kunnr = kunnr.
*      IF sy-subrc EQ 0 AND t_pernr IS NOT INITIAL.
*        SELECT SINGLE smtp_addr FROM adr6 INTO t_smtp_addr
*          WHERE persnumber = t_pernr.
*        IF sy-subrc EQ 0.
*          smtp_addr =  t_smtp_addr.
*        ENDIF.
*      ENDIF.
*    ENDIF.
*  ENDIF.

ENDFORM.                    "get_email_address