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

how to get first 5 records of key using SYNCSORT


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Rajeev_mainframe

New User


Joined: 21 Aug 2006
Posts: 13

PostPosted: Sat Sep 01, 2007 12:37 am
Reply with quote

Hi,
I have a requirement to select first 5 records of key from the input file using Syncsort. the sorting key is 2 byte field and it has values from '01' till '20', I need to get the output file containing 5 records of each '01' till '20' field.
Can anyone help me how do I get the first 5 occurances of keys in Syncsort.

Thanks,
Rajeev
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Sat Sep 01, 2007 1:06 am
Reply with quote

If the restriction to IFTHEN will allow 20 of them, start a seqnum on each key and on output include only the first five....
Back to top
View user's profile Send private message
Rajeev_mainframe

New User


Joined: 21 Aug 2006
Posts: 13

PostPosted: Sat Sep 01, 2007 1:14 am
Reply with quote

William,

Can you explain in more detail and if you can provides some samples on this.

Thanks,
Rajeev
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Sat Sep 01, 2007 1:39 am
Reply with quote

If you would check your manual and additional addendems, use the IFTHEN logic to add a sequence number to the record, sort as needed and upon output omit the records with a seqnum greater than five (while striping the seqnum)....
Is your site licensed for Syncsort?
Back to top
View user's profile Send private message
Rajeev_mainframe

New User


Joined: 21 Aug 2006
Posts: 13

PostPosted: Sat Sep 01, 2007 3:23 am
Reply with quote

I am not very proficient in SYNCSORT and thats why if you can give some samples as to how do we use IFTHEN in Syncsort, will be of great help.
The test region where I am testing supports SYNCSORT utility. I am first sorting the input file on key and then somehow I have to select first 5 records of each key and output it to another file. I a not aware of syntax in the COND parameter for 'FIRST 5' or IF THEN loop in SYNCSORT. Also I will appreciate if you can direct me to any link which has SYNCSORT manual where i can reference.
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Sat Sep 01, 2007 4:23 am
Reply with quote

Get the manuals, it is not that difficult.....
Quote:
Unfortunately, all licensed SyncSort customers must request manuals directly from us, or download it from our website using an online support account. It is in breach of contract for an individual to share SyncSort documentation with others outside of their own company. However, please feel free to pass on my contact info to anyone who is in need of manuals and I would be happy to assist.
Regards,
Alissa
Alissa Margulies
SyncSort Mainframe Support
201.930.8260
zos_tech@syncsort.com
Back to top
View user's profile Send private message
krisprems

Active Member


Joined: 27 Nov 2006
Posts: 649
Location: India

PostPosted: Sun Sep 02, 2007 4:37 pm
Reply with quote

Rajeev_mainframe
Provide some sample set of i/p records and the key position also show your o/p file sample.
In addition to that also provide the RECFM and LRECL of your file's.
Back to top
View user's profile Send private message
krisprems

Active Member


Joined: 27 Nov 2006
Posts: 649
Location: India

PostPosted: Sun Sep 02, 2007 5:44 pm
Reply with quote

Rajeev_mainframe
Use this SORT JCL in which the KEY is in 12th position.
The o/p would contain the records that have 5 records for each key.
Code:


//*******************************************************               
//STEP1    EXEC PGM=SORT                                               
//SYSOUT   DD SYSOUT=*                                                 
//SORTIN   DD *                                                         
QWER       01                                                           
 SADF      01                                                           
ASDF       01                                                           
DFHY       01                                                           
SDGF       01                                                           
FGGH       01                                                           
QWER       01                                                           
FGGH       11                                                           
QWER       11                                                           
 SADF      11                                                           
ASDF       11                                                           
DFHY       11                                                           
----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
/*                                                                     
//SORTOUT  DD SYSOUT=*                                                 
//SYSIN    DD *                                                         
  SORT FIELDS=COPY                                                     
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,8,ZD,RESTART=(12,2)))     
  OUTFIL INCLUDE=(81,8,ZD,LE,+5),OUTREC=(1,80)                         
/*                                                                     
//                                                                     

SORTOUT contains
Code:
QWER       01 
 SADF      01 
ASDF       01 
DFHY       01 
SDGF       01 
FGGH       11 
QWER       11 
 SADF      11 
ASDF       11 
DFHY       11 


Try implementing this as per your requiremnt, if still unresolved then post the details that i have asked in my previous post
Back to top
View user's profile Send private message
Rajeev_mainframe

New User


Joined: 21 Aug 2006
Posts: 13

PostPosted: Fri Sep 14, 2007 6:08 am
Reply with quote

Thnks guys for the replies. I was able to do this through file-aid from option 3.3.
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 -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 3
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
Search our Forums:

Back to Top