ng:spoolMapRel

ng:spoolMapRel

The built-in function, ng:spoolMapRel is only available in InterFormNG2, if you are running InterFormNG2 on the IBM i platform, or have activated the AS400 option in InterFormNG2. This function only supports spooled files loaded in the version 2 format. The spooled file versions are explained in the section, Spooled file formats.

 

With this function you can map and extract data from an input spooled file in the designer, in a line number, that is relative to a selected spooled file line. This function can be very useful, if you want to scan a spooled file for specific lines (with a condition), and then process the following spooled file lines (after the true condition) as a block of lines.

 

An alternative to the ng:spoolMapRel is the ng:spoolMap function, that maps spooled file lines from a specific line.

 

The ng:spoolMapRel function can only be used within a repeat, that iterates across spooled file pages, and it has been created to be used within a line repeat inside of the page repeat.

 

The ng:spoolMapRel has these parameters:

ng:spoolMapRel(Line, StartPos, Length, StartLine, NbrOfLines)

(As described below the parameters can be typed in manually, but it is much easier to select the area with the mouse).

 

Line

This is the line, that you want as a reference. This should normally be a dot (.) in order to refer to the current spooled file within a repeat loop, that iterates across spooled file lines, but you can refer to a fixed spooled file line within the currently selected page by typing e.g. this value: ./line[17]. This refers to line 17 of the current page.

 

StartPos

This selects the start position of the text, that you want to extract from the spooled file.

 

Length

This sets the length of the text, that you want to exact from the spooled file.

 

StartLine

This is the relative start line compared to the currently selected spooled file line. A value of 0 indicates the current line. Negative values e.g. lines above the current line cannot be used. A value of 1 refers to the line just below the current line.

 

NbrOfLines

This parameter is optional. This is the number of lines, that the ng:spoolMapRel function should extract. If you do not set this parameter, then it defaults to 1. This means, that these functions do the same: ng:spoolMapRel(., 2, 78, 3,1) and ng:spoolMapRel(., 2, 78, 3)

 

Handling vertical flow for blank texts

Please notice, that blank texts (including texts with only blanks) does not trigger a vertical repositioning in a dynamic flow. The section, Vertical flow for a blank text of the text element covers how you can force blank lines to be displayed in the output.

 

 

Explanation of use

As an example lets consider a spooled file like this:

NG2SpoolMapRel0001

 

In this case we want to scan the detail lines for lines, that are not blank on the left and then handle 2 lines as a section, which means that we need a way to refer to a relative line number compared to the currently selected spooled file line. We can do that with a setup like this:

 

NG2SpoolMap0002

The first repeat loop iterates across all pages in the spooled file, the second repeat iterates across the detail lines starting in line 19 and for the next 26 lines. Inside this repeat a special condition has been inserted and this is where a special prerequisite is setup:

 

NGSpoolMap0003

 

 

Relative mode

On the if element (and the Select element) we can activate the Relative mode option (when a spooled file is used as input). This means, that you should select an anchor line:

 

NGSpoolMapRel0004

 

If you enable Relative mode, then the text: Select anchor line is shown as above. This is an indication, that InterFormNG2 expects you to select one of the spooled file lines (with the mouse). The lines shown in light blue as the lines, that fits the condition and after you have selected the anchor line, then the anchor line becomes dark blue as shown in the previous image.

 

The anchor line

The anchor line is a help in the designer and has no effect on the final output. You can use the anchor line, if you insert a relative spooled file mapping within the condition. You can consider the anchor line as an indication of a start of a conditioned section in the spooled file. This can be used, when you use the ng:spoolMapRel function, which you can insert with a mouse in this way:

 

When we insert a text within the condition, which is to map spooled file data, then we can again use the relative mode on the spooled file mapper in the text element in order to map spooled file lines, that are found relatively to the currently selected spooled file line:

 

This maps the part number from the first line of a section:

 

NGSpoolMapRel0005

 

NGSpoolMapRel0006

 

Where this maps the data of the line just below the trigger/anchor line:

 

NGSpoolMapRel0007

 

NGSpoolMapRel0008

 

The resulting output looks like this:

(The spool mappings of the first line is in bold and the mapping of the line below is in the normal font).

 

NGSpoolMapRel0009

    • Related Articles

    • ng:spoolMap

      The built-in function, ng:spoolMap is only available in InterFormNG2, if you are running InterFormNG2 on the IBM i platform. With this function you can map data from an input spooled file in the designer, and extract information from the spooled file ...
    • ng:spoolMapCond

      IMPORTANT: This function is only supported for spooled files loaded in the old format, Version 1, which is not recommended - it is not supported for spooled files loaded in version 2, which is better, default alternative to load spooled files in. ...
    • ng:resourceExist

      ng:resourceExist(resource,path) This function checks, if a resource in InterFormNG2 exists or not. The function returns a boolean: true or false. The ng:resourceExist Xpath function has this format: ng:resourceExist(resource,path), where: resource ...
    • ng:decrypt

      The built-in function, ng:decrypt is linked with the encryption functions: ng:encrypt and the workflow component, Set secure workflow variable. The function, ng:decrypt can decrypt contents, that was previously encrypted with these functions. The ...
    • ng:minimum

      InterFormNG2 includes the special built-in XPath function, ng:minimum. This function returns the smallest value of two numeric arguments. The function only accepts two numeric arguments - no more and no less. Examples: ng:minimum(-14,2) returns 2 ...