38 Using IBM Application Development Tools for z/OS and OS/390
Figure 2-20 Computer generated record
The default values for the fields are mostly fixed, as listed in Table 2-2.
Table 2-2 Some default values used in the example
2.1.9 How to split a single file into constituent record types
There may be times when you need to take one or more of the record types in a multi-record
file and segregate the records for additional processing. The recommended way to do this is
by using a DFSORT procedure. We show batch job streams, using both DFSORT and REXX
procedures, that take a file and split it into three record types. All other record types are
ignored.
The required DFSORT procedure would be similar to that shown in Example 2-8.
Example 2-8 DFSORT procedure
//*
//FILEMGR EXEC PGM=FMNMAIN
//STEPLIB DD DSN=FMN.V4R1M0.SFMNMOD1,DISP=SHR
//* DD DSN=IGY.SIGYCOMP,DISP=SHR
//REC01 DD DSN=REDBK2.TEST.SEQFILEA,DISP=OLD
//REC02 DD DSN=REDBK2.TEST.SEQFILEB,DISP=OLD
//REC03 DD DSN=REDBK2.TEST.SEQFILEC,DISP=OLD
//SYSPRINT DD SYSOUT=*
Field Type Default value
CUST-NM AN FX 'TEST ADT' repeat
KEYREC-DOT AN FX ‘x’
COMP-NM AN RO 'aaabbbcccdddeeefff'
DEC-NO-SHARES PD Init=10, Incr=7
BUY-FROM AN FX ‘Unknown’
BUY-FROM-NO AN RA '0123456789'
Chapter 2. Introducing File Manager 39
//FMNTSPRT DD SYSOUT=*
//SYSTERM DD SYSOUT=*
//SYSIN DD *
$$FILEM DSC DSNIN=REDBK2.TEST.SEQFILE,
$$FILEM POSITION=0,
$$FILEM DISP=MOD,
$$FILEM DSNOUT=REDBK2.TEST.SEQFILEX,
$$FILEM PROC=*
*FASTPROC
OUTFIL FNAMES=REC01,INCLUDE=(1,2,CH,EQ,C'01')
OUTFIL FNAMES=REC02,INCLUDE=(1,2,CH,EQ,C'02')
OUTFIL FNAMES=REC03,INCLUDE=(1,2,CH,EQ,C'03')
/+
The same requirement can be met by using an in-stream REXX routine to process the
records.The File Manager step of the batch job, shown in Example 2-9, illustrates this.
Example 2-9 File Manager step of batch job
//*
//FILEMGR EXEC PGM=FMNMAIN
//STEPLIB DD DSN=FMN.V4R1M0.SFMNMOD1,DISP=SHR
//* DD DSN=IGY.SIGYCOMP,DISP=SHR
//REC01 DD DSN=REDBK2.TEST.SEQFILEA,DISP=OLD
//REC02 DD DSN=REDBK2.TEST.SEQFILEB,DISP=OLD
//REC03 DD DSN=REDBK2.TEST.SEQFILEC,DISP=OLD
//SYSPRINT DD SYSOUT=*
//FMNTSPRT DD SYSOUT=*
//SYSTERM DD SYSOUT=*
//SYSIN DD *
$$FILEM DSC DSNIN=REDBK2.TEST.SEQFILE,
$$FILEM POSITION=0,
$$FILEM DISP=MOD,
$$FILEM DSNOUT=REDBK2.TEST.SEQFILEX,
$$FILEM PROC=*
DDNAME = 'REC' || FLD(1,2)
IF NCO(FLD(1,2),1,2,3) THEN DO
WRITE(DDNAME)
RETURN 'DROP'
END
/+
What is happening in these jobs
The file SEQFILE is the input file that contains multiple record types. The default output file
has the DD name SEQFILEX. Each of the record types we are interested in go into REC01,
REC02, or REC03.
The File Manager program keyword DSC is used to invoke the Data Set Copy function. The
input and output files are identified, and the keyword PROC=* is used to indicate that an
in-stream routine is being supplied.
The result is that all type 01 records end up in REC01, type 02 records go to REC02, type 03
records go to REC03, and all other record types go to the file EXTRA.
Let us review the report output
The key portion of the batch job’s output report is listed in Example 2-10.
Get Using IBM Application Development Tools for z/OS and OS/390 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.