IBM Support

FAQ: Can the translator preserve leading and trailing zeros when generating numeric values? (SCI10958) *|* -5841F90DFF530

Question & Answer


Question

FAQ: Can the translator preserve leading and trailing zeros when generating numeric values? (SCI10958) *|* -5841F90DFF530F4585257918002269FA- *|*

Answer

Technote (FAQ)


Question

FAQ: Can the translator preserve leading and trailing zeros when generating numeric values? (SCI10958)

Answer

The GENTRAN (and GIS/SI) translator by default removes insignificant zeros leading and trailing?from all numeric values.? Insignificant zeros appear before the actual field value (000025) and trail a decimal point (1.00).?


---LEADING---?

For delimited file formats there are three options available for numeric suppression.? These options are available on the 'Delimiters' tab in the Properties for the Output Delimited File Format Object.
Default suppression and padding of leading zero on Numeric values
Leading zeros are suppressed for all values greater than 1. Decimal values less than 1 will retain a single leading zero (e.g. 000.25 --> 0.25).
This is the default selection.
This box is only active on the output side of the map for all EDI types.

Suppress leading zero on Numeric R* format values (e.g. 0.25---> .25)
Same as default behavior except leading zeros are also suppressed on elements that use an R-format numeric and whose value is less than 1.
This box is only active on the output side of the map for all EDI types.

Pad with leading zero on Numeric values (e.g. 25---> 000025) Gentran:Server for Windows 5.0 and higher
Numeric values regardless of format are padded with leading zeros out to the maximum length of the field.
This box is only active on the output side of the map for all EDI types.


---TRAILING---?


If there is a requirement to output a numeric value with trailing zeros after the decimal point the value must be changed to a string and the necessary zeros added to the value.??Below is an example extended rule that will add trailing zeros to a decimal value.

This extended rule will perform the following functions:
1. Convert the numeric value to a?string value using the NTOA Extended Rule Function and store the string value in an extended rule variable
2. Check the string value for a decimal point and add the necessary zeros to the end of the value to format it in the correct decimal format.? The current rule formats the value with two decimal places; the number of decimal places can be changed to the desired number.
3.?Assign the string variable value to a string temporary element?on?the input side of the map?that is linked to an output string field.

Example Rule:

integer dec_pos;? //Position of the Decimal Point
string[15] str_UnitPrice;? //String Variable?for the numeric value
?
dec_pos = 0;
str_UnitPrice = "";

ntoa(#fieldnamestr_UnitPrice);? //Convert the Numeric input value to a string an store it in the str_UnitPrice variable
?
dec_pos = strstr(str_UnitPrice".");? //Find the decimal position and store it in the dec_pos variable

if dec_pos = -1 then????? // -1 return codes signifies the character being searched for in the strstr function was not found
???str_UnitPrice =?str_UnitPrice + ".00";
?
if dec_pos = len(str_UnitPrice) - 1 then
?? str_UnitPrice = str_UnitPrice + "0";
?
if dec_pos = len(str_UnitPrice)? then
?? str_UnitPrice = str_UnitPrice + "00";
?
#tempstringfield = str_UnitPrice;

?
Note:? The field/element that?the?tempstringfield?element is linked to?MUST be a string to?keep the .00 on the output value

Please?see the Application Integration Users Guide for more information on the NTOA function.

Cross reference information
SegmentProductComponentPlatformVersionEdition
CommerceSterling Gentran:Server for Microsoft WindowsMapping and Translation

Historical Number

PRI327

Product Alias/Synonym

Fact


Translation
Map Editor
Gentran Integration Suite All Releases

Gentran:Server for Windows All Releases
SCI10958


Goal


FAQ: Can the translator preserve leading and trailing zeros when generating
numeric values?

[{"Business Unit":{"code":"BU055","label":"Cognitive Applications"},"Product":{"code":"SS73G6","label":"Sterling Total Payments for Financial Services"},"Component":"","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"All Versions","Edition":"","Line of Business":{"code":"","label":""}}]

Document Information

Modified date:
12 October 2021

UID

ibm10766575