Execute this SQL command
  • update SID.USR02 set UFLAG=64 where MANDT='110' and BNAME != 'SAP*';    
  • Explain : UFLAG=64 means lock
  • BNAME !='SAP*' means lock everyone except SAP*

Alternately, try the below SQL command:

use HRS
UPDATE [hrs].[USR02]
SET UFLAG = '64'
WHERE (UFLAG = '0') 
AND NOT (BNAME like 'SAP%' OR BNAME = 'DDIC' OR BNAME = 'TMSADM' 
         OR BNAME like 'J2EE%' OR BNAME like 'SLD%' OR BNAME = 'JCO_DATA'
         OR BNAME = 'BASIS_ADMIN')