Download as pdf or txt
Download as pdf or txt
You are on page 1of 64

Advanced Tips for

Exploiting LSMW for


Logistics Data
Conversion: Minimal
ABAP Required!
Mitresh Kundalia
Quality Systems & Software
© 2005 Wellesley Information Services. All rights reserved.
What We’ll Cover …

Legacy System Migration Workbench (LSMW) overview: What,


When, and why

Converting data with LSMW – an example

Getting LSMW up and running at your company

Tips and tricks for getting the most out of LSMW

2
What Is Data Conversion Really?

• Data conversion describes three activities


! Data migration
o Moving data from one system to another
! Data conversion
o Converting data from a source system to target system
o Data typically requires reformatting
! Data updates
o Updating specific fields in existing R/3 records

You may be used to different jargon..


Note For simplicity, I will use data conversion for all three activities

3
Data Conversion Used to Be...

• A one-time activity
! Usually only during initial SAP implementation
! Or to bring in data from non-SAP systems
• ABAP-focused
! Single-use ABAP programs were developed to perform highly
specialized conversions
• Expensive
! One-time activity – not much attention paid to it
! Part of the huge SAP implementation budget

4
Data Conversion Is Now a Day-to-Day Activity

• Example scenarios
! Mass updating customer master records to reflect a revised
organizational structure
! Mass updating sales orders to reflect changes in pricing/
expected delivery/account assignments
! Uploading batches of purchasing requisitions/orders
! Uploading batches of customer/vendor invoices

You cannot afford to rely heavily on custom ABAP

5
Today’s Data Conversion Toolbox

• Computer Aided Test Tool (CATT or eCATT)


! Primary strength is testing, but can also be used for
conversions
• Data Transfer Workbench (DXWB)
! Primarily used during complex and involved conversion
projects
• Mass maintenance (MASS)
! Primarily used for data objects with simple data structures
o e.g., customers, vendors, material master records
• Legacy System Migration Workbench (LSMW)
! Flexible data migration, tool

6
Today’s Data Conversion Toolbox (cont.)
• Computer Aided Test Tool (CATT)
! Part of ABAP Development Workbench for testing SAP
transactions
! Single test cases can be linked together to test an entire process
! New eCATT in Web Application Server (WAS) can test cross-
system and Web applications as well!
• Limitations
! Limited conditional (if-then-else) processing t-code
! Data massaging not possible SCAT

7
Today’s Data Conversion Toolbox (cont.)

• Data Transfer Workbench (DXWB)


! A comprehensive data transfer tool
! Provides access to most of the SAP standard transfer
programs
! Used for complex data transfer requirements
t-code
Requires in-depth technical SXDA

knowledge about data structures


(“techie” stuff)

8
Today’s Data Conversion Toolbox (cont.)

• Mass Maintenance
! Generic (cross-application) tool to change large quantity of data
o Mass Maintenance or Mass Updates
! Introduced in Release 4.5A as a part of standard system
o Refer to OSS# 126198 to retrofit to Release 4.0B
• Limitations t-code
! Limited to specific SAP objects only MASS
o Customers, vendors
o Material master records
o Purchasing info records
o etc.
! Cannot use conditional processing
o i.e., if..then..else logic
9
Today’s Data Conversion Toolbox (cont.)

• Mass Maintenance

10
Today’s Data Conversion Toolbox (cont.)

• LSMW is one of SAP’s best data conversion tools


! No need for ABAP programming skills
o Most conversion and migration tasks are manageable
with standard functionality
o For more complex requirements, ABAP coding is
supported within LSMW
! Provides data reformatting options
o Simple mapping to complex data reformatting rules
! Can be used for conversion tasks against production data
o Not just for legacy data!
• So LSMW is the right choice for all conversion and
migration
! LSMW is SAP’s preferred data conversion tool 11
What We’ll Cover …

LSMW overview: what, when, and why

Converting data with LSMW – an example

Getting LSMW up and running at your company

Tips and tricks for getting the most out of LSMW

12
Key LSMW Features

• Load via over 50 standard interface programs


! Available for most R/3 master and transactional data
o e.g., customer master, material master
o e.g., sales documents, purchasing documents
• Load via transaction recordings
! You record an SAP transaction, updating only required fields
! LSMW runs recording with data from source system
• Extremely easy interface
! Wizard-like interface supports you step by step

13
LSMW Load Process – Overview

Legacy System or R/3 System


Source data starts
out as flat files PC/App Srv Tab delimited Fixed record

Conversion Rules LSMW read program


Read Data reads the source data
1 : 1 Translation
Interval Translation Read Data
Initial value
Constant
Conversion Rules are
Assign Source field
applied to reformat and
Prefix/Suffix
Concatenate …. Converted Data remap the data

SAP R/3 System

Batch Input Direct Input IDocs

14
LSMW Load Process – Overview (cont.)

Legacy System or R/3 System

PC/App Srv Tab delimited Fixed record

Conversion Rules
Read Data
1 : 1 Translation
Interval Translation Read Data
Initial value
Constant Convert program
Assign Source field
converts (reformats) the
Prefix/Suffix
source data into an R/3-
Concatenate …. Converted Data
specific format
Standard programs
upload converted SAP R/3 System
data to R/3 tables
OR
Batch Input Direct Input IDocs
Data is loaded via
batch input using
your recording 15
Loading Data with LSMW – A Quick Example

• Scenario
! You need to regroup many of your customers
o i.e., change a customer’s sales office, sales group, or
customer groups
• How it’s done in SAP
! Use transaction XD02 to update customer’s sales view
manually
o Provide customer key
# Customer number, sales organization, distribution
channel, division
o Update relevant fields on sales view screen
• Let’s do it instead with LSMW...

16
Conversion Prerequisite: Create a New Object

• LSMW has three constructs for organizing conversions


! Projects, subprojects, and objects
! Using this three-level hierarchy provides easy referencing, e.g.,
o Use projects to represent your various initiatives
o Use subprojects to represent application modules
o Use objects to represent specific R/3 target objects

t-code
LSMW

17
Conversion Process Overview: Steps We’ll Cover

LSMW main screen


• Step-by-step wizard
• Personal menu
! Display/hide some steps
• Numbers on/off
! Toggle numbers for steps
• Double-click edit/display
! Toggle switch to display or
edit steps

18
Step 1 – Maintain Object Attributes

• Define object attributes


! Owner
o Your ID
! Data transfer
o One-time
• Import technique
! Choose standard object
o 0050 Customer
! Choose method
o 0000 Batch Input
! Other options are
o Batch recording
o BAPI/IDocs
19
Step 2 – Maintain Source Structures

• Name source structure from source system


! Name source structure as XD02S
• You can have one or more structures for source data
! One source file
o Single source file with customer data
! Two source files
o Header and details lines for FI documents

20
Step 3 – Maintain Source Fields

• For each source structure, define source fields and field


attributes

21
Step 4 – Maintain Structure Relations

• Assign source structures to R/3 object structures


! e.g., assign source structure XD02S to R/3 structures
Tip
! You can have one-to-one or one-to-many relationship between
source and R/3 structures

22
Step 5 – Maintain Field Mapping, Conversion Rules

• Assign source field to R/3 target field


! For each relevant field in R/3 target structure
o Assign source field from the source structure
• You could use reusable conversion rules
! As constants
o e.g., checkbox X, transaction code XD02
! As translations
o e.g., map source field A to 10, B to 20

23
5 – Maintain Field Mapping, Conversion Rules (cont.)

22

Choose target field, click on


icon “assign source field”,
select the source field from
source structure

11

33

24
5 – Maintain Field Mapping, Conversion Rules (cont.)

• You can also define rules for reformatting the data


! e.g., constant, fixed values, translation, prefix, suffix

Sample Conversion Rules

1$A 101 - 200 $ AB ABC $ XABC X


2$B 201 - 300 $ CD PQR $ XPQR
3$C 301 - 400 $ EF
LMN $ XLMN
401 - 999 $ ZZ

Translation Translation Prefix Constant

25
5 – Maintain Field Mapping, Conversion Rules (cont.)

Repeat the field


mapping for all
required fields

26
Step 6 – Maintain Fixed Values, Translations, etc.

• Fixed values
! e.g., company code 0001
• Translations
! e.g. if-then-else formatting
o If source A then target 0010
• User-defined routines
! ABAP coding for more complex custom logic

