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
 

 

How to get last 15000 records from a Flat file

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> SYNCSORT
View previous topic :: :: View next topic  
Author Message
Sachin Sukumaran

New User


Joined: 31 Jul 2012
Posts: 3
Location: India

PostPosted: Mon Jun 17, 2013 5:53 pm    Post subject: How to get last 15000 records from a Flat file
Reply with quote

I have a log file of 8.5 GB. I FTPed it to mainframe. I don't know the exact count of records of the file . I need to get the last 15000 records from that file.
I am expecting to get a JCL for this .
(Why I need this : I have a job hung , so only after getting the last records , I can debug this )

Thanks in advance
Back to top
View user's profile Send private message

Pandora-Box

Moderator


Joined: 07 Sep 2006
Posts: 1529
Location: Andromeda Galaxy

PostPosted: Mon Jun 17, 2013 6:31 pm    Post subject:
Reply with quote

Whats the sort product you have?
Back to top
View user's profile Send private message
Gary McDowell

Active User


Joined: 15 Oct 2012
Posts: 139
Location: USA

PostPosted: Mon Jun 17, 2013 6:41 pm    Post subject:
Reply with quote

I guess you could use something to count number of records on file first, then extract the last 15000 records - something like this...
Code:
//*-- COUNT NUMBER OF RECORDS ON FILE WITHOUT DETAIL SHOWING
//STEP010  EXEC PGM=SORT                                   
//SYSOUD   DD SYSOUT=*                                     
//SYSOUT   DD SYSOUT=*                                     
//SYSPRINT DD SYSOUT=*                                     
//SORTIN   DD DSN=INPUT.FILE.HERE,DISP=SHR                 
//SORTOUT  DD DSN=OUTPUT.FILE.HERE,                         
//            DISP=(NEW,CATLG,DELETE),                     
//            SPACE=(TRK,(1,1),RLSE),                       
//            UNIT=SYSDA,                                   
//            DCB=(LRECL=???,RECFM=FB,BLKSIZE=0)           
//SYSIN DD *                                               
   SORT FIELDS=COPY                                         
   OUTFIL NODETAIL,TRAILER1=(1/,5:'COUNT=',COUNT)           
