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 

Sorting the data as a group.

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


Joined: 25 Feb 2009
Posts: 5
Topics: 3

PostPosted: Mon Jul 13, 2009 5:45 am    Post subject: Sorting the data as a group. Reply with quote

Hello All,

Per my requirment I need to sort the data as a group.
I have a VB file of length 737. And below is the sample data present in my input file:
Code:

AABBBH1XXXP21CC
AABBBD1   456LL
AABBBD2   456SS
AABBBD3   456PP
BBCCCH2YYYX3XCC
BBCCCD1   123KK
BBCCCD2   123OO
BBCCCD4   123PP
AACCCH3ZZZL08CC
AACCCD1   234EE
AACCCD2   234UU
AACCCD3   234RR

Now my output should be like below:
Code:

BBCCCH2YYYX3XCC
BBCCCD1   123KK
BBCCCD2   123OO
BBCCCD4   123PP
AACCCH3ZZZL08CC
AACCCD1   234EE
AACCCD2   234UU
AACCCD3   234RR
AABBBH1XXXP21CC
AABBBD1   456LL
AABBBD2   456SS
AABBBD3   456PP


My input data contain one header record (like H1,H2,H3) followed by some detail records (like D1,D2,D3,D4).
Now I need to sort my input data based on ID in the position 11-13. Constraint is that the corresponding header record should come along with the detail records.

Few important things:
1) In the header record, we don't have the ID and in the position 11-13 and some other value is present which is required for some other processing. So we should not overlay the header record data in the position 11-13.
2) The common value between the header and detail record is in the postions 1-5.
3) There is no fixed number of header or detail records count.
4) In the group of detail records (under one header) the ID (in the positions 11-13) is same.

Hope this information make sence.

Thanks
Anand
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: Mon Jul 13, 2009 11:05 am    Post subject: Reply with quote

anandmsteds,

The following DFSORT JCL will give you the desired results. I assumed that you have 'h' for header record and 'd' for detail record in byte 10 (4 bytes rdw + 5 byte key + 1 byte to denoting 'h' or 'd')


Code:

//STEP0100 EXEC PGM=SORT                                       
//SYSOUT   DD SYSOUT=*                                         
//SORTIN   DD DSN=your input vb file,DISP=SHR
//SORTOUT  DD DSN=&&T1,DISP=(,PASS),SPACE=(CYL,(X,Y),RLSE)     
//SYSIN    DD *                                                 
  SORT FIELDS=(5,6,CH,A),EQUALS                                 
  OUTREC IFTHEN=(WHEN=INIT,BUILD=(1,4,3X,C'1',5)),             
  IFTHEN=(WHEN=GROUP,BEGIN=(14,1,CH,EQ,C'D'),PUSH=(5:19,3)),   
  IFTHEN=(WHEN=(14,1,CH,EQ,C'H'),OVERLAY=(8:X))                 
/*                                                             
//STEP0200 EXEC PGM=SORT                                       
//SYSOUT   DD SYSOUT=*                                         
//SORTIN   DD DSN=&&T1,DISP=SHR                                 
//SORTOUT  DD SYSOUT=*                                         
//SYSIN    DD *                                                 
  SORT FIELDS=(5,4,CH,A),EQUALS                                 
  OUTREC BUILD=(1,4,9)                                         
/*

_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
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