2025 Apr 22 12:02 PM - edited 2025 Apr 22 1:23 PM
Hello Experts,
I'm trying my best to use the FM BAPI_USER_CREATE1 so i'll be able to create a user on S/4, since i'm working in a managed scenario i have implemented a determination on save so when a new record is created a method that is using BAPI_USER_CREATE1 will be triggered as shown below
determination createUser on save {create;}
METHOD CreateUser.
READ ENTITIES OF zi_user1_rh IN LOCAL MODE
ENTITY User
ALL FIELDS WITH CORRESPONDING #( keys )
RESULT DATA(entites).
LOOP AT entites INTO DATA(entity).
DATA: ls_address TYPE bapiaddr3.
ls_address-firstname = entity-Firstname.
ls_address-lastname = entity-Lastname.
DATA: ls_logondata TYPE bapilogond.
ls_logondata-ustyp = 'A'.
DATA: lv_password TYPE bapipwd VALUE 'passworD123@@',
lv_username TYPE bapibname-bapibname.
lv_username = entity-Username.
ENDLOOP.
CALL FUNCTION 'BAPI_USER_CREATE1'
IN UPDATE TASK
EXPORTING
username = lv_username
logondata = ls_logondata
password = lv_password
address = ls_address.
ENDMETHOD.PS: Please ignore the password that is being mentioned directly in the code as i'm still testing
Unfortunately that didn't work and i got the below st22 dump.
So i decided to take a different approach, so i create a different method which the same logic as the previous one and made it executable via an action button as shown below
action CreateUser result[1] $self;However i'm still getting exactly the same dump, i came across many blogs like the below one which indicates that a validation or a determination should work with a FM in a managed scenario.
https://community.sap.com/t5/technology-q-a/adding-custom-code-function-module-in-managed-scenario-s...
And recommendations please ?
Request clarification before answering.
Hello everyone,
I have solved the issue by wrapping BAPI_USER_CREATE1 logic in a remote-enabled custom function module
I have created a custom function module with the below parameter but first make sure to enable remote module as shown below
Next for the import i used the below ofc you can add more attributes if you want to use more just use BAPI_USER_CREATE1 as your reference.
As for the source code i used the below
and at last i called the custom FM in my method as shown below
METHOD add_user.
READ ENTITIES OF zi_user1_rh IN LOCAL MODE
ENTITY User
ALL FIELDS WITH CORRESPONDING #( keys )
RESULT DATA(users).
LOOP AT users INTO DATA(user).
CALL FUNCTION 'Z_CREATE_SU01_USER'
STARTING NEW TASK 'USRCREATE'
DESTINATION IN GROUP DEFAULT
EXPORTING
iv_username = user-username
iv_firstname = user-firstname
iv_lastname = user-lastname
iv_password = 'passworD123@@'.
ENDLOOP.
READ ENTITIES OF zi_user1_rh IN LOCAL MODE
ENTITY User
ALL FIELDS WITH CORRESPONDING #( keys )
RESULT DATA(userlist).
result = VALUE #( FOR user1 IN userlist ( %tky = user-%tky %param = user ) ).
ENDMETHOD.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 13 | |
| 8 | |
| 6 | |
| 4 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.