Вы находитесь на странице: 1из 12

LSMW Mass User Creation

LSMW stands for Legacy System Migration WorkBench. Originally it was a tool supplied by SAP to migrate data from a legacy system to SAP. owe!er" as we will see in this article" it can be used to upload almost any data into SAP. #n the present case" we will be creating a lsmw script to create a bunch of user ids" a $ob which is common for any security administrator. Since lsmw is based on sap B%& 'batch(data(communication sessions) we would ha!e to first create a recording to store the entire se*uence of actions in!ol!ed in creating a user" read the user data for a set of users from a data file and use the read data to create a session for user creation. At the final step we would run the session to actually create the users. +hough # ha!e taken the e,ample of user creation" by no means should it be assumed that this is the only application of lsmw in security. As long as you can create a recording for a se*uence of repetiti!e actions" lsmw can step in and lighten your load. +o start LSMW we use the transaction -lsmw.. We start create a pro$ect" subpro$ect and ob$ect as shown below.

lsmw ( create pro$ect Once the pro$ect is created we are greeted with the lsmw main screen showing a set of actions needed to create the complete script. %epending on the nature of the script and the data all or some of these option need to be updated.

lsmw ( main screen Step / 0 We start by maintain the ob$ect attributes. +he most important attribute which needs to be specified is the name of the recording which will be used to create the B%& session. A recording is basically a set of actions that the script will replicate during e,ecuting. We can create a recording from following the menu options in the same screen. #n the present case" we create a recoding for the S12/ transaction and fill up the !arious input fields needed to create a user.

lsmw ( maintain ob$ect attributes Step 3 0 We create a source structure to store the data needed for the script. +his will store the user attributes needed by the script.

lsmw ( display source structure Step 4 0 5e,t we maintain the data fields in the source structure. #n the present case" # ha!e only used the data fields 0 system id" last name" first name" department" email" user group and password. 5othing is really stopping you from using more or less fields. 5ote that unless all users use the same roles" it would be difficult to incorporate role addition into the same script.

lsmw ( source fields

Step 6 0 5e,t we maintain the structure relations. Since we defined only one structure in our script" we accept the default !alues suggested and click sa!e. +his single data structure is used as the data source for the recording that is used to create each user.

lsmw ( maintain structure Step 67 Maintain field mapping between the data structure and the fields used in the recording.

lsmw ( map structure fields Step 87 #n the ne,t screen we can define our own fi,ed !alues" translations or routines to be used in the script. #n the present script" these options are left unused.

lsmw ( con!ersion routines Step 97 #n the ne,t screen we define the path and format of the input files which would actually store the legacy data meant to be loaded by the script. We ha!e used a cs! file in the local machine as our data source.

lsmw ( specify input files Step :7 5e,t we assign the data from the file to any of the structures used in the script. +he present script uses a single file and a single data structure. So we $ust accept the default !alues suggested.

lsmw ( assign files Step ;7 5e,t we import the data from the source file

lsmw ( import data from file Step <7 On clicking e,ecute we get the ne,t screen displaying details about the data read. +he input file in our case had 44 records for creation of 44 users.

lsmw ( show details for import data Step /27 We can display the read data to !erify that input data has been correctly imported into the script.

lsmw ( display imported data Step //7 +he ne,t 3 steps are con!erting imported data and displaying the con!erted data for !erification. Since" we use imported data without change" these options remain unused for our script. =inally we generate the B%& session for our recording and using the imported data from the source file. Once the B%& session has been successfully generated we use the last screen option in lsmw or transaction SM48 to e,ecute the session. #f the recording is without errors and the data is correct" e,ecuting of the session will create the 44 users whose attributes were originally pro!ided in the source file.

lsmw ( generate B%& session LSMW is !ery similar to creating a recording through transaction S %B" generating an ABAP report for the recoding and modifying the generated code to read a source file and use the data to generate a B%& session. A seasoned ABAP de!eloper might prefer this method as custom code pro!ides a greater degree of fle,ibilty to answer complicated user re*uirements. owe!er" custom code in!ariably results in greater maintenance and testing effort. So finally which method you end up following will probably depend on your own special re*uirements.