Code: Alles auswählen.
FUNCTION zfb_save_email_tempo.
*"----------------------------------------------------------------------
*"*"Lokale Schnittstelle:
*" IMPORTING
*" REFERENCE(I_PARTNER) TYPE BU_PARTNER
*" REFERENCE(I_EMAIL) TYPE AD_SMTPADR
*" REFERENCE(I_REMARK) TYPE AD_REMARK2 DEFAULT 'Aus Terminportal'
*"----------------------------------------------------------------------
DATA: wa_adsmtp TYPE bapiadsmtp,
ls_addr_use TYPE bapibus1006_addressusage,
wa_adtel TYPE bapiadtel,
wa_adfax TYPE bapiadfax,
lt_adtel TYPE STANDARD TABLE OF bapiadtel,
lt_adsmtp TYPE TABLE OF bapiadsmtp,
lt_adsmtp_x TYPE TABLE OF bapiadsmtx,
wa_adsmtp_x TYPE bapiadsmtx,
lt_adfax TYPE TABLE OF bapiadfax,
lt_adfax_x TYPE TABLE OF bapiadfaxx,
wa_adfax_x TYPE bapiadfaxx,
ls_adfax TYPE bapiadfax,
lt_adtel_x TYPE TABLE OF bapiadtelx,
ls_adtel_x TYPE bapiadtelx,
lt_return TYPE TABLE OF bapiret2.
DATA x_rltyp TYPE tbz0-rltyp.
DATA ty_adr6 TYPE STANDARD TABLE OF adr6.
DATA ty_email TYPE STANDARD TABLE OF fkk0adsmtp.
DATA ls_email TYPE fkk0adsmtp.
DATA: ls_valid_to TYPE AD_VALTO.
DATA: ls_addrnumber TYPE ad_addrnum,
ls_adrt TYPE adrt.
x_rltyp = '000000'. " GPartner allgemein
CALL FUNCTION 'ISU_DB_PARTNER_SINGLE'
EXPORTING
x_partner = i_partner
x_rltyp = x_rltyp " GPartner allgemein
x_xaddr_mult = 'X'
x_xemail_mult = 'X'
TABLES
ty_adr6 = ty_adr6
ty_email = ty_email
EXCEPTIONS
partner_not_found = 1
partner_in_role_not_found = 2
internal_error = 3
OTHERS = 4.
IF sy-subrc <> 0.
* Implement suitable error handling here
EXIT.
ENDIF.
"neue Email-adresse für ADR6
wa_adsmtp-valid_from = sy-datum && '000000'.
wa_adsmtp-e_mail = i_email .
wa_adsmtp-std_recip = 'X'.
wa_adsmtp-valid_from = sy-datum && '000000'.
wa_adsmtp-valid_to = '99991231235959'.
APPEND wa_adsmtp TO lt_adsmtp.
"Updatestruktur, welche Felder geupdated werden sollen
wa_adsmtp_x-e_mail = 'X'.
wa_adsmtp_x-std_recip = 'X'.
wa_adsmtp_x-valid_from = 'X'.
wa_adsmtp_x-valid_to = 'X'.
wa_adsmtp_x-updateflag = 'I'.
APPEND wa_adsmtp_x TO lt_adsmtp_x.
ls_valid_to = wa_adsmtp-valid_from .
SORT TY_EMAIL by valid_from DESCENDING .
LOOP AT ty_email INTO ls_email .
IF ls_email-valid_to = '99991231235959'
OR ls_email-valid_to IS INITIAL .
MOVE-CORRESPONDING ls_email TO wa_adsmtp .
wa_adsmtp-valid_to = ls_valid_to - 1 .
ls_valid_to = ls_email-valid_from.
"Diese Mailadresse muss geupdated werden.
wa_adsmtp_x-valid_to = 'X'.
wa_adsmtp_x-updateflag = 'U'. "update
APPEND wa_adsmtp_x TO lt_adsmtp_x.
ENDIF.
ENDLOOP.
CALL FUNCTION 'BAPI_BUPA_ADDRESS_CHANGE'
EXPORTING
businesspartner = i_partner
TABLES
bapiadtel = lt_adtel
bapiadfax = lt_adfax
bapiadsmtp = lt_adsmtp
bapiadtel_x = lt_adtel_x
bapiadfax_x = lt_adfax_x
bapiadsmt_x = lt_adsmtp_x
return = lt_return.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X' .
"Text (Hinweis) zur Adresse speichern, dazu suche ich die gerade gespeicherte Nummer
SELECT SINGLE MAX( addrnumber ), MAX( consnumber ) INTO ( @ls_adrt-addrnumber, @ls_adrt-consnumber )
FROM adr6
WHERE smtp_addr = @i_email.
ls_adrt-comm_type = 'INT'. "Internet-Adresse
ls_adrt-langu = 'D'.
ls_adrt-remark = i_remark.
MODIFY adrt FROM ls_adrt .
ENDFUNCTION.