SAP LSMW — Data Migration & Batch Input Guide
In this tutorial, you'll learn about SAP LSMW. We cover key concepts, practical examples, and best practices.
SAP LSMW (Legacy System Migration Workbench) is the primary tool for migrating data from legacy systems into SAP — supporting batch input, BAPI calls, IDocs, and direct input methods without custom ABAP programming.
What You'll Learn
You will learn LSMW project structure, recording batch input sessions, field mapping and conversion rules, running migrations in test and production mode, and troubleshooting common migration errors.
Why It Matters
Every SAP implementation requires moving data from the old system — customer records, vendor masters, material masters, open invoices, and inventory balances. Without LSMW, this requires custom ABAP programs for every data type. LSMW provides a repeatable, auditable framework that non-developers can use.
Real-World Use
A company migrating from legacy ERP to S/4HANA needs to move 50,000 material masters, 20,000 customer records, and 100,000 open AP invoices. The migration team uses LSMW to map fields, apply conversion rules (date formats, unit conversions), run test migrations in QAS, and execute the final migration in PRD — all within 3 weeks.
Learning Path
flowchart LR A["SAP ABAP"] --> B["SAP Basis"] B --> C["SAP LSMW
You are here"] C --> D["SAP IDoc"] D --> E["SAP Security"] style C fill:#f90,color:#fff
LSMW Architecture
flowchart TD A["Source Data
(Excel / CSV / Text)"] --> B["LSMW Project"] B --> C["Field Mapping
& Conversion"] C --> D["Batch Input
Recording"] C --> E["BAPI / IDoc
Method"] D --> F["Test Run"] E --> F F --> G{"Result?"} G -->|"Pass"| H["Production
Run"] G -->|"Fail"| I["Fix Mapping
& Retry"]
LSMW Project Structure
Creating a Project
Transaction: LSMW
Project: ZMATMIG (Material Master Migration)
Subproject: ZMATMIG_SUB
Object: ZMATMIG_OBJ
Steps:
1. Maintain object attributes — method selection
2. Maintain source structures — define source data layout
3. Maintain source fields — define source field names and types
4. Maintain structure relations — map source to SAP structure
5. Maintain field mapping and conversion rules
6. Maintain fixed values, translations, user-defined routines
7. Specify files — upload source data
8. Assign files — link file to source structure
9. Read data — import data from file
10. Display read data — verify import
11. Convert data — apply mapping and rules
12. Display converted data — verify conversion
13. Create batch input session — generate session
14. Run batch input session — execute in foreground or background
Migration Methods
| Method | Best For | Speed | Complexity |
|---|---|---|---|
| Batch Input | Transactional data (F-43, FB01) | Medium | Low |
| BAPI | Master data (materials, customers) | Medium | Medium |
| IDoc | Large volumes, async processing | High | High |
| Direct Input | High-volume master data | High | Medium |
| Recording | Simple transactions | Low | Very Low |
Batch Input Recording
Recording captures a manual transaction and creates a template:
* Batch input structure (generated from recording)
DATA: lt_bdc TYPE TABLE OF bdcdata.
* Fill screens
APPEND VALUE #(
program = 'SAPMF02D'
dynpro = '0101'
dynbegin = 'X'
) TO lt_bdc.
APPEND VALUE #(
fnam = 'RF02D-MATERIAL'
fval = 'MAT-100'
) TO lt_bdc.
APPEND VALUE #(
fnam = 'RF02D-DESCRIPTION'
fval = 'Aluminum Sheet'
) TO lt_bdc.
* Call transaction
CALL TRANSACTION 'MM01'
USING lt_bdc
MODE 'N' " Background mode
UPDATE 'S'.
Field Mapping and Conversion
LSMW provides powerful conversion rules:
| Rule | Purpose | Example |
|---|---|---|
| Move | Direct copy | Source -> Target |
| Constant | Fixed value | Always '1000' for company code |
| Date conversion | Format change | DD.MM.YYYY -> YYYYMMDD |
| Unit conversion | UoM mapping | 'EA' -> 'PC' |
| Translation | Code to value | 'M' -> Male, 'F' -> Female |
| ABAB routine | Custom logic | User-written conversion |
| Table lookup | Reference data | Look up plant from source code |
Custom ABAP Routine
* ABAP routine in LSMW for custom logic
DATA: lv_source TYPE string.
* Convert material type from legacy code
CASE lv_source.
WHEN 'FG'.
lv_matnr = 'FERT'.
WHEN 'RM'.
lv_matnr = 'ROH'.
WHEN 'WIP'.
lv_matnr = 'HALB'.
WHEN OTHERS.
lv_matnr = 'HAWA'.
ENDCASE.
File Formats
LSMW accepts multiple source file formats:
MATNR,MAKTX,MEINS,MATKL,MTART
MAT-100,Aluminum Sheet,PC,M-100,FERT
MAT-200,Steel Rod,PC,M-200,ROH
MAT-300,Bolt M10,PC,M-100,HAWA
<?xml version="1.0" encoding="UTF-8"?>
<Materials>
<Material>
<MATNR>MAT-100</MATNR>
<MAKTX>Aluminum Sheet</MAKTX>
<MEINS>PC</MEINS>
<MATKL>M-100</MATKL>
<MTART>FERT</MTART>
</Material>
</Materials>
Testing and Execution
Three-Run Strategy
Run 1: Test in QAS with 10 records
- Verify field mapping
- Check date formats
- Confirm transaction codes
Run 2: Test in QAS with 1000 records
- Performance check
- Error rate acceptable? (<1%)
- Validate master data results
Run 3: Production run
- Execute in background (MODE 'N')
- Monitor batch input session (SM35)
- Post-process errors
Real-World Scenario: Customer Master Migration
- Extract 20,000 customer records from legacy ERP to CSV
- Create LSMW project with BAPI method (BAPI_CUSTOMER_CREATEFROMDATA1)
- Map legacy fields to BAPI structure
- Apply conversion rules:
- Legacy date YYMMDD → SAP YYYYMMDD
- Legacy region codes → SAP region codes (table lookup)
- Default sales area from company code
- Run test with 50 records — fix 3 mapping errors
- Run full test with 20,000 records — 18,952 pass, 48 errors
- Fix errors (missing country codes, invalid VAT numbers)
- Production run: 19,998 records pass, 2 manual corrections
Common Errors
1. Batch Input Session Not Created
The session generation step may fail if the source data does not match expected formats. Check step 12 (display converted data) before creating the session.
2. Date Format Mismatch
SAP expects dates in YYYYMMDD format. Source data in DD.MM.YYYY or MM/DD/YYYY must be converted using the date conversion rule.
3. Missing Mandatory Field
BAPIs and transactions have mandatory fields. If a required field is not mapped or empty, the record fails. Check the BAPI documentation for required parameters.
4. Session Shows Errors in SM35
Batch input sessions with errors appear in SM35 with status "Error." Double-click to see the exact screen where the transaction failed.
5. Conversion Routine Crashes
Custom ABAP routines may have syntax errors or dump. Test the routine with LSMW's test functions before the full run.
6. Target System Differences
A migration that works in QAS may fail in PRD due to different configuration (e.g., different plant structure, missing GL accounts). Validate PRD configuration before migration.
Practice Questions
What is LSMW? Legacy System Migration Workbench — SAP's tool for migrating data from legacy systems to SAP.
What are the four main migration methods in LSMW? Batch Input, BAPI, IDoc, and Direct Input.
What transaction runs LSMW? LSMW — the legacy system migration workbench.
What is a batch input session? A recorded sequence of SAP transactions created from source data that can be played back in background mode.
What is a conversion rule in LSMW? A rule that transforms source data to target format (date conversion, unit mapping, table lookup, etc.).
Challenge: Migrate 50,000 open AP invoices from a legacy system to SAP FI (transaction F-43). Design the LSMW project with batch input recording including vendor, amount, document date, and posting date. Plan the three-run strategy and error handling for common mismatches.
FAQ
What's Next
| Tutorial | What You'll Learn |
|---|---|
| SAP IDoc & BAPI | How IDocs and BAPIs complement LSMW for integration |
| SAP ABAP Programming | Write custom ABAP for complex migration scenarios |
Built by the developers of Doda Browser, DodaZIP, and Durga Antivirus Pro. Updated 2026-06-24.
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro