MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Sort subset of records within a file

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
erasani
Beginner


Joined: 02 Oct 2021
Posts: 17
Topics: 7

PostPosted: Thu Nov 11, 2021 6:45 am    Post subject: Sort subset of records within a file Reply with quote

Hi All,

We have a requirement where we have to sort the I621* and I618* record types. These records can occur between BH(batch header) and (BT)Batch Trailer records.

Currently, the records are being written in the order they are being received. From the below Input file, the order in one of the batch is I6211, I6212, I6181, I6182, I6183 and I6184. We need them to be in order of I6181, I6182, I6183, I6184, I6211, I6212. Only the record types I618* and I621* need to be ordered. For the other record types, there are no changes to the order.

We are planning either modify the program that creates the file or write a new program to arrange the records in the desired order.

Please let me know if there is any way the below can be achieved using DFSORT/ICETOOL.

Input:
Code:

$$
$$
DH
BH
I1056
I3391
I6001
I6100
I6211
I6212
I6181
I6182
I6183
I6184
BT   
BHT60
I1056
I3792
I6001
I6100
I6211
I6212
I6184
I6185
I6186
I6187
BT   
DT


Desired Output:
Code:

$$
$$
DH
BH
I1056
I3391
I6001
I6100
I6181
I6182
I6183
I6184
I6211
I6212
BT   
BHT60
I1056
I3792
I6001
I6100
I6184
I6185
I6186
I6187
I6211
I6212
BT   
DT


Record types:
Code:

$$ - Headers
DH - Data Header
DT - Data Trailer
BH - Batch Header
BT - Batch Trailer
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Thu Nov 11, 2021 7:27 am    Post subject: Reply with quote

erasani,

Use the following untested which will give you the desired results. I assumed that your input file has LRECL=80 and RECFM=FB.

Basically you just tag the records with an ID number at position 81 whever there is a header or trailer.now within the group you put a constant of 0 at position 90 for all the records and when there is a I618* record you update that value to 1 and when there is I621* record you update the constant to 2.

Now sort on the ID number and the constant, so that the 0 records stay in the same place and 1 and 2 records will be sorted. Once we are done sorting just remove the id and the constant.


Code:

//STEP0100 EXEC PGM=SORT     
//SYSOUT   DD SYSOUT=*       
//SORTIN   DD DISP=SHR,DSN=Your.input.FB.80.Byte.file
//SORTOUT  DD SYSOUT=*                                   
//SYSIN    DD *                                         
  INREC IFTHEN=(WHEN=GROUP,                             
               BEGIN=(1,2,SS,EQ,C'$$,DH,BH,BT,DT'),     
                PUSH=(81:ID=8)),                         
        IFTHEN=(WHEN=INIT,                               
             OVERLAY=(90:C'0',                           
                      90:01,04,CHANGE=(1,C'I618',C'1',   
                                         C'I621',C'2'), 
                              NOMATCH=(90,1)))           
                                                         
  SORT FIELDS=(81,08,CH,A,                               
               90,01,CH,A),EQUALS                         
                                                         
  OUTREC BUILD=(01,80)                                   
/* 

_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
erasani
Beginner


Joined: 02 Oct 2021
Posts: 17
Topics: 7

PostPosted: Thu Nov 11, 2021 10:54 am    Post subject: Reply with quote

Thanks a lot once again kolusu.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group