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 

DFSORT to restrict last 5 years data

 
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: Mon May 25, 2015 11:53 am    Post subject: DFSORT to restrict last 5 years data Reply with quote

Hi,

I need last 5 years data from a file. where i have only 'YY' in 29th byte.

I tried writing below code, it works, Is there a better way to do this. Because i am overlaying 2 bytes for every record.

Code:

//SYMNAMES DD *                                     
CURDT,S'&YR2'                                       
//SORTIN  DD *                                       
                            12                       
                            11                       
                            09                       
                            08                       
                            13                       
                            15                       
//SORTOUT    DD SYSOUT=*                             
//SYSOUT DD SYSOUT=*                                 
//SYSIN DD *                                         
  INREC OVERLAY=(81:29,2,ZD,ADD,+5,TO=ZD,LENGTH=2)   
  OPTION COPY                                       
  OUTFIL INCLUDE=(81,2,CH,GE,CURDT),BUILD=(1,80)     
/*                                                   


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: Tue May 26, 2015 10:10 am    Post subject: Reply with quote

Magesh_J,

That looks ok, but how are you are limiting the data to last 5 years?. With just the year you are looking at more than 5 years of data. Since you did not have the month you will include the data from the months that are completed in the current year.

For example if the current date is december 31st you would still include the data for 2010 which in reality should only have 1 day data.

If you had the month also then you can use

Code:

  INCLUDE COND=(81,4,Y2T,GE,Y'DATE2'-60)

_________________
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: Tue May 26, 2015 9:36 pm    Post subject: Reply with quote

Kolusu,

Thanks for the kind response.
Kolusu wrote:

For example if the current date is december 31st you would still include the data for 2010 which in reality should only have 1 day data.

Yes, we dont have month option, only YY data.

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


Joined: 21 Jun 2014
Posts: 259
Topics: 54

PostPosted: Tue May 26, 2015 10:30 pm    Post subject: Reply with quote

Kolusu,

Tried this way to avoid overlay on every record, But getting so13 error. Please advise.

Code:

//SORT010    EXEC PGM=SORT                       
//SORTIN  DD *                                   
A                                               
//SORTOUT    DD DSN=&&TEMP,DISP=(,PASS,DELETE), 
//        SPACE=(CYL,(1,1),RLSE)                 
//SYSOUT DD SYSOUT=*                             
//SYSIN DD *                                     
  INREC BUILD=(1:DATE2-60)                       
  OPTION COPY                                   
  OUTFIL BUILD=(C'YEART,',3,2)                   
/*                                               
//*                                             
//STEP020   EXEC PGM=SORT                       
//SYMNAMES DD DSN=&&TEMP,DISP=SHR               
//SORTIN  DD *                     
                            12     
                            11     
                            09     
                            08     
                            13     
                            15     
//SORTOUT    DD SYSOUT=*           
//SYSOUT DD SYSOUT=*               
//SYSIN DD *                       
   INCLUDE COND=(29,2,ZD,GE,YEART)
   OPTION COPY                     
/*                                 


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


Joined: 21 Jun 2014
Posts: 259
Topics: 54

PostPosted: Tue May 26, 2015 10:38 pm    Post subject: Reply with quote

SYMNAMES expect 80 bytes records. Changed it working good.

Code:

OUTFIL BUILD=(C'YEART,',3,2,80:X)   


Now please advise, If the overlay is better or this way is better ?


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: Tue May 26, 2015 10:53 pm    Post subject: Reply with quote

Magesh_J wrote:
SYMNAMES expect 80 bytes records. Changed it working good.

Code:

OUTFIL BUILD=(C'YEART,',3,2,80:X)   


Now please advise, If the overlay is better or this way is better ?


Thanks
Magesh


Magesh,

As you realized S013 abend is due to Synnames Dataset not being 80 bytes with RECFM=FB.

As for optimization, why bother creating symbols. Simply create the include statement in first step and use the control cards in next step

Code:

/SORT010  EXEC PGM=SORT                       
//SORTIN  DD *                                   
A                                               
//SORTOUT    DD DSN=&&TEMP,DISP=(,PASS,DELETE),
//        SPACE=(CYL,(1,1),RLSE)                 
//SYSOUT DD SYSOUT=*                             
//SYSIN DD *                                     
  INREC BUILD=(DATE2-60)                       
  OPTION COPY                                   
  OUTFIL BUILD=(3:C'OPTION COPY',/,
                3:C'INCLUDE COND=(29,2,ZD,GE,',3,2,C')',80:X)   
//*
//STEP020  EXEC PGM=SORT                       
//SORTIN   DD *                     
                            12     
                            11     
                            09     
                            08     
                            13     
                            15     
//SORTOUT  DD SYSOUT=*           
//SYSOUT   DD SYSOUT=*   
//SYSIN    DD DSN=&&TEMP,DISP=SHR

_________________
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: Wed May 27, 2015 12:05 am    Post subject: Reply with quote

Kolusu,

Great idea, This way we are avoiding SYMNAMES.

Thanks

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


Joined: 03 Jun 2012
Posts: 437
Topics: 0

PostPosted: Wed May 27, 2015 6:19 am    Post subject: Reply with quote

Mmmm... the symbols/SYMNAMES aren't costing anything for performance.

If you need(ed) more than the COPY and INCLUDE in the step, the is additional "complexity" (either all the cards generated, or the INCLUDE and then concatenated names, or reading and updating a "skeleton").

Code:
//GENNAME  EXEC PGM=SORT
//SYMNAMES DD *
GEN-SYMNAME-VARIABLE-CONTENT,3,2,CH
GEN-SYMNAME-NAME,C'SELECTION-YEAR-MINUS-FIVE,C'''
A-QUOTE,C''''
//SYMNOUT DD SYSOUT=*
//SYSOUT   DD SYSOUT=*
//SORTOUT  DD DSN=&&SYM,UNIT=SYSDA,DISP=(,PASS),SPACE=(TRK,1)
//SORTIN  DD *
CONTENT NOT IMPORTANT, BUT MUST BE AT LEAST ONE RECORD
//SORTOUT    DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSIN DD *
 OPTION COPY,STOPAFT=1,NULLOUT=RC4
                                                             
 INREC IFTHEN=(WHEN=INIT,
               BUILD=(DATE2-60)),
       IFTHEN=(WHEN=INIT,
               BUILD=(GEN-SYMNAME-NAME,
                      GEN-SYMNAME-VARIABLE-CONTENT,
                      A-QUOTE,
                      80:X))



Add the SYMNAMES and SYMNOUT DDs and just use the generated name (whatever you want to call it) in the INCLUDE COND=.

You get a bit of description, you can add (by concatenation) other symbols, for instance to describe the source of the data for the comparison.

The above is fairly general for generating a symbol. The first WHEN=INIT gets the data (JPn, or something like this, for instance) and the second formats the symbol itself. So quite reusable.

Either way will work, but I don't see a reason for "avoiding SYMNAMES" as though it were something which would lead to improvement.
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: Wed May 27, 2015 11:28 am    Post subject: Reply with quote

William Collins wrote:
Mmmm... the symbols/SYMNAMES aren't costing anything for performance.
Either way will work, but I don't see a reason for "avoiding SYMNAMES" as though it were something which would lead to improvement.


William,

The suggestion of avoiding symnames is purely based on how simple the include cond is. It is not effecting the performance in any way.

I for one am not a big fan of symbols as I like to see my control cards all aligned and easy to read. With symbols everything is squeezed and it is not that easy to read them if you need to fix anything.

You on the other hand is a big fan of symbols. Very Happy
_________________
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 May 29, 2015 3:35 am    Post subject: Reply with quote

Thanks William.

Regards,
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