SAP - LSMW – Including custom developments
In this step, you configure the basic attributes of data load – e.g. one time or periodic data transfer, which object to load (Vendor Master, Material Master) and its method. SAP provides all the fundamental objects and their associated programs either Direct Input or Batch Input.
In few objects, one or more options may be available and you may need to choose which one to go for. Further, ‘Intermediate Document’ (Idoc) may also be used. If the R/3 System does not provide any suitable batch or direct input program, you can use the batch input recorder to create a user-specific class of migration objects. You can also create your own custom program in customer name space and assign it in the first option ‘Standard Batch/Direct Input’.
To Include custom development into LSMW 3 main actions need to be taken
- Creation of the target structures as structures in the Data Dictionary
- Updating SAP tables SXDA0, SXDA1, SXDA2 and SXDA3.
- Adapting the ABAP development
Creation of target structures
Go to SE11 to create the target structures. These will be similar to the input structures, but don’t forget to add the following to fields in front of the structure, STYPE (containing the record identifier) and REC_LINK(containing the unique identifier of the structure).
This is necessary because only one file will be delivered to the custom program, even in the case of several input files. The linking of different files will be done in the read step.
Updating SXDA SAP tables
If you want to upload any custom table(also for standard update) using custom programs, you need to update SXDA tables. Go to SM30
Step 1 - Maintain table SXDA0.
If you dont find any appropriate Object then you can create an object by simply entering the number(agree on a number range for the custom programs, for example from 900 to 999) and short text.
- DX Type, you can specify which type you would like to use the custom program. For eg – if you want to directly use UPDATE/INSERT/MODIFY commands or a BAPI in your program to load data to your custom tables then specify S or D (Standard Batch/Direct Input).
Step 2 - Maintain table SXDA1.
Enter the Object you created in above step and provide a number to the DX sub cat. Provide proper text and the DX program you created. You just need a program name created and you can write the code later. Program Type B(Batch Input) or D(Direct Input).
Maintain the same program name in the last column – Program also with Active checked.
Step 3 – Maintain table SXDA2.
If you use flat structure and use direct input method using UPDATE/INSERT/MODIFY commands to upload the data then you can specify structure of data you get from the file. You need to create the structure in Data Dictionary(SE11) first with the same structure as the flat file.
Your first field should always be STYPE (Data Element STYPE_BI)
But if you want to use Batch Input programming in your custom program (CALL TRANSACTION or BDC SESSIONS) then you need to have the file Item 1 with Structure BGR00 as Parent Segment and Mandatory Segment. Please have Active flag checked also.
and you need to have Item 2 with Structure as you flat file structure and Parent Segment referring to BGR00.
Check for example object 050 (customer master) on how to fill the different fields
Step 4 – Maintain table SXDA3.
If Direct Input method is being used then you need one entry with your Object, Sub Cat, Item = 1, Table name = Structure of your flat file specified while maintaining SXDA2.
If you are using Batch Input method then you need 2 entries
Item = 1, Table Name - BGR00 Field Name – GROUP
Item = 1, Table Name - BGR00 Field Name – STYPE
Item = 2, Table Name = Structure of your flat file specified while maintaining SXDA2, Field Name – STYPE.
Note – If your flat file structure contains more levels of data then you would need a REC_LINK to uniquely identify the lines related to one header line in different files. In such a case you need to maintain the SXDA3 table with all the structures and field name STYPE.
For eg – You get 2 different files from external systems and Project ID is the key. You would need a REC_LINK field which has unique value in the first file(HEADER).
and you have another file which has this REC_LINK and say multiple members assigned to the project.
You would have to maintain the SXDA3 with one more entry ITEM = 3 and the structure (same as that of the file) created via SE11.
Adaptations in the ABAP program
Build a program that expects a simple file with different record identifiers, the file path can be found in table /SAPDMC/LSOFIL (field file_conv)
Following code can be used to get the filenames
IMPORT /SAPDMC/LSMEMORY FROM MEMORY ID '/SAPDMC/LSMW'.
Call function '/SAPDMC/LSM_FILE_INFO_GET'
PROJECT = /SAPDMC/LSMEMORY-project
SUBPROJ = /SAPDMC/LSMEMORY-subproj
OBJECT = /SAPDMC/LSMEMORY-object
X_ONLY_USED_FILES = 'X'
* FILE_READ =
* PATH_CONV_LOG =
* FILE_CONV_LOG =
NO_SUCH_OBJECT = 1
OTHERS = 2.