Skip to Content
author's profile photo Former Member
Former Member

BAPI_USER_CHANGE does not update changes

Hi ABAPERS!

I’m calling bapi BAPI_USER_CHANGE remotely in order to change expired date & user group.

Although the BAPI returns message: “User XXXXX has changed” no changes are made when I check SU01 transaction in the target system.

If I test the bapi via SE37 transaction, changes are made.

In more detail, my requirement is to set up some actions automatically when a user leaves a company. For this purpose created a FM which include BAPI calls. All of them are working fine except BAPI_CHANGE_USER. Here the list of actions and the bapi I use.

- Lock the user -> BAPI_USER_LOCK

- Remove all roles -> BAPI_USER_ACTGROUPS_DELETE

- Remove profiles -> BAPI_USER_PROFILES_DELETE

- Expire the user / Change the user group to a specific user group --> BAPI_USER_CHANGE

My code:

CLEAR ls_logondata.
ls_logondata-class = 'LEAVERS'.
ls_logondata-gltgb = sy-datum.
ls_logondatax-class = 'X'.
ls_logondatax-gltgb = 'X'.

CALL FUNCTION 'BAPI_USER_CHANGE' DESTINATION lv_dest
EXPORTING
username = lv_username
logondata = ls_logondata
logondatax = ls_logondatax
TABLES
return = lt_return.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' DESTINATION lv_dest



If I check the system log, it seems that a rollback is executed by the system setting expired date/ user group to original values.

Any idea about this problem? Or do you know another BAPI to use for the same purpose?

Thank you!



Captura.JPG (34.1 kB)
Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

7 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jul 28, 2016 at 07:08 AM

    Hi all,

    I would like to share with all of you that I've found the problem debugging and I confirm that it is not in the BAPI_CHANGE_USER. It is in the configuration of GRC Access Request BRF+ rules and the Request Type.

    The Request type contains two Actions: User Defaults and Change User.

    So the BAPI is called 2 times. The first of them into the User Defaults (here the Z function module is executed with all BAPI calls) and the second one in the Change User action (which is an standard execution)

    In more details:

    When I start the flow, the breakpoint stops for the 1st time in target BAPI_CHANGE_USER system with the desired values (user group: 'LEAVERS' and expired date: sy-datum) and a commit work is executed.

    Then I press F8 to finish the flow and STOPS AGAIN in the bapi BAPI_CHANGE_USER with OLD values. Here there is the second commit work and values are overlaped.

    So the 1st time the update is due to my RFC call but the 2nd time is the standard procedure linked to CHANGE USER rule!

    Thanks for your help!

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 26, 2016 at 08:42 AM

    Is your system managed by CUA? This might be the reason the change is rolled back by the system.

    Best regards,

    Anders

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jul 26, 2016 at 08:42 AM

    BAPI TRANSACTION COMMIT also has a return parameter, maybe you will find some info there?

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jul 26, 2016 at 09:10 AM

    The BAPI you use is perfectly fine.

    Could you elaborate on the following one:

    Sira Agulló Salvia wrote:

    If I test the bapi via SE37 transaction, changes are made.

    Does it work when you execute BAPI_USER_CHANGE in target system using your own user or does it work when you execute BAPI_USER_CHANGE in source system with destination set?

    I would suggest to turn on system trace (ST01) for user DRC_DE3_180 in target system for Authorization Check and RFC Calls and then execute your logic once again and check if you find any clues in the trace file.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 26, 2016 at 10:16 AM

    Hi Sira,

    Did you check if the destination is correct? Try removing it.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jul 26, 2016 at 11:22 AM

    We are calling BAPI_USER_LOCK and then BAPI_USER_CHANGE. I am suspecting it has something to do with the sequence of BAPI. As you said, when you run it from SE37 it run as expected. Can you just comment the BAPI_USER_LOCK and then test your custom FM to see the behavior or call only BAPI_USER_CHANGE from your custom FM and check the behavior.

    Regards

    Sachin

    Add a comment
    10|10000 characters needed characters exceeded

    • May I know know how you called the wrapper function module after commenting other 3 BAPI.

      Did you called it wrapper FM from SE37 or through program?

      If you called from SE37 then it should work because, it contains only single BAPI i.e. BAPI_USER_CHANGE and this BAPI is working as expected when called from SE37.

      In Wrapper FM did you used commit BAPI ?

  • Posted on Jul 26, 2016 at 12:00 PM

    Hi Sira,

    Is it possible for you to create a custom wrapper function module in the target system, where you call the bapi_user_change and bapi_transaction_commit, and use import and export parms from the bapi_user_change?

    If that is possible, you can try to call that user module remote from the source system.

    reg. Bob

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.