LSMW
(Legacy System Migration Workbench)
Advantages of using LSMW
• Simple data transfer tool.
• Requires no or minimum coding.
• Can be carried out by even Functional
consultants having no/min knowledge of ABAP
Coding
• Standard tool provided by SAP itself, hence
fully compatible with all SAP Transactions.
• Can be used to upload data from non SAP
system into the SAP R3 system.
• The Legacy Systems Migration Workbench (LSMW) is an R/3-based tool that supports one-
time and periodic transfer of data from non-SAP systems (legacy systems) to R/3.
• This easy-to-use tool supports the conversion of data from the non-SAP system that can
then be imported into the R/3 System using batch input, call transaction, direct input, BAPIs,
or IDocs.
• In addition, the LSMW provides a recording function, which you can use to generate a data
migration object from a create or change transaction.
© SAP AG 1999
CT
BAPI
DI
IDoc
 Available as an add-on
 One-time and periodic data transfer from external system to
R/3
 LSMW uses standard technologies
LSMW: Characteristics
BI
• The core LSMW functions are:
• Reading data files from an external system into an internal LSMW format
• Converting the data, that is, formatting and assigning the data to the required
structures
• Calling the standard transfer program or BAPIs or IDocs to perform the data
transfer into the R/3 tables.
©SAP AG 1999
 Read data
 Spreadsheet tables
 Sequential files
 Convert data
 Import data
LSMW: Core Functions
Data transfer
• The LSMW reads the external files and converts the contents into the
corresponding target structures or fields, producing an output file in the
required format. This output file can then be input to the appropriate data
transfer program.
©SAP AG 1999
SAP-DB
Conversion
External
format
SAP format
Definition
The LSMW Concept
SAP
Data
transfer
• To read these files, you must define the structure of the file (source structure).
• The file contents are then read into an internal LSMW format and stored as an LSMW file.
• The next step is to define structure relationships and field assignments. These specify the
mapping of the source structure fields to the target structure fields.
• Using these definitions, the contents of the LSMW file are converted to the target structure
and can then be transferred using the specified transfer method.
© SAP AG 1999
Conversion
• Structure Relationships
• Field Assignments
• Conversion Rules
On PC
Application
Server
• Source Structure Definitions
LSMW Concept
SAP
• The LSMW generates two executable ABAP programs from the structure
definitions and the conversion rules - a READ program and a CONVERSION
program.
© SAP AG 1999
Conversion
program
• Structure relationships
• Field assignments
• Conversion rules
• Source structure definitions
Generated Programs
Read
program
• The LSMW supports the following transfer methods:
• Standard transfer programs used with batch input, call transaction, and direct input.
• Data transfer using IDocs.
• Data transfer using BAPIs.
• Creation of a recording using the transaction recorder and generation of a batch
input session.
© SAP AG 1999
SAP Record
Layout
Structure
SAP IDoc
Structure
Flat SAP
Structure
Standard
Transfer
Program
Recorder
BAPI
LSMW Transfer Procedure
IDoc
• To start the LSMW, call transaction LSMW.
• On the initial screen, you can create related subprojects and objects by choosing Create new
projects.
• Project: Maximum of 10 characters to identify your data transfer project. If you want to
transfer data from several external systems, you can create a project for each external
system.
• Subproject: Maximum of 10 characters; used as an additional subdivision.
• Object: Maximum of 10 characters; used to identify a business data object.
© SAP AG 1999
Starting the LSMW
Transaction LSMW
Initial Screen:
LSMW organized by:
You must specify a name
and short description for
each of these.
Project
Subproject
Object
 Project
 Subproject
 Object
© SAP AG 1999
Project Overview
 All Objects
 Overview of objects contained in system
 My Objects
 Overview of objects the user created
 All Objects in a Project
 Overview of objects in the current project
