This example reads records, extracts a name from the records and copies it to an output record, and writes the output records.
This does not check for whether the files were opened and closed successfully, and it does not use the structured macros.
We have the following lines in the JCL:
//INFILE DD DSN=WHATEVER.IT.IS,DISP=SHR
//OUTFILE DD SYSOUT=*
We have the following in the executable code:
MVI FLAG,C'N' Initialize the flag.
OPEN (OUTDCB,(OUTPUT))
OPEN (INDCB,(INPUT))
GET INDCB,INREC Read the 1st record.
LOOP DS 0H
CLI FLAG,C'Y' Check the flag.
BE ENDLOOP If done, end the loop.
MVC OUTNAME(15),INNAME Copy the name.
PUT OUTDCB Write the detail line
MVC 0(121,1),OUTREC into the output buffer.
GET INDCB,INREC Read the next record.
B LOOP
ENDLOOP DS 0H
CLOSE (INDCB)
CLOSE (OUTDCB)
We have the following in storage:
FLAG DS C End-of-file flag for INFILE.
INDCB DCB DDNAME=INFILE,DEVD=DA,DSORG=PS,MACRF=GM,EODAD=INEOF
* For INFILE, other DCB parameters will be taken from the label record.
OUTDCB DCB DDNAME=OUTFILE,DEVD=DA,DSORG=PS,LRECL=121,BLKSIZE=1210, X
RECFM=FBA,MACRF=PL
* OUTFILE is a new file, so all parameters are listed.
INREC DS 0H Input record.
INNAME DS 15C
INOTHER DS 65C
OUTREC DS 0H Output record.
DC C'0' Double-spacing.
OUTNAME DS 15C
DS 105C' '
INEOF DS 0H INFILE end-of-data routine.
MVI FLAG,C'Y' Change the flag.
BR 14 Return from the EODAD.
* We put the EODAD down here to be sure it will not be executed
* by accident.