These functions help you perform basic formatting actions on the output data.
Expands each byte of character data into the ASCII hexadecimal equivalent. If reverse mode is selected, the filter converts hexadecimal data to character data.
None.
Data:
935-0488,charHexConv()
Results in:
3933352D30343838
Data:
536D697468, charHexConv()
Results in:
Smith
Converts decimal data into a packed hex format using the COBOL computational -3 trailing sign half-character. The COBOL computation -3 sign digit representation is shown below.
Sign value in decimal |
Sign half-character in hexadecimal |
---|---|
unsigned |
0x0F |
+ |
0x0C |
- |
0x0D |
None.
Data:
-47325, COBOLpack()
Results in:
-G2]
Converts packed hexadecimal data that is in the COBOL computational -3 trailing half-character signed format into one of a variety of formats, including a string format and various numeric formats, depending on the format specifier used.
A printf() format specifier – specifies how the result of unpacking the hexadecimal data is stored and displayed. Use any of these specifiers— “EdFfGgdiuoXxs”. Refer to a C\C++ reference manual for more information about the printf format specifier.
Positively signed data (0x0C trailing half-character) is not
signed when converted. Place a plus sign (+) in the format
specifier to explicitly sign the unpacked data (for example, %+d
)
If the data is negatively signed, then a plus sign in the format
specifier has no effect.
Using the “s” specifier results in formatting the output from unpacking the packed hexadecimal data as a string of digits, where each digit is a digit in the decimal value that was originally COBOLpacked. When reverse mode is unselected, a leading zero is inserted at the beginning of the string. When Reverse Mode is selected, no leading zero is inserted.
Use the “s” specifier in cases where the decimal value of the number you want to display is too large to store in a numeric format but still needs to display. An example of this would be a telephone number that is being COBOLunpacked.
Data:
-G2], COBOLunpack()
Results in:
-47325
Converts numeric data to a machine-independent two byte binary representation of the data. 65535 is the maximum value on which this function can operate. If the data is greater than 65535, the hexadecimal 16 function truncates the result.
None.
Data:
4867, hex16()
Results in:
1303
Converts numeric data to a machine-independent four byte binary representation of the data. 4294967295 is the maximum value on which this function can operate. If the data is greater than 4294967295, the hexadecimal 32 function truncates the result.
None.
Data:
93024718, hex32()
Results in:
058b71ce
Converts hexadecimal data to decimal data. If Reverse Mode is selected, the filter converts decimal data to hexadecimal data. FFFF is the maximum value that this function can handle. If the data is greater than FFFF, the filter fails.
None.
Data:
35AC, hexDecConv()
Results in:
13740
Reverse example. Data:
7598, hexDecConv()
Results in:
1DAE
Left justifies the data and uses space characters to pad the current blob area to the length indicated in the argument. If the current blob area is an empty string (contains only “ ”), then this built-in filter function pads the current blob area with space characters to the length indicated in the argument. If the current blob area contains nothing (it is null), then this builtins uses null characters to pad current blob area to the length indicated in the argument.
Length of resultant field.
Data:
foo hl7FixedChar(8)
Results in:
“foo “
Right justifies the data and uses zeros to pad the current blob area to the length indicated in the argument. If the current blob area is an empty string (contains only “ ”), then this built-in filter function pads the current blob area with zeros to the length indicated in the argument. If the current blob area contains nothing (it is null), then this built-in filter function uses null characters to pad current blob area to the length indicated in the argument.
Length of resultant field.
Data:
12345 hl7FixedChar(10)
Results in:
0000012345
Justifies the data in the specified direction and uses the specified fill character to increase the current blob area to the indicated length.
Direction of justification—left or right.
Fill character.
Length of resultant field.
L$24
left justifies
and fills with a dollar sign ($) to a length of 24.
R*126
right
justifies using an asterisk (*) as fill to a length of
126.
Left justifies the current data and blank (space) fill for the length given in the argument.
Length of resultant field; for example, “44
”.
Left justifies the current data and zero fills for the length given in the argument string.
Length of resultant field; for example, “123
”.
Converts incoming decimal data to the AS/400 compatible packed format. Any incoming data that is not an integer or a sign extension is skipped and not packed.
If a field object or datalink object contains the packed
data, then that object can be any datatype that accepts digits and
printable characters (for example, raw, alphanumeric, printable,
and so on).
None.
Right justifies the current data into a field length identified by the argument and blank (space) fill extra characters.
Length of resultant field; for example “22
”.
Right justifies the current data into a field length identified by the argument and zero fills extra characters.
Length of resultant field; for example “14
”.
Truncates the current blob area after the pattern specified in the arguments.
The character or pattern after which to truncate the data.
Data:
123hellozvt, strTruncL(hello)
Results in:
123hello
Truncates the current blob area up to the pattern specified in the arguments.
The character or pattern up to which to truncate the data.
Data:
“123hellozvt”, strTruncR(hello)
Results in:
“hellozvt”
Truncates the current blob area to a specified length, starting from its right-most position. In other words, truncates the current blob area to the left-most values for the specified length. If you do not pass an argument to this built-in filter function, then it clears the current blob area of all data.
The length of the data you want to retain, with left justification;
for example, “122
”.
Data:
ABCDE, truncL(3)
Results in:
ABC
Both truncL and truncR filters
insert null characters when the original blob is
shorter than the new length
Truncates the current blob area to a specified length, starting from its left-most position. In other words, truncates the current blob area to the right-most values for the specified length. If you do not pass an argument to this function, it clears the current blob area of all data.
The length of the data you want to retain, with right justification;
for example, “23
”.
Data:
ABCDE, truncR(3)
Results in:
CDE
Converts incoming AS/400 packed data to decimal format. Optional argument string allows printf style formatting of the unpacked data.
The field object or datalink object containing the packed
data can be any datatype that accepts digits and printable characters
(for example, raw, alphanumeric, printable).
Optional. The printf style formatting string;
for example, “%.2f
”.
Data:
0x123C, unpack(%.2f)
Results in:
-1.23
Copyright © 2005. Sybase Inc. All rights reserved. |
![]() |