qie.createFixedLengthMessage¶
Signature: qie.createFixedLengthMessage(length, lineEnding, encoding*, fieldDefinition*)
Returns: FixedLength Message message - the newly created message object
Replace the current message with an empty Fixed Width formatted message.
Note
You must specify either length or lineEnding or both.
Note
The environment variable used for the fieldDefinition must contain the following columns: name, offset, length.
Note
The return value MUST ALWAYS be assigned to the bound-in message object.
Note
encoding is optional. When not specified, {source encoding} is the encoding set on the channel's source node, or the encoding of the current message when the channel has none.
Parameters¶
| Type | Name | Description | Default |
|---|---|---|---|
| Integer | length | the length of each line in the fixed width message | |
| String | lineEnding | the record delimiter to use for parsing | |
| String | encoding* | (optional) the character encoding for this message | {source encoding} |
| String | fieldDefinition* | (optional) the system variable table containing columns specified for 'name','offset','length' that define the fixed width message parts |
Example¶
/*
fixedWidth system variable table looks like this:
** Note the offset is 1 based which can be tricky **
+-------+----------------------------+--------+--------+
| Order | name | offset | length |
+-------+----------------------------+--------+--------+
| 1 | Record Type Code | 1 | 1 |
| 2 | Transaction Code | 2 | 2 |
| 3 | Receiving DFI Id | 4 | 8 |
| 4 | Individual Name | 12 | 68 |
| 5 | Trace Number | 80 | 15 |
+-------+----------------------------+--------+--------+
*/
message = qie.createFixedLengthMessage(
94, // length: total length of each fixed-width line
'\r\n', // lineEnding: record delimiter
'ASCII', // encoding: character encoding
'fixedWidth' // fieldDefinition: system variable table defining fields
);
message.setNode("Record Type Code[1]", "4");
message.setNode("Individual Name[1]", "Blimey Harry, you are a wizard"); // will auto-pad as needed
message.setNode("Record Type Code[3]", "D");
message.setNode("Individual Name[3]", "Are you not entertained"); // will auto-pad as needed