📜 ⬆️ ⬇️

Downloading historical data to SAP using LSMW (Legacy System Migration Workbench)

When implementing an SAP ERP system, one of the most important issues is the issue of loading historical data systems (those that operated at the enterprise before SAP was introduced) into a new ERP. For this there is a powerful tool inside the SAP - the Data Transfer System from Historical Systems (LSMW). Over 8 years of working with SAP, I have gained considerable experience working with this system, and since LSMW does not have easy-to-understand manuals (especially in Russian) and I constantly get advice from my colleagues, having found me on the Russian SAP forum, I dare to believe that this article will be very informative both for interns and experienced consultants who have not yet had experience working with LSWM.

We start the LSMW transaction and, lo and behold, we are already welcomed: Welcome to the Legacy System Migration Workbench!

On the initial screen we see the following picture.
')
image

First of all, you need to create a project (Project). A project can be, for example, a top-level “project” (for example, with the name “PM” to work with it for the entire TORO group (Maintenance and repair of equipment)), or a more localized project, for example, the project for loading into the Technical Objects system (let's call his "Tech Objects"). I recommend not to produce entities, and, remembering Uncle Okam’s commandment, to start a top level as a project. This is very convenient for all project groups - in LSMW you can see your modules as a project.

Become a cursor in the Project field and click the white sheet. Create a project. In the case of my example, this will be “PM”.

Then create a subproject (Subproject). This is also just a structuring of your project, therefore, depending on the decision made on choosing a project, we also create a subproject accordingly. In the case of my example, the sub-project will be “Tech Objects”.

Well, the object (Object). Here we are detailing exactly what we are going to load into the system / change using LSMW. For example, I need to load the equipment units. In this case, I create the “PoE Upload” object.

image

We created a project, a subproject and an object, we launch it.

We see a screen with twenty steps
(in the menu item Edit we turn on Numering On so that a sequence number is displayed next to each step)

image

1) Step One - Maintain object attributes

At this step, we need to specify how we will load the data. I will dwell on the two methods that I most often use and are popular in principle.

A) Standard Object (Standart Batch / Direct Input)

LSMW provides a list of predefined objects, among which there is a high probability that you need one.

In my case, it is a piece of equipment.

image

In the Method field, select 0001 - Create PackVV (that is, “batch input”).

image

Save, exit.

B) Batch Input Recording

If you don’t have enough standard object, or for your needs there is no standard object in principle, in this case you need to write a “macro” (as I call it). That is, you call a transaction, the data of which you need to download, and write down the sequence of your actions, and then, in subsequent steps, match the recorded “macro” and create a structure for the download template file.

I will write out the Batch Input Recording method if there is time in a separate topic (this is a large separate topic) if the topic finds its reader.

2) Step Two - Maintain source structures

In this step, we need to determine the structure of our loadable data. In the case of Equipment Units, the structure will be single-level (“flat”), without subordinate substructures. The latter would be useful to us, say, in the case of loading Maintenance Orders, when there can be N operations for one Order header, each of which can have M components. A piece of equipment has a number and data set, without nesting.

If the structure is flat, then this step is a formality. Create a structure, for example, “Main”. Save, exit.

image

3) Step Three - Maintain source fields

In step 3, we define the fields that we plan to load. Position the cursor on our Main structure, click the white sheet icon and create the fields.

Fields are the fields that you are going to load for your object. In my case, I want, say, for a piece of equipment to ship:

- EO number
- name EO
- type of object

This is naturally an example. You can load any fields. For the sake of brevity, I shall confine myself to these three.

So that in the future, in step 5, you don’t bother with comparing your invented field names with system fields, or just for clarity, I suggest you name the fields as they are called in the system. To find out what this or that field is called, what type and what bitness they are, we become the cursor on this field and press “F1”.

image

In the window that appears, fail by double-click (drill down) in the entry "Field Name"

image

Among the fields we find the one we are interested in (in this case, “Equipment number” is the EQNR field), its type (CHAR) and length (18 characters). And, accordingly, we prescribe this data in the field created at the third step.

image
image

We created a set of interesting fields as loadable fields, save, exit.

4) Step Four - Maintain structure relations

In this step, we need to associate our structures with standard ones. In the case of my simple, flat structure, everything is very simple: we position the cursor on IBIP: Equipment Unit, click the white leaf. Our only Main structure is tied to the standard EO structure by an automatic machine. Save, exit.

image

5) Step Five - Maintain field mapping and conversion rules

Here we need to link our created fields, supposed to be loaded, with the corresponding EO fields known to the system

image

It is here that we will come in handy because in step 3 we called the fields as the system knows them. Now, in the Extras menu item, click on Auto-Field Mapping, after which the system automatically smokes the fields. In all the windows that appear next, you need to click "OK" and, if you do not have errors in the name of the fields you created, then the system will automatize everything.

image

After all fields are saved, we save and exit.

6) Step Six - Maintain fixed values, translations, user-defined routines

We skip it, we do not need it in this case.

7) Step Seven - Specify files
At this step, we need to specify the template file with the data to be loaded.

There are two options:

a) Legacy Data On the PC (Frontend)
b) Legacy Data On the R / 3 server (application server)

image

Option "a" is the choice of a template file located directly on your computer, and "b" is on the SAP server. With the second option somehow did not come across. All the time for convenience I use the file located directly in my file system. Positioning on Legacy Data (on the red area, click the “Create” leaflet)

Actually, create a text file on your hard disk. We remember that we are grouping three fields:

EO number
EO name
View EO

You can in the template file in the first line through TAB specify the system names of the fields for clarity. In the second and subsequent lines also through TAB we write values ​​for loading

image

On the screen that appears, select the location of the template file on the disk of your computer, set the “Tabulator” radio button on the Delimiter subscreen (delimiter), put a checkmark on the “Field Names at Start of File” (specify that the first line of the file is technical field names) .
If you have a sequence of fields in the template file does not match the corresponding sequence of step three - Maintain source fields, then you need to uncheck “Fields Order Matches Source Structure Definition”. The rest on the screen do not touch, close and exit.

image

8) Step Eight - Assign files

Since we have a flat structure with one incoming template file, open this item for editing, save and exit. Our only file is bound to a single structure. Formality.

9) Step Nine - Read Data

In this step, we read our file. We carry out.

10) Step Ten - Display read data

Here we look at the results of reading in step 10. If everything is normal, then the correct data fall into the correct fields.

image

11) Step Eleven - Convert data

Convert data to internal system format

12) Step Twelve - Display converted data

Actually, we look at the results of the conversion

image

13) Step Thirteenth - Create batch input session

We launch, checkboxes are set up as on the print-screen below and allow the SAP GUI to create an error file on the local railway.

image

14) Step fourteenth - Run Batch Input session

We start, we see in the list of tasks ours. Select the line, click "Run", a window opens. In it, you can select “Run visually” (then each filled field for each of the N lines from the template file will be filled apparently for you and require you to confirm each entry with Enter; this is usually used for the test of the packet written by us on one line), or "Background mode". In the background mode, the package execution will be invisible, and you will be able to inquire about any errors or their absence in the log file.

image

I created this example without rehearsal. In particular, on the visible run I realized that I did not specify the “Type of EO” field when creating an EO in the third step, and also, since the numbering for the EO acc. type is internal (that is, the incremental counter), then it was not necessary to specify the EQUNR field as a loadable field. After correcting these two blunders, the bagger successfully worked and created an automated EO. Thus, a massive load of historical data in SAP occurs. At least, this is one of the most convenient and simple ways. Good luck in mastering LSMW!

Source: https://habr.com/ru/post/215655/


All Articles