MainframeMaster

MODS

The MODS control statement tells DFSORT to use user-written exit routines. Exits are programs you write (typically in Assembler or COBOL) that DFSORT calls at specific points during processing. The most common are E15 (input exit—called as records are read) and E35 (output exit—called as records are written). You name your load module(s) in MODS; DFSORT loads them and invokes them according to the exit type. Exits let you implement logic that cannot be done with INCLUDE, OMIT, INREC, or OUTREC alone—for example, variable-length record parsing, one-to-many record creation, or custom formatting. This page covers what MODS does, E15 and E35, and how to specify and use user exits.

Control Statements
Progress0 of 0 lessons

What MODS Does

MODS (Modifications) is the statement that links your own code into the DFSORT step. You write one or more programs that conform to the DFSORT exit interface (calling convention, parameter list). You put the compiled load module in a library that the step can access (STEPLIB or JOBLIB), and you tell DFSORT which module(s) to use via MODS. When DFSORT reaches the appropriate phase, it calls your routine so you can inspect or change the record (or produce multiple records from one).

E15: Input Exit

The E15 exit is invoked during the input phase. For each input record (or block, depending on product and options), DFSORT calls your E15 routine. The routine can: pass the record through unchanged, modify the record and return it, drop the record (return a code that says "skip this record"), or return multiple records (one input record becomes several). So E15 is used when you need selection or transformation that goes beyond INCLUDE/OMIT/INREC—for example, parsing variable-length or complex records, or creating detail records from one header.

E35: Output Exit

The E35 exit is invoked during the output phase. When DFSORT is about to write a record, it can call your E35 routine. The routine can modify the record or request that it be dropped. So E35 is for custom output logic that cannot be expressed with OUTREC or OUTFIL alone.

Other Exits (E32, etc.)

DFSORT may support other exit points (e.g. E32). Their order and purpose are documented in the DFSORT Application Programming Guide. The principle is the same: MODS names the module, and DFSORT calls it at the defined point.

Specifying MODS

In SYSIN you code MODS=(load_module_name) or the form that assigns modules to exit types (e.g. E15=name1, E35=name2). The load module must be in a dataset in the step's library concatenation (STEPLIB or JOBLIB). If the exit is in the same module for more than one exit type, or in separate modules, follow your product's MODS syntax.

Explain It Like I'm Five

MODS is like saying: "When you read a card, call my helper first so they can change it or throw it away" (E15). And: "When you write a card, call my other helper so they can fix it before it goes in the box" (E35). Your helpers are the programs you write; MODS tells the sorter their names so it can call them.

Exercises

  1. When would you use an E15 exit instead of INCLUDE and INREC?
  2. What must be true about the load module named in MODS for the step to find it?

Quiz

Test Your Knowledge

1. What does MODS do in DFSORT?

  • Sorts the file
  • Specifies user-written exit routines (e.g. E15, E35) that DFSORT calls during processing
  • Merges two files
  • Defines the sort key

2. When is the E15 exit invoked?

  • After the sort
  • During the input phase—as each record is read, before the sort
  • Only with OPTION COPY
  • At the end of the job

3. When is the E35 exit invoked?

  • Before the sort
  • During the output phase—as each record is written
  • Only with MERGE
  • At job start

4. What language are DFSORT exits typically written in?

  • COBOL only
  • Assembler, or COBOL; they must follow the exit interface (register conventions, parameter list)
  • Java only
  • REXX only