In data migration testing, we can come across a situation where the records which are being created as per the file provided by the client, later on can be irrelevant from the functional point of view. So what to do now? Will we have to delete them manually? The answer to this problem lies in this blog post.
During the testing phase of LSMW for BOM Header + Component creation in the SAP system, some duplicate records with wrong mapping were posted. The same records were filtered in the Data File (received excel file for migration) and we were asked to upload the same file once again with new data, deleting all the records (Number of Records were around 1.1 Lacs)
Initially we thought to create a recording passing all relevant source fields. But the execution time was so much high that it resulted as a performance issue and the same was not at all desired from technical/functional perspective, so we came with the below solution as mentioned in this blog post.
In this blog post you will learn the procedure to delete all the BOM (Bill of Material) Components from the SAP system in very less period of time by using 3 Functional Modules.
Expectation and benefits
- The system integration is not at all affected.
- It does not affect the details of the header material, only deletes the BOM Components.
- Execution time for around 10,000 headers consisting of multiple Components is around 15 minutes.
Techno functional knowledge of both the Bill of Material component creation and to write LSMW code.
Legacy System Migration Work Bench (LSMW)
Legacy System Migration Workbench (LSMW) is handy tool for data uploads. In most of the big projects there is a separate development / data migration team is available. However, at times, it would be responsibility of the functional consultant to load the data such as vendor master, customer master and asset master etc. It would be real handy for a functional consultant to know LSMW (at least recording method) and it would help them to successfully complete the task.
High Level Steps to delete BOM Components.
The following are the high level steps that are necessary for the deletion of Bill of Material Components from the system.
- Create a LSMW through T-Code ‘LSMW’.
- Call the SE38 T-code via Recording.
- Maintain the source Fields.
- Declare all the necessary global Variables in the __GLOBAL_DATA__.
- Call the FM’s in the ‘__BEGIN_OF_TRANSACTION__’.
- Specify the files in the same format as in maintained in the Source Field Structure, then Assign the same file.
- Read Data.
- Lastly, Convert Data.
- For testing purpose you can test for a single record in Convert data step.
- Check if the Components are deleted through the T-Code ‘CS03’.
The following are the steps for the deletion of Bill of Material Components from the system.
- Go to Transaction LSMW.
- Create the object, subproject and object as below and then press enter.
3.Go to ‘Maintain Object Attributes’. And the press Ctrl + F1 and then create a recording ‘DUMMY’ (DUMMY stands here that the recording will not be executed and as per the LSMW requirement in the first step, we have to provide a method that we are going to use to just fulfil the first mandatory step of LSMW;
4. Maintain the source structure.
5. Maintain Source Fields as follow or you can modify it as per requirement.
6. Maintain the Structure Relations.
7. In Maintain Field Mapping and Conversion Rules tab, write the code as follow: In global data you will declare all the internal table, work areas, constants etc.
8. In the __BEGIN_OF_TRANSACTION__ write the following Code:
Calling the Function Module ‘CSAP_MAT_BOM_OPEN’ and passing the values as follow:
Then Loop the above internal Table IT_STPO into its WorkArea
And call the Function Module ‘CSAP_BOM_ITEM_MAINTAIN’ to Delete the Components :
After the Endloop Call the Function Module ‘CSAP_MAT_BOM_CLOSE’ to close the BOM:
9. Specify the file in the ‘Specify Files’ in the same format as in maintained in the Structure of ‘Source Field’.
10. Assign the File.
11. Read the Data
12. CONVERT THE DATA.
Corresponding to the header BOM, all its corresponding components are deleted, resulting in saving time to manually delete the same, due to which the Data Migration consultant can experiment at the time of testing and creating LSMW to migrate the BOM component data in development and testing system.
Please excuse for the naming convention used; you can use as per the standards maintained in your project.
For any issues, improvements, additions or any other concerns, please feel free to contact me.
I look forward for your feedback and suggestions.
Keep learning!! Keep improving!!