I want to remove the zeros after the decimal point and display
Input 123.111 → Display 123.111
Input 123.000 → Display 123
As Sergio said, the easiest way is using a replace method. You can also verify your variable/attribute before using the replace.
if &your_variable.ToString().EndsWith(".000")
&your_variable.ToString().replace(".000", "")
endif
Remember that if &your_variable is Numeric you will have to convert it to string, since the replace method takes a Char, LongVarChar or VarChar data type as parameter.
The easiest way to do this is to use a string replace.
Here is the documentation: https://wiki.genexus.com/commwiki/servlet/wiki?12710,Replace+method
An example would be:
&String1 = '123.000' &String2 = &String1.Replace('.000', '')
If you are starting with a numeric variable, for example, N(10,3), then convert it to a string first: &String1 = &Numeric1.ToString().Trim()
One option is to assign the variable with decimals into a variable without decimals
Example:
&aux2 = 3.2 // &aux2 is defined as Numeric 4.2
&aux3 = &aux2 // &aux3 is defined as Numeric 4
Result: &aux3 = 3
A second option is to use the round function
Example:
&aux2 = 3.2 // &aux2 is defined as Numeric 4.2
&aux2.round(0)
Result: &aux2 = 3.00