What I try to achieve is to omit some record numbers. I have a list of records to remove from a dataset (Ex: 5,9,38,..).
5 mean the fifth record in the dataset, etc..
I found that there is the STARTREC and ENDREC that can be used in a OUTFIL group, but this cannot achieve what I wan to do.
With this, we can put records from 1..4 to one file, omit rec 5, put 6..8 to another file, omit 9, put 10..37 to another file, etc
But of course, I would like 1..4,6..8,10..37 to be in the same file !
I found a solution, but I don't like it, as I have to refer to the LRECL of the dataset. And as I will use this to process different LRECLs, I don't want to hardcode them in the JCL.
But, here it is for you information, and in case you have an idea on it:
with SEQNUM, I generate a sequence number which I add as the first field of the input data set.
For this, I do : INREC BUILD=(SEQNUM,8,ZD,1,247) --> where 1,247 means append the input dataset (247 is its LRECL, that what I don't want to refer to).
Then, I can use the OMIT command to as OMIT=(1,8,EQ,ZD,5,OR,1,8,EQ,ZD,9,OR,1,8,EQ,ZD,38,...).
After that, OUTREC BUILD=(9,247) so I can remove the sequence number from the output (again I reference the LRECL of the input file)
In that case, what I would need is a way of avoid putting the length (247) but something that says 'till the end of the record'. I saw that this exists omitting the length for variable length records (V), but mine are fixed (FB).
The records to skip are not known in advance. I have a cobol program that says which records to skip. My cobol is generic, it can read an input file of any LRECL. But cobol has a limitation that says you have to specify in advance the record buffer length for output files. So I cannot use my cobol program to write in 1 file the accepted records and in another 1 the rejected ones (because I don't know in advance the LRECL of the input file. Am I clear?). So my solution is that my cobol will write in a 80-bytes file the SYSIN, etc data to provide to the next SORT JCL step. So it is my cobol program that will write lines such :
COPY FROM(IN) TO(OUT) USING(CTL1)
COPY FROM(IN) TO(OUT) USING(CTL2)
COPY FROM(IN) TO(OUT) USING(CTL3)
.
Now, about the solution Shankar provided, this cannot work for me, as with this solution we use an unknown in advanced number of CTLXCNTL DD files. But my cobol program must have his output files declared in advanced in its program.
So I tried it as suggested it should work too with OUTFIL.
Hence, using only 1 SYSIN DD that would my cobol generate.
For a test I tried the following, but I have unexpected results.
Here the job:
So with that job I want to put records 2,5,7,8 in REJECTF dataset
and the others in ACCEPTF (the SAVE command takes what hasn't been taken). Unexpected results because in results I have:
For REJECTF --> only record 2
For ACCEPTF--> all the others
So it seems, like it takes only the first OUTFIL FNAMES=REJECTF command.
Any clue?
By the meantime, thanks because this is already a progress.
You could use a different output data set for each OUTFIL statement and then copy all of the resulting output data sets to one MOD output data set in another step. For example:
The problem with the different output datasets is that we don't know in advance how many of them there will be. This is going to be a problem because the cobol program which will generate these datasets must know in advance the number of them.
The solution you provide should work is the cobol program does not generate the outfil datasets but a complete JCL. Then my source JCL would include the dataset containing the cobol generated JCL and put it in the internal reader so it can be executed.
Your cobol pgm can create a file with seqnum values of your records you want to reject in a VB file. Concatenate it with your input VB file and use SELECT with NODUPS to get what you want.
Thank you for the answer. It is indeed something like this I'm now implemeting.
In fact, I generate a file with LRECL=1. A record contains 'A' for accepted and 'R' for rejected. In the SORT program, I generate the sequence number for the 2 files so I can concatenate them. Then I use INCLUDE and SAVE for saving in one files the one with contain 'A' and in the other the ones containing the 'R'.
But, I generate the DD files containing the SORT commands in the COBOL program. This is because when you concatenate the files, you don't want at the end the sequence number to appear in your output datasets. So you have to to something like OUTREC BUILD=(9,146), where 146 is the LRECL of the initial input file. As I have 30 possible LRECLs, I don't want to hard-code them in the JCL, so they are generated from the cobol pgm which knows the LRECL of the input file.