SAP e-mail addresses accounts receivable
Do you need a program or a query to read e-mail data from the data of the customer master?
Here is a simple ABAP program that reads a customer’s e-mail address from tables KNA1 and ADR6:
This ABAP program reads the customer number from KNA1, searches for the corresponding address data in ADR6, and outputs the customer’s customer number, name, and e-mail address, if an e-mail address is available. Be sure to adjust the customer number accordingly to select the customer for whom you want to retrieve the email address.
SAP Email Addresses Customer Database Tables
- Table KNA1 – Customer base (general part)
- Table ADR6 – Address Data (Business Address Services)
*&---------------------------------------------------------------------*
*& Report Z_READ_CUSTOMER_EMAIL
*&---------------------------------------------------------------------*
*& SAP Stammdaten E-Mail-Adresse
*& Beispiel Tabelle Debitoren Mail SAP (KNA1 und ADR6)
*&---------------------------------------------------------------------*
REPORT Z_READ_CUSTOMER_EMAIL.
DATA: wa_kna1 TYPE kna1,
wa_adr6 TYPE adr6.
DATA: lv_customer_number TYPE kna1-kunnr,
lv_email_address TYPE adr6-smtp_addr.
CONCATENATE '0000000002' ' ' INTO lv_customer_number.
SELECT SINGLE * FROM kna1 INTO wa_kna1 WHERE kunnr = lv_customer_number.
IF sy-subrc = 0.
SELECT SINGLE * FROM adr6 INTO wa_adr6
WHERE ADDRNUMBER = wa_kna1-adrnr
AND smtp_addr IS NOT Null. "SAP E-Mail Adressen auslesen
IF sy-subrc = 0.
lv_email_address = wa_adr6-smtp_addr.
WRITE: / 'Kundennummer:', wa_kna1-kunnr,
/ 'Name:', wa_kna1-name1,
/ 'E-Mail-Adresse:', lv_email_address.
ELSE.
WRITE: 'Keine E-Mail-Adresse gefunden für den Kunden', lv_customer_number.
ENDIF.
ELSE.
WRITE: 'Kunde nicht gefunden', lv_customer_number.
ENDIF.
Note: If your company has more than one sales organization, you can functionally extend the ABAP program to include the KNVV (customer master sales data) via a JOIN . This allows you to make additional selections via the sales organization. In Purchasing, you can determine the affiliation to the purchasing organizations using the LFM1.
References MailCenter – Excerpt –
Excerpt from the list of MailCenter customers who have implemented MailCenter .
SAP function module Read e-mail address
BAPI_ADDRESSORG_GETDETAIL
Determine data via BAPI – Alternatively, it is possible to determine the data via a program with the BAPI_ADDRESSORG_GETDETAIL .
To do this, specify the following parameters for the function block.
OBJ_TYPE ->KNA1
OBJ_ID -> 0000000002
Further possibilities via function blocks:
UBC_USER_GET_BY_EMAIL – Determine user from EMAIL address
/ISDFPS/FIND_EMAIL_ADDRESS – Returns e-mail address for user ID
BUA_GET_ADDRESS_FROM_EMAIL – Address data of types 1,2,3 for an e-mail address are read
EFG_GEN_GET_USER_EMAIL – Print Workbench: Returns the email address of the user master
SAP E-mail Addresses Supplier
The e-mail addresses of suppliers in the SAP system can be stored in different tables, depending on the specific requirements and configuration of the system. Here are the steps to extract the address data of suppliers from the SAP system:
- How do I call tables in SAP? Open transaction SE16 (or SE16N) in the SAP Easy Access screen.
- Enter “LFA1” in the “Table” field and confirm. This will open the LFA1 table, which stores common vendor master data.
- Find the appropriate vendor records from which you need the email addresses.
- Make a note of the address number (ADRNR) of the desired supplier.
- Open the ADR6 table and enter the vendor number in the ADDRNUMBER field to search for the address data. In the SMTP_ADDR field, you will find the desired SAP e-mail address of the supplier.
E-mail Address Supplier Tables
- LFA1 – Vendor master (general part)
- ADR6 Address Data (Business Address Services)
SAP user e-mail address
The e-mail addresses of the users in the SAP system are stored in the “USR21” table. Here are the steps to extract users’ data from the SAP system:
- Open transaction SE16 (or SE16N) in the SAP Easy Access screen.
- Enter “USR21” in the “Table” field and confirm.
- This will open the USR21 table, where the user information is stored.
- In the list, find the appropriate user records from which you need the e-mail addresses. Use the BNAME field (user name in the user master) for the search.
- Make a note of the “PERSNUMBER” of the desired user. Small help: You can choose between the field name and the field identifier via the Settings -> User Parameters -> Data Browser -> Keyword menu.
- Open the “ADR6” table and enter the personnel number in the “PERSNUMBER” field to search for the address data. In the SMTP_ADDR field, you will find the desired SAP e-mail address of the user.
E-mail Address User Tables
- USR21 – Mapping Username Address Key
- ADR6 Address Data (Business Address Services)
SAP contact person E-mail address
In this example, we use the KNVK for the contact data and the ADR6 for the email addresses. The prsnr and smtp_addr fields are used to retrieve the appropriate information from the tables.
*&---------------------------------------------------------------------*
*& z_read_customer_contacts
*&
*&---------------------------------------------------------------------*
REPORT z_read_customer_contacts.
DATA: lt_contacts TYPE TABLE OF knvk,
lt_addresses TYPE TABLE OF adr6,
ls_contact TYPE knvk,
ls_address TYPE adr6.
PARAMETERS: p_custom TYPE kunnr.
START-OF-SELECTION.
SELECT * FROM knvk
INTO TABLE lt_contacts
WHERE kunnr = p_custom.
IF lt_contacts IS NOT INITIAL.
LOOP AT lt_contacts INTO ls_contact.
SELECT SINGLE * FROM adr6
INTO ls_address
WHERE persnumber = ls_contact-prsnr.
IF ls_address IS NOT INITIAL.
WRITE: / 'Contact Person:', ls_contact-namev, ls_contact-name1,
'Email:', ls_address-smtp_addr.
ELSE.
WRITE: / 'No address found for contact person:', ls_contact-namev, ls_contact-name1.
ENDIF.
ENDLOOP.
ELSE.
WRITE: / 'No contacts found for customer', p_custom.
ENDIF.
E-mail address Contact person Tables
- KNVK – Customer base Contact data
- ADR6 Address Data (Business Address Services)
You are interested in further contributions or have questions on this topic. You are also welcome to subscribe to our free newsletter . Would you like to learn more about our products, solutions, services and support? Just get in touch with us. We look forward to hearing from you.
Other interesting links on the topic: