Reduce Development Time By Validating Source Data Directly Into LSMW Fields
Failing to validate data and report issues has caused catastrophic results for many SAP implementations. Simply checking to see if source data matches internal SAP tables allows migration specialists to report issues prior to loading and provides a great way to affect necessary customizations and changes to source data.
In this example, a simple recording-based LSMW object was required so that the team can touch the KONDM field (pricing group). It took just 5 minutes to write enough ABAP code to ensure that the material exists, is extended to the sales organization and the distribution channel and that the pricing group in the source data exists in SAP.
No variables were defined, but instead, each SELECT
statement populates fields in the MM02K structure created by the recording. By obviating the need to define structures and variables, the development time was greatly improved.
When the target structure in LSMW has field names that match the fields in a transparent table, multiple fields can be populated at once by adding INTO CORRESPONDING FIELDS OF
to the SELECT
statement. See the code below for a simple example of selecting many fields from the table holding Material Sales Organization data into the target LSMW structure.
shift MM02S-MATNR right deleting trailing space. overlay MM02S-MATNR with '000000000000000000'. select single MATNR VKORG VTWEG KONDM from MVKE into "lMVKE corresponding fields of MM02K where MATNR eq MM02S-MATNR and VKORG eq MM02S-VKORG and VTWEG eq MM02S-VTWEG. if sy-subrc ne 0. write: / MM02S-MATNR color col_negative, MM02S-VKORG, MM02S-VTWEG, 'Material not extended to sales org/dist channel.'. skip_transaction. else. if MM02K-KONDM eq MM02S-KONDM. write: / MM02S-MATNR color col_positive, MM02S-VKORG, MM02S-VTWEG, 'Pricing group already set to', MM02S-KONDM. skip_transaction. else. select single KONDM from T178 into MM02K-KONDM where KONDM eq MM02S-KONDM. if sy-subrc ne 0. write: / MM02S-MATNR, MM02S-KONDM color col_positive, 'Price condition is invalid.'. skip_transaction. endif. endif. endif.