Wednesday, November 3, 2010

Validations in LSMW

Requirement: Validation in LSMW. Here we are taking a simple example to change the customer telephone number. Do the validation in LSMW to check whether the provided customer is valid or not. We will handle the Validations in 5th step (Maintain field mapping and conversion rules) of LSMW. If the customer is invalid collect the record to the error internal table and skip the further processing of the record. Download all the error customers into an excel file once the conversion of the all the customers is done. This example mainly will help you to write the custom code in LSMW.

Create the Project, Subproject and Object in the LSMW Transaction.

1. Maintain Object Attributes

Do the recording to change the customer telephone number.

2. Maintain Source Structures

Create the source structure - CUST_DETAILS

3. Maintain Source Fields

Maintain the source fields as per the input file. Here we are taking only Customer and Telephone number as our flat file contains only those two fields shown blow.

4. Maintain Structure Relations

5. Maintain Field Mapping and Conversion Rules

We will do the validation in this step. Execute this step. Go to the change mode.

Click on the button (layout) and select all the check boxes.

Double click on Global Data (this block is like Global data in normal ABAP programs), will get an ABAP editor. Declare the required fields and Internal tables here as shown below.

Validate the customer:

Double click on BEGIN_OF_TRANSACTION block (this block will trigger for every new transaction), and write the validation code as shown below.

We can validate the given customer by checking the table KNA1. If the customer is invalid, then append the Customer to the error internal table with appropriate message. Skip further execution of the record using the Global function skip_transaction (Insert->Global Function-> skip_transaction). This statement will skip the current record and goes to the next record.

Download the Error records:

Double click on the END_OF_PROCESSING block (this block will trigger after conversion of all the transactions), and write the code to download and display the error records as shown below.

The error records will download to the specified file path when we execute the convert data step and same will be displayed.

6. Specify Files

Specify the input file

7. Assign Files

Assign the file and save.

8. Read Data

Execute the read data step to read the input file data.

9. Display Read Data [optional]

10. Convert Data

The validations will take place when we execute the convert data step. The error records will download to the specified file path if there any and same will be displayed here as shown below.

And the snap shot downloaded excel wile is

11) Further continue with the processing (Create batch input session and Run batch input Session) to update the valid customers.

No comments:

Tutorials on SAP-ABAP

Adobe Interactive Forms Tutorials

Business Server Pages (BSP)


Web Dynpro for ABAP (Step by step procedure for web dynpro,Tutorials on Web Dynpro,)

ALV Tutorials

Blog Archive