SBWP Distribution List Database table

In SAP Inbox there is a distribution list which can be created and SAP users or external mail ID can be can mapped. Distribution List name can used to select the user or other to send out emails.

The Tables changes if in Distribution List SAP ID or Internet Email

  1. For the user ID maintained
    TYPES : BEGIN OF lty_mail,
    smtp_addr TYPE adr6-smtp_addr,
    END OF lty_mail.

DATA : wrk_dist_list TYPE soid-objnam VALUE ‘ZTEST_USR’,
lt_mail TYPE TABLE OF lty_mail.

SELECT a~smtp_addr
FROM adr6 AS a
INNER JOIN v_soucadcp AS b ON a~addrnumber = b~addrnumber
AND a~persnumber = b~persnumber
INNER JOIN sodm AS c ON c~memtp = b~usrtp
AND c~memyr = b~usryr
AND c~memno = b~usrno
INNER JOIN soid AS d ON d~dlitp = c~dlitp
AND d~dliyr = c~dliyr
AND d~dlino = c~dlino
INTO TABLE lt_mail
WHERE a~flgdefault = ‘X’
AND d~objnam = wrk_dist_list.

2. If the external Mail ID’s are maintained
TYPES : BEGIN OF lty_sodm,
memno TYPE sodm-memno,
END OF lty_sodm, BEGIN OF lty_add,
so_key TYPE v_adcp_so-so_key,
END OF lty_add, BEGIN OF lty_mail2,
name_text TYPE v_adcp_so-name_text,
END OF lty_mail2.

DATA : ls_sodm TYPE lty_sodm,
ls_add type lty_add,
lt_add type TABLE OF lty_add,
lt_sodm TYPE TABLE OF lty_sodm,
lt_mail2 TYPE TABLE OF lty_mail2.

wrk_dist_list = ‘ZTEST_MAIL’.

SELECT memno
FROM sodm AS a
INNER JOIN soid AS b ON b~dlitp = a~dlitp
AND b~dliyr = a~dliyr
AND b~dlino = a~dlino
INTO TABLE lt_sodm
WHERE b~objnam = wrk_dist_list.

LOOP AT lt_sodm INTO ls_sodm.
ls_add-so_key = ls_sodm-memno+2(10).
APPEND ls_add TO lt_add.
ENDLOOP.

IF lt_sodm IS NOT INITIAL.
SELECT name_text
FROM v_adcp_so INTO TABLE lt_mail2
FOR ALL ENTRIES IN lt_add
WHERE so_key = lt_add-so_key.
ENDIF.