Knowing which Documents were Consolidated

It is often useful to know which print streams were included in a specific output document. There are two methods for determining which print streams are in an output document:

  • Using the %%INPUT system variable
  • Using the FOUND function on unique variables for each print stream

%%INPUT System Variable

The %%INPUT system variable contains a blank-delimited list of all inputs used to create the current document. So, in the code below %%INPUT would have these values.

Table 1. Example Values for %%Input
Document Set Inputs Used to Create Document Set
A "LETTER STATEMENT"
B "LETTER"
C "LETTER STATEMENT"
D "LETTER"
E "STATEMENT"
F "STATEMENT"

You can use the WORDPOS function to determine if a specific input is included in the list. For example, the code shown below will add a cover letter to those documents which include a statement.

DOCUMENT:
   IF WORDPOS("STATEMENT",%%INPUT) THEN
      <APPEND> CoverLetter B
   ENDIF

FOUND Function

The FOUND function identifies whether a specified field was found, or included, in the current document. So, you can use this function to see if unique fields on each input are included in the current output—and thus if the input is included. However, if the field is not found in the document, it doesn't necessarily mean the input isn't present. It could mean the input is present, though the field is not.

Similarly, just checking to see of the field is non-blank can have inconsistent results. The field is reset to blank before each document in which the input is included. If the input isn't included in the current document, the field retains the value from the last document in which the input was included. So it isn't always an accurate indicator of whether an input is present or not.

If you want to check to see what inputs made up the document, use the %%INPUT system variable and the WORDPOS function. This is the only truly accurate way to determine what inputs are included in each document.