*
* Extract the smtp email address from the User Profile SU01 or
* Vendor Master LFA1
*
* Written by : SAP Basis, ABAP Programming and Other IMG Stuff
*
*
REPORT ZSMTPADR.
TABLES: USR21,
LFA1,
ADR6.
DATA: BEGIN OF WA,
BNAME TYPE USR21-BNAME,
LIFNR TYPE LFA1-LIFNR,
ADRNR TYPE LFA1-ADRNR,
PERSNUMBER TYPE ADR6-PERSNUMBER,
ADDRNUMBER TYPE ADR6-ADDRNUMBER,
SMTP_ADDR TYPE ADR6-SMTP_ADDR,
END OF WA,
ITAB LIKE SORTED TABLE OF WA
WITH NON-UNIQUE KEY BNAME LIFNR.
SELECT-OPTIONS: UNAME FOR USR21-BNAME.
SELECT-OPTIONS: LIFNR FOR LFA1-LIFNR.
IF UNAME-LOW <> SPACE.
SELECT U~BNAME U~PERSNUMBER U~ADDRNUMBER
A~SMTP_ADDR
INTO CORRESPONDING FIELDS OF TABLE ITAB
FROM ( USR21 AS U
INNER JOIN ADR6 AS A ON A~PERSNUMBER = U~PERSNUMBER
AND A~ADDRNUMBER = U~ADDRNUMBER )
WHERE U~BNAME IN UNAME.
LOOP AT ITAB INTO WA.
WRITE:/ WA-BNAME, WA-SMTP_ADDR(50).
ENDLOOP.
ENDIF.
IF LIFNR-LOW <> SPACE.
SELECT L~LIFNR L~ADRNR
A~SMTP_ADDR
INTO CORRESPONDING FIELDS OF TABLE ITAB
FROM ( LFA1 AS L
INNER JOIN ADR6 AS A ON A~ADDRNUMBER = L~ADRNR )
WHERE L~LIFNR IN LIFNR.
LOOP AT ITAB INTO WA.
WRITE:/ WA-LIFNR, WA-SMTP_ADDR(50).
ENDLOOP.
ENDIF.
*-- End of Program
No comments:
Post a Comment