• A total of 26 different work steps are provided. The work steps displayed are
dependent on the selected object.
• You can create a customized personal menu of the work steps. In the personal
menu you can select a subset of the 26 work steps you want to display.
©SAP AG 1999
Define object attributes
Define source structures and source fields
Define structure relationships
Define field mapping and conversion rules
Read data
Convert data
Import data
The Main Steps
• Before you start using the LSM Workbench, create a “mapping on paper”
for the object. For this, create and print an “object overview”.
• At this time, the overview only contains the design and description of the
R/3 structures and the fields they contain. You can use this overview to
help you map these target structures and fields to the corresponding
source structures and fields.
© SAP AG 1999
EXCEL List
STYPE Record type CHAR 1
TCODE Transaction code CHAR 20
KUNNR Customer number CHAR 10 a3ktn2 10 M
BUKRS Company code CHAR 4
Field Length Conversion .........
SAP Fields
Field Description Type Length
Non-SAP Fields
Conversion on Paper
• The file with the data from the external system must be imported by the
LSMW. Therefore you have to define the structure of this data in the LSMW. It
is called the definition of the source structure.
• The source structure may be structured in different ways.
• If the source structure is a flat structure, each line in the file has the same
structure. For the definition the structure name and the field names as well as
the technical characteristics of the fields must be defined.
© SAP AG 1999
File with flat structure:
Structure A
Field 1 Field 2 Field 3
Definition contains:
 Structure name
 Field name
Flat Source Structure
• In this step, you define the object structures, including name, description,
and hierarchical relationships.
• In the dialog box, choose Change. You can now choose to create new
structures, or change, rearrange, or remove these. Use the relevant
pushbuttons to execute these functions.
©SAP AG 1999
Source Structures
  HEAD
POSI
Document header
Document position
 Object attributes
Name of the source structure
 Description of the source structure
Maintain Source Structures
• In this step, you create and maintain fields for the structures
created in the previous step.
© SAP AG 1999
Object attributes
 Field name
 Field ID
 Field length
 Field type
Source Fields
  HEAD
SET1 C(001) Record ID
REF_NO C(009) Reference number
  POSI
SET2 C(001) Record ID
DATE DDMY(010) Posting date
:
:
Maintain Source Fields
• The structure relationships define the relationships between the source and target
structures.
• To set structure relationships, place the cursor on a field in the R/3 structure or
target structure. Choose Relationship. A dialog box appears with a list of the
source structures you have created. Select a structure from this list.
• If you want to change the relationship, you must first delete the existing
relationship using the relevant pushbutton.
• A check function is available to check the structure relationships for errors.
Messages for this check are displayed in the status bar (error message or “No
structure relationship errors found”)
© SAP AG 1999
Structure Relationships
  BGR00 Batch input structure for session data <<<<
  BBKPF Document header .... <<<<
  BBSEG Document segment .... <<<< POSI
BWITH .....
Object Attributes
Source structure assignment
SAP
Record
Layout
Structure
SAP IDoc
Structure
Flat SAP
StructureBAPI
Maintain Structure Relations
HEAD
HEAD
• In this step, you assign source fields to the target fields and specify how the field
contents are to be converted.
• The following information is displayed for each target field:
• Field ID
• Any source fields assigned
• Rule type (default value, translation, and so on)
• Code
©SAP AG 1999
Field mapping and rules
  BGR00
Fields
  BBKPF
  Fields
BLDAT Date
BUKRS Company code
Field Information
Documentation
Valid values
Navigation in the ABAP Dictionary
Maintain Field Mapping and Conversion Rules
• Assigning source fields:
To assign a source field, place the cursor on a target field in the tree structure and
choose Assign source field. A list of available source fields appears, from which you can
select the desired source field by double-clicking it.
• Deleting source field assignments:
To unassign a source field, place the cursor on a target field in the tree structure and
choose Remove source field. If only one source field is assigned, this assignment is
removed. If more than one source field is assigned, a list of all assigned source fields
appears; to select the desired field, double-click it.
• After you have assigned the source fields, you define the conversion rules. The default is
“MOVE”. Various standard techniques are available by choosing the relevant
pushbutton.
©SAP AG 1999
 Sequence
1. Assignment of source field to target field
2. Definition of conversion rule
1.
2.
Source Field Assignment
• In this step you specify all the files that are to be used in the following
steps:
• Your legacy data on the PC and/or R/3 server
• The file for the imported data
• The file for the converted data
© SAP AG 1999
 Object attributes
 Specify paths and files
