Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Skip Last 5 records

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
sasikumar1984

Active User


Joined: 02 Jul 2007
Posts: 109
Location: Chennai - India

PostPosted: Tue Aug 26, 2008 5:11 pm    Post subject: Skip Last 5 records
Reply with quote

Hi,

I just wanted to remove last five records in a file. its a VB file and LREC is 996.
Back to top
View user's profile Send private message

enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10288
Location: italy

PostPosted: Tue Aug 26, 2008 5:24 pm    Post subject: Reply to: Skip Last 5 records
Reply with quote

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
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


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

PostPosted: Tue Aug 26, 2008 9:13 pm    Post subject:
Reply with quote

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:

www.ibm.com/systems/support/storage/software/sort/mvs/ugpf/
Back to top
View user's profile Send private message
sasikumar1984

Active User


Joined: 02 Jul 2007
Posts: 109
Location: Chennai - India

PostPosted: Thu Aug 28, 2008 6:51 am    Post subject: Reply to: Skip Last 5 records
Reply with quote

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
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1288
Location: Chennai, India

PostPosted: Thu Aug 28, 2008 11:57 am    Post subject: Reply to: Skip Last 5 records
Reply with quote

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
View user's profile Send private message
sasikumar1984

Active User


Joined: 02 Jul 2007
Posts: 109
Location: Chennai - India

PostPosted: Fri Aug 29, 2008 6:59 am    Post subject: Thanks Aaru Vedam
Reply with quote

Thanks for explaination Aaru.

Ya ya i changed that COUNT-1 to COUNT-5. it worked fine....
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1288
Location: Chennai, India

PostPosted: Fri Aug 29, 2008 11:22 am    Post subject: Reply to: Skip Last 5 records
Reply with quote

Sasi,

Quote:
Thanks for explaination Aaru.


You are welc icon_biggrin.gif me.

Quote:
Ya ya i changed that COUNT-1 to COUNT-5. it worked fine....


Good to hear.
Back to top
View user's profile Send private message
sasikumar1984

Active User


Joined: 02 Jul 2007
Posts: 109
Location: Chennai - India

PostPosted: Mon Sep 01, 2008 6:52 am    Post subject: Hi All,
Reply with quote

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
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1703
Location: Australia

PostPosted: Mon Sep 01, 2008 10:29 am    Post subject:
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Check if any Detail records and extra... V S Amarendra Reddy SYNCSORT 19 Mon May 08, 2017 8:54 pm
No new posts Join giving more records than expected Danielle.Filteau SYNCSORT 2 Thu Mar 09, 2017 3:28 am
No new posts TSO or command line utility to genera... kishpra JCL & VSAM 3 Thu Mar 09, 2017 1:11 am
No new posts Extract set of records matching on ac... bhaskar_kanteti DFSORT/ICETOOL 3 Mon Mar 06, 2017 7:19 am
No new posts Inserting records based on conditions vickey_dw DFSORT/ICETOOL 9 Wed Feb 22, 2017 1:33 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us