OL Learn

Variable Number of Detail Tables


#1

I’m having conceptual difficulty with building a data map. There are a variable number of “pages” and each page can have a variable number of “lines”.

The data is a text file. The first ten columns are an account number value, and I’ve set the Boundary when this value changes. So far so good.

Here is a little stump of the leftmost columns of the data file:

0000007326REM1*=============
0000007326REM * RA NUMBER # 
0000007326REM * PAYMENT   # 
0000007326REM *             
0000007326REM * PAYEE NAME: 
0000007326REM *             
0000007326REM2*=============
0000007326REM * RA NUMBER # 
0000007327REM1*=============
0000007327REM * RA NUMBER # 
0000007327REM * PAYMENT   # 
0000007327REM *     

So when 7326 becomes 7327, that’s a new record. That part I can do.

But then I need to extract all the lines for page “1”, which is 6 lines in this sample. I can do that, into a detail table, looking at that column and looping until it isn’t empty. Then loop through page “2”, which in this sample is just 2 lines. A new detail table.

What I cannot figure out is how to make this open ended. I need to loop through the entire record, extracting lines into a detail table, until a new “page” is reached, at that point I need to create a new detail table and loop until finished.

I can do the inner loop, but how do I construct the outer loop so that I can have a variable number of “pages”, one detail table per page?

What I’d expect from the data sample above is 2 records (7326 and 7327).

Record 7326 would have two detail tables, the first with 6 lines, the next with 2 lines.
Record 7327 would have a single detail table, with 4 lines.

Is this possible?


#2

And if it’s not possible, to have an outer loop that reads the entire record, all lines, with an inner loop to create a new detail table every time the “page counter” value is encountered (column 14), then the challenge becomes instead to do the pagination in the template. Extract all lines into a single detail table, but tell the template to “paginate” whenever I encounter a detail line that begins with a certain value.

Is that possible?

Capture

In this screen cap of my Data Map, how would I place this detail table in the template and have it paginate every time the PageControl field is not blank?


#3

Just had to think this through. This Script handled the pagination for me nicely.

results.each(function(index) {
    var somestring = record.tables['detail'][index].fields.Page_Control;
    if( somestring.trim() >= "2") {
        this.addClass('before');
    }   
});

The CSS rule:

.before {
    page-break-before: always;
}

thinking