How to find a validating function in SAP

Jimbo's picture

Many times it becomes necessary to rely on SAP's functions to validate source data. The optimal place to validate source data tends to be in the target system that the data will be loaded.

Some examples of source data that can be validated using ABAP functions written by SAP include dates, postal codes and tax jurisdictions. A little bit of know-how and the right function can save hours of effort and reporting by ensuring that source data is correct before attempting to load in SAP.

Start by identifying the source data to be validated. For this example the format of date values in source data will be validated.

Launch the Function Builder transaction (SE37). This transaction is used for creating, editing and testing functions. An easy way to find the desired function is to search for functions that contain the word "check". Press the "F4" key and then click the "Information System" button. In Find Function Modules window, type *check*. Blank the "Maximum No. of Hits" field and press the "Enter" key.

After a short wait the system will present a list of all the functions that contain the word "check" in the name. This list will be too long to search manually, but it is possible to search again within this list. Click the search button and search in this list for a word that represents the value to be validated. In the case of this example the date is being validated. Be sure to change the "Cancel search after hits:" field to 999.

A filtered list appears with far fewer possible entries. A quick search leads to a function with a name that sounds like it might be the correct function, but only testing will ensure that it is. Select this function in this window and in previous windows until it populates the field in Function Builder: Initial Screen.

Testing the function will require some experimentation. For a date validation function, simply providing a test date in different formats is enough to ensure that it works. For more complex functions more testing is required and the first function selected from the list may not be the right one.

Seldom is enough documentation provided in SE37. Fortunately, it is possible to see how the original programmers used a function.

For an example of how the function is called, click the "Where Used" button in the Function Builder: Initial Screen. Be sure that "Programs" is checked and press enter.

Double click on a function to display the sample code where the function is used. Copy this code into the LSMW object where it is required. In most cases a simple check to ensure that sy-subrc is equal to zero when a test is performed is enough to ensure that the source data is correct. In some cases additional checks may be required.