Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

INCLUDE Condition with current date.

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
View previous topic :: :: View next topic  
Author Message
spradeepece

New User


Joined: 25 Jun 2008
Posts: 19
Location: Chennai

PostPosted: Fri Aug 29, 2008 3:09 pm    Post subject: INCLUDE Condition with current date.
Reply with quote

Hi..
Let the input file contains updated date of a record.
I need to extract records which was updated within last 1 year (month). i.e.,. current year (month) -1.
I dont need any date field to be populated in my output file.

Someone plz suggest a solution.

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

Arun Raj

Moderator


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

PostPosted: Fri Aug 29, 2008 3:45 pm    Post subject:
Reply with quote

Quote:
Someone plz suggest a solution.

It will be a really difficult task with whatever data you have provided.

What does your input record look like? Post some sample data using the "Code" tag and also give the field positions/file attributes.

Thanks,
Arun
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Fri Aug 29, 2008 8:51 pm    Post subject:
Reply with quote

spradeepece,

You need to do a better job of explaining what you want to do before anyone can help you.

What is the form of the date (yyymmdd, yyyyddd, yymmdd, mmddyy, ?).

What is the format of the date (character, zoned decimal, packed decimal, ?).

What is the starting position of the date?

It's not clear what you mean by "I need to extract records which was updated within last 1 year (month). i.e.,. current year (month) -1.". You need to explain what you mean more clearly.

Show an example of the records in your input file (relevant fields only) and what you expect for output. Explain the "rules" for getting from input to output. Give the starting position, length and format of all relevant fields. Give the RECFM and LRECL of the input file.
Back to top
View user's profile Send private message
spradeepece

New User


Joined: 25 Jun 2008
Posts: 19
Location: Chennai

PostPosted: Mon Sep 01, 2008 11:36 am    Post subject:
Reply with quote

Hi,
The date is in YYYY-MM-DD form in zone decimal format.

For example let the input file contains the following dates starting from 1st column.

Code:
2008-05-31
2007-08-28
2007-08-27
2007-09-01
2008-04-28
2007-08-19
2007-02-07


The current date is '2008-09-01'. The output file should contain,

Code:
2008-05-31                                                             
2007-09-01
2008-04-28


I have used 'Sort' to filter out, with the following SYSIN card,

Code:
//SYSIN    DD *                                         
  SORT FIELDS=COPY                                       
  INREC FIELDS=(1,80,DATE=(4MD-))                       
  OUTREC FIELDS=(1,80,(81,4,ZD,SUB,+1),EDIT=(TTTT),85,6)
  OUTFIL FILES=OUT,INCLUDE=(1,4,ZD,GT,81,4,ZD,OR,       
                            (1,4,ZD,EQ,81,4,ZD,AND,     
                             6,2,ZD,GT,86,2,ZD),OR,     
                            (1,4,ZD,EQ,81,4,ZD,AND,     
                             6,2,ZD,EQ,86,2,ZD,AND,     
                             9,2,ZD,GE,89,2,ZD))         