Conversionon PC
Application
server
File name
File name File name
File name
Specify Files
• The system proposes a name for the file containing the imported data.
You can change the name if you wish to.
© SAP AG 1999
Read Data File
File transprBC420_46_D_CT_01.lsmw.read
File name: <path><file name>.lsmw.read
 Specify paths and file names
File name = Project name + subproject name + object name
• You have the following options with the function “Read data":
• If you want to process all the data belonging to an object, execute the
function.
• If you simply want to migrate a part of the dataset, you can limit the
amount of data that you migrate in the field
“Standard selection parameters”. Select your data in “Transaction
number” “from ... to ...".
© SAP AG 1999
 Object attributes
 Specify which data is to be imported
 Amount fields
Amount fields are converted into decimal format
(with decimal point)
 Date values
Date fields are converted into the internal format
(YYYYMMDD)
Read Data
Amount fields -> 1234.56
Date values -> YYYYMMDD
• In this step you can display a part of or all of the imported data in a table. By
clicking on a table row (or selecting Field contents) you can display all the
information in this row.
• With the function Change display you can switch between one line and multiple
line display.
© SAP AG 1999
1 DOCUMENTS HBC100000119990730 07 31.07.199930.07.1999DM
2 POSI P0004S100000 3410.50 1740.89 Info 1
3 POSI P0005H113100 3005.50 1536.41 Info 2
4 POSI P0005S110000 405 204.48 Info 3
5 DOCUMENTS HBC100000219990730 07 31.07.199930.07.1999$
6 POSI P0004S100000 3420.50 3206.89 Info 1
7 POSI P0005H113100 3010.50 2830.77 Info 2
8 POSI P0005S110000 410 376.12 Info 3
1 HEAD HBC100000119990730 07 3107199930071999DM
2 POSI P0004S100000 3410.50 1740.89 Info 1
3 POSI P0005H113100 3005.50 1536.41 Info 2
4 POSI P0005S110000 405 204.48 Info 3
5 HEAD HBC100000219990730 07 3107199930071999$
6 POSI
7 POSI
8 POSI
Display Read Data
Field name Field text Field value
SET1 Record indicator H
REF_NO Reference number BC1000001
DOC_DATE Doc. date 30071999
TYPE TYPE 07
CURR_KEY document currency DM
 Display read data
 By record
 By field
• The imported data is converted into the target file by the using the defined
rules.
• If you do not select any data, confirm by executing the process. Otherwise
select the data in “from..…to..." in the “Transaction number”. You can also
select several transaction numbers.
© SAP AG 1999
Generated
conversion
program
Field assignments
Transactions read: 5
Records read: 20
Transactions written: 5
Records written: 21
Convert Data
Note:
Amount fields (AMT1...) for standard
transfer programs are formatted
according to user-defined settings.
Date fields are NOT formatted - they
are always displayed in format
YYYYMMDD
• In this step, you can display part or all of the converted data in a table.
To display information about a line, double-click it, or choose Field
contents.
• To choose between a one-line or multiple-line view, choose Change
display.
©SAP AG 1999
1 BGR00 0KNA1_A 100ROBERTS /
2 BBKPF 1FB01 30071999SA0001/ / DEM
3 BBSEG 2BBSEG 40/ //
4 BBSEG 2BBSEG 50/ //
5 BBSEG 2BBSEG 50/ //
6 BBKPF 1FB01 30071999SA0001/ / USD
7 BBSEG 2BBSEG 40/ //
8 BBSEG 2BBSEG 50/ //
9 BBSEG 2BBSEG 50/ //
 Displaying the converted data
 By record
 By field
Field Field text Field value
STYPE Record type 1
TCODE Transaction code FB01
BLDAT Date 30071999
BLART Document type SA
BUKRS Company code 0001
BUDAT Date /
WAERS Currency key DEM
Display Converted Data
• If you have selected a standard SAP transfer program, it may support batch
input, call transaction, or direct input or some combination of them.
• If you use batch input:
You must create the session and then process the session using the batch input
monitor.
You can go to the batch input monitor; only the batch input sessions for the
selected object will be displayed.
• If you use call transaction:
You can start the program directly and import the data immediately.
• If you use direct input:
You can start the direct input program directly (should only be used for testing),
or start the data transfer using the direct input monitor.
©SAP AG 1999
SAP DB
BAPI
Starting Transfer

Lsmw ppt in SAP ABAP

  • 1.
  • 2.
    Advantages of usingLSMW • Simple data transfer tool. • Requires no or minimum coding. • Can be carried out by even Functional consultants having no/min knowledge of ABAP Coding • Standard tool provided by SAP itself, hence fully compatible with all SAP Transactions. • Can be used to upload data from non SAP system into the SAP R3 system.
  • 3.
    • The LegacySystems Migration Workbench (LSMW) is an R/3-based tool that supports one- time and periodic transfer of data from non-SAP systems (legacy systems) to R/3. • This easy-to-use tool supports the conversion of data from the non-SAP system that can then be imported into the R/3 System using batch input, call transaction, direct input, BAPIs, or IDocs. • In addition, the LSMW provides a recording function, which you can use to generate a data migration object from a create or change transaction. © SAP AG 1999 CT BAPI DI IDoc  Available as an add-on  One-time and periodic data transfer from external system to R/3  LSMW uses standard technologies LSMW: Characteristics BI
  • 4.
    • The coreLSMW functions are: • Reading data files from an external system into an internal LSMW format • Converting the data, that is, formatting and assigning the data to the required structures • Calling the standard transfer program or BAPIs or IDocs to perform the data transfer into the R/3 tables. ©SAP AG 1999  Read data  Spreadsheet tables  Sequential files  Convert data  Import data LSMW: Core Functions Data transfer
  • 5.
    • The LSMWreads the external files and converts the contents into the corresponding target structures or fields, producing an output file in the required format. This output file can then be input to the appropriate data transfer program. ©SAP AG 1999 SAP-DB Conversion External format SAP format Definition The LSMW Concept SAP Data transfer
  • 6.
    • To readthese files, you must define the structure of the file (source structure). • The file contents are then read into an internal LSMW format and stored as an LSMW file. • The next step is to define structure relationships and field assignments. These specify the mapping of the source structure fields to the target structure fields. • Using these definitions, the contents of the LSMW file are converted to the target structure and can then be transferred using the specified transfer method. © SAP AG 1999 Conversion • Structure Relationships • Field Assignments • Conversion Rules On PC Application Server • Source Structure Definitions LSMW Concept SAP
  • 7.
    • The LSMWgenerates two executable ABAP programs from the structure definitions and the conversion rules - a READ program and a CONVERSION program. © SAP AG 1999 Conversion program • Structure relationships • Field assignments • Conversion rules • Source structure definitions Generated Programs Read program
  • 8.
    • The LSMWsupports the following transfer methods: • Standard transfer programs used with batch input, call transaction, and direct input. • Data transfer using IDocs. • Data transfer using BAPIs. • Creation of a recording using the transaction recorder and generation of a batch input session. © SAP AG 1999 SAP Record Layout Structure SAP IDoc Structure Flat SAP Structure Standard Transfer Program Recorder BAPI LSMW Transfer Procedure IDoc
  • 9.
    • To startthe LSMW, call transaction LSMW. • On the initial screen, you can create related subprojects and objects by choosing Create new projects. • Project: Maximum of 10 characters to identify your data transfer project. If you want to transfer data from several external systems, you can create a project for each external system. • Subproject: Maximum of 10 characters; used as an additional subdivision. • Object: Maximum of 10 characters; used to identify a business data object. © SAP AG 1999 Starting the LSMW Transaction LSMW Initial Screen: LSMW organized by: You must specify a name and short description for each of these. Project Subproject Object  Project  Subproject  Object
  • 10.
    © SAP AG1999 Project Overview  All Objects  Overview of objects contained in system  My Objects  Overview of objects the user created  All Objects in a Project  Overview of objects in the current project
  • 11.
    • A totalof 26 different work steps are provided. The work steps displayed are dependent on the selected object. • You can create a customized personal menu of the work steps. In the personal menu you can select a subset of the 26 work steps you want to display. ©SAP AG 1999 Define object attributes Define source structures and source fields Define structure relationships Define field mapping and conversion rules Read data Convert data Import data The Main Steps
  • 12.
    • Before youstart using the LSM Workbench, create a “mapping on paper” for the object. For this, create and print an “object overview”. • At this time, the overview only contains the design and description of the R/3 structures and the fields they contain. You can use this overview to help you map these target structures and fields to the corresponding source structures and fields. © SAP AG 1999 EXCEL List STYPE Record type CHAR 1 TCODE Transaction code CHAR 20 KUNNR Customer number CHAR 10 a3ktn2 10 M BUKRS Company code CHAR 4 Field Length Conversion ......... SAP Fields Field Description Type Length Non-SAP Fields Conversion on Paper
  • 13.
    • The filewith the data from the external system must be imported by the LSMW. Therefore you have to define the structure of this data in the LSMW. It is called the definition of the source structure. • The source structure may be structured in different ways. • If the source structure is a flat structure, each line in the file has the same structure. For the definition the structure name and the field names as well as the technical characteristics of the fields must be defined. © SAP AG 1999 File with flat structure: Structure A Field 1 Field 2 Field 3 Definition contains:  Structure name  Field name Flat Source Structure
  • 14.
    • In thisstep, you define the object structures, including name, description, and hierarchical relationships. • In the dialog box, choose Change. You can now choose to create new structures, or change, rearrange, or remove these. Use the relevant pushbuttons to execute these functions. ©SAP AG 1999 Source Structures   HEAD POSI Document header Document position  Object attributes Name of the source structure  Description of the source structure Maintain Source Structures
  • 15.
    • In thisstep, you create and maintain fields for the structures created in the previous step. © SAP AG 1999 Object attributes  Field name  Field ID  Field length  Field type Source Fields   HEAD SET1 C(001) Record ID REF_NO C(009) Reference number   POSI SET2 C(001) Record ID DATE DDMY(010) Posting date : : Maintain Source Fields
  • 16.
    • The structurerelationships define the relationships between the source and target structures. • To set structure relationships, place the cursor on a field in the R/3 structure or target structure. Choose Relationship. A dialog box appears with a list of the source structures you have created. Select a structure from this list. • If you want to change the relationship, you must first delete the existing relationship using the relevant pushbutton. • A check function is available to check the structure relationships for errors. Messages for this check are displayed in the status bar (error message or “No structure relationship errors found”) © SAP AG 1999 Structure Relationships   BGR00 Batch input structure for session data <<<<   BBKPF Document header .... <<<<   BBSEG Document segment .... <<<< POSI BWITH ..... Object Attributes Source structure assignment SAP Record Layout Structure SAP IDoc Structure Flat SAP StructureBAPI Maintain Structure Relations HEAD HEAD
  • 17.
    • In thisstep, you assign source fields to the target fields and specify how the field contents are to be converted. • The following information is displayed for each target field: • Field ID • Any source fields assigned • Rule type (default value, translation, and so on) • Code ©SAP AG 1999 Field mapping and rules   BGR00 Fields   BBKPF   Fields BLDAT Date BUKRS Company code Field Information Documentation Valid values Navigation in the ABAP Dictionary Maintain Field Mapping and Conversion Rules
  • 18.
    • Assigning sourcefields: To assign a source field, place the cursor on a target field in the tree structure and choose Assign source field. A list of available source fields appears, from which you can select the desired source field by double-clicking it. • Deleting source field assignments: To unassign a source field, place the cursor on a target field in the tree structure and choose Remove source field. If only one source field is assigned, this assignment is removed. If more than one source field is assigned, a list of all assigned source fields appears; to select the desired field, double-click it. • After you have assigned the source fields, you define the conversion rules. The default is “MOVE”. Various standard techniques are available by choosing the relevant pushbutton. ©SAP AG 1999  Sequence 1. Assignment of source field to target field 2. Definition of conversion rule 1. 2. Source Field Assignment
  • 19.
    • In thisstep you specify all the files that are to be used in the following steps: • Your legacy data on the PC and/or R/3 server • The file for the imported data • The file for the converted data © SAP AG 1999  Object attributes  Specify paths and files Conversionon PC Application server File name File name File name File name Specify Files
  • 20.
    • The systemproposes a name for the file containing the imported data. You can change the name if you wish to. © SAP AG 1999 Read Data File File transprBC420_46_D_CT_01.lsmw.read File name: <path><file name>.lsmw.read  Specify paths and file names File name = Project name + subproject name + object name
  • 21.
    • You havethe following options with the function “Read data": • If you want to process all the data belonging to an object, execute the function. • If you simply want to migrate a part of the dataset, you can limit the amount of data that you migrate in the field “Standard selection parameters”. Select your data in “Transaction number” “from ... to ...". © SAP AG 1999  Object attributes  Specify which data is to be imported  Amount fields Amount fields are converted into decimal format (with decimal point)  Date values Date fields are converted into the internal format (YYYYMMDD) Read Data Amount fields -> 1234.56 Date values -> YYYYMMDD
  • 22.
    • In thisstep you can display a part of or all of the imported data in a table. By clicking on a table row (or selecting Field contents) you can display all the information in this row. • With the function Change display you can switch between one line and multiple line display. © SAP AG 1999 1 DOCUMENTS HBC100000119990730 07 31.07.199930.07.1999DM 2 POSI P0004S100000 3410.50 1740.89 Info 1 3 POSI P0005H113100 3005.50 1536.41 Info 2 4 POSI P0005S110000 405 204.48 Info 3 5 DOCUMENTS HBC100000219990730 07 31.07.199930.07.1999$ 6 POSI P0004S100000 3420.50 3206.89 Info 1 7 POSI P0005H113100 3010.50 2830.77 Info 2 8 POSI P0005S110000 410 376.12 Info 3 1 HEAD HBC100000119990730 07 3107199930071999DM 2 POSI P0004S100000 3410.50 1740.89 Info 1 3 POSI P0005H113100 3005.50 1536.41 Info 2 4 POSI P0005S110000 405 204.48 Info 3 5 HEAD HBC100000219990730 07 3107199930071999$ 6 POSI 7 POSI 8 POSI Display Read Data Field name Field text Field value SET1 Record indicator H REF_NO Reference number BC1000001 DOC_DATE Doc. date 30071999 TYPE TYPE 07 CURR_KEY document currency DM  Display read data  By record  By field
  • 23.
    • The importeddata is converted into the target file by the using the defined rules. • If you do not select any data, confirm by executing the process. Otherwise select the data in “from..…to..." in the “Transaction number”. You can also select several transaction numbers. © SAP AG 1999 Generated conversion program Field assignments Transactions read: 5 Records read: 20 Transactions written: 5 Records written: 21 Convert Data Note: Amount fields (AMT1...) for standard transfer programs are formatted according to user-defined settings. Date fields are NOT formatted - they are always displayed in format YYYYMMDD
  • 24.
    • In thisstep, you can display part or all of the converted data in a table. To display information about a line, double-click it, or choose Field contents. • To choose between a one-line or multiple-line view, choose Change display. ©SAP AG 1999 1 BGR00 0KNA1_A 100ROBERTS / 2 BBKPF 1FB01 30071999SA0001/ / DEM 3 BBSEG 2BBSEG 40/ // 4 BBSEG 2BBSEG 50/ // 5 BBSEG 2BBSEG 50/ // 6 BBKPF 1FB01 30071999SA0001/ / USD 7 BBSEG 2BBSEG 40/ // 8 BBSEG 2BBSEG 50/ // 9 BBSEG 2BBSEG 50/ //  Displaying the converted data  By record  By field Field Field text Field value STYPE Record type 1 TCODE Transaction code FB01 BLDAT Date 30071999 BLART Document type SA BUKRS Company code 0001 BUDAT Date / WAERS Currency key DEM Display Converted Data
  • 25.
    • If youhave selected a standard SAP transfer program, it may support batch input, call transaction, or direct input or some combination of them. • If you use batch input: You must create the session and then process the session using the batch input monitor. You can go to the batch input monitor; only the batch input sessions for the selected object will be displayed. • If you use call transaction: You can start the program directly and import the data immediately. • If you use direct input: You can start the direct input program directly (should only be used for testing), or start the data transfer using the direct input monitor. ©SAP AG 1999 SAP DB BAPI Starting Transfer