Application Development 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: 

BAPI_USER_CHANGE - cannot initialise communication fields

former_member221770
Contributor
0 Kudos

Hi friends,

I am using BAPI_USER_CHANGE to synchronise SAP User data with our Exchange Server. Included in these changes are the user's telephone and mobile number. Now say for example if I want to change these numbers there is no problem, but if a user no longer has a (desk) telephone number because they are now splitting their time evenly over several sites or no longer has a mobile number I want to the appropriate fields to be empty in SAP.

Here is a segment of my code:



* Structure to hold Communication 'X' structure
DATA: BEGIN OF st_commx.
        INCLUDE STRUCTURE bapiadcomx.
DATA: END OF st_commx.

* Internal Table to hold Telephone / Mobile Numbers
DATA: BEGIN OF tbl_comm OCCURS 0.
        INCLUDE STRUCTURE bapiadtel.
DATA: END OF tbl_comm.
  
  CLEAR tbl_comm.
  ADD 1 TO l_counter.
  tbl_comm-std_no     = 'X'.
  tbl_comm-telephone  = st_user_change-mob_number.
  tbl_comm-std_recip  = 'X'.  "SMS Compatible?
  tbl_comm-r_3_user   = '3'.  "Mobile?
  tbl_comm-home_flag  = 'X'.
  tbl_comm-consnumber = l_counter.

  st_commx-adtel = 'X'.

....

  CALL FUNCTION 'BAPI_USER_CHANGE'
    EXPORTING
      username = st_user_change-username
      address  = st_addr
      addressx = st_addrx
      addcomx  = st_commx
    TABLES
      return   = tbl_return
      addsmtp  = tbl_email
      addtel   = tbl_comm.

  CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

So, if st_user_change-mob_number is empty, I would assume that the BAPI would overwrite the existing number with blanks, but this is not happening - the old number is still there.

Any assistance will be rewarded accordingly.

Cheers,

Pat.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

sorry about the incorrect reply in my last reply. The source code of BAPI at point is written as below

IF SY_SUBRC = 0 AND <CHANGEFIELD> IS INITIAL.

<NEWFIELD> = <OLDFIELD>.

ENDIF.

This is code written in FM which is called by FM mentioned by you. Because of this if the <CHANGEFIELD> ie. the field which we want to change is initial then it is not going take effect on existing value. This is a bug can be reported SAP.

5 REPLIES 5

christian_wohlfahrt
Active Contributor
0 Kudos

Hi Pat!

There is no flag-structure(-table) for table addtel - so you would overwrite everything, if you try to add one additional info.

-> Try to fill one (or 30) space instead of empty mob_number. This might be trigger override.

Regards,

Christian

Former Member
0 Kudos

Hi,

Your code is ok only 'append tbl_comm' is missing so your code is not working. Just add this append statement after you populate the required data.

Former Member
0 Kudos

Hi,

sorry about the incorrect reply in my last reply. The source code of BAPI at point is written as below

IF SY_SUBRC = 0 AND <CHANGEFIELD> IS INITIAL.

<NEWFIELD> = <OLDFIELD>.

ENDIF.

This is code written in FM which is called by FM mentioned by you. Because of this if the <CHANGEFIELD> ie. the field which we want to change is initial then it is not going take effect on existing value. This is a bug can be reported SAP.

0 Kudos

Hi Chintamani,

Yes I found the line you are referring to in the SUSR_BAPI_USER_CHANGE FM. I was hoping that I had missed something silly within one of the other parameters to the BAPI.

Will report this as a possible bug to SAP as you suggested.

In the meantime for those interested, I have put together a little work around.

If the number is initial, I put in a '0' into the number and put a 'X' the 'FLG_NOUSE' field - therefore the "DO NOT USE" flag is ticked.

Cheers,

Pat.

Former Member
0 Kudos

BAPI_USER_CHANGE actuallu calls SUSR_BAPI_USER_CHANGE in which the code is written which I have posted in my answer before this reply