Code: Alles auswählen.
IF lf_iscustomer = abap_true.
" BUP_BUPA_BUT000_GET
CALL FUNCTION 'BUP_BUPA_BUT000_GET'
IMPORTING
e_but000 = ls_but000
e_but000_stat = ls_but000_stat
TABLES
et_adsmtp = lt_adsmtp.
" BUA_BUPA_ADDRICOMM_GET - addressunabhängige Komm-Daten
CALL FUNCTION 'BUA_BUPA_ADDRICOMM_GET'
TABLES
t_sza11_0100 = lt_com_unabh.
lf_flag = abap_false.
LOOP AT lt_com_unabh ASSIGNING FIELD-SYMBOL(<com_unabh>).
IF NOT <com_unabh>-smtp_addr IS INITIAL.
lf_flag = abap_true. " E-Mail vorhanden
ENDIF.
ENDLOOP.
IF lf_flag = abap_false.
" keine adressunabhängige E-Mail gepflegt
" Ermittle aktuelles Adresshandle, -nummer für
" adressunabhängige Kommunikation
CALL FUNCTION 'BUA_BUPA_ADDRICOMM_HANDLE_GET'
IMPORTING
e_addr_icomm = ls_addr_icomm
TABLES
t_mem_addr_icomm = lt_mem_addr_icom. " im Memeory vorhandene Handles
IF NOT ls_addr_icomm-addrnumber IS INITIAL.
CLEAR ls_addr_icomm-addrhandle.
ENDIF.
" Alle vorhandenen Mail-Adressen lesen
CALL FUNCTION 'BUA_BUPA_ADR6_GET'
TABLES
t_adr6 = lt_adr6. " Mail-Adressen
ls_cam1-addrhandle = ls_addr_icomm-addrhandle.
ls_cam1-addrnumber = ls_addr_icomm-addrnumber.
APPEND INITIAL LINE TO ls_cam1-adsmtp_tab ASSIGNING FIELD-SYMBOL(<smtp>).
<smtp>-adsmtp-flgdefault = abap_true.
<smtp>-adsmtp-home_flag = abap_true.
<smtp>-adsmtp-updateflag = 'I'.
IF lines( lt_adr6 ) > 0.
" Es gibt schon eine Mail-Adresse
" -> kopieren in unabhängig
<smtp>-adsmtp-smtp_addr = lt_adr6[ 1 ]-smtp_addr.
ELSE.
" Es gibt noch keine Mail-Adresse
" -> DEFAULT-Mail-Adresse setzen (xxx.xx.de)
<smtp>-adsmtp-smtp_addr = 'xxx.xx.de'.
ENDIF.
IF lines( lt_mem_addr_icom ) = 0.
" adressunabhängige Komm-Daten Insert
" ab hier hakt es !
ELSE.
" adressunabhängige Komm-Daten Update
CALL FUNCTION 'ADDR_CAM1_MAINTAIN_COMPLETE'
EXPORTING
updateflag = 'U'
addr_cam1_complete = ls_cam1
IMPORTING
returncode = lv_inri_retcode
TABLES
error_table = lt_error
EXCEPTIONS
parameter_error = 1
address_not_exist = 2
handle_exist = 3
internal_error = 4
address_blocked = 5
OTHERS = 6.
ENDIF.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF. " IF sy-subrc <> 0.
ENDIF. " IF lf_flag = abap_false.
Code: Alles auswählen.
EXCEPTIONS
parameter_error = 1
address_not_exist = 2
internal_error = 3
address_blocked = 4
OTHERS = 5.
Code: Alles auswählen.
"------ Address-indep. comm. data --------------------------------------
"------ Current address to be processed --------------------------------
TYPES: BEGIN OF ty_addr_icomm,
partner TYPE but000-partner,
addrnumber TYPE but020-addrnumber,
addrhandle TYPE addr1_sel-addrhandle,
END OF ty_addr_icomm.
DATA: lf_flag TYPE flag,
lf_iscustomer TYPE flag,
lf_isvendor TYPE flag,
ls_addr_icomm TYPE ty_addr_icomm,
lt_adsmtp TYPE TABLE OF adsmtp,
lv_retcode TYPE ad_retcode,
lt_ad_error TYPE TABLE OF addr_error,
ls_cam1 TYPE szadr_addr1_complete,
lf_nosmtp TYPE flag,
lf_handleexists TYPE flag,
lv_cam1_updateflag TYPE ad_updflag.
CONSTANTS:
cv_smtp_default TYPE ad_smtpadr VALUE 'test@test.de',
cv_smtp_remark_default TYPE ad_remark2 VALUE 'Test'.
...
IF lf_iscustomer = abap_true.
****************************************************************************
*** 1. Keine adressunabhängige E-Mail-Adresse bei deb. Partner - Warnung ***
****************************************************************************
" Adresshandle adressunabhängige Komm ermitteln
CALL FUNCTION 'BUA_BUPA_ADDRICOMM_HANDLE_GET'
IMPORTING
e_addr_icomm = ls_addr_icomm.
" lese vorhandene Mail-Adressen (adressunabhängig)
CALL FUNCTION 'ADDR_COMM_GET'
EXPORTING
address_handle = ls_addr_icomm-addrhandle
address_number = ls_addr_icomm-addrnumber
table_type = 'ADSMTP'
IMPORTING
returncode = lv_retcode
TABLES
comm_table = lt_adsmtp
error_table = lt_ad_error
EXCEPTIONS
parameter_error = 1
address_not_exist = 2
internal_error = 3
address_blocked = 4
OTHERS = 5.
CASE sy-subrc.
WHEN 0.
" Adresshandle vorhanden, prüfe Rückgabetabelle
lf_handleexists = abap_true.
IF lines( lt_adsmtp ) = 0.
lf_nosmtp = abap_true.
ELSE.
lf_nosmtp = abap_false.
ENDIF.
WHEN 2.
" Adresshandle nicht vorhanden -> keine unabh. Mail-Adressen vorhanden
lf_handleexists = abap_false.
lf_nosmtp = abap_true.
CLEAR lt_adsmtp.
WHEN OTHERS.
" AM, 001, &1 &2 &3 &4
CALL FUNCTION 'BUS_MESSAGE_STORE'
EXPORTING
arbgb = 'AM'
msgty = 'A'
txtnr = 001
msgv1 = 'Interner Fehler bei ADDR_COMM_GET'
msgv2 = 'Abbruch'.
CLEAR lt_adsmtp.
ENDCASE.
IF lf_nosmtp = abap_true.
" keine adressunabhängige E-Mail gepflegt
" Einfügen Default-Mail-Adresse
ls_cam1-addrhandle = ls_addr_icomm-addrhandle.
ls_cam1-addrnumber = ls_addr_icomm-addrnumber.
APPEND INITIAL LINE TO ls_cam1-adsmtp_tab ASSIGNING FIELD-SYMBOL(<smtp>).
<smtp>-adsmtp-smtp_addr = cv_smtp_default.
<smtp>-adsmtp-smtp_srch = to_upper( <smtp>-adsmtp-smtp_addr ).
<smtp>-adsmtp-flgdefault = abap_true.
<smtp>-adsmtp-home_flag = abap_true.
<smtp>-adsmtp-remark = cv_smtp_remark_default.
<smtp>-adsmtp-updateflag = 'I'.
IF lf_handleexists = abap_true.
lv_cam1_updateflag = 'U'.
ELSE.
lv_cam1_updateflag = 'I'.
ENDIF.
" ADDR_CAM1_MAINTAIN_COMPLETE
CALL FUNCTION 'ADDR_CAM1_MAINTAIN_COMPLETE'
EXPORTING
updateflag = lv_cam1_updateflag
addr_cam1_complete = ls_cam1
IMPORTING
returncode = lv_retcode
TABLES
error_table = lt_ad_error
EXCEPTIONS
parameter_error = 1
address_not_exist = 2
handle_exist = 3
internal_error = 4
address_blocked = 5
OTHERS = 6.
IF sy-subrc <> 0.
" Konnte nicht angelegt werden - Warning nicht vorhanden ausgeben
" Keine adressunabhängige Mail-Adresse bei debitorischem Partner angegeben!
CALL FUNCTION 'BUS_MESSAGE_STORE'
EXPORTING
arbgb = 'AM'
msgty = 'W'
txtnr = 001
msgv1 = 'Keine adressunabhängige Mail-Adresse bei debitorischem Partner angegeben!'.
ELSE.
" Adressunabhängige DEFAULT-Mail-Adresse eingefügt! Bitte prüfen!
CALL FUNCTION 'BUS_MESSAGE_STORE'
EXPORTING
arbgb = 'AM'
msgty = 'W'
txtnr = 001
msgv1 = 'Adressunabhängige DEFAULT-Mail-Adresse eingefügt! Bitte prüfen!'.
ENDIF.
ELSE. " IF lf_nosmtp = abap_true.
" prüfe auf zulässige Bemerkung
SELECT * FROM z_c_remark INTO TABLE @DATA(lt_mailremark).
LOOP AT lt_adsmtp ASSIGNING FIELD-SYMBOL(<ad_smtp>).
IF <ad_smtp>-remark IS NOT INITIAL.
IF line_exists( lt_mailremark[ remark = <ad_smtp>-remark ] ).
" alles OK
ELSE.
" Bemerkung nicht zulässig!
CALL FUNCTION 'BUS_MESSAGE_STORE'
EXPORTING
arbgb = 'AM'
msgty = 'W'
txtnr = 001
msgv1 = 'Bemerkung nicht zulässig!'
msgv2 = <ad_smtp>-remark
msgv3 = <ad_smtp>-smtp_addr.
ENDIF.
ELSE. " IF <ad_smtp>-remark IS NOT INITIAL.
" Bemerkung zur Mail-Adresse '&1' ist leer!
CALL FUNCTION 'BUS_MESSAGE_STORE'
EXPORTING
arbgb = 'AM'
msgty = 'W'
txtnr = 001
msgv1 = 'Bemerkung ist leer!'
msgv2 = <ad_smtp>-smtp_addr.
ENDIF. " IF <ad_smtp>-remark IS NOT INITIAL.
ENDLOOP.
ENDIF. " IF lf_nosmtp = abap_true.
ENDIF. " IF lf_iscustomer = abap_true.
Folgende Benutzer bedankten sich beim Autor Lehrberger für den Beitrag (Insgesamt 2):
ewx • msfox