{"audience":"SAP authorization administrators, IT security teams and internal audit responsible for user lifecycle controls.","authorization_objects":[{"note":"Lock (activity 05) and change authorization by user group; granted to the background user","object":"S_USER_GRP"}],"components":[],"countries":[],"effort_days_max":4,"effort_days_min":3,"effort_size":"S","faq":[{"a":"No. The program only sets a lock with BAPI_USER_LOCK and optionally changes the validity end with BAPI_USER_CHANGE. Passwords, password hashes or password change data are neither read nor written.","q":"Does the program change or read passwords?"},{"a":"The administrator lock is removed in SU01 or SU10. When the user logs on again, the last logon date is updated and the counter starts from zero.","q":"How is a locked user unlocked again?"},{"a":"The default selection only takes dialog users (type A). System, communication and service users are not locked unless they are added to the selection; emergency users are excluded by user group.","q":"Are RFC and background users affected?"}],"features":[{"code":"background","label":"Runs as a background job","note":""},{"code":"test_run","label":"Test mode (check without posting)","note":""},{"code":"log","label":"Line-by-line result and error log","note":""},{"code":"email","label":"Send the result by email","note":"Users receive a warning and the security team receives a run summary."},{"code":"alv","label":"ALV list (sort, filter, subtotals)","note":""}],"functions":[{"name":"BAPI_USER_LOCK","role":"Locks a user above the threshold with an administrator lock"},{"name":"BAPI_USER_CHANGE","role":"Optionally sets the validity end (GLTGB) to today"},{"name":"SO_NEW_DOCUMENT_ATT_SEND_API1","role":"Sends the warning to the user and the summary to the security team"}],"gap":"SU10 can lock users in bulk, but someone has to choose who gets locked; there is no automatic selection by last logon, no warning email in advance and no exclusion list. Logon rules set through profile parameters only govern password and logon behavior; they do not lock inactive users in an audit-friendly way. The audit question \"are users inactive for 90 days locked?\" is therefore answered manually in most companies.","id":"basis-inactive-user-auto-lock-job","industries":[],"input_columns":[],"kind":"program","language":"en","lastmod":"2026-11-17","logic":"1. Dialog users (USTYP = A) in the selection are read from USR02; locked users (UFLAG ≠ 0), excluded user groups (CLASS) and the exclusion list of users are skipped.\n2. Inactive days = today − last logon date (TRDAT); for users who never logged on, the creation date (ERDAT) is used with a separate threshold.\n3. Warning stage: users whose inactive days reach the lock threshold minus the warning days receive an information email at the address from USR21 and ADR6, sent with SO_NEW_DOCUMENT_ATT_SEND_API1.\n4. Lock stage: for users above the threshold, BAPI_USER_LOCK is called (administrator lock). With \"Set validity end\" selected, LOGONDATA-GLTGB is set to today through BAPI_USER_CHANGE. The program never touches passwords or password fields.\n5. In test mode no BAPI is called and no email is sent; only the candidate list is produced.\n6. The result per user is written to the application log; a summary of locked and warned users is emailed to the security team.","module":"BASIS","object_type":"batch_job","output_columns":[{"calculated":false,"formula":"","label":"User","source_field":"BNAME","source_table":"USR02"},{"calculated":false,"formula":"","label":"User group","source_field":"CLASS","source_table":"USR02"},{"calculated":false,"formula":"","label":"Last logon","source_field":"TRDAT","source_table":"USR02"},{"calculated":true,"formula":"Today − USR02-TRDAT (no logon: − USR02-ERDAT)","label":"Inactive days","source_field":null,"source_table":null},{"calculated":false,"formula":"","label":"Email","source_field":"SMTP_ADDR","source_table":"ADR6"},{"calculated":true,"formula":"Number of valid AGR_USERS entries","label":"Roles","source_field":null,"source_table":null},{"calculated":true,"formula":"Warned, locked, skipped (exclusion) or test","label":"Action","source_field":null,"source_table":null},{"calculated":true,"formula":"BAPI return message or email send result","label":"Message","source_field":null,"source_table":null}],"parameters":[{"example":"* hariç FIREFIGHTER*","kind":"select_option","label":"User (including exclusions)","name":"S_UNAME","ref_field":"USR02-BNAME","required":false},{"example":"≠ SUPER, EMERG","kind":"select_option","label":"User group (exclude: technical, emergency)","name":"S_CLASS","ref_field":"USR02-CLASS","required":false},{"example":"A","kind":"select_option","label":"User type","name":"S_USTYP","ref_field":"USR02-USTYP","required":false},{"example":"90","kind":"parameter","label":"Lock threshold (days)","name":"P_DAYS","ref_field":"","required":true},{"example":"30","kind":"parameter","label":"Threshold for users who never logged on (days)","name":"P_NEVER","ref_field":"","required":false},{"example":"7","kind":"parameter","label":"Warning before lock (days)","name":"P_WARN","ref_field":"","required":false},{"example":"","kind":"checkbox","label":"Set validity end to today","name":"P_VALID","ref_field":"","required":false},{"example":"sap-guvenlik@ornek.com.tr","kind":"parameter","label":"Summary email recipient","name":"P_MAIL","ref_field":"","required":false},{"example":"X","kind":"checkbox","label":"Test mode (list without locking)","name":"P_TEST","ref_field":"","required":false}],"part_of":[],"performance":"Run the program every night as a background job. Even with several thousand users the USR02 read is fast; send the emails in one batch at the end of the run rather than one by one.","quote_url":"https://nekuhub.com/en/request-a-quote/?report=basis-inactive-user-auto-lock-job","related":["basis-sod-conflicts-by-user","basis-user-license-type-last-logon"],"releases":[],"source":"custom","standard_alternatives":[{"note":"Locks users in bulk; no automatic selection by inactivity, no warning email and no exclusion list.","tcode":"SU10"},{"note":"Lists inactive users; it does not lock them.","tcode":"SUIM"}],"summary":"A custom background program that first warns dialog users who have not logged on for a given period by email, locks them with an administrator lock when the period is over and optionally sets their validity end to today. Emergency and technical users are excluded, and the result of each run is sent to the security team as a summary.","tables":[{"access":"write","join_on":"","role":"User type, group, last logon and lock status; lock and validity are written through the BAPIs","table":"USR02","variant":"both"},{"access":"read","join_on":"USR21-BNAME = USR02-BNAME","role":"Person and address number of the user","table":"USR21","variant":"both"},{"access":"read","join_on":"ADR6-ADDRNUMBER = USR21-ADDRNUMBER AND ADR6-PERSNUMBER = USR21-PERSNUMBER","role":"Email address of the user for the warning","table":"ADR6","variant":"both"},{"access":"read","join_on":"AGR_USERS-UNAME = USR02-BNAME","role":"Number of roles of the locked user (for the summary email)","table":"AGR_USERS","variant":"both"}],"title":"Automatic Lock of Inactive Users Program","url":"https://nekuhub.com/en/programs/automatic-inactive-user-lock-program/","vendor_id":"nekudos"}