IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Syncsort extract date before two months of current date


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
seema_285

New User


Joined: 14 Oct 2010
Posts: 13
Location: pune

PostPosted: Thu Oct 14, 2010 5:27 pm
Reply with quote

Hi,
I want to do some manipulations on date which is in mm/dd/yyyy format in my input file.

I want to extract records which have date before two months of current date.

How to do this using sort.??
I have tried with following sort card but got an user abend.
Code:

  SORT FIELDS=COPY                           
  OUTFIL OUTREC=(01,10,ZD,LT,&DATE2P(MD4/)-2)
  OUTFIL OUTREC=(01,10,ZD,GT,&DATE2P(MD4/)-2)

Please suggest some solutions.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Thu Oct 14, 2010 8:59 pm
Reply with quote

Hello and welcome to the forum,

One easy thing to do is write a bit of code to generate the sort control statements.
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Fri Oct 15, 2010 10:29 am
Reply with quote

seema_285,

Welcome to the forums!

Are you just considering the month alone and not the date (dd) part?

Can you provide some sample input and expected output out of it?
Back to top
View user's profile Send private message
seema_285

New User


Joined: 14 Oct 2010
Posts: 13
Location: pune

PostPosted: Mon Oct 18, 2010 5:56 pm
Reply with quote

Hi Arun,

PFB the input output details:

Input: 08/05/2010
08/08/2010
10/05/2010
08/18/2010
09/18/2010
08/19/2010

Processing shud be: (input date {mm/dd/yyyy}) - (current date (10/18/2010){mm/dd/yyyy} >= 30 days OR 2 months

Output: 08/05/2010
08/08/2010
08/18/2010
Back to top
View user's profile Send private message
Alissa Margulies

SYNCSORT Support


Joined: 25 Jul 2007
Posts: 496
Location: USA

PostPosted: Tue Oct 19, 2010 9:36 pm
Reply with quote

Hello Seema.

Here is an example of a SyncSort for z/OS job that should help you:
Code:
//SORT1 EXEC PGM=SORT                                       
//SORTIN  DD *                                             
08/06/2010                                                 
08/09/2010                                                 
10/06/2010                                                 
08/19/2010                                                 
09/19/2010                                                 
08/20/2010                                                 
//SORTOUT DD SYSOUT=*                                       
//SYSOUT  DD SYSOUT=*                                       
//SYSIN   DD * 
 SORT FIELDS=COPY                                           
 OUTREC IFTHEN=(WHEN=INIT,                               
        OVERLAY=(20:7,4,1,2,4,2,40:&DATENS=(4MD))),       
        IFTHEN=(WHEN=(44,2,CH,EQ,C'01'),                 
        OVERLAY=(44:C'11',40:40,4,ZD,SUB,+1,EDIT=(TTTT))),
        IFTHEN=(WHEN=(44,2,CH,EQ,C'02'),                 
        OVERLAY=(44:C'12',40:40,4,ZD,SUB,+1,EDIT=(TTTT))),
        IFTHEN=(WHEN=NONE,                               
        OVERLAY=(44:44,2,ZD,SUB,+2,EDIT=(TT)))
 OUTFIL INCLUDE=(20,8,ZD,LE,40,8,ZD),BUILD=(1,10)         
/*     

Here is the output produced by the step above:
Code:
08/06/2010
08/09/2010
08/19/2010

Please let us know if you have any further questions.

Regards,
Back to top
View user's profile Send private message
seema_285

New User


Joined: 14 Oct 2010
Posts: 13
Location: pune

PostPosted: Wed Oct 20, 2010 5:21 pm
Reply with quote

Thanks Alissa.

This has worked.. icon_smile.gif

But my question is that Can we do the same with in built date functions in sort like &DATE,&DATE1 or &DATE2 ?

Please let me know if you could help me on this.

Thanking you in anticipation.
Back to top
View user's profile Send private message
Alissa Margulies

SYNCSORT Support


Joined: 25 Jul 2007
Posts: 496
Location: USA

PostPosted: Wed Oct 20, 2010 7:50 pm
Reply with quote

Seema,

I don't understand your question. Can you please provide an example?

Thanks,
Back to top
View user's profile Send private message
seema_285

New User


Joined: 14 Oct 2010
Posts: 13
Location: pune

PostPosted: Thu Oct 21, 2010 5:21 pm
Reply with quote

Alissa,

Can we rewrite the same sort card with the help of &date or &date paramenters in SYNCSORT....
e.g.
SORT FIELDS=COPY
OUTFIL OUTREC=(01,10,ZD,LT,&DATE2P(MD4/)-2)
OUTFIL OUTREC=(01,10,ZD,GT,&DATE2P(MD4/)-2)

I tried but did not get the results.

Let me know if you could throw some light on it.

Thanks.
Back to top
View user's profile Send private message
Alissa Margulies

SYNCSORT Support


Joined: 25 Jul 2007
Posts: 496
Location: USA

PostPosted: Thu Oct 21, 2010 9:34 pm
Reply with quote

You need to reformat your input date field for the comparison. You can code something like this for 60 days:
Code:
//SYSIN   DD *                                       
  SORT FIELDS=COPY                                   
  OUTREC OVERLAY=(12:7,4,1,2,4,2)                   
  OUTFIL INCLUDE=(12,7,CH,LT,&DATE1-60),OUTREC=(1,10)
/*       
Back to top
View user's profile Send private message
seema_285

New User


Joined: 14 Oct 2010
Posts: 13
Location: pune

PostPosted: Fri Oct 22, 2010 5:32 pm
Reply with quote

Thank you so much Alissa... icon_smile.gif
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts Replacing 'YYMMDD' with date, varying... SYNCSORT 3
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Need help for File Aid JCL to extract... Compuware & Other Tools 23
Search our Forums:

Back to Top