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

How to Move the particular records to top of the file


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
itsurfrank

New User


Joined: 31 Aug 2009
Posts: 6
Location: India

PostPosted: Fri Jan 21, 2011 12:27 pm
Reply with quote

Hi I have the PS file which will have following records.

The Input file and out file is FB with size of 400.

Input File:

010 XXXXXx
020 xxxxxx
030 xxxxxx
199 xxxxxx
200 xxxxxx
209 xxxxxx
210 xxxxxx
219 xxxxxx
299 xxxxxx
300 xxxxxx
309 xxxxxx
310 xxxxxx
319 xxxxxx
399 xxxxxx
400 yyyyyy
400 yyyyyy
010 XXXXXx
020 xxxxxx
030 xxxxxx
199 xxxxxx
200 xxxxxx
209 xxxxxx
210 xxxxxx
219 xxxxxx
299 xxxxxx
300 xxxxxx
309 xxxxxx
310 xxxxxx
319 xxxxxx
399 xxxxxx
400 yyyyyy
400 yyyyyy
010 XXXXXx
020 xxxxxx
030 xxxxxx
199 xxxxxx
200 xxxxxx
209 xxxxxx
210 xxxxxx
219 xxxxxx
299 xxxxxx
300 xxxxxx
309 xxxxxx
310 xxxxxx
319 xxxxxx
399 xxxxxx
400 yyyyyy
400 yyyyyy
499 yyyyyy

The OutPut should be has follows,
OutPut File:

400 yyyyyy
400 yyyyyy
400 yyyyyy
400 yyyyyy
400 yyyyyy
400 yyyyyy
499 yyyyyy
010 XXXXXx
020 xxxxxx
030 xxxxxx
199 xxxxxx
200 xxxxxx
209 xxxxxx
210 xxxxxx
219 xxxxxx
299 xxxxxx
300 xxxxxx
309 xxxxxx
310 xxxxxx
319 xxxxxx
399 xxxxxx
010 XXXXXx
020 xxxxxx
030 xxxxxx
199 xxxxxx
200 xxxxxx
209 xxxxxx
210 xxxxxx
219 xxxxxx
299 xxxxxx
300 xxxxxx
309 xxxxxx
310 xxxxxx
319 xxxxxx
399 xxxxxx
010 XXXXXx
020 xxxxxx
030 xxxxxx
199 xxxxxx
200 xxxxxx
209 xxxxxx
210 xxxxxx
219 xxxxxx
299 xxxxxx
300 xxxxxx
309 xxxxxx
310 xxxxxx
319 xxxxxx
399 xxxxxx


The records starting with 400 and 499 only has to be moved to top of the file without rearraging other records.

Each 010 to 399 starting records are set.

The sort should be perform only on first three characters EX 010, 400.


Thanks in Advance..
Back to top
View user's profile Send private message
Guest







PostPosted: Fri Jan 21, 2011 2:04 pm
Reply with quote

Hi,
According to my understanding of your requirement the following Sort step will give the desired result:
Code:

//STEP0100 EXEC PGM=SORT       
//SYSOUT   DD SYSOUT=*         
//SORTIN   DD *               
010 XXXXXX                     
020 XXXXXX                     
030 XXXXXX                     
199 XXXXXX                     
200 XXXXXX                     
209 XXXXXX                     
210 XXXXXX                     
219 XXXXXX                     
299 XXXXXX                     
300 XXXXXX                     
309 XXXXXX
310 XXXXXX
319 XXXXXX
399 XXXXXX
400 YYYYYY
400 YYYYYY
010 XXXXXX
020 XXXXXX
030 XXXXXX
199 XXXXXX
200 XXXXXX
209 XXXXXX
210 XXXXXX
219 XXXXXX
299 XXXXXX
300 XXXXXX
309 XXXXXX
310 XXXXXX
319 XXXXXX
399 XXXXXX
400 YYYYYY
400 YYYYYY
010 XXXXXX
020 XXXXXX
030 XXXXXX
199 XXXXXX
200 XXXXXX
209 XXXXXX
210 XXXXXX
219 XXXXXX
299 XXXXXX
300 XXXXXX
309 XXXXXX
310 XXXXXX
319 XXXXXX
399 XXXXXX
400 YYYYYY                                               
400 YYYYYY                                               
499 YYYYYY                                               
//SORTOUT  DD SYSOUT=*                                   
//SYSIN    DD *                                           
 INREC IFTHEN=(WHEN=INIT,OVERLAY=(21:SEQNUM,2,ZD)),       
       IFTHEN=(WHEN=INIT,OVERLAY=(20:C'9')),             
       IFTHEN=(WHEN=(1,3,CH,EQ,C'400'),OVERLAY=(20:C'1')),
       IFTHEN=(WHEN=(1,3,CH,EQ,C'499'),OVERLAY=(20:C'2'))
 SORT FIELDS=(20,1,CH,A,21,2,CH,A)                       
 OUTREC BUILD=(1,23)                                     
/*                                                       


You can modify the above according to the data in your file.

Devil13
There is always a better solution.
Back to top
Frank Yaeger

DFSORT Developer


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

PostPosted: Sat Jan 22, 2011 12:37 am
Reply with quote

devil13,

You're on the right track, but your solution is more complicated than it needs to be. This simpler DFSORT job would do the trick.

Code:

//S1 EXEC PGM=SORT                           
//SYSOUT DD SYSOUT=*                         
//SORTIN DD DSN=...  input file (FB/400)         
//SORTOUT DD DSN=...  output file (FB/400)   
//SYSIN DD *                                 
   OPTION EQUALS                                               
   INREC IFTHEN=(WHEN=(1,3,SS,EQ,C'400,499'),OVERLAY=(401:Z)) 
   SORT FIELDS=(401,1,BI,A,1,3,CH,A)                           
   OUTREC BUILD=(1,400)                           
/*             
Back to top
View user's profile Send private message
Guest







PostPosted: Sun Jan 23, 2011 10:45 am
Reply with quote

Hi Frank,
I have always been learning from you. This is definitely a new learning.
Thanks a lot.

devil13
There is always a better solution.
Back to top
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 2 files and retrive records f... DFSORT/ICETOOL 0
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
Search our Forums:

Back to Top