View previous topic :: View next topic
Author
Message
ramsri Active User Joined: 18 Oct 2008Posts: 380 Location: India
Hi,
We have a file (RECFM=FB & LRECL=300) with 2 lac records in it. I need to copy the records from particular number to particular number to output file (we can use STARTREC & ENDREC with OPTION COPY). But, the starting record should have "HDR" at column position 21 and ending record should have "TLR" at column position 31. So, I need to copy only the records between these.
My thought is like using INCLUDE with condition to search the file for "HDR" or "TLR" and passing on the record number to STARTREC and ENDREC respectively. I am not able to convert my idea into coding.
Please help.
Thanks.
Back to top
acevedo Active User Joined: 11 May 2005Posts: 344 Location: Spain
I'do it in 2 steps.
1-to get the SEQNUM associated to HDR and LTR (using INREC), the output would be the sysin to the second step.
OUTFIL STARTREC=positionofHDRhere,ENDREC=positionofLTRhere
2-sort with the previous sysin (+ option copy)
sure other members could achieved in one step.
hth
Back to top
ramsri Active User Joined: 18 Oct 2008Posts: 380 Location: India
Hi,
Based on your suggestions this is how I could write my job but unsuccessful
Code:
//STEP0101 EXEC PGM=SORT
//SORTOUT DD DSN=&&T1,DISP=(MOD,PASS,DELETE),SPACE=(TRK,(1,1),RLSE)
//SYSOUT DD SYSOUT=*
//SORTIN DD *
ABCD1111
BCDE2222
CDEF3333
DEFG4444
EFGH5555
FGHI6666
GHIJ7777
HIJK8888
IJKL9999
JKL10000
/*
//SYSIN DD *
OPTION COPY
INREC BUILD=(1,8,10:SEQNUM,3,ZD)
/*
//STEP0102 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTOUT DD DSN=&&T2,DISP=(MOD,PASS,DELETE),SPACE=(TRK,(1,1),RLSE)
//SORTIN DD DSN=&&T1,DISP=(MOD,DELETE,DELETE)
//SYSIN DD *
OPTION COPY
INCLUDE COND=(5,4,ZD,EQ,2222,OR,5,4,ZD,EQ,8888)
OUTFIL IFTHEN=(WHEN=(5,4,ZD,EQ,2222),
BUILD=(2:C'OPTION COPY',/,
2:C'OUTFIL',X,C'STARTREC=',10,3,C',')),
IFTHEN=(WHEN=(5,4,ZD,EQ,8888),BUILD=(1:C'ENDREC=',10,3))
/*
//STEP0103 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTOUT DD SYSOUT=*
//SORTIN DD *
ABCD1111
BCDE2222
CDEF3333
DEFG4444
EFGH5555
FGHI6666
GHIJ7777
HIJK8888
IJKL9999
JKL10000
//SYSIN DD DSN=&&T2,DISP=(MOD,DELETE,DELETE)
/*
I am not able to understand why am getting all the 10 records into the output file where as it should be only 7.
The STEP0102 creates the temporary output file as given below:
Code:
OPTION COPY
OUTFIL STARTREC=002,
ENDREC=008
But when I look at the SYSOUT after completion of the job the SYSIN supplied to STEP0103 looks like this
Code:
SYSIN :
OPTION COPY OUTFIL STARTREC=002,ENDREC=008
OUTFIL STARTREC=002,ENDREC=008
ENDREC=008
I have tried hard but could not fix it......
Any suggestions or alternatives please
Thanks.
Back to top
ramsri Active User Joined: 18 Oct 2008Posts: 380 Location: India
Ok......at last, I have achieved it (per my thinking).......
The SYSIN in STEP0102 has been modified to get through it......
Code:
//SYSIN DD *
OPTION COPY
INCLUDE COND=(5,4,ZD,EQ,2222,OR,5,4,ZD,EQ,8888)
OUTFIL IFTHEN=(WHEN=(5,4,ZD,EQ,2222),
BUILD=(2:C'OPTION COPY',77X,/,
2:C'OUTFIL',X,C'STARTREC=',10,3,C',',67X)),
IFTHEN=(WHEN=(5,4,ZD,EQ,8888),BUILD=(2:C'ENDREC=',10,3))
/*
I request the SYNCSORT experts to fine tune this so that lots of junk can be removed.......
Thanks a lot to acevedo for giving the idea........
Back to top
Frank Yaeger DFSORT Developer Joined: 15 Feb 2005Posts: 7129 Location: San Jose, CA
For those of you who have DFSORT, you can do this kind of thing quite easily with the new WHEN=GROUP function available with z/OS DFSORT V1R5 PTF UK90013 (July, 2008).
Quote:
the starting record should have "HDR" at column position 21 and ending record should have "TLR" at column position 31. So, I need to copy only the records between these.
Here's the DFSORT job for this one:
Code:
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input file (FB/300)
//SORTOUT DD DSN=.. output file (FB/300)
//SYSIN DD *
OPTION COPY
INREC IFTHEN=(WHEN=GROUP,BEGIN=(21,3,CH,EQ,C'HDR'),
END=(31,3,CH,EQ,C'TLR'),PUSH=(301:ID=1))
OUTFIL INCLUDE=(301,1,CH,NE,C' '),BUILD=(1,300)
/*
Here's the DFSORT job for the 2222-8888 one:
Code:
//S2 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD *
ABCD1111
BCDE2222
CDEF3333
DEFG4444
EFGH5555
FGHI6666
GHIJ7777
HIJK8888
IJKL9999
JKL10000
/*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INREC IFTHEN=(WHEN=GROUP,BEGIN=(5,4,ZD,EQ,2222),
END=(5,4,ZD,EQ,8888),PUSH=(81:ID=1))
OUTFIL INCLUDE=(81,1,CH,NE,C' '),BUILD=(1,80)
/*
For complete details on all of the new DFSORT and ICETOOL functions available with the July, 2008 PTF, see:
Use [URL] BBCode for External Links
Back to top
ramsri Active User Joined: 18 Oct 2008Posts: 380 Location: India
wow.......very useful and simplified.....
Thank you Frank.
Back to top
Please enable JavaScript!