Macro reuse is why mainframe shops adopt the Macro Facility in the first place—one authoritative PERSNL layout, dozens of programs, zero copy-paste drift. Reuse succeeds when libraries are governed like production source: named owners, Endevor promotions, regression compiles, and documented parameter contracts. Reuse fails when developers embed instream test macros in production members, when positional parameter order changes without a migration plan, or when nobody recompiles dependent programs after a silent library update. This page covers library architecture, composable macro design, naming conventions, change-control workflows, team patterns for FILE versus REPORT macros, anti-patterns to avoid, and handoff between application releases and macro library levels. Treat it as the operational companion to syntax, arguments, and expansion tutorials—you know how macros work; here is how organizations keep them working for decades.
Enterprise installations catalog macro libraries in compile JCL or IDE host profiles. Preprocessor search order may include application-private macros first, then department standard library, then site-wide layout library. Document search order so a duplicate macro name in two libraries does not surprise developers with wrong expansion.
| Tier | Typical contents | Change rigor |
|---|---|---|
| Site-wide | PERSNL, GL-MASTER, standard TITLE blocks | Highest— CAB approval |
| Application | App-specific FILE variants | Application lead review |
| Developer test | MSTART instream prototypes | Local only—never production invoke |
Instead of one MEGA-LAYOUT macro emitting FILE, fifty DEFINE fields, REPORT headers, and working storage, split responsibilities. Callers compose invocations in library section order matching valid Easytrieve structure.
123456%PERSNL-FILE %PERSNL-WORK %STD-PAGE-HDR PAY-RPT JOB INPUT PERSNL PRINT PAY-RPT
| Pattern | Example | Meaning |
|---|---|---|
| FILE suffix | PERSNL-F | FILE/DEFINE layout only |
| RPT prefix | RPT-STD | Report skeleton lines |
| Version suffix | PERSN2 | Parallel migration macro |
| App prefix | PY-PERSNL | Payroll-specific variant |
Eight-character default limit forces abbreviations—publish a site dictionary mapping abbreviations to full file names.
Header comment block on each macro member should list positional order, keyword defaults, invoking example, owning team, and last data dictionary version. Future maintainers should not reverse-engineer invocation from body alone.
123456* MACRO: PERSNL-F OWNER: HR-DATA DICT: 2026-03 * POS: none KEY: RECLEN default 150 BLKSIZE default 1800 * EXAMPLE: %PERSNL-F RECLEN=200 MACRO 0 RECLEN 150 BLKSIZE 1800 ... MEND
Single source for FILE offsets—highest reuse value. Pair with data dictionary automation where available.
TITLE and LINE macros enforce audit headers (date, page, department name) consistently across regulated reports.
Db2 table macros generate INCLUDE field sets for programs accessing same tables—reduce drift between online and batch Easytrieve SQL.
Parameterized DEFINE VALUE blocks for application ID or company code in multi-tenant batch streams.
Breaking changes need explicit strategy. Parallel macro name (PERSNL2) lets teams migrate program-by-program. Big-bang migration updates all invocations in one release window with full regression suite. Never change production macro in place without caller inventory—grep source libraries for %MACRONAME before edit.
Before any shared macro edit, run source search across PDS libraries for % invocations. Endevor impact analysis may list elements including macro references in compile control cards. Maintain spreadsheet of top invoking programs for quick regression subset.
Onboarding should include: where macro libraries live, how to read expansion listings, parameter header comments, and who approves site-wide changes. Junior developers invoke macros first; senior owners edit library members after review.
Reuse is sharing one good recipe card in the school kitchen instead of every kid writing their own. If the recipe card gets a typo fix, every kid who uses the card gets the fix next time they cook—but only if they pick up the new card. The library is the recipe box; change control is the teacher approving recipe edits.
1. Production macros should live in:
2. After editing a shared FILE macro you should:
3. Macro reuse differs from copy-paste because:
4. Breaking change to positional parameter order requires:
5. Good macro reuse candidate is: