You are on page 1of 11

Automate user creation using SAP GUI Scripting

Applies to:
Applies to All R/3 Versions Currently Supported by SAP Applies to SAP GUI 6.20 and future versions.

Summary
The Purpose of this document is to provide the Security Administrator with guidance on preparing for the SAP Mass Users Creation with Roles using SAP GUI Script tools provided by the SAP. This will also consumes the time and reduce the manual efforts. Author: Venkata Gadi & Raghu Boddu Created on: 20.Nov.2011 Author Bio: Venkata Gadi is a SAP Basis and Security consultant, working with Tata Consultancy services, having extensive experience in SAP Basis & Security and GRC components. Raghu has excellent command over SAP R/3, BI, HR, and GRC. He is good known to the community for easy to understand articles. He has authored 30+ articles for Microsoft knowledgebase and also an xMVP in Windows shell area (2005-2008). He also bagged the SAP SDN Community Contributor award for 2008. His exclusive documents, FAQs, and recommendation papers are available in his blog.

Table of Contents

Table of Contents .............................................................................................................................................................. 2 Introduction: ...................................................................................................................................................................... 3 How to automate user creation with SAP GUI Script........................................................................................................ 3 Script Recording and Playback: ........................................................................................................................................ 3 Recording your script: ....................................................................................................................................................... 4 Preparing for the Recording ......................................................................................................................................... 4

Recording the transaction code ................................................................................................................................... 4 Modifying the script: ....................................................................................................................................................... 5 How to play script after the changes: .......................................................................................................................... 8 Script Development tools .............................................................................................................................................. 8
Enable GUI Scripting: ....................................................................................................................................................... 9 Further references: 10 Community Disclaimer .................................................................................................................................................... 11

Introduction:
SAP GUI Scripting is an automation interface which is available in SAP. It enhances the capabilities of SAP GUI. Using this interface, end users may automate repetitive tasks by recording and running macro-like scripts. It is shipped with SAP GUI 6.20 and later versions and compatible with all R3 versions currently supported by SAP and applications built on top of WEB AS 6.10 to 6.40 Non -Dynpro based applications (BSP, Web Dynpro) are not supported. See SAP note 58702 for known limitations.

How to automate user creation with SAP GUI Script


Script Recording and Playback:
This will allow recording the activities in SAP and playback again to repetitive the same tasks. Below are the steps: 1. Click Customize Local Layout button in the SAP Easy Access window

2. Select Script Recording and Playback option

NOTE: If the Script Recording and Playback option is grayed out as shown above, follow the steps mentioned in the Enable GUI Scripting section 3. Select Play button in the Record and Playback screen

Recording your script:


Preparing for the Recording
1. 2. Go to customize local layout and select Script Recording and Playback Go to button more

3. 4. 5.

Save your file. to start recording your script Press the Record button Execute the steps to start recording

Recording the transaction code


1. Enter transaction code SU01

2. Enter the Username and click Create 3. Enter all the required fields (Last name is mandatory by default in SAP). 4. Goto Logon Data tab and provide password and usergroup details. Note: These details will be encrypted and you need to modify the script once recording is done. SAP GUI scripting will not record the passwords. 5. Goto Roles tab and assign the required roles. 6. Update any additional fields that are required, and Save the user.

7. Click the Stop Recording button

Modifying the script:


Now the recorded script should be modified. Open the File that was saved earlier. After Recording SAP GUI Script Code Looks Like Below.

To make feasible you need to insert some basic VB commands to extract the data from Excel or note pad.

1: Insert below script1 to take values from Excel you have after

2: Insert below script2 after

To take values from row in excel

3: Replace this script line already available Replaced code:

4 : Replace the below script line already available after recording.

Replaced code:

Note: Password will be encrypted like as below after initial recording of the script, please change them to display as below Before:

After Replaced with welcome:

5. Insert Loop after the last line of the code.

Final Script after changes looks like below and you are ready to create n number of users in SAP with Recording and play back option.

Refer Script in Point 1 above


C:\Gadi\BOOK1.xls refers Excel path

Refer Script in Point 2 & 3 above

Refer Script in Point 4 above Refer Note Above

Refer Script in Point 5

Save it and play now.

How to play script after the changes:


1. Select options script recording and play back

2. Click on

Play button and select the file you saved in Recording your script (ref point 2)

Script Development tools


The script development tools will help you to troubleshoot scripting issues. To use the script development tools, click the Local Layout button -

in the SAP Easy Access window

Enable GUI Scripting:


To enable GUI Scripting, follow the steps mentioned below: 1. Click the Customize Local Layout Icon. 2. Click Options

3. Enable the scripting options as shown below:

If the scripting option still doesnt work, ensure that the parameters in the profile parameters are activated. Follow the below mentioned steps: 1. Goto RZ10 transaction code. 2. Select Default profile from the Possible entries list of Profile. 3. Select Extended Maintenance option and click Change. 4. Set the parameter value to True for parameter sapgui/user_scripting (The parameter can be added with the value, incase if it doesnt exist)

5. Add parameter sapgui/user_scripting_per_user with value True 5. Save and activate.

Adding the parameter sapgui/user_scripting_per_user with value True, will do an authorization check and will allow only the users who has authorization to the authorization object S_SCR with activity 16 (Execute).

Further references:
SAP Note 983990 - SAP GUI Scripting security: Enable Scripting per system user SAP Note 480149 - New profile parameter for user scripting at the front end SAP Note 1098286 - Authorization check for user scripting SAP Note 692245 - Additional server based security options for Scripting SAP Wikis and Documents

Community Disclaimer
Important note: sapsecurityexpert.com grants free access to the content posted. However, if you are redistributing, we recommend not removing the author names. Statements and opinions expressed in articles, reviews and other materials herein are those of the authors. While every care has been taken in the compilation of this information and every attempt made to present up-todate and accurate information, we cannot guarantee that inaccuracies will not occur. sapsecurityexpert.com will not be held responsible for any claim, loss, damage or inconvenience caused as a result of any information within these pages or any information accessed through this site. No responsibility is assumed by sapsecurityexpert.com for the contents of these pages. All the images (SAP screens and descriptive images) are copyrighted by SAP AG, and the other images are copyrighted by the respective companies. sapsecurityexpert.com thanks them for allowing third party web sites to include their respective copyright images. For completed Disclaimer, refer the Disclaimer page @ www.sapsecurityexpert.com

sapsecurityexpert.com support Go Green and encourage the readers to read this document only online. Print access has been revoked on this document. Authors Disclaimer
Some part of this article is referenced from SAP Help and Wiki documents. We have presented this document as a complete reference document for using SAP GUI scripting for user creation since there is no such documentation available. We hereby acknowledge the credit for the extracted content to the real authors and we thank them for providing such an useful information to the community.

You might also like