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
 

 

Sort group of records

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
Karthikeyan Subbarayan

New User


Joined: 24 Feb 2008
Posts: 56
Location: Boston

PostPosted: Fri Oct 25, 2013 2:21 am    Post subject: Sort group of records
Reply with quote

Hi,
I have a requirement to sort like below.

the First character will be either "B" or "D". I need to do sort based on the "FUND" but the FUND will be available only in "B" record.
The link between "B" and "D" is Account number.

Input Record will be like below:
Code:

BACCOUNT1FUND1
BACCOUNT2FUND2
BACCOUNT3FUND1
DACCOUNT3DATE01
DACCOUNT3DATE02
BACCOUNT4FUND1
BACCOUNT5FUND2
DACCOUNT5DATE01
BACCOUNT6FUND1


Output record should be like below:
Code:

BACCOUNT1FUND1
BACCOUNT3FUND1
DACCOUNT3DATE01
DACCOUNT3DATE02
BACCOUNT4FUND1
BACCOUNT6FUND1
BACCOUNT2FUND2
BACCOUNT5FUND2
DACCOUNT5DATE01
Back to top
View user's profile Send private message

mistah kurtz

Active User


Joined: 28 Jan 2012
Posts: 268
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Fri Oct 25, 2013 12:40 pm    Post subject:
Reply with quote

Will your 'D' record corresponding to the 'B' record always come immediately after? I mean your data will always be the way you have shown or it could be jumbled up like this:

Code:
BACCOUNT1FUND1
BACCOUNT2FUND2
BACCOUNT3FUND1
DACCOUNT5DATE01
BACCOUNT4FUND1
BACCOUNT5FUND2
DACCOUNT3DATE01
BACCOUNT6FUND1
DACCOUNT3DATE02
Back to top
View user's profile Send private message
Pandora-Box

Moderator


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

PostPosted: Fri Oct 25, 2013 12:50 pm    Post subject:
Reply with quote

Hi

Try this

Code:
//SYSIN     DD *
  OPTION EQUALS
  INREC  IFTHEN=(WHEN=GROUP,BEGIN=(2,7,CH,EQ,C'ACCOUNT',AND,
                            10,4,CH,EQ,C'FUND'),
                 PUSH=(20:2,15))
  SORT   FIELDS=(28,5,CH,A,20,8,CH,A)
  OUTREC FIELDS=(1:1,19,61X)
Back to top
View user's profile Send private message
mistah kurtz

Active User


Joined: 28 Jan 2012
Posts: 268
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Fri Oct 25, 2013 1:02 pm    Post subject:
Reply with quote

Assuming that your data could be in any order and LRECL=20 and RECFM=20, you can try this SORT card:
Code:
//SYSIN    DD *                                                   
  SORT   FIELDS=(2,8,CH,A,1,1,CH,A)                               
  OUTREC IFTHEN=(WHEN=GROUP,BEGIN=(1,1,CH,EQ,C'B'),PUSH=(21:10,5))
  SORT   FIELDS=(21,5,CH,A)                                       
  OUTFIL BUILD=(1,20)                                             
/* 
Back to top
View user's profile Send private message
Karthikeyan Subbarayan

New User


Joined: 24 Feb 2008
Posts: 56
Location: Boston

PostPosted: Fri Oct 25, 2013 7:50 pm    Post subject: Reply to: Sort group of records
Reply with quote

hi,
Thanks for the reply !!

The Detail record will always come after balance record,
I got the answer with the below code
Code:

//SYSIN    DD *                                                   
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,1,CH,EQ,C'B'),                   
  PUSH=(21:10,5))
  SORT   FIELDS=(21,5,CH,A)                                       
  OUTREC BUILD=(1,20)                                             
/* 


I never knew in push we can use on the field values, so for i have used unique id only with this comment. thanks for the support
Back to top
View user's profile Send private message
Pandora-Box

Moderator


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

PostPosted: Fri Oct 25, 2013 8:09 pm    Post subject:
Reply with quote

Hi Just modified the code slightly to get your expected output

Code:
    OPTION EQUALS
    INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,1,CH,EQ,C'B'),
    PUSH=(21:10,5))
    SORT   FIELDS=(21,5,CH,A,2,8,CH,A)
    OUTREC BUILD=(1,20)
Back to top
View user's profile Send private message
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 Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts How to split the records using the am... vnktrrd DFSORT/ICETOOL 24 Fri Oct 28, 2016 7:33 pm
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm
No new posts How to delete second instance from Fl... Gunapala CN DFSORT/ICETOOL 6 Tue Oct 18, 2016 11:42 pm


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