Creating JCL for running a mainframe task is the most common use for ISPF's File Tailoring — because it does it so well. Too often, though, such tasks are approached with a 'Bigger Hammer' mentality because the process to be tailored is seen as uncomfortably complex. For instance: your installation uses COBOL, PL/I, and ForTran; some programs use DB2; some run as part of CICS. When it comes time to compile something, you may have to run the DB2 preprocessor; you may have to run the CICS preprocessor; the compiler must be appropriate to the source language; if the compile is successful, the object module is to be link-edited; much of the compiler listing for DB2/CICS modules is crap that does little beyond making the printed version harder to lift. Is the compiler listing to be saved as a dataset or just printed? If 'saved', where? Are you going to trim away all the frou-frou before you print or save?
Faced with such a collection of decisions, most installations opt to have individual PROCs for each potential combination and to name them under a convention that allows the programmer to correctly specify the name of the PROC that does a DB2/non-CICS/PLI compile-and-link. When a new compiler is released, somebody gets to fix and test a dozen PROCs to insert the updated library information, and it's usually several weeks before anyone realizes that an error sneaked through. Ouch.
The reason file tailoring is not considered in these instances is because of all those mays above. The DB2 precompile hands its output to the CICS precompile, but there may not be a DB2 precompile step at all. The compiler gets its input from the CICS precompile step... unless there isn't a CICS precompile step. Where does the input come from then? There is a solution.
You always start off with an IEFBR14, the safest program in the visible universe:
//ORIGIN EXEC PGM=IEFBR14 //SOURCE DD DISP=SHR,DSN=&SRCDS(&SRC) )SET LSTEP = ORIGIN )SET LDDN = SOURCE
Note that this piece of skeleton identifies itself by setting LSTEP and LDDN. Later steps can use these to find the input they need to focus upon. Let's posit that if we have to ZORK and PARFLE and FLENCH a program, they always happen in that order, although some (or none) of them may happen at all.
)SEL &ZORK = Y //* --------------- ZORK processor -------------- */ //ZORK EXEC PGM=ZORK //SYSIN DD DSN=*.&LSTEP..&LDDN //SYSPRINT DD SYSOUT=* //SHIPOUT DD UNIT=VIO,SPACE=(CYL,(5,1)),DISP=(,PASS), // DCB=(RECFM=FB,LRECL=80,BLKSIZE=0) )SET LSTEP = ZORK )SET LDDN = SHIPOUT // IF (ZORK.RC << 8) THEN )ENDSEL &ZORK = Y )SEL &PARFLE = Y //* --------------- PARFLE processor ------------ */ //PARFLE EXEC PGM=PARFLV2 //PARFIN DD DSN=*.&LSTEP..&LDDN //SYSPRINT DD SYSOUT=* //PARFOUT DD UNIT=VIO,SPACE=(CYL,(5,1)),DISP=(,PASS), // DCB=(RECFM=FB,LRECL=80,BLKSIZE=0) )SET LSTEP = PARFLE )SET LDDN = PARFOUT // IF (PARFLE.RC << 4) THEN )ENDSEL &PARFLE = Y )SEL &FLENCH = Y //* --------------- FLENCH processor ------------ */ //FLENCH EXEC PGM=FLENCH00 //SYSIN DD DSN=*.&LSTEP..&LDDN //SYSPRINT DD SYSOUT=* //OUTFLEN DD UNIT=VIO,SPACE=(CYL,(5,1)),DISP=(,PASS), // DCB=(RECFM=FB,LRECL=80,BLKSIZE=0) )SET LSTEP = FLENCH )SET LDDN = OUTFLEN // IF (FLENCH.RC << 8) THEN )ENDSEL &FLENCH = Y
If the ZORK processor is activated, it gets its input from '*.ORIGIN.SOURCE' because those are the current settings for LSTEP and LDDN. When it's complete, it indicates that any later steps should use ZORK.SHIPOUT by setting LSTEP to 'ZORK' and LDDN to 'SHIPOUT'. If the ZORK processor is not activated, LSTEP remains set at 'ORIGIN' and LDDN at 'SOURCE'.
If only the FLENCH processor is cleared to run, neither of the other two steps have altered LSTEP or LDDN and it picks up the dataset mentioned by the IEFBR14 step as its input. Whichever combination of steps ran or didn't, the next step downstream will always find its input via '*.&LSTEP..&LDDN'.
Of course, things could be more complicated necessitating a little more finesse, but File Tailoring is, I assure you, up to the task.