Data Transformation Engine Functions and Expressions Reference Guide

Chapter 3 - Function Reference TEXTTOBCD
Functions and Expressions Reference Guide
201
TEXTTOBCD
The TEXTTOBCD function converts a text item from decimal digits to BCD (Binary
Coded Decimal) format.
Syntax
TEXTTOBCD ( single-integer-text-expression )
Meaning
TEXTTOBCD ( text_to_be_converted )
Returns
This function returns a single-BCD-formatted-text-item.
TEXTTOBCD converts text_to_be_converted (which consists of decimal digits)
to BCD format. In this format, each byte contains two decimal digits
represented as binary numbers. If there is an odd number of decimal digits in
the input, the high-order half-byte of the leftmost output byte will contain the
decimal value 15 (hex "F").
If anything other than a decimal digit is encountered in the input,
TEXTTOBCD
returns NONE.
Examples
TEXTTOBCD ( "1234" ) returns the hex value x’1234’.
TEXTTOBCD ( "123" ) returns the hex value x’F123’.
TEXTTOBCD ( "123A" ) returns NONE.
The values shown as input (for example, "123") are meant to represent
character items in whatever character set is native to the machine on which
the map is running. On a PC, "123" would contain the ASCII characters for the
digits, that have the HEX values "31", "32", and "33". The output, described as
"the HEX value "F123"", consists of the two binary bytes "F1" and "23".
Note On an IBM mainframe the input string would contain EBCDIC characters for the
digits which have the hex values "F1", "F2", "F3", , but the output would be
the same as the PC output.