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

How to get last 15000 records from a Flat file


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

Global Moderator


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

PostPosted: Mon Jun 17, 2013 6:31 pm
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
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
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
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

Global Moderator


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

PostPosted: Mon Jun 17, 2013 7:38 pm
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

Global Moderator


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

PostPosted: Mon Jun 17, 2013 9:02 pm
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Mon Jun 17, 2013 9:11 pm
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
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

Global Moderator


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

PostPosted: Mon Jun 17, 2013 11:34 pm
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
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Tue Jun 18, 2013 3:34 am
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

Global Moderator


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

PostPosted: Tue Jun 18, 2013 8:43 am
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: 2481
Location: @my desk

PostPosted: Tue Jun 18, 2013 12:34 pm
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: 316
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Tue Jun 18, 2013 3:53 pm
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
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: 2454
Location: Hampshire, UK

PostPosted: Mon Jun 24, 2013 10:58 pm
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Mon Jun 24, 2013 11:07 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> SYNCSORT

 


Similar Topics
Topic Forum Replies
No new posts Unable to interpret a hex value to De... COBOL Programming 7
No new posts combine multiple unique records into ... DFSORT/ICETOOL 2
No new posts how to eliminate null indicator value... DB2 7
No new posts To Omit records based n SORT condition DFSORT/ICETOOL 6
No new posts Format Binary file to EBCDIC JCL & VSAM 4
Search our Forums:

Back to Top