cancel
Showing results for 
Search instead for 
Did you mean: 

How to deactive SU01 user password using Function module / BAPI

lrayapat73
Participant
0 Kudos

Hi All,

I need to deactive the SU01 user password programatically, using NCo (.Net connector), could you please suggest how can I deactivate user password. Essentially users need to access the system by other means like SSO, however their password logon should be deactivated.

Thanks in advance.

Accepted Solutions (1)

Accepted Solutions (1)

jmodaal
Active Contributor

Hello,

try this:

Read the current data of the user with function module BAPI_USER_GET_DETAIL. Use the LOGONDATA structure as input parameter for BAPI_USER_CHANGE. Clear fields BCODE, LTIME, PASSCODE, PWDSALTEDHASH and set field value of CODVN to 'X'.

Then set the corresponding change indicators in import parameter structure LOGONDATAX to 'X' and call the function module. After that (and a commit work) the password of the user should be deactivated.

lrayapat73
Participant
0 Kudos

Thanks Jan for the input, will check.

jmodaal
Active Contributor
0 Kudos

After having a look on it: I think the first step with BAPI_USER_GET_DETAIL is not necessary. You can leave it, it should work.

lrayapat73
Participant
0 Kudos

Yes Jan, It worked without BAPI_USER_GET_DETAIL.

In BAPI/FM documentation through SAP GUI it's not showing above fields related to LogonData. Can you please take look at the following question related to BAPI_USER_CHANGE,

https://answers.sap.com/questions/13203254/bapi-user-change-how-to-update-license-type-field.html

Thanks.

jmodaal
Active Contributor

Hello, regarding the other question mateuszadamus already pointed into the right direction. There is - others than in most (or all?) other structures - no change indicator for each single field. So try it with

UCLASSX.SetValue("UCLASS", "X");

I am not sure about the other field UCLASSSYS. In a first attempt I would leave it out.


Answers (1)

Answers (1)

SajithP
Participant
0 Kudos

Can you try this?

Data:ls_user_logondata type bapilogond,
ls_user_password type bapipwd,
ls_user_address type bapiaddr3,
ls_user_logondata-gltgv = sy-datum.
ls_user_logondata-gltgb = '99991231'.
ls_user_logondata-ustyp = 'A'.
ls_user_logondata-CODVN = 'X'.
ls_user_logondata-CODVC = 'X'.
ls_user_password-bapipwd = ''.
clear ls_user_password-bapipwd.
lv_alias-USERALIAS = lvusrnam.
ls_user_address-firstname = lvfname.
ls_user_address-lastname = lvlname.

PARAMETERS: lvusrnam type uname,
lvfname type bapiaddr3-firstname,
lvlname type bapiaddr3-lastname.
CALL FUNCTION 'BAPI_USER_CREATE1'
EXPORTING
USERNAME = lvusrnam
LOGONDATA = ls_user_logondata
PASSWORD = ls_user_password
ADDRESS = ls_user_address

ALIAS = lv_alias.