How to iterate across detail lines in spooled file

How to iterate across detail lines in spooled file

In this section I will show you how you can make InterFormNG2 iterate across detail lines in an input spooled file, and how to setup conditions on each detail line.

 

This can be done in two different ways depending on which spooled file format, that is used. The recommended and most simple way is to use the version 2.0 of the spooled file format.

 

The related section: Handling multi-line conditioned sections is recommended.

 

Solution for version 2.0 (recommended)

 

An example is explained in steps below, but you can also refer to this video for help:




For this example we want to scan all the detail lines of a spooled file. The detail lines are in the range from line 30 to 42 and they look like below (starting with the line InterWord400):

 

NG2ItAcrossDetailSplfLines0001

 

We want to scan all detail lines of all pages in the spooled file. For each detail line we want to print out the Product and verify if the Product starts with the text 'Inter', If so, then we want to insert an extra text 'InterForm!' next to it.

 

 

First you need to create a new template and load the spooled file in the designer.

 

Now you need insert a repeat element and select the option For each spool page on the left, bottom part of the properties as shown here.

 

Now you need to rearrange the repeat element and the page element, so that the page element is placed inside the repeat element:

 

NG2ItAcrossDetailSplfLines0002

For each page we want to scan line 30 to 42, so we insert an extra repeat within the page element and in the repeat element we can select the lines to scan with the mouse and then click OK to save the change. (Please notice, that you can only select the lines - not specific positions)

 

NG2ItAcrossDetailSplfLines0012

 

Now the template tree looks like this:

 

NG2ItAcrossDetailSplfLines0013

(The last repeat element specifies, that we are doing a repeat on the current page and we start at line 30 and repeats through the next 13 lines).

 

Inside the repeat we insert a container to hold the columns of each detail line. We set a fixed height as the texts insider a going to have fixed positions (in this way each element can be placed independently of each other):

 

NG2ItAcrossDetailSplfLines0014

 

We have chosen these fixed dimensions of the container:

 

NG2ItAcrossDetailSplfLines0006

 

Inside of this we can now place a text element to print out the first column (in a fixed position):

 

NG2ItAcrossDetailSplfLines0015

(Please notice, that the spooled file area handled by the last repeat is marked in dark grey, when we extract spooled file data in the text element).

 

When we click OK to add the new text element (in a fixed position), then the element tree looks like this:

 

NG2ItAcrossDetailSplfLines0016

 

The text element use the standard XPath function, substring to extract the spooled file data from position 8 and the next 16 characters of the current spooled file line within the repeat loop.

 

Next we want to use a condition to verify, if the first 5 character of the product is 'Inter'. We do that with the if element or a select element. You can consider to activate relative mode and setup an anchor line, and use the function, ng:spoolMapRel if you want to handle conditioned sections of a spooled file.

 

NG2ItAcrossDetailSplfLines0017

(We also select the characters of the current line like we did for the text element above).

 

Inside the condition we now finally insert the conditioned text:

 

NG2ItAcrossDetailSplfLines0018

 

The final result looks like this:

 

NG2ItAcrossDetailSplfLines0019


    • Related Articles

    • Options for handling detail lines

      When it comes to detail lines of a document, then you of course need to use a repeat loop, that iterates across all of the detail lines of your input file. Here I use this XML file as input: (You can find that in the document Library of InterFormNG2 ...
    • Spooled file support

      InterFormNG2 is able to process spooled files, if you install InterFormNG2 on the IBM i platform. Please notice, that spooled file support, as well as Spool2XML, are modules for InterFormNG2, that are purchased separately. You can also use the ...
    • Change page breaks of a spooled file

      When you merge an input spooled file with a template in InterFormNG2 e.g. for PDF or print output, then you normally want the same page breaks in the output as in the original input spooled file. You are however not necessarily limited by that and ...
    • Enrich spooled file from database

      Enrich spooled file from database It is possible to change the contents of a spooled file (as known on the IBM i platform) and to add data from an external database with the advanced special workflow component: Enrich spooled file from database. You ...
    • Spooled file into Excel

      This section shows how a spooled file can be converted into Excel. The example relates to a spooled file, that has a format like below: The spooled file is a multi-page spooled file with a header, some details lines (in the middle blue frame), which ...