<h2><a name="_Toc515533081"></a>Basics</h2>
<p>LSMW is a standard SAP tool to do any kind of mass data changes. It has a number of ways how to update the data in the system:</p>
<ul>
<li>BAPI</li>
<li>IDOC</li>
<li>Batch Recording</li>
<li>Direct Input</li>
</ul>
<p>BAPI is the fastest way, but there is a limited number of BAPIs available to the customer.</p>
<p>In 99% cases, we use Batch Recording which works like macros in MS Excel/Word. The system follows user’s steps, recording screen by screen. Once done we map data file to these screens and data fields. Than system repeats the same steps like the user would be doing manually.</p>
<h2><a name="_Toc515533082"></a>Organizing LSMW projects</h2>
<p>In LSMW transaction we have projects, subprojects, and objects.</p>
<p><a href="https://saphcmsolutions.com/wp-content/uploads/2018/12/t_lsmw_1.png"><img class="alignnone size-full wp-image-1275" src="https://saphcmsolutions.com/wp-content/uploads/2018/12/t_lsmw_1.png" alt="" width="587" height="210" /></a></p>
<p>Ideally, there should be one global project for routine updates, one for data migration.</p>
<p>The subproject is something meaningful, like OM, PA, PT, and PY for different HR areas. Or it could be one subproject for all infotypes, no matter.</p>
<p>An object usually represents what’s being changed: infotype, table or something else.</p>
<p>To start we need to create all three entities: project, subproject, object or choose them if they are already created.</p>
<p><a href="https://saphcmsolutions.com/wp-content/uploads/2018/12/t_lsmw_2.png"><img class="alignnone size-full wp-image-1276" src="https://saphcmsolutions.com/wp-content/uploads/2018/12/t_lsmw_2.png" alt="" width="596" height="212" /></a></p>
<p>Here is the main LSMW window. Steps “Define Object Attributes” to “Assign Files” are settings, other for execution for the end-user.</p>
<p><a href="https://saphcmsolutions.com/wp-content/uploads/2018/12/t_lsmw_3.png"><img class="alignnone size-full wp-image-1277" src="https://saphcmsolutions.com/wp-content/uploads/2018/12/t_lsmw_3.png" alt="" width="890" height="531" /></a></p>
<p><!--more--></p>
<h2><a name="_Toc515533083"></a>LSMW customizing steps</h2>
<p>All steps should proceed one by one in the same order like on the screen.</p>
<h3><a name="_Toc515533084"></a>Define Object Attributes</h3>
<p><a href="https://saphcmsolutions.com/wp-content/uploads/2018/12/t_lsmw_4.png"><img class="alignnone size-full wp-image-1278" src="https://saphcmsolutions.com/wp-content/uploads/2018/12/t_lsmw_4.png" alt="" width="571" height="639" /></a></p>
<p>Here we set the way how we want to load the data into the system. Again, for 99% it is ‘Batch Input Recording’. Usually, we create a new recording for each new mass changes. To create a new recording click on ‘Recordings: Overview’ button to the right.</p>
<p><a href="https://saphcmsolutions.com/wp-content/uploads/2018/12/t_lsmw_5.png"><img class="alignnone size-full wp-image-1279" src="https://saphcmsolutions.com/wp-content/uploads/2018/12/t_lsmw_5.png" alt="" width="665" height="368" /></a></p>
<p>Before we start recording we need to make sure we have all the data for all fields handy. When we record user activities system records all steps. If we click on the list to choose a value for some field it will also be recorded. We don’t want the system to record these screens with help values.</p>
<p>Click Create. It’s a good practice to give prefix for recordings like here R stands for Recording.</p>
<p><a href="https://saphcmsolutions.com/wp-content/uploads/2018/12/t_lsmw_6.png"><img class="alignnone size-full wp-image-1280" src="https://saphcmsolutions.com/wp-content/uploads/2018/12/t_lsmw_6.png" alt="" width="597" height="145" /></a></p>
<p>For OM module (infotypes 1000 – 1999) we PP02 transaction.</p>
<p><a href="https://saphcmsolutions.com/wp-content/uploads/2018/12/t_lsmw_7.png"><img class="alignnone size-full wp-image-1281" src="https://saphcmsolutions.com/wp-content/uploads/2018/12/t_lsmw_7.png" alt="" width="381" height="124" /></a></p>
<p>Pay attention we enter all data without using any help values or lists.</p>
<p><a href="https://saphcmsolutions.com/wp-content/uploads/2018/12/t_lsmw_8.png"><img class="alignnone size-full wp-image-1282" src="https://saphcmsolutions.com/wp-content/uploads/2018/12/t_lsmw_8.png" alt="" width="534" height="387" /></a></p>
<p>Click Create.</p>
<p><a href="https://saphcmsolutions.com/wp-content/uploads/2018/12/t_lsmw_9.png"><img class="alignnone size-full wp-image-1283" src="https://saphcmsolutions.com/wp-content/uploads/2018/12/t_lsmw_9.png" alt="" width="607" height="252" /></a></p>
<p>Click Save. Then exit transaction.</p>
<p>The system brings us back to the recording. Click ‘Default All’ button to fill field names automatically. We will use these names in mapping rules.</p>
<p><a href="https://saphcmsolutions.com/wp-content/uploads/2018/12/t_lsmw_10.png"><img class="alignnone size-full wp-image-1284" src="https://saphcmsolutions.com/wp-content/uploads/2018/12/t_lsmw_10.png" alt="" width="898" height="709" /></a></p>
<p>Save and go back to the main screen with ‘Change Object Attributes’. Select our recording from the list.</p>
<p><a href="https://saphcmsolutions.com/wp-content/uploads/2018/12/t_lsmw_11.png"><img class="alignnone size-full wp-image-1285" src="https://saphcmsolutions.com/wp-content/uploads/2018/12/t_lsmw_11.png" alt="" width="565" height="411" /></a></p>
<p>Save and go back to the main menu.</p>
<p> ;</p>
<h3><a name="_Toc515533085"></a>Define Source Structures</h3>
<p>Source structure reflects data from a file. If we have a hierarchy in a file or have several files to load at once, we create on structure per each data entity or file. It’s a good practice to use a prefix in naming, like here ZS – Z stands for customer object, S – structure.</p>
<p><a href="https://saphcmsolutions.com/wp-content/uploads/2018/12/t_lsmw_12.png"><img class="alignnone size-full wp-image-1286" src="https://saphcmsolutions.com/wp-content/uploads/2018/12/t_lsmw_12.png" alt="" width="656" height="299" /></a></p>
<p>Save and go back.</p>
<h3><a name="_Toc515533086"></a>Define Source Fields</h3>
<p>Source fields created for each structure. It’s a good practice to</p>
<ul>
<li>Keep the real file fields order the same in the source structure</li>
<li>Use SAP dictionary names in structure</li>
</ul>
<p><a href="https://saphcmsolutions.com/wp-content/uploads/2018/12/t_lsmw_13.png"><img class="alignnone size-full wp-image-1288" src="https://saphcmsolutions.com/wp-content/uploads/2018/12/t_lsmw_13.png" alt="" width="728" height="172" /></a></p>
<p>Choose structure and click on table icon. It’s more convenient to enter all fields on one screen.</p>
<p>Enter all fields you want to load from file. If you have fields with constant values they can be omitted and defined on later steps as constants.</p>
<p><a href="https://saphcmsolutions.com/wp-content/uploads/2018/12/t_lsmw_14.png"><img class="alignnone size-full wp-image-1289" src="https://saphcmsolutions.com/wp-content/uploads/2018/12/t_lsmw_14.png" alt="" width="646" height="209" /></a></p>
<p>Save and return to the main menu.</p>
<h3><a name="_Toc515533087"></a>Define Structure Relations</h3>
<p>Here we need to define relations between our recordings and structures. If it’s one recording and structure system proposes relation. All we need is to save and return.</p>
<p><a href="https://saphcmsolutions.com/wp-content/uploads/2018/12/t_lsmw_15.png"><img class="alignnone size-full wp-image-1290" src="https://saphcmsolutions.com/wp-content/uploads/2018/12/t_lsmw_15.png" alt="" width="831" height="179" /></a></p>
<h3><a name="_Toc515533088"></a>Define Field Mapping and Conversion Rules</h3>
<p>This is the most complicated step. Here we define how our data from a file (source structure) maps to recording fields. On the screen, we see all recorded fields from the first step. For each field, we need to assign some value. There are some options:</p>
<table>
<tbody>
<tr>
<td width="204"><strong>Button in toolbar</strong></td>
<td width="420"><strong>Meaning</strong></td>
</tr>
<tr>
<td width="204">Source field</td>
<td width="420">Takes data from the file (source structure)</td>
</tr>
<tr>
<td width="204">Rule</td>
<td width="420">Converts data with some predefined conversion rules or custom ABAP code</td>
</tr>
<tr>
<td width="204">Initial</td>
<td width="420">Leave value as is from the infotype logic</td>
</tr>
<tr>
<td width="204">Constant</td>
<td width="420">Constant value</td>
</tr>
<tr>
<td width="204">Move</td>
<td width="420">Copy a field or part of it</td>
</tr>
<tr>
<td width="204">Fixed value</td>
<td width="420">Fixed value from some predefined list</td>
</tr>
<tr>
<td width="204">Translation</td>
<td width="420">Conversion through mapping “if this value, choose that value”</td>
</tr>
</tbody>
</table>
<h3><a href="https://saphcmsolutions.com/wp-content/uploads/2018/12/t_lsmw_16.png"><img class="alignnone size-full wp-image-1291" src="https://saphcmsolutions.com/wp-content/uploads/2018/12/t_lsmw_16.png" alt="" width="789" height="726" /></a></h3>
<h3><a name="_Toc515533089"></a>Define Fixed Values, Translations, User-Defined Routines</h3>
<p>Here we can define fixed values, translations or ABAP procedures which are used in the previous step. For simple tasks in 99%, this is not needed.</p>
<h3><a name="_Toc515533090"></a>Specify Files</h3>
<p>Here we create a file reference.</p>
<p><a href="https://saphcmsolutions.com/wp-content/uploads/2018/12/t_lsmw_17.png"><img class="alignnone size-full wp-image-1292" src="https://saphcmsolutions.com/wp-content/uploads/2018/12/t_lsmw_17.png" alt="" width="1138" height="731" /></a></p>
<p>Click on Legacy Data on the PC and click Create. It means the file will be downloaded from your PC, not SAP server.</p>
<p>File – full path to file.</p>
<p>Name – technical name. Use prefix, like ZF.</p>
<p>Depending on file choose correct delimiter.</p>
<p>It’s a good practice to have field names in the very first row in the file and follow the order from the source structure. So, tick both check boxes under ‘File Structure’ frame.</p>
<p>The file would look like this.</p>
<p><a href="https://saphcmsolutions.com/wp-content/uploads/2018/12/t_lsmw_18.png"><img class="alignnone size-full wp-image-1293" src="https://saphcmsolutions.com/wp-content/uploads/2018/12/t_lsmw_18.png" alt="" width="708" height="110" /></a></p>
<p>Save and exit.</p>
<h3><a name="_Toc515533091"></a>Assign Files</h3>
<p>Here we assign file reference to the source structure. Usually, it’s one file to one structure.</p>
<p><a href="https://saphcmsolutions.com/wp-content/uploads/2018/12/t_lsmw_19.png"><img class="alignnone size-full wp-image-1294" src="https://saphcmsolutions.com/wp-content/uploads/2018/12/t_lsmw_19.png" alt="" width="436" height="189" /></a></p>
<p>Save and exit.</p>
<h3><a name="_Toc515533092"></a>Read Data</h3>
<p>Here the system reads the file and converts to internal format on the server.</p>
<p><a href="https://saphcmsolutions.com/wp-content/uploads/2018/12/t_lsmw_20.png"><img class="alignnone size-full wp-image-1295" src="https://saphcmsolutions.com/wp-content/uploads/2018/12/t_lsmw_20.png" alt="" width="566" height="187" /></a></p>
<p>If the file is large and we want to test our LSMW project, delimit a number of records to read and process.</p>
<p><a href="https://saphcmsolutions.com/wp-content/uploads/2018/12/t_lsmw_21.png"><img class="alignnone size-full wp-image-1296" src="https://saphcmsolutions.com/wp-content/uploads/2018/12/t_lsmw_21.png" alt="" width="889" height="500" /></a></p>
<h3><a name="_Toc515533093"></a>Display Read Data</h3>
<p>Here we can double check ourselves if the file was organized correct and data placed into right fields.</p>
<p><a href="https://saphcmsolutions.com/wp-content/uploads/2018/12/t_lsmw_22.png"><img class="alignnone size-full wp-image-1297" src="https://saphcmsolutions.com/wp-content/uploads/2018/12/t_lsmw_22.png" alt="" width="655" height="185" /></a></p>
<p>If you click on the data record, it shows record content parsed into source structure.</p>
<p><a href="https://saphcmsolutions.com/wp-content/uploads/2018/12/t_lsmw_23.png"><img class="alignnone size-full wp-image-1298" src="https://saphcmsolutions.com/wp-content/uploads/2018/12/t_lsmw_23.png" alt="" width="372" height="220" /></a></p>
<h3><a name="_Toc515533094"></a>Convert Data</h3>
<p>The system converts data from the source structure to the recording structure including all kind of mapping we’ve done on ‘Define Field Mapping and Conversion Rules’ step.</p>
<p><a href="https://saphcmsolutions.com/wp-content/uploads/2018/12/t_lsmw_24.png"><img class="alignnone size-full wp-image-1299" src="https://saphcmsolutions.com/wp-content/uploads/2018/12/t_lsmw_24.png" alt="" width="903" height="423" /></a></p>
<h3><a name="_Toc515533095"></a>Display Converted Data</h3>
<p>The same as display read data step but shows already converted data. This data will be entered during simulation (batch input).</p>
<p><a href="https://saphcmsolutions.com/wp-content/uploads/2018/12/t_lsmw_25.png"><img class="alignnone size-full wp-image-1300" src="https://saphcmsolutions.com/wp-content/uploads/2018/12/t_lsmw_25.png" alt="" width="377" height="359" /></a></p>
<h3><a name="_Toc515533096"></a>Create Batch Input Session</h3>
<p><a href="https://saphcmsolutions.com/wp-content/uploads/2018/12/t_lsmw_26.png"><img class="alignnone size-full wp-image-1301" src="https://saphcmsolutions.com/wp-content/uploads/2018/12/t_lsmw_26.png" alt="" width="589" height="207" /></a></p>
<p>If you want to keep all recordings for your records, tick ‘Keep batch input folders’. Otherwise, the system deletes all successful recordings. Only failed will remain in the system until they are processed.</p>
<h3><a name="_Toc515533097"></a>Run Batch Input Session</h3>
<p>SAP opens a SM35 transaction with Batch Input sessions.</p>
<p><a href="https://saphcmsolutions.com/wp-content/uploads/2018/12/t_lsmw_27.png"><img class="alignnone size-full wp-image-1302" src="https://saphcmsolutions.com/wp-content/uploads/2018/12/t_lsmw_27.png" alt="" width="1029" height="259" /></a></p>
<p>Select the recording and click ‘Process’.</p>
<p><a href="https://saphcmsolutions.com/wp-content/uploads/2018/12/t_lsmw_28.png"><img class="alignnone size-full wp-image-1303" src="https://saphcmsolutions.com/wp-content/uploads/2018/12/t_lsmw_28.png" alt="" width="491" height="255" /></a></p>
<p>For 1 record to test it’s recommended to use ‘Process/foreground’ as the system shows every step on the screen with the data filled in.</p>
<p>Display error only is to run the process in the foreground and stop only on errors, so that user could react somehow.</p>
<p>In case of a large volume, it’s better to run in the background. It’s the fastest way.</p>
<p>If the record was not processed it would show errors in the log.</p>
<p><a href="https://saphcmsolutions.com/wp-content/uploads/2018/12/t_lsmw_29.png"><img class="alignnone size-full wp-image-1304" src="https://saphcmsolutions.com/wp-content/uploads/2018/12/t_lsmw_29.png" alt="" width="794" height="236" /></a></p>
<p>If we double-click on the recording there is a tab with a log. Once errors fixed (most common the employee or OM object is locked by another user) you can restart recording process. It will run ONLY for incorrect records.</p>
<p>Once all errors are fixed and recording is processed it will disappear from the list.</p>
<p>It means no more error occurred and we can verify the data.</p>
<p><a href="https://saphcmsolutions.com/wp-content/uploads/2018/12/t_lsmw_30.png"><img class="alignnone size-full wp-image-1305" src="https://saphcmsolutions.com/wp-content/uploads/2018/12/t_lsmw_30.png" alt="" width="887" height="273" /></a></p>
<h2><a name="_Toc515533098"></a>Business scenario specific details</h2>
<p>There are some scenario specific recommendations.</p>
<h3><a name="_Toc515533099"></a>Flat PA infotypes (like 0, 1, 2, etc.)</h3>
<p>It’s the same like was explained above. To upload these infotypes use PA30 transaction.</p>
<h3><a name="_Toc515533100"></a>Table PA infotypes (8, 27)</h3>
<p>These infotypes have tables, so the loading is a little different. Before loading we need to ensure we know max number of rows in the uploading data. If, let’s say, there are max 3 rows (one per wage type or cost center), than in our recording we need to fill three rows, so the system would provide three fields for wage types, rates, etc. If we fill only the first row, we’ll have just one field, and records with 2-3 rows will be skipped.</p>
<h3><a name="_Toc515533101"></a>PA Actions (PA40)</h3>
<p>You need to make sure there is no actions in PA40 transaction which need you to scroll the screen. If so you need to change user group parameter in SU3 to UGR = 10 to show only US actions. If this is completely impossible, actions could be loaded in PA30 in infotype 0000.</p>
<h3><a name="_Toc515533102"></a>System tables update (like T510, T710 for rates increase)</h3>
<p>When saving data in these system tables it asks for a transport request. Moreover it asks only the first time. So the transport request screen will appear during LSMW recording and not again. LSMW will try to find data for that screen and won’t find it throwing an error. To avoid this create couple entries manually, save them in the transport request. Then don’t exit the session, open LSMW, make a recording and data upload within one session. Systems stores transport request in the session memory and doesn’t ask for it until you exit. So all LSMW activities will be performed without requiring transport request as it was entered during first manual data entries.</p>
<h3><a name="_Toc515533103"></a>Flat OM infotype</h3>
<p>Proceed as described above.</p>
<h3><a name="_Toc515533104"></a>Table OM infotype</h3>
<p>Proceed as described in Table PA infotype section.</p>
<h2>Advanced techniques</h2>
<p><a href="https://saphcmsolutions.com/sap-lsmw-translation-rules/">SAP LSMW Translation Rules</a></p>
<p><a href="https://saphcmsolutions.com/advanced-lsmw/">Advanced LSMW use examples</a></p>
<p><a href="https://saphcmsolutions.com/lsmw-file-read-error-codes/">LSMW errors when you work with files</a></p>
<p><a href="https://saphcmsolutions.com/load-several-files-lsmw/">How to load multiple files in SAP LSMW</a></p>
<p><a href="https://saphcmsolutions.com/easy-way-to-mass-change-any-field-in-sap/">Easy way to mass change any field in SAP</a></p>
<p><a href="https://saphcmsolutions.com/how-to-run-any-functional-module-with-input-data-from-text-file/">How to run any functional module with input data from text file</a></p>
<p> ;</p>