Automatic processing of data using BDC , LSMW
I have been thinking of writing this post for a long time as not many people in SRM make use of LSMW and other similar technologies for enabling faster upload of data . I have tried to include here some of my understanding of what LSMW is and how it is different from the other BDC which enables both recording and generation of an ABAP code using the recording .
There is always a question if LSMW is available for SRM as well for which we need to understand that all SAP releases have this functionality and since a very long time SAP system releases (as of SAP Web AS 6.20) have LSMW as an ‘integrated’ solution . Thus, no need to install an LSMW as add-on because it is already available in the system.
We just need to try using Tcode LSMW to be able to use it .
Try IT My recommendation is whether you are Technical or not this has got nothing to do with it . There are a set of 14 steps initially to be followed without doing ANY coding which you need to follow to be able to automate your tasks .
Why LSMW : We can use LSMW for a good amount of upload of data by just uploading the file and the system automatically processes it in the correct format and stores at the relevant place.
- It is faster and more reliable and very less efforts needed to setup the structure of your LSMW
- For transfer of data from Legacy to SAP R/3 as a one time activity during initial setup
- Periodic data transfer or upload of data
- No coding at all just basic Configuration steps
How it can be used
– IT can be used for filling data in standard Tcodes
– It can be used for Updating ZTables
– It can be used for filling data when you know the FM to do automatic approval for multiple documents
– It may also come in handy when we have to run FM which do not accept multiple values in one go .
A similar approach like LSMW is the BDC called via Tcode SHDB and just create a new recording to get started. This helps to map the new recording correctly
Difference b/w LSMW and BDC : LSMW is mainly for uploading the file BUT one has to manually execute each step as shown below to carry out the automatic changes in system
BDC is used to put the recording into a program via automatic code so that an end user be able to do the same . (Generally an end user finds it difficult to get past all the steps of LSMW ).
I have an example below for LSMW steps used in an Implementation of SRM projects where the client wanted the vendors to be extended to another purchasing org .
Create LSMW :
We have these 14 steps primarily
Step1 : Maintain object attributes Select the button to record your steps . I am using Ztable to fill the data
which has 4 fields Vendor , Pur Org , Ref vendor , Ref pur org .
After you finish your recording I used it for a Ztable we have to use Tcode SM30 to enter the data in via table entry
After you click on ‘Default all’ you would see the fields are automatically recognized .Now select this recording via the search help Do not type it .
Now select this recording via the search help Do not type it .
Step 2 : Maintain Source Structures
Create a new one as shown below
Step 3 : Maintain source fields we are filling in 4 fields at the first screen which helps in populating data in the table.
We add all 4 fields as shown below to map them to the source structure
Vendor number , Vendor new Org , Vendor reference number , Vendor old Org .
Step 4 : Maintain Structure Relations : Nothing to be done in this step just check the source gets mapped correctly
Step 5 : Map all the source fields created above by the correct numbers
By clicking on the source fields it would show the filed which we created in Step 3 mark them to the fields shown here . These will be the fields which will be used to pass the data based on which the new entries would be created in the table
Step 6 : Maintain Fixed Values, Translations, User-Defined Routines
Nothing to be done
Step 7 : Specify Files
We specify the way In which we shall be uploading the data which means we can either upload using a R/3 server or on the PC or some other options available as you can see below .I prefer to use a file created on my desktop to be used for running LSMW .
We would see the file uploaded correctly with all the data as shown below
Step 8 :Assign Files
Check if the file is shown here automatically if not then we need to Click on change and then create assignment , But ideally it should come on its own .
Step 9 Read Data
When we execute this line it gives a POP UP as shown it will give you the number
Of entries it can find in the program . I had only 1 entry so it reads that .
We are doing a trial with 1 entry and if it works we can upload multiple entries via file upload .
The number of entry shown here is same as what has been uploaded via the file .
Step 10 : Display Read Data
When you have seen the number of records and validated them then we would want the system to read the data now and see if it has read correctly . Double click on the line and you would see if the data has been set up correctly in the corresponding fields .
Double click on the line above which has contents ..Ensure the fields are coming up correctly against the different structures .
Step 11 Convert DATA :
Execute the Tcode below to convert the data a next screen would show the summary of the data converted which should ideally be equal to the number of records .
Step 12: Display Converted data
Now we can display the converted data
Step 13 : Create Batch Input Session execute the below to generate a batch input session .
Step 14: Run Batch input session Find the list of batch input sessions and identify your own one and click on process
After a while you can select the entry and click on Log to check the result , and then display to check hwo many vendors have been replicated or if any went into error status .
Go back and click again and you would see the entries have been created in the Table in SM30 …
Check the logs and see the number of success entries error etc would be shown .
Want to delete the LSMW ?
1. Goto >> Administration
2. Select your entry and click on Delete .
Hope it is found useful .
Now we can try creating another program using SHDB which is the BDC technique this however requires some basic level of coding technique to be able to
create a program but is also easy enough .
Everyone must have used the Tcode SW01 while testing to approve documents from backend
to be able to do the job quickly I have prepared an easy to use BDC program.
Create a recording for approving All PO using SWO1 Tcode by entering the GUID of the PO and clicking on the method SET_RELEASED.
Below shows the recording which has been created for the SWO1 Tcode by passing the GUID .
We ask the user to pass the PO number here as input by the user as seen in the selection screen below
– Based on which the GUID would be selected from the CRMD_ORDERADM_H table .
SELECT GUID OBJECT_ID from CRMD_ORDERADM_H INTO TABLE GT_GUID
WHERE OBJECT_ID in SO_PO
– Now check for this line Open_group and create a LOOP entry to carry out the recording for each GUID one after the other .
LOOP AT GT_guid into wa_guid.
– Remember to replace the hardcoded GUID value from the recording and replace it with the value which you are passing .
perform bdc_field using ‘OBJID-VALUE(01)’
– Now check for this line close_group and just before that ENDLOOP entry should be there
Now we can execute this program by passing the PO number and get it approved .
Instead of doing this activity repeatedly using SWO1 we can take the list and Pass it by the PO number to help do the job quickly .
There could be numerous other ways this could be used .Sorry for the long document I hope some one tried these technologies out with the help of my document .
EDIT 8th June
Some error messages I came across and how to fix them
- LSMW error related to File Name converted Data Max 45 characters (Remaining data saved) Reduce the file name in the section Converted Data and Imported data to a smaller length and the error would disappear
2. Error ‘Specify Files first’
The error can be fixed by placing the file in the desktop and ensuring the file format option as shown in step is followed
Good read :
LSMW for Functional Consultants in simple step-by-step way
Thank you for the detailed information.
I would have a question though. Is it possible or recommended to use LSMW in operations related to POs with multiple lines?