Easytrieve Virtual Fields

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.

Progress0 of 0 lessons

Virtual Fields vs FILE Fields

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.

FILE fields compared to virtual working storage fields
AspectFILE fieldVirtual W or S field
Storage locationRecord buffer at POSITIONWorking storage area
Initial content on READBytes from datasetVALUE or zeros or blanks
DEFINE locationStart position after FILEW or S on DEFINE
Output without PUTUnchanged on input fileNever written unless assigned to FILE out

W Virtual Fields and Report Spooling

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.

text
1
2
3
4
5
6
7
8
9
DEFINE 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 Static Virtual Fields

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.

text
1
2
3
4
5
6
DEFINE GRAND-TOT S 9 P 2 DEFINE BAR-GRAPH S 40 A JOB INPUT PERSNL GRAND-TOT = GRAND-TOT + GROSS PRINT SALARY-RPT

Virtual Derived Fields

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 VIRTUAL (VFM) — Not a Virtual Field

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.

text
1
2
3
4
5
6
FILE SORTWRK FB(150 1800) VIRTUAL FILE PERSNL FB(150 1800) SORT PERSNL USING EMPL# OUT SORTWRK END-SORT

Qualifying Virtual Fields with WORK

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.

Virtual Fields in Online SCREEN Activities

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.

Virtual Fields and SORT

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.

Choosing W or S for Virtual Fields

Decision guide for virtual field storage type
Use caseChooseReason
Per-record rank or sequence on reportWSpool value at each PRINT
Grand total on last pageSEvaluate at format time
Scratch in JOB IF logic onlyWSimple; no report reference
Company title constant on reportSStable; not per-record spool
BAR-GRAPH in control breakSBuilt in BEFORE-BREAK at print

Common Mistakes

  1. Confusing FILE VIRTUAL with virtual W fields.
  2. Accumulating file-wide total in W then SORTing report work file.
  3. PRINT before assigning virtual derived field.
  4. Expecting RESET during report formatting pass.
  5. Same field name on FILE and W without WORK: qualifier.
  6. Putting virtual field on FILE layout when not on physical record.

Explain It Like I'm Five

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.

Exercises

  1. Define W virtual rank field; PRINT each record; explain spooled value.
  2. Define S grand total; add GROSS each record; use on final LINE.
  3. Write FILE SORTWRK VIRTUAL for a SORT step without JCL DD.
  4. Qualify WORK:COUNT when COUNT exists on FILE and in storage.
  5. Diagram timing: assignment, PRINT, SORT, format for W field.

Quiz

Test Your Knowledge

1. In Easytrieve report processing, W fields are:

  • Copied to report work files when referenced at PRINT
  • Never used in reports
  • Always static
  • Only in JCL

2. Virtual fields in Easytrieve most often means:

  • Working storage fields not on the input file record
  • COBOL LINKAGE SECTION
  • VSAM control intervals
  • MACRO parameters only

3. FILE SORTWRK VIRTUAL invokes:

  • Virtual File Manager temporary storage
  • Virtual machine
  • Screen section
  • SQL cursor

4. Grand totals across entire file should use:

  • S static fields
  • W fields only
  • FILE overlay
  • TITLE

5. RESET on W fields during report printing:

  • Is not performed per Broadcom report processing rules
  • Runs on every LINE
  • Clears FILE buffer
  • Reloads JCL
Published
Read time15 min
AuthorMainframeMaster
Reviewed by MainframeMaster teamVerified: Broadcom Easytrieve 11.6 W S spooling VIRTUAL VFM report processingSources: Broadcom Easytrieve 11.6 Define Files and Fields, Describe Files and Fields, Report ProcessingApplies to: Easytrieve virtual working storage and VFM