27
Step 7 – Specify (and Prepare) Source Files

• Required file attributes


! Filename
! Field delimiter (tab)
! Column names

28
Step 8 – Assign Files to Source Structures

• e.g., assign source file C:\XD02.txt to source structure


XD02S

! Almost done! Now we’re ready to perform the data updates!

29
Step 9 – Tell LSMW to Read the Source Data

• LSMW can read the data all at once, or enter transaction


numbers to read specific rows
! Review number of transactions read and written
! Tip: Execute this step for sample records, until finalized

30
Step 10 – Display Read Data

Double-click to
display the field
contents

31
Steps 11/12 – Convert and Display Converted Data

• The step “Convert data” converts the data into R/3 format
! LSMW uses conversion rules to reformat the data per R/3
definitions
! Optionally, you can display the converted data
o View how the source fields are reformatted to target
definitions, with conversion rules

32
11/12 – Convert and Display Converted Data (cont.)

Double-click to
display the field
contents

33
Steps 13/14 – Create and Execute Batch Input

• Create batch input session


! For batch input import technique , BDC session is created
! Run BDC session and review the log (transaction SM35)
! Confirm the updates by reviewing the customer records in
SAP system (transaction XD03)

34
Detailed Instructions Are on Your Take-Home CD

• Step-by-step instructions Wizard


! Multistep process looks cumbersome, but it’s very easy to
learn and use
Note
! Step-by-step wizard makes it easy to understand

• Another option: Record a transaction to use for the load


! Record the SAP transaction, and batch recording acts as a
target structure
! Map source structure/fields to target structure/fields as usual

Detailed step-by-step Instructions document demonstrating


use of LSMW

35
What We’ll Cover …

LSMW overview: what, when, and why

Converting data with LSMW – an example

Getting LSMW up and running at your company

Tips and tricks for getting the most out of LSMW

36
Getting LSMW Up and Running at Your Company

• Find out what LSMW version is relevant for your SAP


release
! WAS 6.20 – LSMW 4.0
! WAS 6.10 – LSMW 3.0
! SAP Release 4.6 – LSMW 1.8
! SAP Release 4.0, 4.5 – LSMW 1.7
! SAP Release 3.0F, 3.1x – LSMW 1.0
• Install LSMW into your SAP system
Where
! Part of standard starting 6.20 to
FIND it
! For other releases, download
o Free from http://service.sap.com/lsmw
! Refer to component BC-SRV-DX-LSM for OSS notes, if required
• Start using it! Transaction code LSMW
37
Getting LSMW Up and Running at Your Company (cont.)

• Introduce LSMW to team members as early as possible


! Hold an LSMW workshop to familiarize team members with
the tool
! LSMW will be useful in many more situations than you think
! It’s extremely fast and easy to learn
o Can learn the tool in less than a day
o Become an expert in couple of days!
• LSMW training suggestions
! No specific training class for LSMW; part of BC420
! Examples on the service marketplace can be used for self-
study
! LSMW workshops by SAP or consulting firms
38
When Do I Need Custom ABAP?

• Most data conversion tasks can be done without ABAP


! More than 60% of data updating tasks can be done by
functional analysts, without any ABAP coding
! With little ABAP, > 80% of conversion tasks can be achieved
• ABAP can be coded right within LSMW
! To specify custom logic for data formatting
o e.g., adjust a material number to conform to custom format
! For conditional processing
o e.g., process records only when a specific condition is
met; otherwise, ignore
o Without this feature, you'd have to clean the data in Excel
first!

39
How Others Are Using LSMW

• Examples from recent upgrade projects


! Updating master data records for specific changes
o e.g., Reorganization of customers
! Updating the dates for orders received in the last few days
o e.g., shipment dates, pricing dates, PO dates
! Material master clean-up
! Post CO-PA-only entries for revenues/costs adjustments
! Post business transactions to test interfaces (like taxware)
! Uploading custom table records
o e.g., quickly upload records, map legacy and SAP fields
! Changing the settings for configuration tables
o e.g., enable logging changes for configuration tables
! Mass changes to security profiles to user master records
40
Key Pitfalls to Avoid with LSMW

• Using LSMW directly in production!


! Test LSMW conversion projects in Dev and QA first
! Do not use LSMW in production environment directly
! Once successfully tested in Dev, export to QA and test again
• Re-using objects from another LSMW blindly!
! Double-check your LSMW objects, especially if you are re-
using existing LSMW objects in other projects
o e.g., recordings, routines
• Using LSMW for small data updates
! Don’t go overboard with LSMW–analyze the alternatives first
o e.g., for updating a handful of customers, you may be
better off with SAP’s MASS function or even manual
updates 41
What We’ll Cover …

LSMW overview: what, when, and why

Converting data with LSMW – an example

Getting LSMW up and running at your company

Tips and tricks for getting the most out of LSMW

42
LSMW Tips and Tricks

• LSMW provides features for logical processing


! Inserting small code in LSMW, you can avoid writing complex
ABAP programs

• Examples of how functional team members can tap into


advanced LSMW features
! If-then-else conditional processing
o Dealing with conditional processing
! Variable number of lines for documents
o Dealing with an unknown number of line items

43
LSMW Tips and Tricks: If-Then-Else Processing

• Scenario – update the records only if the data meets


specific conditions (if-then-else processing)
! For example
o Update record only if the plant in 1000 or 2000
! Typical solution
o Create an input file with rows that meet the specific
conditions
! Drawback
o Preparing the input file is cumbersome
# Prepare an Excel file with all records
# Filter out rows that do not meet criteria
# Save the input file as text file

44
Typical LSMW for VA02 Recording

VA02_REC
Transaction recording
for VA02 transaction

Assign order number


from source data file

Assign item number


from source data file

Assign plant
number from
source data file

45
If-Then-Else Processing (cont.)

• LSMW trick
! Use SKIP_RECORD or TRANSFER_RECORD
o SKIP_RECORD ignores the input record for processing
Solution
o TRANSFER_RECORD forwards the input row for processing
! Create a transaction recording and map fields from source
structure
• Double-click on “Maintain field mapping and rules”
1. Click on Extras
2. Click on Display variant
3. Choose Processing points checkbox
4. Review the _END_OF_RECORD_ section
o By default, coding is set as TRANSFER_RECORD
o Double-click on Coding and write a simple code with
SKIP_RECORD or TRANSFER_RECORD
46
Example: If-Then-Else Processing

47
LSMW Tips and Tricks: Variable Number of Lines

• Scenario
! You want to update all line items for specific sales orders, but
you don’t know how many line items there are
o i.e., there are variable numbers of lines
• Typical solution
! Create an input file with specific sales order numbers and all
line items for those orders
! Drawback:
o You first have to collect all orders and items in a single
file
# e.g., separate SE16 for sales order header table, and
then for order items table for these specific orders

48
Variable Number of Lines (cont.)

• Manual steps involved in preparing input file


11! Prepare a data file with sales order numbers
22! For all these sales order numbers, get the item numbers
33! Use LSMW to update sales order line items

Prepare a file Use LSMW


Input file with
with
with Transaction Recording
Order Numbers and
Sales Order (VA02 using
Item Numbers
Numbers Order and Item Number)
(Use SE16 on VBAP)
11 22 33

Step 2 is the most time-consuming!


49
Variable Number of Lines (cont.)

• Manual steps involved in preparing input file


! Prepare a data file with sales order numbers
! For all these sales order numbers, get the item numbers
Sales Order Item Number
(VBAP-VBELN) (VBAP-POSNR)

11 10001 10
Sales Order 10001 20
(VBAK-VBELN) 22
10001 30
10001 10013 20
10013 10013 30
10013 50
10024
10013 70
10025
10024 20
10025 40
10025 50 50
Variable Number of Lines (cont.)

• Typical LSMW conversion


33

VA02
Transaction
Recording

Assign Order
Number from
Source data file

Assign Item
Number

Change Plant to
1000
51
Variable Number of Lines (cont.)

• LSMW trick
! Use an input file with just sales order numbers
! Within LSMW, loop through the sales order item table (VBAP)
and use TRANFER_RECORD multiple times

SELECT POSNR
INTO VA02_REC-POSNR
FROM VBAP
WHERE VBELN = VA02S-ORDERNO.
TRANSFER_RECORD
ENDSELECT.
Solution
52
Example: Variable Number of Lines

53
Example: Variable Number of Lines (cont.)

54
Example: Variable Number of Lines (cont.)

• How did it work?


! Use input file with just sales order numbers
! The code gets the item numbers and creates data records; it
repeats as many times as there are items for the order
o The code first converts the sales order number in SAP’s
internal format
# SO# 12345 is internally stored as 0000012345
# Use function module
CONVERSION_EXIT_ALPHA_INPUT to convert
o It loops through VBAP table for this sales order
# Gets the item number
# Assigns item number to target VA02_REC-POSNR
# Transfers this data row for further processing
55
Variable Number of Lines – Extended Scenario

• Extended scenario
! You want to update all line items for specific sales orders that
are not shipped yet
• Challenge
! Preparing an input file with sales order and item number
! For example:
o Prepare a data file with sales order numbers (SE16 on
VBAK)
o Based on sales order numbers, get the item numbers
(SE16 on VBAP)
o Based on sales orders and item numbers, get item status
(SE16 on VBUP)
o Prepare an input file with sales order and item numbers
56
LSMW Tips and Tricks: Variable Number of Lines (cont.)

• Manual steps involved in preparing input file


o With specific sales orders and items only
SO# Item No Dlvy
(VBAP- (VBAP- Status
VBELN) POSNR) (VBUP-
Sales Order Item No LFSTA) Sales Order Item No
(VBAP- (VBAP- (VBAP- (VBAP-
VBELN) POSNR) 10001 10 C VBELN) POSNR)
Sales Order
(VBAK- 10001 10 10001 20 B 10001 20
VBELN) 10001 20 10001 30 C 10013 20
10001 10001 30 10013 20 A 10013 50
10013 10013 20 10013 70
10013 30 C
10024 10013 30 10025 50
10013 50 A
10025 10013 50
10013 70 A
10013 70
10024 20 10024 20 C

10025 40 10025 40 C
10025 50 10025 50 B
57
Variable Number of Lines (cont.)

• LSMW trick
! Use an input file with just sales order numbers
! Within LSMW
o Loop through sales order item table (VBAP); get item
numbers
o Find the delivery status from VBUP table
o If delivery status <> complete
# Use TRANSFER_RECORD

Solution

58
Example: Variable Number of Lines (cont.)

59
LSMW Tips and Tricks (cont.)

• Did you know?


! You don’t need developer access to write these small ABAP
routines
! This is one of the advantages of LSMW, even functional
analysts can tweak the processing logic without heavily
relying on ABAPers
• LSMW strengths
! In addition to robust conversion routines, LSMW provides
features for logical data processing
! LSMW can be used in more situations than you think
possible!

60
Resources

• LSMW on the SAP service marketplace


! http://service.sap.com/LSMW
! Detailed information and literature
! Examples and exercises
• OSS component – BC-SRV-DX-LSM
• LSMW papers published by me
! Reduce your reliance on ABAP for Logistics Data Conversion
using LSMW
o In May 2004 issue of SCM Expert
! Mass Changes with LSMW: an Easier Method for Complex
Requirements
o In July 2004 issue of SCM Expert
! Examples with step-by-step instructions 61
7 Key Points to Take Home

• Having visual tools is critical for low-cost SAP upgrades


and maintenance
! Data migration, conversion, and mass updates
! CATT, DXWB, MASS, and LSMW
• LSMW is the most flexible of the bunch
! Comes with over 50 standard load programs for R/3 objects
! Otherwise, create and use your own transaction recording!
• LSMW is free but must be installed into R/3
! Download from service.sap.com/lsmw
• LSMW is run directly in your productive SAP
environment

62
7 Key Points to Take Home (cont.)

• Introduce LSMW to your team as a group


! Start using it for basic conversion tasks to begin with
! Then start replacing ABAP programs with LSMW projects
• LSMW is designed for functional team members
! Lets functional team visually define conversion rules to
reformat and map source data without ABAP
• You will need an ABAPer on hand for more complex
logic
! e.g., retrieving delivery status for the sales orders and
updating plants only when the status is not complete

63
Your Turn!

How to contact me:


Mitresh Kundalia
Mitresh@QSandS.com
64

You might also like