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 Move the particular records to top of the file

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: How to Move the particular records to top of the file
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    Post subject:
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 Moderator


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

PostPosted: Sat Jan 22, 2011 12:37 am    Post subject:
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Changing of LRECL of a file abdulrafi DFSORT/ICETOOL 2 Fri Mar 24, 2017 3:25 pm
No new posts splitting a file abdulrafi DFSORT/ICETOOL 3 Fri Mar 24, 2017 11:51 am
No new posts Receive a file using PCOMM macro Harald.v.K IBM Tools 0 Thu Mar 23, 2017 6:50 pm
No new posts Export flat file data into excel sheet murali.andaluri DFSORT/ICETOOL 2 Mon Mar 20, 2017 5:39 pm
No new posts Formatting VB File Learncoholic DFSORT/ICETOOL 3 Mon Mar 20, 2017 12:29 pm


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