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

Add 1 to Date of format YYYY-MM-DD if found as Sunday


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
madishpa

New User


Joined: 18 May 2007
Posts: 28
Location: Hyderabad

PostPosted: Wed Aug 15, 2012 10:47 pm
Reply with quote

Hi,

I wanted to add +1 to a date if it is found to be a Sunday.
The format of the date is YYYY-MM-DD.

I tried using Y4T option, but looks like it expects in the format of YYYYMMDD.

Please could you help!!

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

Senior Member


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

PostPosted: Wed Aug 15, 2012 11:19 pm
Reply with quote

madishpa,

1.What is the LRECL and RECFM of the input/output file?
2. What is the position of the date field?
Back to top
View user's profile Send private message
madishpa

New User


Joined: 18 May 2007
Posts: 28
Location: Hyderabad

PostPosted: Thu Aug 16, 2012 3:32 am
Reply with quote

Hi,

LRECL is 20 and RECFM is FB.

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

New User


Joined: 18 May 2007
Posts: 28
Location: Hyderabad

PostPosted: Thu Aug 16, 2012 3:33 am
Reply with quote

Hi,

Just to add the date starts at position 1.

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

Senior Member


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

PostPosted: Thu Aug 16, 2012 3:51 am
Reply with quote

madishpa,

Use the following DFSORT JCL which will give you the desired results.

Code:

//STEP0100 EXEC PGM=SORT                                 
//SYSOUT   DD SYSOUT=*                                   
//SORTIN   DD *                                         
2012-08-10                                               
2012-08-11                                               
2012-08-12                                               
2012-08-13                                               
2012-08-14                                               
2012-08-15                                               
2012-09-30
//SORTOUT  DD SYSOUT=*     
//SYSIN    DD *                                             
  SORT FIELDS=COPY                                           
  INREC IFOUTLEN=20,IFTHEN=(WHEN=INIT,                       
  OVERLAY=(21:1,10,UFF,M11,LENGTH=8,21,8,Y4T,WEEKDAY=CHAR3)),
   IFTHEN=(WHEN=(29,3,CH,EQ,C'SUN'),                         
  OVERLAY=(11:21,8,Y4T,ADDDAYS,+1,TOGREG=Y4T(-)))           
//*                                                         


The output from this job is
Code:

2012-08-10         
2012-08-11         
2012-08-122012-08-13
2012-08-13         
2012-08-14         
2012-08-15         
2012-09-302012-10-01
Back to top
View user's profile Send private message
madishpa

New User


Joined: 18 May 2007
Posts: 28
Location: Hyderabad

PostPosted: Thu Aug 16, 2012 3:42 pm
Reply with quote

Hi,

Thank you very much for the reply.
Please could you help advise as what would needs to be done if the date is as follows:

2012-08-12 2012-08-12 2012-08-12 2012-08-11

The expected o/p is as follows:

2012-08-13 2012-08-13 2012-08-13 2012-08-11

As the 2012-08-12 being a Sunday, the day has been incremented.

Appreciate your kind help.

Thanks
Madishpa.
Back to top
View user's profile Send private message
knickraj
Warnings : 1

New User


Joined: 11 Jun 2007
Posts: 50
Location: Euro

PostPosted: Thu Aug 16, 2012 7:40 pm
Reply with quote

try this..

Code:
//STEP0100 EXEC PGM=SORT                                   
//SYSOUT   DD SYSOUT=*                                     
//SORTIN   DD *                                             
2012-08-12 2012-08-12 2012-08-12 2012-08-11                 
//SORTOUT  DD SYSOUT=*                                     
//SYSIN    DD *                                             
  SORT FIELDS=COPY                                         
  INREC IFOUTLEN=50,IFTHEN=(WHEN=INIT,                     
  OVERLAY=(51:1,10,UFF,M11,LENGTH=8,51,8,Y4T,WEEKDAY=CHAR3,
  71:12,10,UFF,M11,LENGTH=8,71,8,Y4T,WEEKDAY=CHAR3,         
  91:23,10,UFF,M11,LENGTH=8,91,8,Y4T,WEEKDAY=CHAR3,         
  111:34,10,UFF,M11,LENGTH=8,111,8,Y4T,WEEKDAY=CHAR3)),     
   IFTHEN=(WHEN=(59,3,CH,EQ,C'SUN'),                       
  OVERLAY=(1:51,8,Y4T,ADDDAYS,+1,TOGREG=Y4T(-)),HIT=NEXT), 
   IFTHEN=(WHEN=(79,3,CH,EQ,C'SUN'),                       
  OVERLAY=(12:71,8,Y4T,ADDDAYS,+1,TOGREG=Y4T(-)),HIT=NEXT),
   IFTHEN=(WHEN=(99,3,CH,EQ,C'SUN'),                       
  OVERLAY=(23:91,8,Y4T,ADDDAYS,+1,TOGREG=Y4T(-)),HIT=NEXT),
   IFTHEN=(WHEN=(119,3,CH,EQ,C'SUN'),                       
  OVERLAY=(34:111,8,Y4T,ADDDAYS,+1,TOGREG=Y4T(-)))         
Back to top
View user's profile Send private message
madishpa

New User


Joined: 18 May 2007
Posts: 28
Location: Hyderabad

PostPosted: Thu Aug 16, 2012 8:00 pm
Reply with quote

Ohh...Thanks..
It helps..

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

Senior Member


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

PostPosted: Thu Aug 16, 2012 9:31 pm
Reply with quote

madishpa wrote:
Hi,

Thank you very much for the reply.
Please could you help advise as what would needs to be done if the date is as follows:

2012-08-12 2012-08-12 2012-08-12 2012-08-11

The expected o/p is as follows:

2012-08-13 2012-08-13 2012-08-13 2012-08-11

As the 2012-08-12 being a Sunday, the day has been incremented.

Appreciate your kind help.

Thanks
Madishpa.


Madishpa,

Can you tell me the trick of storing 4 date fields in CCYY-MM-DD format into a 20 byte FB file?

Why can't you tell us the actual requirement when you cannot modify the control cards supplied to you? You are just wasting not only your time as well as anyone who is trying to help you.

Knickraj,

I am sure you just got a glimpse of the actual number of date fields. It might be a month worth of data that needs to modify and in such cases it is better to go with weekday function to return the day of week in numeric format so that we can reduce the length of the expanded record.
Back to top
View user's profile Send private message
madishpa

New User


Joined: 18 May 2007
Posts: 28
Location: Hyderabad

PostPosted: Fri Aug 17, 2012 3:27 pm
Reply with quote

Hi,

We we receive these 4 dates from a different application, for which we do not have control as they send these dates to different applications.
As our application alone does not run on a Sunday, we will have to consider incrementing the day by 1 which will be used down the line in the job.

Trust the requirement is clear.

Thanks
Madishpa
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 -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Replacing 'YYMMDD' with date, varying... SYNCSORT 3
No new posts Populate last day of the Month in MMD... SYNCSORT 2
No new posts How I Found a Bug in a FORTRAN Compiler All Other Mainframe Topics 4
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts Need to convert date format DFSORT/ICETOOL 20
Search our Forums:

Back to Top