Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Identify Weekends & Bank Holidays

Status
Not open for further replies.

madhouse

Programmer
Sep 17, 2002
165
GB
Is there a way of identifying when it's a weekend & Bank Holiday on an AS400?

The reason I ask is that I've got a scheduled job to run a program which copies a file (PST00101B), runs some queries and then outputs the results to an outfile for some performance analysis that I'm doing. The file gets populated during overnight processing, but if it's a weekend i.e. Sat or Sun, or a Bank Holiday Monday for example, I don't want the program to run. Hence why I am wondering if there a means of identifying whether it's a weekend or a Bank Holiday so that we can ensure the program doesn't run??
 
You can use the CEEDYWK api to return the day of the week, 1=Sunday 7=Saturday. However this won't help with bank holidays. The solution I used a number of years ago was to simply create a program where an user could enter bank holidays, factory shutdowns, weekends etc into a file which other programs then interrogate to check if they should run or to help calculate number of working days between two dates.

Hope this helps

[2thumbsup] --------------------------------
If it ain't broke, don't fix it!
 
Hi madhouse

We have a similar system to gpzcrasher - a calendar file keyed on year/month/day. For each date, it indicates whether it's a working day or not, has a julian equivalent, and a day number to allow date calculations to be performed.

 
If you're using a CLP, try rtvsysval sysval(QDayofWeek) RtnVar(&DayofWeek) .

This will retrieve the day of the week (*MON, *TUE, *WED, *THU, *FRI, *SAT, *SUN)

Then you can have your job end if &DayOfWeek = *SAT or *SUN.

In addition, is you're submitting your job using the job scheduler (wrkjobscde), you can tell it to not run on certain dates (like your bank holidays). The draw back here is you have to hard code the actual dates to this parm.
The parm is called OMITDATE


RedMage1967
IBM Certified - RPG IV Programmer
 
I would say your best solution is what gpzcrasher said. There are formulas to determine holidays like easter, but i think the best bet is hard-code or the file. iSeriesCodePoet
IBM iSeries (AS/400) Programmer
[pc2]
Want to have all your bookmarks in one spot?
 
You could schedule the job with the built-in job scheduler (ADDJOBSCDE). You can omit the weekends specifically with that command, for example, if you have a job that runs Monday through Friday at 4:00 AM, you can use the following command; it's not really necessary to programatically exclude weekends. The command to add that entry would be:

[tt]ADDJOBSCDE JOB(job_name)+
CMD(CALL PGM(program_name)) +
FRQ(*WEEKLY) +
SCDDATE(*NONE) +
SCDDAY(*MON *TUE *WED *THU *FRI) +
SCDTIME('04:00:00') +
RELDAYMON(*SAME) +
OMITDATE(*NONE) +
RCYACN(*SBMRLS)
JOBD(library/job_desc)
JOBQ(library/job_queue)
USER(user_profile)
MSGQ(*USRPRF)[/tt]


Write a maintenance program which your users can run periodically to put in the bank holidays. First, execute the CHGJOBSCDE command with OMITDATE(*NONE) to clear out the previous holidays, then you can have them input up to 20 dates to omit for the coming year (you can have them prompt the command directly, and exclude the other parameters in the command). See the following link about selective prompting for CL commands:


Or you could have the bank holiday file which you can maintain, and have another scheduled job which updates the job schedule entry for this sheduled job from the bank holiday file (it could take the 20 highest value dates which have not already occured and run the CHGJOBSCDE with the OMITDATE parameter command for you).
"Don't worry about the world coming to an end today. It's already tomorrow in Australia."
--Charles Schultz
 
Isn't it amazing how powerful the standard job scheduler is?

All of OS/400 is extremely powerful, if you're willing to do a little digging in IBM's AS/400 Infocenter. In my 10 years on this platform, I've found that there's always something new out there that I never knew about before. "Don't worry about the world coming to an end today. It's already tomorrow in Australia."
--Charles Schultz

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top