Temporary files are scratch space: sort work, intermediate extracts, merged buffers, and trial output that should not persist after the job. Easytrieve offers two beginner-relevant patterns. First, FILE WORKFILE VIRTUAL (optionally MEMORY, DISK, or RETAIN) lets the Virtual File Manager allocate sequential storage without cataloging a production dataset. Second, ordinary FILE declarations map to JCL temporary datasets whose names start with && and whose DISP=(NEW,DELETE) removes them when the step or job ends. Confusing these with GDG generations, VSAM masters, or virtual W fields in reports causes maintenance nightmares—FILE VIRTUAL is a file attribute, not a working-storage field. This page teaches VIRTUAL syntax, RETAIN across activities, CLOSE deletion rules, JCL && SPACE sizing, SORTWRK patterns, when temporaries beat GDG (+1), security implications of scratch datasets in shared LPARs, and cleanup failures that fill DASD when DELETE does not run.
12345678910111213FILE EXTRACT SEQUENTIAL FB(80 800) FILE SORTWRK VIRTUAL MEMORY FB(80 800) FILE FILTERED VIRTUAL DISK FB(80 800) JOB INPUT EXTRACT IF STATUS-CODE EQ 'A' MOVE EXTRACT-REC TO WRK-REC PUT SORTWRK END-IF JOB SORT SORTWRK USING SORTWRK JOB INPUT SORTWRK PUT FILTERED
EXTRACT is a real input DD in JCL. SORTWRK is VIRTUAL MEMORY—VFM holds records in memory until size forces spill. FILTERED is VIRTUAL DISK—spill datasets on DASD. SORT activity reads SORTWRK and writes FILTERED without a cataloged production name. Record format on VIRTUAL must match data moved in PUT buffers. VIRTUAL files use GET, PUT, SORT, and CLOSE like sequential files except allocation is product-managed.
| Option | Effect | Use when |
|---|---|---|
| VIRTUAL alone | Default VFM allocation | General scratch sequential |
| MEMORY | Prefer memory-resident storage | Small to medium work files fit in memory |
| DISK | Use spill datasets | Large sorts exceeding memory limits |
| RETAIN | Survive CLOSE for later activity | Pass work file from JOB to REPORT activity |
| (no RETAIN) | CLOSE may delete virtual data | One-activity scratch only |
RETAIN is critical when activity one writes SORTWRK and activity two reads it after CLOSE in the first activity. Without RETAIN, CLOSE deletes and the second activity EOFs immediately. With RETAIN, you still must CLOSE appropriately between activities per program flow documentation—test multi-activity programs in SYSPRINT trace modes when available.
CLOSE SORTWRK on a VIRTUAL file without RETAIN releases VFM space. CLOSE chapter documents virtual file deletion semantics. Explicit CLOSE before job end is good practice when no later activity needs the file—frees memory on long batch windows. RETAIN virtual files consume resources until final CLOSE or job termination; do not RETAIN large DISK spills unnecessarily on shared systems.
123456//EXTRACT DD DSN=PROD.PAYROLL.DAILY,DISP=SHR //WORKFILE DD DSN=&&WORK1, // DISP=(NEW,DELETE,DELETE), // UNIT=SYSDA, // SPACE=(CYL,(50,10)), // DCB=(RECFM=FB,LRECL=80,BLKSIZE=8000)
WORKFILE matches FILE WORKFILE SEQUENTIAL FB(80 800) in Easytrieve. Double ampersand names are unique per job. NEW allocates; DELETE on step or normal termination removes the dataset. PASS may forward temporaries to later steps in the same job—Easytrieve single-step jobs rarely need PASS. SPACE must handle peak PUT volume during extract phase. UNIT=SYSDA or SMS-managed unit per shop standards.
| Factor | FILE VIRTUAL | JCL && temporary |
|---|---|---|
| JCL DD required | Usually omitted | Required with SPACE |
| Catalog entry | None—VFM internal | Uncataloged temp |
| Multi-activity RETAIN | RETAIN keyword | Keep DD open across activities if same step |
| Sort integration | Native SORT on VIRTUAL | Works with SORTWK DD conventions |
| Visibility to ops | Less visible in 3.4 | Visible as && in job output |
Easytrieve SORT activities often use VIRTUAL SORTWRK automatically when coded FILE SORTWRK VIRTUAL. Large extracts may need VIRTUAL DISK or explicit SPACE on JCL temporaries when site limits memory. SORT FIELDS and KEYS must reference fields defined on the virtual FILE layout. After SORT, JOB INPUT on the sorted virtual file feeds REPORT or second-pass logic. Do not point SORT at production GDG (+1) when a VIRTUAL intermediate avoids catalog clutter.
GDGs retain generations for audit and downstream replay. Temporaries die at job end—use when only this job needs scratch. Nightly payroll might write GDG (+1) for auditors but use VIRTUAL for in-program sort before the final PUT to GDG. Mixing them correctly keeps catalog LIMIT chains clean.
Virtual W and S fields in reports are working-storage concepts—see virtual-fields tutorial. FILE VIRTUAL is a dataset. Naming SORTWRK VIRTUAL does not create a virtual rank field on PRINT. Teach new developers the vocabulary distinction early in code review.
EXIT user programs on FILE are invalid for SQL, IDMS, DLI per FILE chapter. VIRTUAL files support standard GET PUT paths; verify EXIT compatibility with your release if attaching exits to work files. SQL tables are never VIRTUAL—use FILE name SQL for DBMS access.
A temporary file is scratch paper. FILE VIRTUAL is scratch paper the Easytrieve program keeps in its own desk drawer—it throws the paper away when done unless you label RETAIN to keep it for the next chapter. JCL && is scratch paper the computer room gives you with a sticky note that says throw away when the job finishes. You would not file scratch paper in the official notebook stack (GDG) unless you need to keep it for tomorrow.
1. FILE SORTWRK VIRTUAL creates:
2. Without RETAIN on VIRTUAL, CLOSE typically:
3. JCL &&TEMPNAME with DISP=(NEW,DELETE) is:
4. VIRTUAL MEMORY versus DISK:
5. FILE VIRTUAL is invalid for: