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 

Retrieve specific records from VSAM(KSDS) dynamically

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


Joined: 21 Oct 2003
Posts: 70
Topics: 25

PostPosted: Tue Aug 16, 2005 2:41 pm    Post subject: Retrieve specific records from VSAM(KSDS) dynamically Reply with quote

Hallo Friends,
I have VSAM(KSDS) file with key starting from 1 to 16, out of which starting 6 bytes gives the year(YYYY format) and month(MM format). I need to get the last 4 months records i.e., from 200504 - 200507. Can I do using some utilities(Idcams/sort/any) ?. I have tried it with Easytrieve but I need alternatives to compare the efficiency. Its a monthly job so the key should be dynamic.

For ex:-
For August : I need records starting with 200504 and ending with 200507
For Septemeber: I need records starting with 200505 and ending with 200508
and so on....

I tried to search for this specifc problem but couldn't find the right one..

Please let me know.

Thanx in advance,
Lal
Back to top
View user's profile Send private message
lal
Beginner


Joined: 21 Oct 2003
Posts: 70
Topics: 25

PostPosted: Tue Aug 16, 2005 3:13 pm    Post subject: Reply with quote

Hi Friends,
I am continuing with the above post.
I believe we can do something like FROMKEY(200504*) - TOKEY(200507*).
But can I do something to change these pararmeter dynamically for everymonth in IDCAMS.

Thanx,
Lal
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12375
Topics: 75
Location: San Jose

PostPosted: Tue Aug 16, 2005 5:07 pm    Post subject: Reply with quote

Lal,

Try this untested JCL. I just wrote the date logic on a piece of paper. see if I missed any criteria. The first step creates a dynamic include step as follows which will be used in the next step to filter the records.

Code:

 SORT FIELDS=COPY                                   
 INCLUDE COND=(1,6,ZD,GE,200504,AND,1,6,ZD,LT,200508)


The trick part is to subtract the year in case of the months jan, feb, mar and apr. For those months you subtract 92 from the year and month portion so as to pick the last year date with 4 months subtracted. For the rest of the months it is simply subtracting 4 from the month portion.

Code:
 
//STEP0100 EXEC PGM=SORT                                     
//SYSOUT   DD SYSOUT=*                                       
//SORTIN   DD *                                             
 DUMMY RECORD                                               
//SORTOUT  DD DSN=&T1,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE)
//SYSIN    DD *                                               
  SORT FIELDS=COPY                                           
  INREC FIELDS=(DATE2)                                       
  OUTREC FIELDS=(1,6,                                         
                 7:5,2,CHANGE=(2,C'01',C'92',                 
                                 C'02',C'92',                 
                                 C'03',C'92',                 
                                 C'04',C'92'),NOMATCH=(C'04'))

  OUTFIL OUTREC=(C' SORT FIELDS=COPY',/,                     
                 C' INCLUDE COND=(1,6,ZD,GE,',               
                 1,6,ZD,SUB,7,2,ZD,EDIT=(TTTTTT),             
                 C',AND,1,6,ZD,LT,',                         
                 1,6,                                         
                 C')',80:X)                                   
/*                                                           
//STEP0200 EXEC PGM=SORT         
//SYSOUT   DD SYSOUT=*           
//SORTIN   DD *                 
20050301                         
20050402                         
20050503                         
20050604                         
20050705                         
20050806                         
//SORTOUT  DD SYSOUT=*           
//SYSIN    DD DSN=&T1,DISP=OLD   
/*


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
lal
Beginner


Joined: 21 Oct 2003
Posts: 70
Topics: 25

PostPosted: Tue Aug 16, 2005 5:42 pm    Post subject: Reply with quote

Hello Kolusu,
Its excellent solution....thanx...for your help

Regards,
Lal
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: Fri Apr 21, 2006 6:20 pm    Post subject: Reply with quote

With z/OS DFSORT V1R5 PTF UK90007 or DFSORT R14 PTF UK90006 (April, 2006), you can now do this using relative dates as follows:

Code:

  OPTION COPY                                           
  INCLUDE COND=(1,6,ZD,GE,DATE2P-4,AND,1,6,ZD,LT,DATE2P)

_________________
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