Altova MapForce 2022 Enterprise Edition

Preserving Leading Zeros During Conversion

Home Prev Top Next

In the TRADACOMS specification, the data type of the TRDT-1 and TRDT-2 (Date and Time of Transmission) data elements is defined as "decimal". This means that, by default, when you map data from the TRDT-1 or TRDT-2 fields, any leading zeros in these fields would be trimmed during conversion, and thus produce undesired results. This may also be the case of any other items which are defined as "decimal", but store values which are meant to be treated as string.


You can instruct MapForce to treat numeric fields as string (and thus preserve the leading zeros) by applying the core | format-number MapForce function. In the following example, the value of the TRDT-1 item in the source file is "020312". The normal output of this item would be "20312" (as a result of conversion to decimal), which is not the desired result. Therefore, to keep the leading zero, the format-number function has been added to the mapping.


Preserving leading zeros with the format-number function

As illustrated above, the function has the following two input arguments:


1.The value to be formatted (in this case, "020312").

2.The format mask "000000".


To test the output of the function, this example uses a simple output component (see Simple Output ). When you click the Output button, the output of the mapping (which is the same as the result of the function) is "020312", as intended.

© 2016-2022 Altova GmbH