Creating built-in filters  Editing functions

Chapter 3: Building Production Objects

Formatting filter functions

These functions help you perform basic formatting actions on the output data.


charHexConv()

Description

Expands each byte of character data into the ASCII hexadecimal equivalent. If reverse mode is selected, the filter converts hexadecimal data to character data.

Argument

None.

Example

Data:

935-0488,charHexConv()

Results in:

3933352D30343838

Reverse example

Data:

536D697468, charHexConv() 

Results in:

Smith

COBOLpack()

Description

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

Arguments

None.

Examples

Data:

-47325, COBOLpack()

Results in:

-G2]

COBOLunpack()

Description

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.

Arguments

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.

Examples

Data:

-G2], COBOLunpack()

Results in:

-47325

hex16()

Description

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.

Arguments

None.

Examples

Data:

4867, hex16()

Results in:

1303

hex32()

Description

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.

Arguments

None.

Examples

Data:

93024718, hex32()

Results in:

058b71ce

hexDecConv()

Description

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.

Arguments

None.

Examples


hl7FixedChar()

Description

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.

Arguments

Length of resultant field.

Examples

Data:

foo hl7FixedChar(8)

Results in:

“foo   “

hl7FixedNum()

Description

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.

Arguments

Length of resultant field.

Examples

Data:

12345 hl7FixedChar(10)

Results in:

0000012345

justify()

Description

Justifies the data in the specified direction and uses the specified fill character to increase the current blob area to the indicated length.

Arguments

Examples

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.


ljbf()

Description

Left justifies the current data and blank (space) fill for the length given in the argument.

Arguments

Length of resultant field; for example, “44”.


ljzf()

Description

Left justifies the current data and zero fills for the length given in the argument string.

Arguments

Length of resultant field; for example, “123”.


pack()

Description

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.

NoteIf 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).

Arguments

None.


rjbf()

Description

Right justifies the current data into a field length identified by the argument and blank (space) fill extra characters.

Arguments

Length of resultant field; for example “22”.


rjzf()

Description

Right justifies the current data into a field length identified by the argument and zero fills extra characters.

Arguments

Length of resultant field; for example “14”.


strTruncL()

Description

Truncates the current blob area after the pattern specified in the arguments.

Arguments

The character or pattern after which to truncate the data.

Examples

Data:

123hellozvt,  strTruncL(hello)

Results in:

123hello

strTruncR()

Description

Truncates the current blob area up to the pattern specified in the arguments.

Arguments

The character or pattern up to which to truncate the data.

Examples

Data:

“123hellozvt”,  strTruncR(hello)

Results in:

“hellozvt”

truncL()

Description

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.

Arguments

The length of the data you want to retain, with left justification; for example, “122”.

Examples

Data:

ABCDE, truncL(3)

Results in:

ABC

NoteBoth truncL and truncR filters insert null characters when the original blob is shorter than the new length


truncR()

Description

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.

Arguments

The length of the data you want to retain, with right justification; for example, “23”.

Examples

Data:

ABCDE, truncR(3)

Results in:

CDE

unpack()

Description

Converts incoming AS/400 packed data to decimal format. Optional argument string allows printf style formatting of the unpacked data.

NoteThe field object or datalink object containing the packed data can be any datatype that accepts digits and printable characters (for example, raw, alphanumeric, printable).

Arguments

Optional. The printf style formatting string; for example, “%.2f”.

Examples

Data:

0x123C, unpack(%.2f)

Results in:

-1.23




Copyright © 2005. Sybase Inc. All rights reserved. Editing functions

View this book as PDF