Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Update or Insert Email Using BAPI_ADDRESSORG_CHANGE

VijayCR
Active Contributor
0 Likes
5,740

Hello Experts,

I am facing an issue while Updating an Email in XD02 Transaction using BAPI_ADDRESSORG_GETDETAIL and BAPI_ADDRESSORG_CHANGE. I am able to update only the email not the notes.Can Some tell me where i had went wrong and If you can please expalin me the 3 bapiadsmtp,bapicomrem,bapiadsmtx tables used for this.

My input is LIFNR and Remark(Notes).

READ TABLE t_bapicomrem INTO f_bapicomrem
                WITH KEY comm_notes = gf_file-remarks.
        READ TABLE t_bapiadsmtp INTO f_bapiadsmtp
                   WITH KEY  consnumber = f_bapicomrem-consnumber.
        IF f_bapicomrem-comm_notes EQ  gf_file-remarks.
          f_bapiadsmtp-e_mail = gf_file-smtp_addr.
          MODIFY TABLE t_bapiadsmtp FROM f_bapiadsmtp.
          f_bapiadsmtx-e_mail     = 'X'.
          f_bapiadsmtx-updateflag = 'U'.
          APPEND f_bapiadsmtx TO t_bapiadsmtx.
        ELSE.
          f_bapiadsmtp-e_mail      = gf_file-smtp_addr.
          f_bapicomrem-comm_notes  =  gf_file-remarks.
          f_bapicomrex-comm_notes  = gf_file-remarks.
          f_bapiadsmtx-e_mail     = 'X'.
          f_bapiadsmtx-updateflag = 'I'.
          f_bapicomrex-LANGU      = 'EN'.
          f_bapicomrex-LANGU_ISO  = 'EN'.
          f_bapicomrex-updateflag = 'I'.
          APPEND f_bapiadsmtp TO t_bapiadsmtp.
          APPEND f_bapicomrem TO t_bapicomrem.
          APPEND f_bapiadsmtx TO t_bapiadsmtx.
        ENDIF.
        clear : f_bapicomrem,
                f_bapicomrem,
                f_bapiadsmtx.
      ENDLOOP.
  CALL FUNCTION 'BAPI_ADDRESSORG_CHANGE'
        EXPORTING
          obj_type       = 'LFA1'
          obj_id         = lv_objid
          save_address   = 'X'
        IMPORTING
          address_number = lv_adrnr
        TABLES
          bapiadsmtp     = t_bapiadsmtp
          bapicomrem     = t_bapicomrem
          bapiadsmt_x    = t_bapiadsmtx
          bapicomre_x    = t_bapicomrex
          return         = t_ret.

Thanks ,

Vijay

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,361

Hi Vijay,

Make few changes in the code you have given,

The code piece given by you..

f_bapiadsmtp-e_mail      = gf_file-smtp_addr.
          f_bapicomrem-comm_notes  =  gf_file-remarks.
          f_bapicomrex-comm_notes  = gf_file-remarks.
          f_bapiadsmtx-e_mail     = 'X'.
          f_bapiadsmtx-updateflag = 'I'.
          f_bapicomrex-LANGU      = 'EN'.
          f_bapicomrex-LANGU_ISO  = 'EN'.
          f_bapicomrex-updateflag = 'I'.

Try this instead of this piece

f_bapiadsmtp-e_mail      = gf_file-smtp_addr.
          f_bapicomrem-comm_notes  =  gf_file-remarks.
          f_bapicomrex-comm_notes  = 'X'.
          f_bapiadsmtx-e_mail     = 'X'.
          f_bapiadsmtx-updateflag = 'I'.
        * f_bapicomrex-LANGU      = 'EN'. " This should be either X or ' ' set this only if you change the language.
        * f_bapicomrex-LANGU_ISO  = 'EN'. " This should be either X or ' ' set this only if you change the language.
          f_bapicomrex-updateflag = 'I'.

Hope this helps.

Regards,

Praveenkumar T.

6 REPLIES 6
Read only

Tamas_Hoznek
Product and Topic Expert
Product and Topic Expert
0 Likes
2,361

Not sure if this is really the issue, but shouldn't you say

f_bapicomrex-comm_notes  = 'X'.

instead of

f_bapicomrex-comm_notes  = gf_file-remarks.

?

If for some reason this FM doesn't work (although it really should), take a look at [this|http://forums.sdn.sap.com/thread.jspa?threadID=2124356] thread... you can probably use function module SD_CUSTOMER_MAINTAIN_ALL. The last post talks about the necessary calling details for structure KNVK where the notes are.

Read only

madhu_vadlamani
Active Contributor
0 Likes
2,361

Hi Vijay,

I will suggest you try with sd_customer_maintain_all .

Regards,

Madhu.

Read only

Former Member
0 Likes
2,361

Hi,

After fetching the address details, as you want to update address details, first delete the existing data by passing

updateflag = 'D'.

Then move the required data to respective fields and then pass updateflag = 'U'.

bapicomre_x-langu = 'E'.

BAPICOMREM-ERRORFLAG = 'X'

don't use these fields bapicomre_x-langu_iso

BAPICOMREM-langu_iso

Still any issues , revert to me .

Edited by: Parupelly on Feb 15, 2012 11:48 AM

Read only

0 Likes
2,361

Hi Parupally,

Can you please send me the full code if you have with you?So that i can understand clearly?

Thank you,

Vijay.

Read only

0 Likes
2,361

Hi,

Once go through function module BAPI_ADDRESSORG_CHANGE documentation

Read only

Former Member
0 Likes
2,362

Hi Vijay,

Make few changes in the code you have given,

The code piece given by you..

f_bapiadsmtp-e_mail      = gf_file-smtp_addr.
          f_bapicomrem-comm_notes  =  gf_file-remarks.
          f_bapicomrex-comm_notes  = gf_file-remarks.
          f_bapiadsmtx-e_mail     = 'X'.
          f_bapiadsmtx-updateflag = 'I'.
          f_bapicomrex-LANGU      = 'EN'.
          f_bapicomrex-LANGU_ISO  = 'EN'.
          f_bapicomrex-updateflag = 'I'.

Try this instead of this piece

f_bapiadsmtp-e_mail      = gf_file-smtp_addr.
          f_bapicomrem-comm_notes  =  gf_file-remarks.
          f_bapicomrex-comm_notes  = 'X'.
          f_bapiadsmtx-e_mail     = 'X'.
          f_bapiadsmtx-updateflag = 'I'.
        * f_bapicomrex-LANGU      = 'EN'. " This should be either X or ' ' set this only if you change the language.
        * f_bapicomrex-LANGU_ISO  = 'EN'. " This should be either X or ' ' set this only if you change the language.
          f_bapicomrex-updateflag = 'I'.

Hope this helps.

Regards,

Praveenkumar T.