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 

Selecting Records using Sort

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


Joined: 07 Oct 2004
Posts: 38
Topics: 15

PostPosted: Tue Apr 12, 2005 3:51 pm    Post subject: Selecting Records using Sort Reply with quote

Hello,

I have a input file that whose format is shown below:

Code:

A1      
A2          B1
A3
A4
A5
A6
A7
A11
A12         B1
A13
A14
A15
A21
A22         B1
A23
A24
A25
A31
A32         B1
A33
A34
A35


Is is possible to write a sort to get the output in this fashion:

Code:

A1
A2          B1
A11
A12         B1
A21
A22         B1
A31
A32         B1


I can write a cobol program to get the output in the above mentioned format. Just curious to know if I do this using SORT/ICETOOL.

Thanks
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Tue Apr 12, 2005 4:19 pm    Post subject: Reply with quote

What are the rules for selecting the records you want in the output data set? From the example you show above, I can think of a few possibilities such as (1) keep each B1 record and the record that precedes it (2) keep each record where the first field ends with '1' or '2'. Please tell us the actual rules YOU want to use. Also, what is the RECFM and LRECL of the input file?
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
sri50131
Beginner


Joined: 07 Oct 2004
Posts: 38
Topics: 15

PostPosted: Wed Apr 13, 2005 9:27 am    Post subject: Reply with quote

Frank, the format of my input file is VB, the length is 9954. My input file is of the format shown below:
Code:

Mem No   Seg no      form no
111111111   10      
111111111            
111111111
111111111
111111111
111111111
111111111   60      B1
222222222   10
222222222                 
222222222
222222222
222222222   60      B1
333333333   10
333333333         
333333333
333333333
333333333   60      B1
444444444   10
444444444
444444444
444444444
444444444   60      B1
555555555   10
555555555
555555555
555555555   60

My output should have
Code:

Mem No   Seg No      form no
11111111   10
11111111   60      B1
22222222   10
22222222   60      B1
33333333   10
33333333   60      B1
44444444   10
44444444   60      B1   

My input file is sorted by Member number and its position on the input file is 35. The position of the Segment no the input file is 122 and the position of the form no on the input file is 912. My requirement is I need to print the all the members that have form number B1 in Segment 60 along with Segment 10. Segment 10 and 60 are mandatory segments.

Thanks
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Wed Apr 13, 2005 11:07 am    Post subject: Reply with quote

sri,

So if I understand what you want correctly, the trick here is to keep the 10/60 pairs where the 60 has B1 and delete the 10/60 pairs where the 60 does not have B1. Since the records are already in order by the member name, we can use a MERGE instead of a SORT for better performance.

With z/OS DFSORT V1R5 PTF UQ95214 or DFSORT R14 PTF UQ95214 (Dec, 2004), you can use DFSORT's new IFTHEN and OVERLAY parameters to do what you want. The trick is to use SUM to add the segment numbers for the 10/60 pairs without B1 to get 70, but not to sum the 10/60 pairs with B1. We can then remove the records with 70, leaving only the 10/60 pairs with B1. Here's the DFSORT job:

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN01 DD DSN=...  input file (sorted by member name)
//SORTOUT DD DSN=...   output file
//SYSIN    DD    *
  OPTION VLSCMP,EQUALS,ZDPRINT
* Get the '10' and '60' records.
  INCLUDE COND=(122,2,CH,EQ,C'10',OR,122,2,CH,EQ,C'60')
* Reformat the '10' records to:
* |RDW|1|...member...10...  ...|
* Reformat the '60' records without 'B1' to:
* |RDW|1|...member...60...  ...|
* Reformat the '60' records with 'B1' to:
* |RDW|2|...member...60...B1...|
  INREC IFTHEN=(WHEN=INIT,BUILD=(1,4,5:C'1',6:5)),
   IFTHEN=(WHEN=(123,2,CH,EQ,C'60',AND,913,2,CH,EQ,C'B1'),
    OVERLAY=(5:C'2'))
* Merge on the member name and the '1' or '2' in cc 5.
  MERGE FIELDS=(36,9,CH,A,5,1,CH,A)
* Sum: '10' records and '60' records with 'B1' are dups
* because they both have '1' for the key in cc 5.  So the
* seg numbers are summed to get '70'.
* '10' records and '60' records without 'B1' are nondups
* because they have '1' and '2' for the key in cc 5, resp.
* So they are not summed.
  SUM FIELDS=(123,2,ZD)
* Delete the records with '70' (no 'B1').
  OUTFIL OMIT=(123,2,CH,EQ,C'70'),
* Remove the '1' or '2' in cc 5.
    OUTREC=(1,4,5:6)
/*


Note that when we add the '1' or '2' in cc 5, it moves all the other data over one column, so we have to use column+1 when referring to these fields (e.g. 123 instead of 122 for the segment field). The OUTFIL OUTREC removes the '1' or '2' in cc 5, restoring the fields back to their original columns.
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
sri50131
Beginner


Joined: 07 Oct 2004
Posts: 38
Topics: 15

PostPosted: Wed Apr 13, 2005 4:01 pm    Post subject: Reply with quote

Frank, thank you very much! However, we do not have the latest version of DFSORT. I guess, I will have to wait for the upgrade to use the sort.

Thanks
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Wed Apr 13, 2005 4:39 pm    Post subject: Reply with quote

Ask your System Programmer to install the Dec, 2004 PTF ASAP (it's free).
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
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