Skip to Content
0

Save an BP-Email using FM? What do i do wrong?

Nov 28, 2017 at 10:10 AM

29

avatar image

This is my implementation, that didn't work :-(

What is wrong?

SPAN { font-family: "Courier New"; font-size: 10pt; color: #000000; background: #FFFFFF; } .L0S31 { font-style: italic; color: #808080; } .L0S32 { color: #3399FF; } .L0S33 { color: #4DA619; } .L0S52 { color: #0000FF; } .L0S55 { color: #800080; } .L0S70 { color: #808080; }

*"----------------------------------------------------------------------
*"*"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_ADDRNUMBER = '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'
* IMPORTING
* return = ls_return
.

SELECT SINGLE MAX( addrnumber ), MAX( consnumber ) INTO ( @ls_adrt-addrnumber, @ls_adrt-consnumber )
FROM adr6
WHERE smtp_addr = @i_email.
* and FLGDEFAULT = @wa_adsmtp-std_recip .



ls_adrt-comm_type = 'INT'. "Internet-Adresse
ls_adrt-langu = 'D'.
ls_adrt-remark = i_remark.

MODIFY adrt FROM ls_adrt .

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Nic Teunckens Nov 28, 2017 at 12:22 PM
0

Hello Sam

I would consider using BAPI's "BAPI_BUPA_CENTRAL_GETDETAIL" and "BAPI_BUPA_CENTRAL_CHANGE" ...

In a similar scenario these have proven to work for me ...


Hope this helps

Nic T.

Share
10 |10000 characters needed characters left characters exceeded