The word virtual means different things on different mainframe products. In Easytrieve, virtual fields are not WebFOCUS-style DEFINE expressions in the master file. They are working storage fields—defined with W or S on DEFINE—that do not appear on your input dataset layout. NET-PAY, WS-COUNT, BAR-GRAPH, and RUN-TOTAL are virtual relative to FILE PERSNL because they live in memory, not at byte 94 on the tape. When those W fields participate in REPORT processing, Easytrieve copies them onto report work files at PRINT time, which creates a second layer of virtual behavior: the printed report sees spooled snapshots, not live memory. Separately, FILE SORTWRK VIRTUAL invokes Virtual File Manager for temporary sort work datasets—a file attribute, not a field. This page clarifies all three meanings beginners confuse, teaches W versus S spooling rules, and shows how to place derived virtual fields correctly in JOB and REPORT flow.
FILE statement fields map to record positions on disk. Virtual fields map to working storage in the address space. READ loads FILE fields from the dataset. Virtual fields start at VALUE or default zeros and blanks until JOB logic assigns them. You can PRINT both on one report line—GROSS from file and NET-PAY from working storage—but only GROSS travels in from the input buffer on READ.
| Aspect | FILE field | Virtual W or S field |
|---|---|---|
| Storage location | Record buffer at POSITION | Working storage area |
| Initial content on READ | Bytes from dataset | VALUE or zeros or blanks |
| DEFINE location | Start position after FILE | W or S on DEFINE |
| Output without PUT | Unchanged on input file | Never written unless assigned to FILE out |
Broadcom documents that W fields copy to report work files when referenced in REPORT subactivities and PRINT executes. Formatting and printing happen later—sometimes after SORT on the work file. The W value on the work file is whatever it was at PRINT time. If you increment WS-COUNT after PRINT, the report still shows the old spooled value. If you accumulate a running total in W during the file and then SORT, the work file carries per-record W snapshots that may not equal the final accumulated value.
123456789DEFINE WS-RANK W 3 N JOB INPUT PERSNL WS-RANK = WS-RANK + 1 PRINT PERSNL-RPT REPORT PERSNL-RPT TITLE 'PERSONNEL' LINE WS-RANK NAME GROSS END-REPORT
WS-RANK is virtual— not on PERSNL file. Each printed line spools WS-RANK at PRINT. SORT on the report reorders spooled ranks with names—behavior you must predict when designing ranking reports.
S fields stay in static working storage. They are not copied to report work files on each PRINT. References in REPORT format use current S values when lines print—better for grand totals, company name constants, and BAR-GRAPH built in BEFORE-BREAK PROCs. Broadcom recommends S unless you understand W spooling implications.
123456DEFINE GRAND-TOT S 9 P 2 DEFINE BAR-GRAPH S 40 A JOB INPUT PERSNL GRAND-TOT = GRAND-TOT + GROSS PRINT SALARY-RPT
Most virtual fields are derived—computed from FILE or other virtual fields. NET-PAY W 7 P 2 virtual storage holds GROSS minus deductions. The derivation happens in assignment; the virtual aspect is storage class W. Combine derived-fields page patterns with virtual spooling rules here.
FILE SORTWRK FB(150 1800) VIRTUAL declares a temporary file managed by Virtual File Manager. VFM allocates memory and spills to disk when needed. SORT work files often use VIRTUAL so JCL does not allocate SORTWRK DD. RETAIN keeps VFM data between steps in multi-step programs. Do not confuse this FILE parameter with virtual W fields.
123456FILE SORTWRK FB(150 1800) VIRTUAL FILE PERSNL FB(150 1800) SORT PERSNL USING EMPL# OUT SORTWRK END-SORT
When the same name exists on FILE and in working storage, qualify with WORK:FLD1 versus FILEA:FLD1. Virtual fields without name collision need no qualifier. Ambiguous references compile to wrong buffer—use WORK: prefix in mixed layouts.
Screen maps display virtual W fields for prompts, echo switches, and computed messages. RESET on W virtual fields restores VALUE when SCREEN activity restarts. FILE fields on screen maps still map to transaction buffers—virtual fields hold UI state.
When SORT sequences report work files containing spooled W virtual fields, those fields sort as ordinary columns on the work record. Accumulators in W that should represent running totals across the entire input file may sort incorrectly if you expected one final total per department. Use S for department totals that format after sort, or restructure JOB into two passes.
| Use case | Choose | Reason |
|---|---|---|
| Per-record rank or sequence on report | W | Spool value at each PRINT |
| Grand total on last page | S | Evaluate at format time |
| Scratch in JOB IF logic only | W | Simple; no report reference |
| Company title constant on report | S | Stable; not per-record spool |
| BAR-GRAPH in control break | S | Built in BEFORE-BREAK at print |
File fields are names written on each card from the mail pile. Virtual fields are sticky notes you keep on your desk while reading the pile—they are not printed on the cards. When you photocopy a card for a report, W virtual notes get taped on the copy at photocopy time. S virtual notes stay on your desk until the report is actually stapled—you read the latest note then. VIRTUAL on FILE is a temporary cardboard box for sorted cards—not a sticky note at all.
1. In Easytrieve report processing, W fields are:
2. Virtual fields in Easytrieve most often means:
3. FILE SORTWRK VIRTUAL invokes:
4. Grand totals across entire file should use:
5. RESET on W fields during report printing: