cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Using a Function Module in SAP RAP managed

gzghidi
Explorer
0 Likes
3,045

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.

gzghidi_0-1745319219181.png

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 ?

 

View Entire Topic
suzanne_alivand
Explorer
0 Likes

Try below note, hope it helps:
https://me.sap.com/notes/0003115094