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 

Converting Mulitiple SORT programs to single ICETOOL program

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


Joined: 21 Jun 2014
Posts: 259
Topics: 54

PostPosted: Thu Jul 03, 2014 12:48 pm    Post subject: Converting Mulitiple SORT programs to single ICETOOL program Reply with quote

Hi,

I have created couple of sort program. Later I thought it can be merged to single sort program using icetool.

This is my first ICETOOL code which I am trying, Please advice if I am doing right or something better can be done.

Code:

//S1   EXEC  PGM=SORT                                   
//SYSOUT DD SYSOUT=*                                   
//SORTJNF1 DD DSN=PDS(MEM1),DISP=SHR       
//SORTJNF2 DD DSN=INP2,DISP=SHR   
//SORTOUT DD DSN=OUT1,               
//           DISP=(NEW,CATLG,DELETE),                   
//           DCB=(LRECL=139,RECFM=FB,BLKSIZE=0),       
//           UNIT=SAVDA,SPACE=(CYL,(50,10),RLSE)       
//SYSIN DD *                                           
  JOINKEYS FILE=F1,FIELDS=(1,3,A)                       
  JOINKEYS FILE=F2,FIELDS=(1,3,A)                       
  REFORMAT FIELDS=(F2:1,139)                           
  SORT FIELDS=(1,17,CH,A)                               
//JNF1CNTL DD *                                         
 INCLUDE COND=(4,4,CH,EQ,C'2102')                       
//JNF2CNTL DD *                                             
 INCLUDE COND=((29,2,CH,EQ,C'30',OR,29,2,CH,EQ,C'40'),AND,   
              (4,5,CH,NE,C'00000'))                         
