IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

OMIT record numbers, LRECL unknown


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
julienloc

New User


Joined: 17 Aug 2007
Posts: 29
Location: Brussels

PostPosted: Fri Aug 17, 2007 6:16 pm
Reply with quote

Hi,

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).

So..any idea?

Thanks.

Synthetis.
Back to top
View user's profile Send private message
shankar.v

Active User


Joined: 25 Jun 2007
Posts: 196
Location: Bangalore

PostPosted: Fri Aug 17, 2007 6:44 pm
Reply with quote

By using DISP=(MOD,CATLG.. in output file, we can append the records by using SKIPREC, STOPAFT or by using OUTFIL STARTREC, ENDREC

Code:
// EXEC PGM=ICETOOL
//DFSMSG DD SYSOUT=*
//TOOLMSG DD SYSOUT=*
//IN DD DSN=INFILE
//OUT DD DSN=OUTFILE,DISP=(MOD,CATLG)
//TOOLIN DD *
 COPY FROM(IN) TO(OUT) USING(CTL1)
 COPY FROM(IN) TO(OUT) USING(CTL2)
 COPY FROM(IN) TO(OUT) USING(CTL3)
 .
 .
 .
//CTL1CNTL DD *
 OPTION COPY,STOPAFT=4
//CTL2CNTL DD *
 OPTION COPY,SKIPREC=5,STOPAFT=3
//CTL3CNTL DD *
 OPTION COPY,SKIPREC=9,STOPAFT=28
.
.
.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Fri Aug 17, 2007 7:19 pm
Reply with quote

Hello,

How is it that you know which record numbers to skip?

Seems like if the skip-record number(s) is/are known, they could be skipped during creation?

If we better understood your requirement, we might have better suggestions.

When i've seen a need to copy a file, skipping some records, the skip is controlled by some value(s), not record number/placement in the file.
Back to top
View user's profile Send private message
julienloc

New User


Joined: 17 Aug 2007
Posts: 29
Location: Brussels

PostPosted: Fri Aug 17, 2007 7:49 pm
Reply with quote

Hi,

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:
Code:
//FILTER   EXEC PGM=SORT                       
//  SET PREFIX='JLO.TEST.FILES'                 
//  SET INF='TEST'                             
//SYSOUT  DD SYSOUT=*                         
//SORTIN  DD DSN=&PREFIX..&INF,               
//           DISP=OLD                         
//ACCEPTF DD DSN=&PREFIX..ACCEPT,             
//           DISP=(MOD,CATLG),               
//           LIKE=&PREFIX..&INF               
//REJECTF DD DSN=&PREFIX..REJECT,             
//           DISP=(MOD,CATLG),               
//           LIKE=&PREFIX..&INF               
//SYSIN DD *                                   
    OPTION COPY                               
    OUTFIL FNAMES=REJECTF,STARTREC=2,ENDREC=2 
    OUTFIL FNAMES=REJECTF,STARTREC=5,ENDREC=5 
    OUTFIL FNAMES=REJECTF,STARTREC=7,ENDREC=8 
    OUTFIL FNAMES=ACCEPTF,SAVE                 
//* 


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.

Julien.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Fri Aug 17, 2007 8:56 pm
Reply with quote

Quote:
it seems, like it takes only the first OUTFIL FNAMES=REJECTF command.


Yes, as expected. If you're using DFSORT, you would have received a warning message to indicate that:

Code:

              OUTFIL FNAMES=REJECTF,STARTREC=2,ENDREC=2   
              OUTFIL FNAMES=REJECTF,STARTREC=5,ENDREC=5     
ICE219I 0 DUPLICATE DDNAME REJECTF  IGNORED                 


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:

Code:

//S1   EXEC PGM=SORT                       
//SYSOUT  DD SYSOUT=*                         
//SORTIN  DD DSN=... input file
//OUT1 DD DSN=&&O1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)   
//OUT2 DD DSN=&&O2,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)             
//OUT3 DD DSN=&&O3,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)                         
//ACCEPTF DD DSN=...   accept output file           
//SYSIN DD *                                   
    OPTION COPY                               
    OUTFIL FNAMES=OUT1,STARTREC=2,ENDREC=2 
    OUTFIL FNAMES=OUT2,STARTREC=5,ENDREC=5 
    OUTFIL FNAMES=OUT3,STARTREC=7,ENDREC=8 
    OUTFIL FNAMES=ACCEPTF,SAVE                 
/* 
//S2   EXEC PGM=SORT                       
//SYSOUT  DD SYSOUT=*                         
//SORTIN  DD DSN=&&O1,DISP=(OLD,PASS)
//  DD DSN=&&O2,DISP=(OLD,PASS)
//  DD DSN=&&O3,DISP=(OLD,PASS)
//SORTOUT DD DISP=(MOD,CATLG),DSN=...  reject output file   
//SYSIN DD *                                   
    OPTION COPY           
/*
Back to top
View user's profile Send private message
julienloc

New User


Joined: 17 Aug 2007
Posts: 29
Location: Brussels

PostPosted: Mon Aug 20, 2007 1:11 pm
Reply with quote

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.

That's a solution, but kind of complicated.

If you guys have another idea?

Thanks.

Julien.
Back to top
View user's profile Send private message
Alain Benveniste

New User


Joined: 14 Feb 2005
Posts: 88

PostPosted: Mon Aug 20, 2007 3:48 pm
Reply with quote

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.

Alain
Back to top
View user's profile Send private message
julienloc

New User


Joined: 17 Aug 2007
Posts: 29
Location: Brussels

PostPosted: Mon Aug 20, 2007 4:28 pm
Reply with quote

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.

I think this solution can work :-)

Thanks everyone for the help.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Tue Aug 26, 2008 1:48 am
Reply with quote

With z/OS DFSORT V1R5 PTF UK90013 (July, 2008) you can use DFSORT's new SUBSET operator to do this kind of thing quite easily like this:


Code:

//S1    EXEC  PGM=ICETOOL
//TOOLMSG   DD  SYSOUT=*
//DFSMSG    DD  SYSOUT=*
//IN DD DSN=...  input file
//OUT DD DSN=...  output file
//TOOLIN DD *
SUBSET FROM(IN) TO(OUT) REMOVE INPUT RRN(2) RRN(5) RRN(7,8)
/*


This will work for data sets with any attributes.

You can use up to 300 RRN operands each containing a single value (e.g. 2) or a range of values (e.g., 7,8).

For complete details on the new SUBSET function and the other new functions available with PTF UK90013, see:

Use [URL] BBCode for External Links
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts FINDREP - Only first record from give... DFSORT/ICETOOL 3
Search our Forums:

Back to Top