BYTE( ) function
Syntax
BYTE(byte_location)
Parameters
Name | Type | Description |
---|---|---|
byte_location | numeric |
The byte position to return as a character value. The value refers to a position in the record (counting from 1), irrespective of any field definitions. |
Output
Character.
Examples
Basic examples
Returns "1" from a record that begins with an ID field containing "1":
byte(112)
Advanced examples
Identify records in print files or PDFs based on consistent formatting
Use BYTE( ) to identify records in a data file where a particular character is present in a particular byte position. This is typically the case in Print Image (Report) files or Adobe Acrobat (PDF) files where data is formatted in a consistent way throughout the document.
For example, to locate and extract records that include a period at byte position 113:
EXTRACT RECORD IF BYTE(113) = "." TO "Output.fil"
Remarks
When to use BYTE( )
Use BYTE( ) to examine the contents of a position in a record, without having to define a field for the purpose.
Using BYTE( ) on EBCDIC data
If you use this function on EBCDIC data, the value returned will also be EBCDIC. You may not be able to compare this to character values.
Related functions
If you want to retrieve the binary representation for specified byte location, use the BIT( ) function.