/*                                                           
//S2   EXEC  PGM=SORT                                       
//SYSOUT DD SYSOUT=*                                         
//SORTJNF1 DD DSN=OUT1,DISP=SHR           
//SORTJNF2 DD DSN=VSAM1,DISP=SHR                 
//SORTOUT DD DSN=OUT2,                 
//           DISP=(NEW,CATLG,DELETE),                       
//           DCB=(LRECL=504,RECFM=VB,BLKSIZE=0),             
//           UNIT=SAVDA,SPACE=(CYL,(50,10),RLSE)             
//SYSIN DD *                                                 
  JOINKEYS FILE=F1,FIELDS=(1,17,A)                           
  JOINKEYS FILE=F2,FIELDS=(2,17,A)                           
  REFORMAT FIELDS=(F1:1,139)
  SORT FIELDS=COPY                                                   
  OUTFIL FNAMES=SORTOUT,FTOV,                                         
  BUILD=(1:C'01020',6:1,3,10:C' ',11:29,2,13:31,1,                   
      14:7,7,21:38,5,PD,ADD,43,6,PD,ADD,49,6,PD,TO=PD,LENGTH=6,474X) 
//JNF2CNTL DD *                                                       
 INCLUDE COND=(49,1,CH,EQ,C'B',AND,2217,2,CH,EQ,C'07')               
/*                                                                   
//


Icetool

Code:

//RUNIT EXEC PGM=ICETOOL,REGION=1024K                 
//TOOLMSG DD SYSOUT=*                                 
//DFSMSG DD SYSOUT=*                                   
//INP1   DD DSN=PDS(MEM1),DISP=SHR       
//INP2  DD DSN=INP2,DISP=SHR   
//VSM   DD DSN=VSAM1,DISP=SHR             
//OUT1   DD DSN=&&TEMP1,DISP=(,PASS,DELETE),           
//          DCB=(LRECL=139,RECFM=FB,BLKSIZE=0),       
//          UNIT=SYSDA,SPACE=(CYL,(50,10),RLSE)       
//OUT2   DD DSN=OUT2,             
//           DISP=(NEW,CATLG,DELETE),                 
//           DCB=(LRECL=504,RECFM=VB,BLKSIZE=0),       
//           UNIT=SAVDA,SPACE=(CYL,(50,10),RLSE)       
//TOOLIN DD *                                         
  COPY JKFROM TO(OUT1) USING(CTL1)                     
  COPY JKFROM TO(OUT2) USING(CTL2)                     
//CTL1CNTL DD *                                       
  JOINKEYS F1=INP1,FIELDS=(1,3,A),TASKID=T1                           
  JOINKEYS F2=INP2,FIELDS=(1,3,A),TASKID=T1                         
  REFORMAT FIELDS=(F2:1,139)                                         
  SORT FIELDS=(1,17,CH,A)                                             
//T1F1CNTL DD *                                                       
  INCLUDE COND=(4,4,CH,EQ,C'2102')                                   
//T1F2CNTL DD *                                                       
  INCLUDE COND=((29,2,CH,EQ,C'30',OR,29,2,CH,EQ,C'40'),AND,           
              (4,5,CH,NE,C'00000'))                                   
//CTL2CNTL DD *                                                       
  JOINKEYS F1=OUT1,FIELDS=(1,17,A),TASKID=T3,SORTED                   
  JOINKEYS F2=VSM,FIELDS=(2,17,A),TASKID=T3,SORTED                   
  REFORMAT FIELDS=(F1:1,139)                                         
  SORT FIELDS=COPY                                                   
  OUTFIL FNAMES=OUT2,FTOV,                                           
  BUILD=(1:C'01020',6:1,3,10:C' ',11:29,2,13:31,1,                   
      14:7,7,21:38,5,PD,ADD,43,6,PD,ADD,49,6,PD,TO=PD,LENGTH=6,474X) 
//T3F2CNTL DD *                                                       
  INCLUDE COND=(49,1,CH,EQ,C'B',AND,2217,2,CH,EQ,C'07')               
//*


Thanks
Magesh
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 Jul 03, 2014 1:11 pm    Post subject: Reply with quote

Magesh_J,

Couple of Issues.


1.) why do you have SORTED for the 2nd joinkeys?

Code:

//CTL2CNTL DD *                                                       
  JOINKEYS F1=OUT1,FIELDS=(1,17,A),TASKID=T3,SORTED                   
  JOINKEYS F2=VSM,FIELDS=(2,17,A),TASKID=T3,SORTED         
//*


2.) What is the point of building a Variable file when all the records are of same length of 504? do you really intend to do it?
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Magesh_J
Intermediate


Joined: 21 Jun 2014
Posts: 259
Topics: 54

PostPosted: Sat Jul 05, 2014 1:41 am    Post subject: Reply with quote

Hi Kolusu,

thanks for looking into this.

Quote:

1.) why do you have SORTED for the 2nd joinkeys?

Out1 file is already sorted in first join key

Code:

SORT FIELDS=(1,17,CH,A)


and VSAM1 filekey (2,17), which is also already in sorted order.

Quote:

2.) What is the point of building a Variable file when all the records are of same length of 504? do you really intend to do it?


Thanks, yes it is not required, I have removed it now.

Regards,
Magesh
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: Sun Jul 06, 2014 1:08 am    Post subject: Reply with quote

Magesh_J,

I was never a fan of combining multiple steps into a single step. If something goes wrong you have to start all over again. For example you have 2 sorts in a single step and lets say your first sort is successful , but your second sort step abended for some reason. Since your DISP=(NEW,CATLG,DELETE), the first sort output datasets are also deleted even though they are successful. Imagine if the first sort ran processed more 10 million records with considerable time, you are left to re-process them once again which in my opinion is a sheer waste of resources.

Ideally I would leave it as 2 step approach and here are a couple of recommendations.

1. Always have the larger file assigned to SORTJNF1
2. Process with only the Fields you need. for ex: you only need the 1st 3 bytes from the PDS member. So cut it down to just those using INREC on JNFxCNTL

Here is my untested version of the Jobs. I switched the JNF1 and JNF2 and also made changes to pick only the Fields I am interested in. I could have picked up only 54 bytes for OUT1 too, but I am not sure if you need the entire file for different processing, so left it as is.
Code:

//STEP0100 EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*
//JNF1JMSG DD SYSOUT=*
//JNF2JMSG DD SYSOUT=*
//SORTJNF1 DD DISP=SHR,DSN=INP2
//SORTJNF2 DD DISP=SHR,DSN=PDS(MEM1)
//SORTOUT  DD DSN=OUT1,               
//            DISP=(NEW,CATLG,DELETE),
//            UNIT=SAVDA,SPACE=(CYL,(50,10),RLSE)
//SYSIN    DD *
  JOINKEYS FILE=F1,FIELDS=(1,3,A)
  JOINKEYS FILE=F2,FIELDS=(1,3,A)
  REFORMAT FIELDS=(F1:1,139)
  SORT FIELDS=(1,17,CH,A)
//*
//JNF1CNTL DD *
  INCLUDE COND=((29,2,CH,EQ,C'30',OR,29,2,CH,EQ,C'40'),AND,
                (4,5,CH,NE,C'00000'))
//*
//JNF2CNTL DD *
  INCLUDE COND=(4,4,CH,EQ,C'2102')
  INREC BUILD=(1,3)
//*
//STEP0200 EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*
//JNF1JMSG DD SYSOUT=*
//JNF2JMSG DD SYSOUT=*
//SORTJNF1 DD DSN=OUT1,DISP=SHR
//SORTJNF2 DD DSN=VSAM1,DISP=SHR
//SORTOUT  DD DSN=OUT2,                 
//            DISP=(NEW,CATLG,DELETE),
//            UNIT=SAVDA,SPACE=(CYL,(50,10),RLSE)
//*
//SYSIN DD *
  JOINKEYS FILE=F1,FIELDS=(1,17,A),SORTED,NOSEQCK
  JOINKEYS FILE=F2,FIELDS=(1,17,A),SORTED,NOSEQCK
  REFORMAT FIELDS=(F1:1,54)
  OPTION COPY
  INREC BUILD=(01:C'01020',
               06:01,3,
               10:X,
               11:29,2,
               13:31,1,
               14:07,7,
               21:38,5,PD,ADD,
                  43,6,PD,ADD,
                  49,6,PD,TO=PD,LENGTH=6)
//*
//JNF2CNTL DD *
  INCLUDE COND=(0049,1,CH,EQ,C'B',AND,
                2217,2,CH,EQ,C'07')

  INREC BUILD=(2,17)
//*

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


Joined: 21 Jun 2014
Posts: 259
Topics: 54

PostPosted: Sun Jul 06, 2014 4:22 am    Post subject: Reply with quote

Wow !!! your advice has further reduced 2 sec cpu.
Thanks Kolusu,

It looks VTOF is required, as the output is suppose to be 504 VB Sad.
The Subsequent programs are product programs, difficult to get approval to touch that.

Just FYI... This was a Cobol program we are trying to convert it to DFSORT.

updated the code as per your advice.

Code:

//S1   EXEC  PGM=SORT                                     
//SYSOUT DD SYSOUT=*                                       
//SORTJNF1 DD DSN=INP2,DISP=SHR     
//SORTJNF2 DD DSN=PDS(MEM),DISP=SHR         
//SORTOUT DD DSN=OUT1,                 
//           DISP=(NEW,CATLG,DELETE),                     
//           DCB=(LRECL=54,RECFM=FB,BLKSIZE=0),      ==>updated     
//           UNIT=SAVDA,SPACE=(CYL,(50,10),RLSE)           
//SYSIN    DD *                                           
  JOINKEYS FILE=F1,FIELDS=(1,3,A)                         
  JOINKEYS FILE=F2,FIELDS=(1,3,A)                         
  REFORMAT FIELDS=(F1:1,54)                               
  SORT FIELDS=(1,17,CH,A)                                 
//JNF1CNTL DD *                                           
  INCLUDE COND=((29,2,CH,EQ,C'30',OR,29,2,CH,EQ,C'40'),AND,
                 (4,5,CH,NE,C'00000'))                     
  INREC BUILD=(1,54)                            ==>Added now           
//*                                                       
//JNF2CNTL DD *                                         
   INCLUDE COND=(4,4,CH,EQ,C'2102')                     
   INREC BUILD=(1,3)                                   
/*                                                     
//S2   EXEC  PGM=SORT                                   
//SYSOUT DD SYSOUT=*                                   
//SORTJNF1 DD DSN=OUT1,DISP=SHR     
//SORTJNF2 DD DSN=VSAM1,DISP=SHR           
//SORTOUT DD DSN=OUT2,             
//           DISP=(NEW,CATLG,DELETE),                   
//           DCB=(LRECL=504,RECFM=VB,BLKSIZE=0),       
//           UNIT=SAVDA,SPACE=(CYL,(50,10),RLSE)       
//SYSIN DD *                                           
  JOINKEYS FILE=F1,FIELDS=(1,17,A),SORTED,NOSEQCK       
  JOINKEYS FILE=F2,FIELDS=(1,17,A),SORTED,NOSEQCK       
  REFORMAT FIELDS=(F1:1,54)                             
  OPTION COPY                                           
  INREC BUILD=(01:C'01020',                             
                06:01,3,                               
                10:X,                                   
                11:29,2,                       
                13:31,1,                       
                14:07,7,                       
                21:38,5,PD,ADD,                 
                   43,6,PD,ADD,                 
                   49,6,PD,TO=PD,LENGTH=6)     
  OUTFIL FNAMES=SORTOUT,FTOV                    ==>added
//*                                             
//JNF2CNTL DD *                                 
  INCLUDE COND=(0049,1,CH,EQ,C'B',AND,         
                 2217,2,CH,EQ,C'07')           
  INREC BUILD=(2,17)                           
//*                                             



Thanks
Magesh
Back to top
View user's profile Send private message
Magesh_J
Intermediate


Joined: 21 Jun 2014
Posts: 259
Topics: 54

PostPosted: Sun Jul 06, 2014 4:36 am    Post subject: Reply with quote

One doubt why dfsort is checking the sequence when we say the record is SORTED ?
Record sorted itself means record is in sequence right.

Please advice



Thanks
Magesh
Back to top
View user's profile Send private message
William Collins
Supermod


Joined: 03 Jun 2012
Posts: 437
Topics: 0

PostPosted: Sun Jul 06, 2014 8:23 am    Post subject: Reply with quote

If the data is told to be SORTED but actually isn't, the results of the JOINKEYS may be incorrect. So the default is to check the sequence. If you know it is in sequence, you can, at your responsibility, tell the JOINKEYS not to check the sequence. Then it is your fault if it not in sequence, not DFSORT's fault.
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 07, 2014 2:01 pm    Post subject: Reply with quote

Magesh_J wrote:
One doubt why dfsort is checking the sequence when we say the record is SORTED ?
Record sorted itself means record is in sequence right.

Please advice



Thanks
Magesh


Magesh_J,

When in doubt, ALWAYS refer the manual. Check this link which explains the NOSEQCK parm in detail here

http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/ICE1CA60/4.3

I am not a big fan of coding DCB parameters in the JCL, DFSORT will automatically calculate the optimal DCB properties from either SORTIN or INREC/OUTREC. So I suggest you remove the DCB properties.


Also I don't think you need 54 bytes of the input data as you only need the following

1. 17 bytes as key to match the vsam file
2. 3 bytes from position 29 to 31 for the final output file.
3. 17 bytes(5+6+6) bytes to perform arithmetic.

So pick only the fields you need in the INREC

Code:

INREC BUILD=(01,17,
             29,03,
             38,17)


and change the REFORMAT statement to the following in both steps.
Code:

REFORMAT FIELDS=(F1:1,37)


and then change the INREC in the 2nd Join to account for the new positions

Code:

  INREC BUILD=(001:C'01020',                             
               006:01,3,                               
               011:18,3,                       
               014:07,7,                       
               021:21,5,PD,ADD,                 
                   26,6,PD,ADD,                 
                   32,6,PD,TO=PD,LENGTH=6,
               500:X)


By default OUTFIL will be SORTOUT, so you really don't have to specify the FNAMES=SORTOUT. You can simply code

Code:

OUTFIL FTOV

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


Joined: 21 Jun 2014
Posts: 259
Topics: 54

PostPosted: Fri Jul 11, 2014 9:16 am    Post subject: Reply with quote

Hi Kolusu,

The solution worked very well. 0.5 second CPU reduced.
Thankyou very much.

Sorry for the delay in response, problem was a mismatch, which is because i missed to add one condition while converting, now i have added it.

The condition is to check if 18,2,CH,EQ,C'40' then need to multiply with -1
((21,5) + (26,6) + (32,6)) * -1
else
(21,5) + (26,6) + (32,6)

Updated code.

Code:

//S1   EXEC  PGM=SORT                                         
//SYSOUT DD SYSOUT=*                                         
//SORTJNF1 DD DSN=IN1,DISP=SHR       
//SORTJNF2 DD DSN=PDS(MEM),DISP=SHR             
//SORTOUT DD DSN=OUT1,                     
//           DISP=(NEW,CATLG,DELETE),                         
//           UNIT=SAVDA,SPACE=(CYL,(50,10),RLSE)             
//SYSIN    DD *                                               
  JOINKEYS FILE=F1,FIELDS=(1,3,A)                             
  JOINKEYS FILE=F2,FIELDS=(1,3,A)                             
  REFORMAT FIELDS=(F1:1,37)                                   
  SORT FIELDS=(1,17,CH,A)                                     
//JNF1CNTL DD *                                               
  INCLUDE COND=((29,2,CH,EQ,C'30',OR,29,2,CH,EQ,C'40'),AND,   
                 (4,5,CH,NE,C'00000'))                       
  INREC BUILD=(01,17,                                         
                29,03,                                       
                38,17)                                       
//JNF2CNTL DD *                                         
   INCLUDE COND=(4,4,CH,EQ,C'2102')                     
   INREC BUILD=(1,3)                                     
/*                                                       
//S2   EXEC  PGM=SORT                                   
//SYSOUT DD SYSOUT=*                                     
//SORTJNF1 DD DSN=OUT1,DISP=SHR       
//SORTJNF2 DD DSN=VSAM1,DISP=SHR             
//SORTOUT DD DSN=OUT2,             
//           DISP=(NEW,CATLG,DELETE),                   
//           DCB=(LRECL=504,RECFM=VB,BLKSIZE=0),         
//           UNIT=SAVDA,SPACE=(CYL,(50,10),RLSE)         
//SYSIN DD *                                             
  JOINKEYS FILE=F1,FIELDS=(1,17,A),SORTED,NOSEQCK       
  JOINKEYS FILE=F2,FIELDS=(1,17,A),SORTED,NOSEQCK       
  REFORMAT FIELDS=(F1:1,37)                             
  OPTION COPY                                           
      INREC IFTHEN=(WHEN=(18,2,CH,EQ,C'40'),             
            BUILD=(001:C'01020',                         
                    006:01,3,                                     
                    011:18,3,                                     
                    014:07,7,                                     
                    021:((21,5,PD,ADD,                           
                        26,6,PD,ADD,                             
                        32,6,PD),MUL,-1),TO=PD,LENGTH=6,         
                    500:X)),                                     
             IFTHEN=(WHEN=NONE,                                   
             BUILD=(001:C'01020',                                 
                    006:01,3,                                     
                    011:18,3,                                     
                    014:07,7,                                     
                    021:21,5,PD,ADD,                             
                        26,6,PD,ADD,                             
                        32,6,PD,TO=PD,LENGTH=6,                   
                    500:X))                                       
  OUTFIL FTOV                                                     
//*                                                               
//JNF2CNTL DD *                                                   
  INCLUDE COND=(0049,1,CH,EQ,C'B',AND, 
                 2217,2,CH,EQ,C'07')       
  INREC BUILD=(2,17)                       
//*                                                                 


Thanks
Magesh
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