Sidebar

How do you set a fixed width input file to read all records?

0 votes
408 views
asked Mar 26, 2019 by kevin-w-8265 (120 points)
The fixed length file mapping processes only the first record. This happens even in test mode though there are multiple rows in the sample message. Thank you.

1 Answer

0 votes

You need to use the message.getCount('/) to get the row count. Then use a for loop to iterate over each row.

//Get the rowCount and then loop through each.
var rowCount = message.getCount('/');
qie.debug('rowCount: ' + rowCount);

//This for loop is what will allow you to get each row.
for (var j = 1; j <= rowCount; j++) {
   //nodetag syntax = Begin Index, Width [ Row Index ]
   qie.info('col1: ' +  message.getNode('2,5[' + j + ']'));
   // so this starts at column 2 and goes 5 spaces. j defines what row to get.
   qie.info('col2: ' +  message.getNode('12,8[' + j + ']'));
   // so this starts at column 12 and goes 8 spaces. j defines what row to get.
}

answered Mar 26, 2019 by brandon-w-8204 (33,270 points)
commented Mar 26, 2019 by kevin-w-8265 (120 points)
The fixed length file is the source. The desired output is the message. message.getCount('/') seems invalid for this and returns 0. source.getCount('/') returns 1. The fixed length is 102 characters. Is there another parameter that should be used in .getCount()? Thanks.
commented Mar 27, 2019 by gary-t-8719 (14,860 points)
The fixed length messages require that the message have a newline (\n) character for each row.  QIE handles the carriage return (\r) but requires that the newline is present.  In his case, the sample message only had a carriage return, but no newline character. So the solution is to ensure that your sample message has a newline character. If your actual live messages don't have a newline character then a preprocessor script can be used to add it.
...