/*                                                       



In this case the last 10 bytes in each record includes '2007-09-01' i.e., current day minus 1 year, which is not required.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Mon Sep 01, 2008 11:07 pm    Post subject:
Reply with quote

How about using these DSORT control statements?

Code:

  OPTION COPY                                     
  INCLUDE COND=(1,10,CH,GT,DATE1(-)-366)       


I used 366 because 2008 is a leap year.
Back to top
View user's profile Send private message
spradeepece

New User


Joined: 25 Jun 2008
Posts: 19
Location: Chennai

PostPosted: Tue Sep 02, 2008 10:35 am    Post subject:
Reply with quote

Frank,

Thanks. The above mentioned code works fine for leap year. But we cannot hardcode (365/366) for every four years. Is there any other way to solve this out?

Regards,
Pradeep.
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Tue Sep 02, 2008 7:49 pm    Post subject:
Reply with quote

Hi,

For leap year here are some links -

http://www.ibmmainframes.com/viewtopic.php?t=31415&highlight=leap
http://www.ibmmainframes.com/viewtopic.php?t=31783&highlight=leap
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Tue Sep 02, 2008 9:27 pm    Post subject:
Reply with quote

Pradeep,

You could generate a DFSORT Symbol for DATE-366 for leap years or DATE1-365 for non leap years like this. I set up the job to handle leap years from 2008 through 2024 but you can change it as appropriate. If you want to handle every possible leap year forever, you can encode the algorithm for that in DFSORT control statements yourself.

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD *
RECORD
/*
//SORTOUT DD DSN=&&S1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//SYSIN    DD    *
  OPTION COPY
  INREC IFOUTLEN=80,
    IFTHEN=(WHEN=INIT,BUILD=(DATE1)),
* If leap year, use DATE1-366
    IFTHEN=(WHEN=(1,4,SS,EQ,
* Set up leap years you want to handle.
      C'2008,2012,2016,2020,2024'),
      BUILD=(C'TDATE,''',DATE1(-)-366,C'''')),
* If not leap year, use DATE1-365
    IFTHEN=(WHEN=NONE,
      BUILD=(C'TDATE,''',DATE1(-)-365,C''''))
/*
//S2    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SYMNAMES DD DSN=&&S1,DISP=(OLD,PASS)
//SORTIN DD DSN=...  input file
//SORTOUT DD DSN=...  output file
//SYSIN    DD    *
  OPTION COPY
  INCLUDE COND=(1,10,CH,GT,TDATE)
/*
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Tue Sep 02, 2008 9:40 pm    Post subject:
Reply with quote

spradeepece,

Here is another version of DFSORT JCL which will give you the desired results

Code:

//STEP0100 EXEC PGM=ICEMAN                                       
//SYSOUT   DD SYSOUT=*                                           
//SORTIN   DD *                                                   
2008-05-31                                                       
2007-08-28                                                       
2007-08-27                                                       
2007-09-01                                                       
2008-04-28                                                       
2007-08-19                                                       
2007-02-07                                                       
//SORTOUT  DD SYSOUT=*                                           
//SYSIN    DD *                                                   
  SORT FIELDS=COPY                                               
  INREC IFTHEN=(WHEN=INIT,                                       
  OVERLAY=(81:DATE1,81,04,ZD,MOD,+4,EDIT=(T),                     
  81,04,ZD,MOD,+100,EDIT=(TTT),81,04,ZD,MOD,+400,EDIT=(TTT))),   
  IFTHEN=(WHEN=(93,3,ZD,EQ,0,OR,(89,1,ZD,EQ,0,AND,90,3,ZD,GT,0)),
  OVERLAY=(81:DATE1(-)-366)),                                     
  IFTHEN=(WHEN=NONE,OVERLAY=(81:DATE1(-)-365))                   

  OUTFIL INCLUDE=(1,10,CH,GT,81,10,CH),BUILD=(1,80)               
/*


Hope this helps...

Cheers
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1703
Location: Australia

PostPosted: Wed Sep 03, 2008 5:17 am    Post subject:
Reply with quote

Hi,

I don't think this leap year concept is correct, just because it's a leap year you can't automatically take 366 days off.

if the date was 2008-02-17, taking 366 days off would be incorrect, so any date LE 2008-02-28 would be -365 and GE 2008-02-29 would be
-366.

Gerry
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Wed Sep 03, 2008 5:38 am    Post subject:
Reply with quote

Gerry,

Good observation. This kind of date arithmetic can get really messy. But I suspect Kolusu will be able to fix his job to deal with this.
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Wed Sep 03, 2008 5:55 am    Post subject: Reply to: INCLUDE Condition with current date.
Reply with quote

gcicchet,

Point taken. Here is the updated version which evaluates if the current date is greater than or equal to feb 29. If the date is less than feb 29 and even though the year is a leap year we subtract 365 days from the current date. If the date is greater than or equal to feb 29 and the year is a leap year then we subtract 366 days from the current date

Code:

//STEP0100 EXEC PGM=ICEMAN                                       
//SYSOUT   DD SYSOUT=*                                           
//SORTIN   DD *                                                   
2008-05-31                                                       
2007-08-28                                                       
2007-08-27                                                       
2007-09-01                                                       
2008-04-28                                                       
2007-08-19                                                       
2007-02-07                                                       
//SORTOUT  DD SYSOUT=*                                           
//SYSIN    DD *                                                   
  SORT FIELDS=COPY                                               
  INREC IFTHEN=(WHEN=INIT,                                       
  OVERLAY=(81:DATE1,81,04,ZD,MOD,+4,EDIT=(T),                   
  81,04,ZD,MOD,+100,EDIT=(TTT),81,04,ZD,MOD,+400,EDIT=(TTT),X)),   
  IFTHEN=(WHEN=(93,3,ZD,EQ,0,OR,(89,1,ZD,EQ,0,AND,90,3,ZD,GT,0)),
  OVERLAY=(96:C'L'))                                             
                                                                 
  OUTREC IFTHEN=(WHEN=(96,1,CH,EQ,C'L',AND,85,4,ZD,GE,229),     
  OVERLAY=(81:DATE1(-)-366)),                                   
  IFTHEN=(WHEN=NONE,OVERLAY=(81:DATE1(-)-365))                   

  OUTFIL INCLUDE=(1,10,CH,GT,81,10,CH),BUILD=(1,80)               
/*



Hope this helps...

Cheers
Back to top
View user's profile Send private message
spradeepece

New User


Joined: 25 Jun 2008
Posts: 19
Location: Chennai

PostPosted: Tue Sep 16, 2008 2:16 pm    Post subject:
Reply with quote

Hi,

The code went fine..
Thanks everyone and sorry for delayed response..

Regards,
Pradeep.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts TOT & DATE parameter in ICEMAN hemanthj642 DFSORT/ICETOOL 4 Mon Nov 14, 2016 5:19 am
This topic is locked: you cannot edit posts or make replies. How to pass the previous month date i... Suganya87 DFSORT/ICETOOL 5 Mon Oct 31, 2016 4:13 pm
This topic is locked: you cannot edit posts or make replies. Get correct date and time when curren... balaji81_k DB2 24 Fri Oct 14, 2016 10:40 pm
No new posts Change date (DD/MM/YY) in 2nd record ... uday kiran DFSORT/ICETOOL 12 Wed Sep 07, 2016 10:57 pm
No new posts Add system date inside of a PS file a... pramitdas DFSORT/ICETOOL 5 Sun Aug 28, 2016 12:06 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us