View previous topic :: View next topic
Author
Message
sasikumar1984 Active User Joined: 02 Jul 2007Posts: 109 Location: Chennai - India
Hi,
I just wanted to remove last five records in a file. its a VB file and LREC is 996.
Back to top
enrico-sorichetti Superior Member Joined: 14 Mar 2007Posts: 10873 Location: italy
when You asked about removing the last record You were given this reply
Code:
//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input file (VB/600)
//SORTOUT DD DSN=&&C1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//SYSIN DD *
OPTION COPY
OUTFIL VTOF,BUILD=(80:X),REMOVECC,NODETAIL,
TRAILER1=(' OPTION COPY,STOPAFT=',COUNT-1=(M11,LENGTH=8))
/*
//S2 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input file (VB/600)
//SORTOUT DD DSN=... output file (VB/600)
//SYSIN DD DSN=&&C1,DISP=(OLD,PASS)
what about showing a bit of ingenuity and try to use the same approach
changing COUNT-1 to COUNT-5
Back to top
Frank Yaeger DFSORT Developer Joined: 15 Feb 2005Posts: 7129 Location: San Jose, CA
Sasikumar,
If you have z/OS DFSORT V1R5 PTF UK90013 (July, 2008), you can use a DFSORT/ICETOOL job 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) INPUT REMOVE LAST(5)
/*
If you don't have PTF UK90013, ask your System Programmer to install it (it's free).
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
sasikumar1984 Active User Joined: 02 Jul 2007Posts: 109 Location: Chennai - India
Code:
//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input file (VB/600)
//SORTOUT DD DSN=&&C1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//SYSIN DD *
OPTION COPY
OUTFIL VTOF,BUILD=(80:X),REMOVECC,NODETAIL,
TRAILER1=(' OPTION COPY,STOPAFT=',COUNT-1=(M11,LENGTH=8))
/*
//S2 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input file (VB/600)
//SORTOUT DD DSN=... output file (VB/600)
//SYSIN DD DSN=&&C1,DISP=(OLD,PASS)
I tried to understand the above code, but seems my understand is wrong. But i got output as i expected.
In step 1 it is trying to build a sort card for &&C1, and this &&C1 is used as a sort card in second step.
But why we used COPY keyword twice and what is (M11,LENGTH=8).
I couldnot able to get it for my knowledge. Can someone please explain me how the two steps are working.
Thanks for providing me this code.
Back to top
Aaru Senior Member Joined: 03 Jul 2007Posts: 1287 Location: Chennai, India
Sasi,
The code which you told produced the desired output.
Quote:
//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input file (VB/600)
//SORTOUT DD DSN=&&C1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//SYSIN DD *
OPTION COPY
OUTFIL VTOF,BUILD=(80:X),REMOVECC,NODETAIL,
TRAILER1=(' OPTION COPY,STOPAFT=',COUNT-1 =(M11,LENGTH=8))
/*
//S2 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input file (VB/600)
//SORTOUT DD DSN=... output file (VB/600)
//SYSIN DD DSN=&&C1,DISP=(OLD,PASS)
But your Original reqt was
Quote:
I just wanted to remove last five records in a file. its a VB file and LREC is 996.
You would not have got the desired output as the code is for removing the last record alone.
Quote:
In step 1 it is trying to build a sort card for &&C1, and this &&C1 is used as a sort card in second step.
Yep, you are correct. It creates a temporary dataset C1 with the control statements which is then used in the SYSIN of the second step.
Quote:
But why we used COPY keyword twice
The first COPY is needed to create the temporary dataset with the count. First the records are copied, count is got and the records are not written as NODETAIL is used. Otherwise, You will not be able to get the count.
Quote:
what is (M11,LENGTH=8).
It is an edit mask with a definite pattern. LENGTH is used so that the coutn that is displayed will be of length 8.
Quote:
Can someone please explain me how the two steps are working.
Simple. The sort card is created dynamically and used.
Hope this helps
Back to top
sasikumar1984 Active User Joined: 02 Jul 2007Posts: 109 Location: Chennai - India
Thanks for explaination Aaru.
Ya ya i changed that COUNT-1 to COUNT-5. it worked fine....
Back to top
Aaru Senior Member Joined: 03 Jul 2007Posts: 1287 Location: Chennai, India
Sasi,
Quote:
Thanks for explaination Aaru.
You are welc me.
Quote:
Ya ya i changed that COUNT-1 to COUNT-5. it worked fine....
Good to hear.
Back to top
sasikumar1984 Active User Joined: 02 Jul 2007Posts: 109 Location: Chennai - India
I have one doubt... In step one, we created dynamic sort card.
What is 'BUILD=(80:X)' , can someone tel me why we are using it? Are we making ourput file of record length 80?? and why we are converting VTO F???
Please can someone tell me.
Back to top
gcicchet Senior Member Joined: 28 Jul 2006Posts: 1702 Location: Australia
Hi,
LRECL for SYSIN parameter in DFSORT is 80.
BUILD=(80:X) allows you to increase the record length of your output records to 80 bytes padded with blanks.
As the input file you are reading is a VB file you neeed to use VTOF to convert the file from VB to FB.
Gerry
Back to top
Please enable JavaScript!