ABAP Numeric Check in SAP HANA

In any ERP system such as SAP which interacts with users and other integrated systems need certain checks to validate the data flowing to the system. The validations could be master data validation, data type validation or other custom validations. Numeric check falls under the category data type validation. Applications can use numeric or number validation to filter out garbage data or invalid data inputted into the system.

Use Cases of ABAP Numeric Check

We need to implement data cleansing logic and validations such as ABAP numeric check when,

  1. Users input data manually to SAP applications.
  2. File-based upload programs used to import data.
  3. Inbound interfaces transfer legacy system data information to ABAP programs, BAPIs, and iDocs.

In these data upload or transmission procedures, we need to validate the input data values. Numeric data fields should not contain other data values such as alphanumeric, boolean or string values. If the correct data type is not passed to SAP applications, it could result in inconsistencies in the application behavior or even short dumps in the SAP system.

Use case 1 of Numeric Validation

For example, let’s assume we have an inbound proxy interface that calls a BAPI that creates invoices in SAP. The invoice amount should be a numeric or decimal value in the correct format. If the ABAP processing logic does not validate the input data of the amount field of the inbound proxy, proxy will pass an incorrect value to the amount field of the BAPI. Hence, the interface processing will end up with a short dump. 

Use case 2 of Numeric Check

If you have an ABAP program to create sales orders in SAP via an Excel or file-based upload program, you must validate the sales order quantity values transferred from Excel file before calling the sales order creation BDC or BAPI. quantity of the sales order cannot be alphanumeric, and it should be an integer value.

Therefore, the first stage of the upload program should be to validate the data elements of the Excel file. ABAP upload program can use either the application log or the output of the ABAP program to log the invalid data values identified by the validation.

Different Number Formats

Globally, we use different number formats based on the region. While North American countries use comma (,) as the thousand separators, Norway uses the decimal point (.) as the thousand separators.

For example, the value represented as 5.321.978.693,000 in Norway is essentially the same as 5,321,978,693.00 in the United States.

Both of these values represent the same numeric value. Hence, it is important to understand numeric check validation should also take into consideration the number format of the input.

Different Methods to Perform Numeric Validation in SAP

In SAP we have a couple of methods to perform the numeric data validation. As we discussed before, the data validation method you pick should match the requirement you have.

Is it a simple integer check? Or Should the ABAP logic also validate the number format of the input data?

The numeric check in SAP can be performed using,

  • Standard Function Module NUMERIC_CHECK or,
  • A custom ABAP logic using keywords CN or CO

Standard Function Module NUMERIC_CHECK

Function Module (FM) validates if the input is an integer value or not. You can only validate whole numbers using this function. Hence, using this function module you cannot validate numbers in different formats with decimal values or thousand separators. This is one of the disadvantages of NUMERIC_CHECK function module. 

FM accepts values through input parameter STRING_IN and returns the data type of the input using export parameter HTYPE. Data type output can be either CHAR or NUMC which are self-explanatory.

The behavior of NUMERIC_CHECK FM

Let’s look at some examples of how the function modules behave for different inputs such as integers, decimals, thousand separated values, alphanumeric values, etc.

Integer or Number Values

Integer values are correctly identified as numbers by the FM.

Decimal Values

Decimal inputs are still identified as CHAR.

behavior of NUMERIC_CHECK FM in SAP for decimal input
The behavior of NUMERIC_CHECK FM for decimal input

Thousand Separated Values

Thousand separated values also cannot be identified as numeric values using the FM NUMERIC_CHECK.

Behavior of NUMERIC_CHECK FM for thousand seperated Input
The behavior of NUMERIC_CHECK FM for thousand separated Input

String and Alphanumeric Values

Alphanumeric or string values can be validated using the NUMERIC_CHECK FM.

Behavior of NUMERIC_CHECK FM for string or alphanumeric Input
The behavior of NUMERIC_CHECK FM for alphanumeric input

Based on the above analysis of the behavior of FM NUMERIC_CHECK, we can conclude that the usability of the FM for numeric validation is limited to only certain cases. However, NUMERIC_CHECK FM can certainly identify if the value contains only numbers or not. Also, you can do a negative validation using the FM.

Hence, in most of the custom ABAP programs, you might need to build your own logic to validate numeric values.

ABAP Keyword CN and CO

Keywords CO and CN come in really handy when it comes to validating input data.

CO – Contains Only

Syntax of CO: <Parameter 1> CO <Parameter 2>

Keyword CO (Contains Only) compares two values and output Boolean values true or false. If the first parameter only contains characters from the second parameter, return output would be true. The function CO takes case-sensitivity of the parameters when comparing them.

ABAP Program using Keyword CO

Now let’s test the program for different input types such as integer, decimal, and alphanumeric values.

Integer validation using ABAP keyword CO
Decimal validation using ABAP keyword CO
Alphanumeric validation using ABAP keyword CO

But what if you enter a value such as 20.20.20? The validation fails!

Negative test case

CN – Contain Not Only

Syntax of CN: <Parameter 1> CN <Parameter 2>

Keyword CN is the negative function of CO. The function CN returns the Boolean value true if the CO expression is false.

The behavior of this ABAP program is similar to the program I have built using keyword Contains Only (CO)

ABAP Program to Validate Numbers and Decimal Values

I have developed this ABAP program to validate numeric and decimal values without a thousand separator. The first step of the validation is to check if there are repeating decimal points in the input value. Then using ABAP keyword CO, I have validated if the input only contains numeric values.

Numeric Check ABAP program validates multiple decimal points

I have made use of the ABAP keyword COUNT to validate if there are multiple decimal points in the input value.

Using the above methods use should be able to build your own ABAP logic in SAP application to check if a value contains only numbers or a decimal numeric value.

If you have any questions on these numeric validation methods, please leave a comment below.


These are some of the tech gadgets I use every day. If you make a purchase through these links I will earn a small comission at absolutely no extra cost to you.

3 thoughts on “ABAP Numeric Check in SAP HANA

  1. Elias Kekakos says:

    Very good thanks. But we must find a way to to transfer the 3.000.000,65 to 3000000.65.
    I am trying to find a sort way.

Leave a Reply

Your email address will not be published. Required fields are marked *