<p>Here is a trick. Some time ago I found how to load hierarchical structures in <a href="http://saphcmsolutions.com/advanced-lsmw/">LSMW</a> from one file. We need to create a file in a special way so that structure record is repeated. These files are hard to create in legacy system particularly when there are no local developers who support the system. That&#8217;s why we prefer to work with flat simple files where one file is a single table. But, let me show you how to load multiple files in SAP LSMW tool with ease.</p>
<p>Couple days ago I was loading payroll wage types into SAP with a standard BUS7023 ManagerExtPayroll object. In the output, there is an IDOC which is stored in T558* tables for payroll migration. IDOC structure is a hierarchy itself, where on the top there is an employee, periods are below, and wage types are on the bottom line.</p>
<h2>Loading multiple files in SAP LSMW</h2>
<p>To simplify I decided to create three files:</p>
<ul>
<li>Employees</li>
<li>Periods</li>
<li>Wage types</li>
</ul>
<p>Every other file contains a reference to the previous one. Look what I&#8217;ve got.</p>
<p><a href="http://saphr.ru/wp-content/uploads/lsmw_py_0.png"><img class="alignnone size-full wp-image-1977" src="http://saphr.ru/wp-content/uploads/lsmw_py_0.png" alt="lsmw_py_0" width="614" height="502" /></a></p>
<p><!--more--></p>
<p>Let&#8217;s define LSMW source structures which are related to each other in a file hierarchy. This hierarchy represents our data files we want to load at once.</p>
<p><a href="http://saphr.ru/wp-content/uploads/lsmw_py_1.png"><img class="alignnone size-full wp-image-1978" src="http://saphr.ru/wp-content/uploads/lsmw_py_1.png" alt="lsmw_py_1" width="502" height="243" /></a></p>
<p>Then we need to create source fields for our LSMW source structures.</p>
<p><a href="http://saphr.ru/wp-content/uploads/lsmw_py_2.png"><img class="alignnone size-full wp-image-1979" src="http://saphr.ru/wp-content/uploads/lsmw_py_2.png" alt="lsmw_py_2" width="807" height="479" /></a></p>
<p>Remember, our relations in this scenario are one to one. One file from our multiple file list connects to one source structure.</p>
<p><a href="http://saphr.ru/wp-content/uploads/lsmw_py_3.png"><img class="alignnone size-full wp-image-1980" src="http://saphr.ru/wp-content/uploads/lsmw_py_3.png" alt="lsmw_py_3" width="923" height="216" /></a></p>
<p>Finally, we need to do the field-based mapping connecting the source and destination fields per data file.</p>
<p> ;</p>
<p> ;</p>
<p><a href="http://saphr.ru/wp-content/uploads/lsmw_py_4.png"><img class="alignnone size-full wp-image-1981" src="http://saphr.ru/wp-content/uploads/lsmw_py_4.png" alt="lsmw_py_4" width="841" height="683" /></a></p>
<p>Define the file location for every logical file.</p>
<p><a href="http://saphr.ru/wp-content/uploads/lsmw_py_5.png"><img class="alignnone size-full wp-image-1982" src="http://saphr.ru/wp-content/uploads/lsmw_py_5.png" alt="lsmw_py_5" width="776" height="648" /></a></p>
<p>And connect source structures to logical files. We&#8217;re done with setting LSMW project to load multiple files in one batch.</p>
<p><a href="http://saphr.ru/wp-content/uploads/lsmw_py_6.png"><img class="alignnone size-full wp-image-1983" src="http://saphr.ru/wp-content/uploads/lsmw_py_6.png" alt="lsmw_py_6" width="536" height="291" /></a></p>