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 

Dynamic Sort

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


Joined: 24 Sep 2004
Posts: 10
Topics: 3

PostPosted: Fri Sep 24, 2004 12:05 pm    Post subject: Dynamic Sort Reply with quote

Hi guys,

I have a record as shown below

----5----0----5----0
ABCDE12345AKLMQ00010
ABCDE12345AKLMP00020
ABCDE12345AKLMR00030
ABCDE99999RTTMT00001
ABCDE99999RTTMT00010
ABCDE99999RTTTT00300


My requirement is to sum the ZD from position 16 to 20, when the the keys from position 1 to 5 and from 6 to 10 are same.
When the value from position 6 to 10 is '99999', we need to check the values from position 11 to 15. Only when the values from position 11 to 15 are equal, we sum the fields.
When the value from position 6 to 10 is '99999', and the values from position 11 to 15 are not equal, we dont' sum the fields.

So my output would like this

----5----0----5----0
ABCDE12345AKLMQ00060
ABCDE99999RTTMT00011
ABCDE99999RTTTT00300

The trick is i want to do this in a single or two sort steps not more than 2. IS it possible.

I dnt have dfsort in my shop, i just have SYNCSORT. Help me use SYNCSORT to do this .
Back to top
View user's profile Send private message
Arian
Beginner


Joined: 24 Sep 2004
Posts: 10
Topics: 3

PostPosted: Fri Sep 24, 2004 3:08 pm    Post subject: Reply with quote

Guys..especially Kolusu...is tis so tough for u guys to break...umm...i realy have a good posting then..
anywa..lemme refine by question.

When you encounter a 99999 in position 6 to 10 my cntlcard could look like tis
Quote:

SORT FIELDS=(6,5,ZD,A,1,5,ZD,A,11,5,ZD,A)
SUM FIELDS=(16,5,ZD)

When you encouter a non 99999 in positions 6 to 10 my cntlcard wud like tis
Quote:

SORT FIELDS=(6,5,ZD,A,1,5,ZD,A)
SUM FIELDS=(16,5,ZD)
Back to top
View user's profile Send private message
srinivasan_srisailan
Beginner


Joined: 18 May 2004
Posts: 11
Topics: 3

PostPosted: Fri Sep 24, 2004 4:44 pm    Post subject: Reply with quote

The following JCL step takes three passes to achieve the desired solution:

Code:
//STEP EXEC PGM=SYNCTOOL           
//TOOLMSG DD SYSOUT=*               
//DFSMSG DD SYSOUT=*               
//SYSOUT DD SYSOUT=*               
//TOOLIN DD *                       
  SORT FROM(IN) TO(OUT1) USING(CTL1)
  SORT FROM(IN) TO(OUT2) USING(CTL2)
  SORT FROM(COM) TO(OUT) USING(CTL3)
/*                                 
//IN DD *                           
ABCDE12345AKLMQ00010               
ABCDE12345AKLMP00020               
ABCDE12345AKLMR00030               
ABCDE99999RTTMT00001               
ABCDE99999RTTMT00010                                         
ABCDE99999RTTTT00300                                         
/*                                                           
//OUT1       DD DSN=&OUT1,DISP=(,PASS),SPACE=(CYL,(5,5),RLSE)
//OUT2       DD DSN=&OUT2,DISP=(,PASS),SPACE=(CYL,(5,5),RLSE)
//COM  DD DSN=&OUT1,DISP=(OLD),VOL=REF=*.OUT1               
//     DD DSN=&OUT2,DISP=(OLD),VOL=REF=*.OUT2               
//OUT DD SYSOUT=*                                           
//CTL1CNTL DD *                                             
  SORT FIELDS=(1,10,CH,A)                                   
  INCLUDE COND=(6,5,CH,NE,C'99999')                         
  SUM FIELDS=(16,5,ZD)                                       
/*                                                           
//CTL2CNTL DD *                                             
  SORT FIELDS=(1,15,CH,A)                                   
  INCLUDE COND=(6,5,CH,EQ,C'99999')                         
  SUM FIELDS=(16,5,ZD)                                       
/*                                                           
//CTL3CNTL DD *                                             
  SORT FIELDS=(1,20,CH,A)                                   
/*


I am eagerly waiting for a better solution.

Regards,
Srinivasan
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: Fri Sep 24, 2004 5:31 pm    Post subject: Reply with quote

Arian,

Quote:

Guys..especially Kolusu...is tis so tough for u guys to break...umm...i realy have a good posting then..


It ain't tough, just was busy at work , that I did not even have a chance to look at the helpboards all day today. I just got back home. So the following JCL will give you desired results.

I assumed that your input file is LRECL=80 & RECFM=FB.

A brief explanation of the job. The first copy operator takes in the input file and using a change command on the INREC , we add a identifier at 81st byte.

If the pos 6 has '99999', then 81st byte will have 1 , for all other records we have '0'

Now using another change command on the OUTREC, we validate the 81st byte. If the 81st byte has '0'(which means it is not a 99999 records) , we add a identifier '00000' at 82nd byte. for all other records(means the 99999 records) , we populate with the contents from 11 thru 5 and written to temp file T1.

The file T1 will look like this

Code:

 ----+----1----+----2----+----8----+-
 ABCDE12345AKLMQ00010          000000
 ABCDE12345AKLMP00020          000000
 ABCDE12345AKLMR00030          000000
 ABCDE99999RTTMT00001          1RTTMT
 ABCDE99999RTTMT00010          1RTTMT
 ABCDE99999RTTTT00300          1RTTTT


Now we sort on pos 1 thru 10 and 81 thru 86 and summing on pos 16 for 5 bytes.

Using outrec we remove the additional identifiers at the end.

Code:

//STEP0100 EXEC PGM=SYNCTOOL             
//TOOLMSG  DD SYSOUT=*                   
//DFSMSG   DD SYSOUT=*                   
//IN       DD *                         
ABCDE12345AKLMQ00010                     
ABCDE12345AKLMP00020                     
ABCDE12345AKLMR00030                     
ABCDE99999RTTMT00001                     
ABCDE99999RTTMT00010                     
ABCDE99999RTTTT00300                     
//T1       DD DSN=&T1,DISP=(,PASS),SPACE=(CYL,(X,Y),RLSE)
//OUT      DD SYSOUT=*                                   
//TOOLIN   DD *                                           
  COPY FROM(IN) USING(CTL1)                               
  SORT FROM(T1) USING(CTL2)                               
//CTL1CNTL DD *                                           
  INREC FIELDS=(1,80,                                     
                81:6,5,CHANGE=(1,C'99999',C'1'),         
                                NOMATCH=(C'0'))           
  OUTFIL FNAMES=T1,                                       
  OUTREC=(1,81,                                           
          82:81,1,CHANGE=(5,C'0',C'00000'),               
                          NOMATCH=(11,5))                 
//CTL2CNTL DD *                                           
  SORT FIELDS=(1,10,CH,A,81,6,CH,A)                       
  SUM FIELDS=(16,5,ZD)                                   
  OUTFIL FNAMES=OUT,                                     
  OUTREC=(1,80)                                           
/*


The output from this job is:
Code:

ABCDE12345AKLMQ00060
ABCDE99999RTTMT00011
ABCDE99999RTTTT00300



Hope this helps...

Cheers

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


Joined: 24 Sep 2004
Posts: 10
Topics: 3

PostPosted: Mon Sep 27, 2004 10:41 am    Post subject: Reply with quote

Kolusu,

That worked..great....thanks a lot. ..keep up ur good work
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