Normal spooled files can be loaded and processed directly in InterformNG2, but there is one deviation from this and this concerns spooled files where the attribute, Variable CPI is Y.
You can identify such spooled files if you select option 8=Attributes for the spooled file e.g. from WRKOUTQ or WRKSPLF and then press <Page Down> until you see this:
Here you might see a Y for Variable CPI, which indicates that this is a special spooled file, which must be handled in a special way.
The procedure is, that you need to call a script to correct the spooled file before it can be used in either the designer and for merging in the workflow.
So in order to use the spooled file in the designer you will need to call the script mentioned below and then save the changed spooled file as a document resource in InterformNG2.
A prerequisite for calling the Java script is, that the
system settings allow this:
Next you need to create the script.
The script is included here as text:
var message = payload.toString();
var newPayload = '';
var linearr = message.split('\n');
for (var i = 0; i < linearr.length; i++) {
var combinedLine = '';
var thisLine = linearr[i].trim();
if (thisLine.indexOf('<line>') != -1) {
thisLine = thisLine.replace('<line>', '')
thisLine = thisLine.replace('</line>', '')
var originalLine = thisLine;
var idx = thisLine.indexOf('CPI');
// Line has CPI information if it contains the exact text CPI with a digit in front
var isCpiLine = idx > 0 && thisLine.charAt(idx - 1) >= '0' && thisLine.charAt(idx - 1) <= '9'
if (!isCpiLine) {
combinedLine = thisLine;
} else while (idx != -1) {
var newLine = thisLine.substring(0, idx + 3);
thisLine = thisLine.substring(idx + 3);
if (combinedLine == '') {
combinedLine = newLine;
while (combinedLine.length < originalLine.length) {
combinedLine = combinedLine + ' ';
}
} else {
for (var l = 0; l < newLine.length; l++) {
var curchar = newLine.charAt(l);
if (curchar != ' ') {
combinedLine = combinedLine.substring(0, l) + curchar + combinedLine.substring(l + 1);
}
}
}
idx = thisLine.indexOf('CPI');
}
// Trim end
if (isCpiLine) {
while (combinedLine.length > 0 && combinedLine.charAt(combinedLine.length - 1) == ' ') {
combinedLine = combinedLine.substring(0, combinedLine.length - 1);
}
}
combinedLine = '<line>' + combinedLine + '</line>';
} else {
combinedLine = thisLine;
}
newPayload = newPayload + combinedLine + '\n';
}
payload.setString(newPayload);
To create the script you can copy the text above, paste it into e.g. Notepad or Notepad++ and then save it as e.g. merge_splf_overprint_ng2 2.js
Now we can refer to the script in workflows, that loads the spooled file like below: