A derived field is any field whose meaning comes from other data rather than a fixed byte position you read blindly from tape. NET-PAY derived from GROSS minus DEDUCTIONS is the classic payroll example. HIRE-MM derived as the first two bytes of DATE-OF-HIRE is a structural overlay. FULL-NAME derived by concatenating FIRST-NAME and LAST-NAME in a PROC is a string derivation. Easytrieve does not let you embed a formula inside DEFINE the way WebFOCUS virtual fields do. You declare the target field, then assign an expression in JOB logic, SORT, or a PROC. That two-step pattern—define storage, compute value—is the heart of derived field processing. This page walks beginners through arithmetic derivations, overlay derivations, date and string derivations, report implications with W versus S fields, and debugging when derived values look almost right.
Broadcom requires the target field to exist before assignment. Define NET-PAY in working storage with length and type that can hold the result. Then in JOB INPUT compute it each record. Skipping DEFINE produces undeclared field errors at compile. Defining NET-PAY as type A when GROSS is packed produces conversion surprises—match quantitative types and decimal positions.
12345678910111213FILE PERSNL FB(150 1800) NAME 17 20 A GROSS 94 4 P 2 DEDUCT 98 4 P 2 DEFINE NET-PAY W 7 P 2 JOB INPUT PERSNL NET-PAY = GROSS - DEDUCT IF NET-PAY LT 0 NET-PAY = 0 END-IF PRINT NET-PAY
Addition, subtraction, multiplication, division, and exponentiation in assignment statements produce derived numeric fields. Operands must be quantitative when signed math is required—decimal positions on DEFINE. Mixed types convert per product rules; beginners should keep operands same type and scale.
| Derived field | Typical expression | Notes |
|---|---|---|
| NET-PAY | GROSS - DEDUCT | Subtraction; watch packed scale |
| TAX-AMT | GROSS * TAX-RATE | Rate constant field times amount |
| PCT-OF-TOTAL | LINE-AMT / GRAND-TOT * 100 | Division—define enough decimals |
| BONUS | BASE * 1.05 | Literal factor in expression |
Overlay syntax derives a subfield from a parent without a new absolute file position. DEFINE HIRE-MM DATE-OF-HIRE 2 N takes the first two bytes of parent DATE-OF-HIRE as month number. The derivation is structural—the bytes are the same memory as the parent. Changing HIRE-MM changes parent bytes and vice versa. Use overlays for year, month, day components, sign nybbles, or status codes embedded in a larger code field.
12345FILE PERSNL FB(150 1800) DATE-OF-HIRE 45 6 N HIRE-CC DATE-OF-HIRE 2 N HIRE-YY DATE-OF-HIRE +2 2 N HIRE-MM DATE-OF-HIRE +4 2 N
HIRE-CC, HIRE-YY, and HIRE-MM are derived views. IF HIRE-MM EQ 06 filters June hires without reading a separate column from the dataset layout document.
Concatenation and substring operations derive alphabetic results. MOVE and assignment with quoted literals build display names. MASK on derived W fields controls report editing. VARYING fields support length-changing derivations for SQL VARCHAR targets. Padding and trimming rules apply—see string handling data type pages.
1234567891011DEFINE FULL-NAME W 40 A PROC BUILD-NAME. FULL-NAME = FIRST-NAME FULL-NAME = FULL-NAME + ' ' FULL-NAME = FULL-NAME + LAST-NAME END-PROC JOB INPUT PERSNL PERFORM BUILD-NAME PRINT FULL-NAME
Date fields stored as N or P can yield derived century, year, month, and day overlays or working storage fields computed with date routines where your shop macros provide them. Internal date representation matters—six-digit YYMMDD overlays differ from eight-digit CCYYMMDD. Misaligned overlay length produces wrong month digits and silent bad reports.
Centralize repeated derivations in PROCs. CALC-NET in one PROC avoids duplicating NET-PAY = GROSS - DEDUCT - TAX in three JOB activities. PROCs accept no parameters in classic Easytrieve—use working storage for inputs and outputs. Call PERFORM CALC-NET before PRINT so derived W fields hold final values.
When PRINT selects a record for a REPORT, W derived fields copy to the report work file at that moment. If you derive NET-PAY after PRINT, the report shows stale or zero values. Order matters: compute, then PRINT. S derived fields used in control breaks evaluate at format time—see working storage page for W versus S spooling rules.
FILE columns exist on the physical record. Derived W fields exist only in memory for the run. Output files receive derived values only when you MOVE or assign into FILE output fields before PUT. Do not add NET-PAY to input FILE unless the source dataset actually contains those bytes.
When derived numbers look wrong, verify operand field positions first—wrong GROSS length shifts every following derivation. DISPLAY operands and result before PRINT in test runs. Compare packed hex in SYSPRINT debug if S0C7 abends appear. Check whether W field was reset by RESET option between JOB activities.
A derived field is the answer you write after doing math with numbers from two other papers. You need an empty line labeled NET-PAY first—that is DEFINE. Then you subtract on that line—that is assignment. An overlay is looking at just the month part of a birthday written as one long number—you did not get a new birthday, you are just looking at piece of the same number.
1. Easytrieve derives field values primarily through:
2. NET-PAY = GROSS - DEDUCTIONS requires:
3. Overlay field HIRE-MM on DATE-OF-HIRE derives:
4. Derived packed field arithmetic needs:
5. A derived field on a report LINE: