Skip to Content
Author's profile photo Vijay Sharma

Data Processing Using ABAP code in LSMW

Data Processing Using ABAP code in LSMW

Before heading towards where and how we can process data using ABAP code I will explain in brief about data migration steps and where LSMW fits in it. Sounds boring, isn’t it!!!

 But will be helpful to those who are new to data migration and LSMW.

Let’s start!!!!

Data Migration

It’s a process to transfer data from Legacy System to SAP.

Data Migration Steps

  • Analyze the data to be Migrated
  • Create field mapping for legacy to SAP fields
  • Extract the Legacy data
  • Transform the Legacy data to SAP format
  • Load Transformed data to SAP
  • Validate the Data Loaded.

In this wiki we will focus on Data load step and specifically to LSMW.

Data Loading Techniques:

There are number of techniques that can be used to load data to SAP each having its benefits and limitations. Some of those loading methods are like:

  • IDOC
  • BDC
  • LSMW
  • Function Module/BAPI etc.


LSMW stands for Legacy System Migration Workbench. It’s migration tool provided by SAP only and Transaction for the same is ‘LSMW’.

Now after this I am assuming that who so ever is reading this doc is aware of the basic LSMW steps.

Now while migrating data many times we come across data we have in load file from legacy is not as required to be loaded in SAP or sometimes we need to apply logic to get the required data. For that a place is required where we can write a code to apply that logic.

Now the question comes, can we write code in LSMW? And the answer is Yes….

Various programming areas are available within the field mapping step in LSMW to customize the data that goes into the R/3 target format.


imageYou will be able to code in any of there areas just by double clicking on it as shown in screen shot below.


These processing areas are not visible by default. You need to activate these areas by selecting the required processing area from Extras->Layout option as shown below.





Global_data – Allows you to declare global variables that can be used across all the forms within the object

Begin_of_processing, End_of_processing – These code areas allow for writing custom code before and after the migration of the data. Each of these blocks are called once during the program run.

Begin_of_transaction, End_of_transaction – These code areas allow for writing custom code before and after the migration of each object. For eg, for each PO that is migrated, you can update to a z table in the End_of_transaction.

Begin_of_record, End_of_record – These are for the custom routines before and after the conversion rules at each structure level. For eg, end_of_record can be used to call ‘transfer_record’ as many times as the particular structure is required to be inserted.

Form_routines – Custom subroutines can be coded here

Some Important Global Variables and Functions that can be used inside these areas :




Screen shot below gives example of code written in End_Of_Record processing area.



Hope this doc will give you confidence to write code in LSMW….

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Sandra Rossi
      Sandra Rossi
      Thx for the blog. Just one word about the display of events and code: by default, it is not shown, you have to activate this option by choosing menu Extras and Layout
      Author's profile photo Vijay Sharma
      Vijay Sharma
      Blog Post Author
      Thanks for the feedback.Don't know how i missed it. Added it now.
      Author's profile photo Former Member
      Former Member
      Interesting, to the point and helpful post!
      Author's profile photo Monica Singhal
      Monica Singhal
      very nice and helpfull for the beginners
      Author's profile photo Vijay Sharma
      Vijay Sharma
      Blog Post Author
      Thanks Monica!!