Header in Zmerge

I’ve a Zmerge script which creates a text file from a database view.I want to add a header which should include the number of records in the file. I’ve included the line /OUT_HEADER=“ \r\n” ]

which will just add a string as a header but i want to display the record count as well. Please help!!!

The code goes here

/JOB_ID=“TEST” ]

[ /EXPORT ]

[ /OUT_HEADER=“ \r\n” ]

[ /NSF_FILE=“Server!!db.nsf” ]

[ /NSF_VIEW=SQL ]

[ /OUT_FILE=“D:\Zmerge\Test.txt” ]

[ /OUT_DELIM=“\r\n” ]

[ /OUT_APPEND=NO ]

[ /OUT_QUOTED=NO ]

[ /ON_SUCCESS= “D:\Zmerge\SuccessTEST.txt” ]

[ /ON_FAILURE= “D:\Zmerge\FailedTEST.txt” ]

[ /FLD_EXCEPTION=STOP ]

[ /STOP_ON_ERROR=NO ]

[ /QUIET=NO ]

[ /RUN_MODE=BATCH ]

FORMULASTART

SELECT @All

FORMULAEND

SQLStatement: UNTIL “|”

Subject: ZMerge headers/trailers

The header parameter is written at the beginning of the ZMerge job and does not have access to the number of documents/records being processed. As an alternative, you could write out the records count in the trailer parameter using replacement syntax-OR-

if you MUST have a header you could create 2 ZMerge jobs, one to write out the header (using the trailer) and one to process and concatenate the actual data.

Subject: trailer parameter using replacement syntax

This is the syntax for trailer/OUT_TRAILER=“”

But how do we add the record count here?

Subject: Use substitution syntax

If you are using the ZMerge admin database to hold your scripts, you can refer to fields in the report document which is created when you run the script when you use the substitution syntax in your script.

For example:

/OUT_TRAILER=“\nRecords=%@RPT.$ZMRecWritten%”