Consolidating Documents

When we sort documents, we place documents in ascending or descending order based on the value of a field. In matching, we consolidate documents that have the same destination so that they can be processed as a package.

To consolidate documents, you use the Sortmatch tag group to sort—and match—documents within multiple inputs. The process for sorting documents within multiple inputs is essentially the same as for a single input.

Note: When multiple inputs are sorted and not matched, they are commingled in the output in sort order. Each input document is treated as a separate document in the output.

Specify a Sortmatch group <INPUTNAME> tag for each Input group that defines a print stream to sort. If any of the inputs are already in the desired sort order, you can increase processing efficiency by setting the Input group <SORTED> tag to YES so Enrichment will not re-sort the input.

After you define all of the necessary <INPUTNAME> tags, define one <SORT> tag for each sort criterion, in the order in which Enrichment should perform the sorts. Note that you must sort all input streams by the same criteria if you sort them in the same run of Enrichment.

The tagging shown below will cause Enrichment to sort the print streams Statements and Invoices with a primary key of branch office (%%branch) and a secondary key of customer number (%%customer). The resulting output contains all documents from the inputs Statements and Invoices sorted in descending order by branch office. Within each branch office grouping, documents are sorted in ascending order by customer number.

Note: Since sorting and matching takes place before rule file processing, you cannot set variables in the rule file for use with Enrichment internal sort. You can use these variables in external sorts called during output processing.
<SORTMATCH>
   <INPUTNAME> Statements
   <INPUTNAME> Invoices
   <SORT> %%branch D
   <SORT> %%customer A
</SORTMATCH>

If you do not want the contents of a particular input to print (for example, if you want to extract data from a matching document without printing that input), set the <INPUTNAME> tag match parameter to YES and set the print parameter to NO.

The diagram below illustrates document consolidation. In the illustration, two input print streams, LETTER and STATEMENT, are matched so that documents from each input are consolidated and sorted by field. The order of the <INPUTNAME> tags indicates the order of pages in the consolidated documents—documents from LETTER are page 1 of the consolidated documents and documents from STATEMENT are page 2. Documents B and D from LETTER and documents E and F from STATEMENT aren't consolidated with other documents (because they’re not in both inputs), but are sorted into the output.