If you look at the FILE statement, you'll see EXIT. The Cobol program is then used for the actual processing of that file, Easytrieve just calls the Cobol program and imagines that "writing" occurs. The EXIT details the program to be called, and any extra parameters - this needs an output area, so that is where it is defined.
Easytrieve does its "normal" processing of DISPLAY, which includes respecting the edit MASK, and immediately appending the X'FF, then passes on the record to the Cobol program.
The Cobol program simply UNSTRING's on the X'FF' (which is not otherwise going to appear in the editing of a field) and puts the real edited input value in the 100-byte output field.
(we did try using the RECORD-LENGTH instead of the X'FF', but Easytrieve wouldn't co-operate)
This will work for any Easytrieve MASK. If you need "formatted" data on an output file, then it can be done like this.
This is a very simple FILE EXIT, but can be used as a basis for many things (standard headers/footers in fixed positions, whilst the REPORT has "SPREAD", routing-information, editing for multiple currency symbols, producing CVS, etc).
It is a good idea to "wrap" the Easytrieve code in MACROs, something like this (for "instream" macros, once working they go in the macro library).
MACRO 2 IN OUT PRINTER EDITOUT1 LIST OFF
* This macro causes Easytrieve Plus to use an Edit Mask
DEFINE DOEDIT-IN-VALUE S 100 A
DISPLAY &PRINTER &IN X'FF'
&OUT = DOEDIT-IN-VALUE
MACRO 0 OUT DOEDIT-IN-VALUE PRINTER EDITOUT1 EXIT TSTEZT LIST OFF
FILE &PRINTER PRINTER EXIT(&EXIT, +
Put these two at the start of your source, before the first statement, including PARM if present.
Then replace the FILE statement that we have for the EXIT with:
%DOEDFI LIST ON
Then replace the DISPLAY statement that we have for the EXIT with:
%DOEDPR WS-IN EDIT-OUT-REC LIST ON
The "LIST ON" bit will list out the contents of the MACRO in the source, by default (in my definition) it is "OFF", so that the code is not listed, makes the output listing "cleaner" once happy that everything is working.
Note that the FILE name and the EXIT program are paramaterised in preparation for multiple use: this can also be extended, macros embedded and all types of interesting things like that :-)
I have added links or new posts to several topics where this has come up before, hopefully new questioners will find the answers without having to ask again :-)
But you can't define any fields on it, and your maximum length is limited by compiler option, which would affect all PRINTER output, and "records" could only be fixed-length. It would require "redefinition" (thus allowing room for the introduction of error) to get binary or packed-decimal onto the "file".
Therefore, unless your required output actually fitted within these constraints, a PRINTER file itself is too limited to be considered a "normal sequential file" in a general-purpose sense.
INFILE-PD 1 5 P 2 MASK ('ZZZZZZ9.99-')