SAP Knowledge Base Article - Public

2400323 - How to convert a number value into a String

Symptom

Sometimes costumer may need to use a number like the year in a document or any other string field in the UI. For this, the costumer uses the business rule engine to retrieve the information and save in the field he will use. But if he uses a number field he is getting 2,016 instead of 2016.

Reproducing the Issue

  1. Generate the document as PDF, and observe that the year was printed as 2,016;
  2. Access the UI and see that the number field is being displayed with a comma;

Cause

This occurs, because when using a numeric field you are assuming the format of numbers, which means that for any number above 999 you'll get a comma E.G: 1,000, 1,001, and so on.

This is a normal behavior for numeric fields.

To solve this, you need to store your data in a string field, but when you change the property of the field to string in your business rule you will see for example that some function are not available.

Resolution

One way to solve this is using the format() function.

  1. Take this rule as an example:

image.jpg

  1. If you change the field genericNumber1 to genericString1 you'll see that this function Year of Date() is not available;

image2.jpg

  1. To solve this, you can use the format() function;

image3.jpg

  1. In the format function you have to select a template, in this case you want a text so you select text;

image4.jpg

  1. When you select text a box will be enabled, there you put %s (this will tells the system that the value should be converted to text).

image5.jpg

  1. The argument field will tell wich value you want to convert, and in this field you can select now any function including the Year of date;

image6.jpg

Tha same logic works if you want con concatenate more than one values, in this case, just remember then for each argument you need to specify the type of conversion as in step 5 E.G: %s - %s - %s (receives three arguments, converts to string and display like text - text - text).

Keywords

Convert number to String using business rule; Type format using business rule; Number being displayed with comma; , KBA , LOD-SF-EC-BCI , Manage Business Configuration (BCUI) & Data Models (XML) , LOD-SF-EC , Employee Central , How To

Product

SAP S/4HANA Cloud Public Edition all versions