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: 

BADI_IDENTITY_UPDATE - Updating users Function & Department in SU01D

0 Kudos
1,602

We have a need to find an enhancement spot/user exit for when the Users SU01 is “touched” so it will put in what our requirements are for the Function & Department fields under the Work Center area (our requirements are based on derived/concatenated fields from the users HR Record).

We were hoping BADI_IDENTITY_UPDATE would provide this but sadly it does not. It fails at the following spot because both of these values are ‘X”. The comment seems to insinuate that you cannot use the set method and we are trying to use the set_workplacedata method as you can see below.

" During SAVE: BADI_IDENTITY_UPDATE MUST not call any SET methodeif gv_active_badi_identity_update eq if_identity=>co_true.
macro_raise_internal_error.endif.

SAP Note 1750161 has this comment in it: “You can no longer change the user data that is to be saved.” We have tried various things and nothing seems to work and google is not providing us any answers either. We know we can use the Function 'BAPI_USER_CHANGE' but if this is how to do it, then we still need to know where to hang it so it trips on a user exit/enhancement - having it run just as an abap job will not work for us. Does anyone know how we can put in our own requirements/data for the Function & Department fields in SU01 whenever this record is “touched” by any program?

Our code if IF_BADI_IDENTITY_UPDATE~SAVE:

LOOP AT it_badi_identity_update REFERENCE INTO lr_identity_update.
AT NEW bname. "New USERTRY.CALL METHOD lr_identity_update->idref->if_identity_person~get_workplacedataIMPORTING
es_workplace = ls_workplace
eo_msg_buffer = lo_msg_buffer.CATCH cx_suid_identity.ENDTRY.
"Temp settings just to see if it will work
ls_workplace-department = 'KH_DEPT2'.
ls_workplace-function = 'KH_FUNCTION2'.

ls_change_fields = 'DEPARTMENT'.APPEND ls_change_fields TO lt_change_fields.
ls_change_fields = 'FUNCTION'.APPEND ls_change_fields TO lt_change_fields.
TRY.CALL METHOD lr_identity_update->idref->if_identity_person~set_workplacedataEXPORTING
it_change_fields = lt_change_fields
is_workplace = ls_workplaceIMPORTING
eo_notify = lo_notify
eo_msg_buffer = lo_msg_buffer.CATCH cx_suid_identity.ENDTRY.
ENDAT.

ENDLOOP

2 REPLIES 2

raymond_giuseppi
Active Contributor
0 Kudos
424

When BADI_IDENTITY_UPDATE is executed, it's already too late to change user data in this transaction.

But you could use this BAdI to call a RFC enabled FM IN BACKGROUND UNIT/TASK so executed after commit and database update. In this wrapper RFC FM you can update the user data and commit your changes using BAPI_USER_CHANGE and BAPI_TRANSACTION_COMMIT. Also in the BAdI implementation care is needed to avoid triggering endlessly the FM again and again (e.g. look in Abap stack for your RFC FM)

0 Kudos
424

Thank-you very much!! This helps and reconfirms things for us. We will proceed with the BAPI_USER_CHANGE