/*                                                         
//*                                                         
//*                                                         
//*-- EXTRACT NUMBER OF RECORDS USING SKIP AND COUNT       
//STEP020  EXEC PGM=IDCAMS                     
//SYSPRINT DD SYSOUT=*                         
//SYSUDUMP DD SYSOUT=*                         
//SYSOUD   DD SYSOUT=*                         
//SYSOUT   DD SYSOUT=*                         
//FILEA    DD DSN=INPUT.FILE.HERE,DISP=SHR     
//FILEB    DD DSN=OUTPUT.FILE.HERE,             
//            DISP=(NEW,CATLG,DELETE),         
//            SPACE=(TRK,(120,60),RLSE),       
//            UNIT=SYSDA,                       
//            DCB=(LRECL=???,RECFM=FB,BLKSIZE=0)
//*                                             
//SYSIN   DD *                                 
   REPRO                         -             
      INFILE(FILEA)              -             
      SKIP(?????)  COUNT(15000)  -             
      OUTFILE(FILEB)                           
/*                                             
//                                             
Back to top
View user's profile Send private message
Sachin Sukumaran

New User


Joined: 31 Jul 2012
Posts: 3
Location: India

PostPosted: Mon Jun 17, 2013 6:50 pm    Post subject:
Reply with quote

Pandora-Box wrote:
Whats the sort product you have?

SYNCSORT
Back to top
View user's profile Send private message
Sachin Sukumaran

New User


Joined: 31 Jul 2012
Posts: 3
Location: India

PostPosted: Mon Jun 17, 2013 6:52 pm    Post subject:
Reply with quote

Gary McDowell wrote:
I guess you could use something to count number of records on file first, then extract the last 15000 records - something like this...
Code:
//*-- COUNT NUMBER OF RECORDS ON FILE WITHOUT DETAIL SHOWING
//STEP010  EXEC PGM=SORT                                   
//SYSOUD   DD SYSOUT=*                                     
//SYSOUT   DD SYSOUT=*                                     
//SYSPRINT DD SYSOUT=*                                     
//SORTIN   DD DSN=INPUT.FILE.HERE,DISP=SHR                 
//SORTOUT  DD DSN=OUTPUT.FILE.HERE,                         
//            DISP=(NEW,CATLG,DELETE),                     
//            SPACE=(TRK,(1,1),RLSE),                       
//            UNIT=SYSDA,                                   
//            DCB=(LRECL=???,RECFM=FB,BLKSIZE=0)           
//SYSIN DD *                                               
   SORT FIELDS=COPY                                         
   OUTFIL NODETAIL,TRAILER1=(1/,5:'COUNT=',COUNT)           
/*                                                         
//*                                                         
//*                                                         
//*-- EXTRACT NUMBER OF RECORDS USING SKIP AND COUNT       
//STEP020  EXEC PGM=IDCAMS                     
//SYSPRINT DD SYSOUT=*                         
//SYSUDUMP DD SYSOUT=*                         
//SYSOUD   DD SYSOUT=*                         
//SYSOUT   DD SYSOUT=*                         
//FILEA    DD DSN=INPUT.FILE.HERE,DISP=SHR     
//FILEB    DD DSN=OUTPUT.FILE.HERE,             
//            DISP=(NEW,CATLG,DELETE),         
//            SPACE=(TRK,(120,60),RLSE),       
//            UNIT=SYSDA,                       
//            DCB=(LRECL=???,RECFM=FB,BLKSIZE=0)
//*                                             
//SYSIN   DD *                                 
   REPRO                         -             
      INFILE(FILEA)              -             
      SKIP(?????)  COUNT(15000)  -             
      OUTFILE(FILEB)                           
/*                                             
//                                             



Thanks ! a lot - Let me give a try and will update you!
Back to top
View user's profile Send private message
Pandora-Box

Moderator


Joined: 07 Sep 2006
Posts: 1529
Location: Andromeda Galaxy

PostPosted: Mon Jun 17, 2013 7:38 pm    Post subject:
Reply with quote

Gary,

You could have dynamically created the SYSIN card for REPRO
Back to top
View user's profile Send private message
superk

Moderator Team Head


Joined: 26 Apr 2004
Posts: 4648
Location: Raleigh, NC, USA

PostPosted: Mon Jun 17, 2013 9:02 pm    Post subject: Reply to: How to get last 15000 records from a Flat file
Reply with quote

The usual process is to use SORT and add a sequence number field, sorting on that field in descending order. Then, another SORT to include only the first 15000 records, sorting on the sequence number field in ascending order and removing the sequence numbers from the final output.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7225

PostPosted: Mon Jun 17, 2013 9:11 pm    Post subject: Reply to: How to get last 15000 records from a Flat file
Reply with quote

Have a look at ICETOOL's SUBSET operator and use LAST(15000).
Back to top
View user's profile Send private message
Gary McDowell

Active User


Joined: 15 Oct 2012
Posts: 139
Location: USA

PostPosted: Mon Jun 17, 2013 10:23 pm    Post subject:
Reply with quote

Pandora-Box wrote:
Gary,

You could have dynamically created the SYSIN card for REPRO

Thanks.
Back to top
View user's profile Send private message
Pandora-Box

Moderator


Joined: 07 Sep 2006
Posts: 1529
Location: Andromeda Galaxy

PostPosted: Mon Jun 17, 2013 11:34 pm    Post subject:
Reply with quote

Gary,
Also have a look at Bills solution
Back to top
View user's profile Send private message
Gary McDowell

Active User


Joined: 15 Oct 2012
Posts: 139
Location: USA

PostPosted: Tue Jun 18, 2013 2:16 am    Post subject:
Reply with quote

Pandora-Box wrote:
Gary,
Also have a look at Bills solution

Yep, I saw the ICETOOL solution. We have SYNCSORT as the original posted has posted also.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7225

PostPosted: Tue Jun 18, 2013 3:34 am    Post subject: Reply to: How to get last 15000 records from a Flat file
Reply with quote

SyncSort have SyncTool, commonly aliased to ICETOOL. If you have SyncTool 1.7.0 or later (versions not in step with SyncSort) which is from something like 2008, then SyncTool has SUBSET. Maybe. I can't check :-)

It seems from elsewhere, that TS had a big logfile on a Citrix system, and didn't know how to get at the last 15,000 records, so thought to FTP it to the mainframe and look for a solution there.

However, simple use of "tail" we think has got him there, without the need to FTP.
Back to top
View user's profile Send private message
Pandora-Box

Moderator


Joined: 07 Sep 2006
Posts: 1529
Location: Andromeda Galaxy

PostPosted: Tue Jun 18, 2013 8:43 am    Post subject:
Reply with quote

If subset doesnt support TS could go for Expat's solution

It is his call now ;-)

Yes Tail works like gem long time since I used it in unix
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2158
Location: @my desk

PostPosted: Tue Jun 18, 2013 12:34 pm    Post subject:
Reply with quote

I remember FILEAID has an option to read the file in reverse and extract 'n' records out of it. If the TS has it in his shop,he could give it a shot.
Back to top
View user's profile Send private message
mistah kurtz

Active User


Joined: 28 Jan 2012
Posts: 268
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Tue Jun 18, 2013 3:53 pm    Post subject:
Reply with quote

Hi Arun..Yes that's right..the option to select backward read is available in File-Aid.

Code:
File-AID --------------  Selection Criteria Options  -------------------------
COMMAND ===>                                                                 
                                                                             
Specify Selection Criteria Options:                                           
                                            Start at the following record key
                                            (both blank for start of dataset)
  Starting record key         ===>                                           
     - OR -                                 OR at the following RBA or RRN   
  Starting RBA or RRN         ===>                                           
                                                                             
  Initial records to skip     ===> 0        then skip this many records       
                                                                             
  Subsequent Selection Interval:            then repeat the following         
    Records to select         ===> 1        - select this many records       
    Records to skip           ===> 0        - then skip this many records     
                                            until                             
  Number of records to search ===> 3        you have read this many records   
  Number of records to select ===> ALL      or selected this many records     
                                                                             
SEQ/VSAM processing direction ===> B       (F = Forward; B = Backward)       
Back to top
View user's profile Send private message
Dale Robertson

New User


Joined: 21 Jun 2013
Posts: 44
Location: U.S.A.

PostPosted: Mon Jun 24, 2013 10:27 pm    Post subject:
Reply with quote

first count the records in batch or on TSO 3.4 with COUNT line command:

//JS1 EXEC PGM=IKJEFT01
//SYSTSPRT DD SYSOUT=*
//SYSTSIN DD *
COUNT 'SEQ.FILE'
/*
//


Then after a little arithmetic use SKIPREC thusly. Be certain to use EQUALS to keep in the order desired!!

//JS2D EXEC PGM=IEFBR14
//DD1 DD DSN=SEQ.FILEOUT,DISP=(MOD,DELETE),SPACE=(TRK,0)
//*
//JS2 EXEC PGM=SYNCSORT
//SORTIN DD DSN=SEQ.FILE,DISP=SHR
//SORTOUT DD DSN=SEQ.FILEOUT,DISP=(,CATLG,DELETE),
// SPACE=(TRK,(10,10),RLSE) or whatever space you need.
//SYSOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY,EQUALS,SKIPREC=(total minus 15000 records)
/*
//
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 1713
Location: UK

PostPosted: Mon Jun 24, 2013 10:58 pm    Post subject:
Reply with quote

Except that 'COUNT' must be a utility local to your shop because it is not on my system. Please check with TSO Help before posting.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7225

PostPosted: Mon Jun 24, 2013 11:07 pm    Post subject: Reply to: How to get last 15000 records from a Flat file
Reply with quote

Even if there is a COUNT, why bother? SyncTool has a COUNT operator. The COUNT output can (probably) be directed to a dataset. Generate the SKIPREC with SORT using the COUNT file as input.

And that's only necessary if your SyncTool version is too old to have SUBSET, where it would all be done, in one pass of the file.
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 -> SYNCSORT All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts CICS Roll back partially - Need to re... dwijadas CICS 4 Wed Nov 16, 2016 4:30 pm


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