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

Skip Last 5 records


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
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
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

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Tue Aug 26, 2008 5:24 pm
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 Developer


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

PostPosted: Tue Aug 26, 2008 9:13 pm
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:

Use [URL] BBCode for External Links
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
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: 1287
Location: Chennai, India

PostPosted: Thu Aug 28, 2008 11:57 am
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
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: 1287
Location: Chennai, India

PostPosted: Fri Aug 29, 2008 11:22 am
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
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: 1702
Location: Australia

PostPosted: Mon Sep 01, 2008 10:29 am
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Join multiple records using splice DFSORT/ICETOOL 5
No new posts EZT program to build a flat file with... All Other Mainframe Topics 9
No new posts JCL sortcard to print only the records DFSORT/ICETOOL 11
Search our Forums:

Back to Top