Software AG Products 10.7 | Integrating On-Premises and Cloud Applications | Processing Flat Files | Sending and Receiving Flat Files | Stateful Encodings | Writing Stateful Encodings
 
Writing Stateful Encodings
Consider a record definition with the following four-byte fields:
Field
Start Position
End Position
Record Value
A
0
3
Character value “AB” encodes to 5 bytes: |123O.
The character “A” is represented by bytes 1 and 2.
The character “B” is represented by byte 3.
B
4
8
Character value “C” encodes to 4 bytes: |45O.
The parser encodes this record as follows:
|12O|45O
Notice that the parser truncated byte 3 (the character “B”) from the first field so that the field would fit within the four-byte limit. This truncation occurred on the character boundary between the characters A and B, creating a properly encoded record.
Note:
A different method of encoding, using a “padding” byte, would have produced this result:
|123450P
where P is an added padding byte, to extend the record length to the required eight bytes. The parser does not use this method of encoding. Using this method, extracting the value for the second field produces:
450P
The parser cannot properly write this byte sequence. All fixed position fields must be encoded as if they were a stand-alone sequence of bytes. No stateful encoding information may be carried from one fixed position field to any other fixed position field. However, delimited fields may carry stateful information from one field to the next field. In contrast, delimited records may not carry stateful information from one record to the next record. Thus, delimited fields are not necessarily “self contained”, but delimited records are.