I am learning mainframe programming (TSO, JCL, COBOL...) and I came across a problem I can't seem to solve, yet.
I have a file with records that contain 3 fields and I want to use 'outfil' to include only certain records in the output file.
My JCL is the following:
000001 //C8112J1 JOB (12345678),C8112,MSGCLASS=H,
000002 // MSGLEVEL=(1,1),NOTIFY=C8112
(...)
000007 //DSNDEL EXEC PGM=IDCAMS
000008 //SYSPRINT DD SYSOUT=*
000009 //SYSIN DD *
000010 DELETE C8112.DATA.FX.SORT
000011 SET MAXCC = 0
000012 /*
(...)
000014 //* --------- S O R T -----------
000020 //MYSORT EXEC PGM=SORT,COND=(0,NE)
000021 //SORTIN DD DSN=C8112.DATA.FX,DISP=SHR
000022 //SORTOUT DD DSN=C8112.DATA.FX.SORT,
000023 // SPACE=(TRK,(100,100),RLSE),
000024 // DISP=(NEW,CATLG,DELETE),
000025 // DCB=(LRECL=61,RECFM=FB)
000026 //SYSIN DD *
000027 SORT FIELDS=COPY
000028 //* SORT FIELDS=(1,18,CH,A) OU SORT=COPY
000029 OUTFIL INCLUDE=(1,18,CH,EQ,C'ANDRADE,LUISA')
...
000031 //* OUTREC=(39,41,1,18,19,38)
000032 END
000033 //SYSOUT DD SYSOUT=*
000034 /*
and the output file:
000001 LUIS,CARLOS AV.PAULO VI RMR
000002 DIAS,PATTY RUA PEDRO CALMON LX
000003 ANDRADE,LUISA AV. DA LIBERDADE LX (1)
000004 SILVA,TONI PALACIO VALMOR LX
000005 ANDRADE,LUISA AV. DA BOAVISTA POT (2)
000006 CISCO,MANUEL QUINTA DA AVELEDA TC
Wasn't I supposed to get only the records (1) and (2)?! By the way, I also tried the 'outrec' to change the bytes organization but it didn't work too. Can anyone give me a hint on what I am doing wrong?
Try the following:
000020 //MYSORT EXEC PGM=SORT,COND=(0,NE)
000021 //SORTIN DD DSN=C8112.DATA.FX,DISP=SHR
000022 //SORTOUT DD DSN=C8112.DATA.FX.SORT,
000023 // SPACE=(TRK,(100,100),RLSE),
000024 // DISP=(NEW,CATLG,DELETE),
000025 // DCB=(LRECL=61,RECFM=FB)
000026 //SYSIN DD *
000027 SORT FIELDS=COPY
000029 OUTFIL INCLUDE=(1,18,CH,EQ,C'ANDRADE,LUISA')
...
000032 END
000031 /*
000033 //SYSOUT DD SYSOUT=*
000034 //*
SORT SYSIN does not allow for "comments". Those lines you thought might have been comments really are't. They terminate the SYSIN DD statements. Basically I just got rid of:
//* SORT FIELDS=(1,18,CH,A) OU SORT=COPY
and
//* OUTREC=(39,41,1,18,19,38)
then it all works fine. Remember, a JCL comment is not a SORT comment! The stuff after a DD *
are data, not JCL source statements so JCL type commenting conventions do not work here. The DD *
is typically terminated by a line starting with: /*
.