Mass update the User Parameter Value

When you need to mass maintain the User parameters to another value. This program will come in handy as you do not need to maintain the parameters for each user manually.

*
* Mass Update User parameters collectively.
*
* Written by : SAP Basis, ABAP Programming and Other IMG Stuff
*              http://www.erpgreat.com
*
REPORT ZUSERPARAM.

PARAMETERS: P_PARID(3), "Parameter ID
P_PARVA(18),            "Parameter Value
P_USER(18).             "User Name

TABLES: USR02, USR05.

DATA BEGIN OF IUSR02 OCCURS 5.
       INCLUDE STRUCTURE USR02.
DATA END OF IUSR02.

ULINE.
WRITE: /, 'Report Selection criteria:'.
WRITE: /10 'Parameter ID:', P_PARID.
WRITE: /10 ' Parm Value:', P_PARVA.
WRITE: /10 'User Name:', P_USER.
ULINE.

SELECT * FROM USR02 INTO TABLE IUSR02 WHERE BNAME = P_USER.

LOOP AT IUSR02. "Loop thru all users
   SELECT SINGLE * FROM USR05
     WHERE BNAME = IUSR02-BNAME
     AND PARID = P_PARID.

IF SY-SUBRC = 0.
   UPDATE USR05
   SET PARVA = P_PARVA
     WHERE BNAME = IUSR02-BNAME
     AND PARID = P_PARID.

   IF SY-SUBRC = 0.
      WRITE: /5 USR05-BNAME, USR05-PARID, 'Old =', USR05-PARVA,
                'New =', P_PARVA.
   ELSE.
      WRITE: /5 'Update rc=', SY-SUBRC, USR05-BNAME.
      EXIT.
   ENDIF.
ELSE.
   CLEAR USR05.
   USR05-BNAME = IUSR02-BNAME.
   USR05-PARID = P_PARID.
   USR05-PARVA = P_PARVA.
   INSERT USR05.
   IF SY-SUBRC = 0.
      WRITE: /5 'Insert ok:', USR05-BNAME, P_PARID, P_PARVA.
   ELSE.
      WRITE: /5 'Bad Insert, rc=', SY-SUBRC, USR05-BNAME.
      EXIT.
   ENDIF.
ENDIF.
ENDLOOP.

*** The end of program

ABAP Tips

Related ABAP Topics:
Make the Value of one parameter depending on another
Value request for parameter

Get help for your ABAP problems
Do you have a ABAP Question?

ABAP Books
ABAP  Certification, Programming, BAPI, Java, SAPscripts, Smart Forms Reference Books

Best regards,
SAP Basis, ABAP Programming and Other IMG Stuff
http://www.erpgreat.com

All the site contents are Copyright © www.erpgreat.com and the content authors. All rights reserved.
All product names are trademarks of their respective companies.  The site www.erpgreat.com is in no way affiliated with SAP AG. 
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk. 
 The content on this site may not be reproduced or redistributed without the express written permission of 
www.erpgreat.com or the content authors.