Top
Systemwalker Operation Manager  Reference Guide
FUJITSU Software

16.1.4 Calendar Update API (Mp_SetCalendar3)

This section explains the calendar update API (Mp_SetCalendar3).

Synopsis

int Mp_SetCalendar3 (char *APL_name,
              char *cal_name,
              CALENDAR_WDAT3 *cal_dat3) ;

Description

The Mp_SetCalendar3 function updates the calendar information (if the specified calendar does not exist, it is handled as a calendar to be registered) and holidays and substitute holidays for which the date changes from year to year. Update start date applied to job nets can also be updated.

The SYSTEM_CALENDAR cannot be updated.

If update start date is omitted, update will be applied to all dates.

Past dates cannot be set.

Parameters

APL_name

Specify the storage area address for the requested source application name (64 bytes or less).

Specify NULL at the end of the requested source application name. Do not use names that begin with "Mp_" or "_CAL_."

cal_name

Specify the storage area address for the calendar name to be updated. Specify the calendar name with up to 24 bytes and set NULL at the end.

cal_dat3

Specify the address of the calendar update information structure (CALENDAR_WDAT3).

Return Values

Return Value

Meaning

Action

0

Normal termination.

-

-5

SYSTEM_CALENDAR specified.

Specify something other than "SYSTEM_CALENDAR".

-6

Not system administrator (a user in the Administrators group on Windows or a superuser on UNIX).

Execute as a system administrator (a member of the Administrators group or the superuser).

-8

Error in calendar information.

Review the specified calendar information (the calendar update information structure "CALENDAR_WDAT3").

-10

Calendar service/daemon is not running.

Start the calendar service or daemon.

-11

There is not enough memory.

Use one of the following methods to increase the amount of available memory:

  • Close other applications.

  • Add more physical memory.

-15

Unspecifiable character specified in calendar name.

Do not use invalid characters in the calendar name.

Calendar names cannot contain spaces, user-defined characters or any of the following characters:

? \ * " < > | / : , ;

-16

Error in file operation (write error).

Check that there is enough space available on the hard disk and that the hard disk is functioning normally.

-17

Illegal calendar name length.

Calendar names can be no more than 24 bytes long.

Format of Calendar Update Information Structure (CALENDAR_WDAT3)

[32-bit version]

typedef struct CALENDAR_WDAT3_TAG {
 short year ;                      // This year in 4 digits
 short sub_holiday ;               // Specify whether to enable or disable substitute
                                   // holiday
 unsigned char holiday_w[12] ;     // Each year's day of the week information (for 12 
                                   // months)
 unsigned long holiday_d[12] ;     // Each year's date information (for 12 months)
 unsigned char holiday_m[12][6] ;  // Each year's week information (for 12 months x 6 
                                   // weeks)
 short cal_dat[3][12][31] ;        // 3 year's (from year) calendar information
 short start_y ;                   // The year of the update start date in 4 digits
 short start_m ;                   // The month of the update start date (1 to 12)
 short start_d ;                   // The day of the update start date (1 to 31)
}CALENDAR_WDAT3 ;

[64-bit version]

typedef struct CALENDAR_WDAT3_TAG {
 short year ;                      // This year in 4 digits
 short sub_holiday ;               // Specify whether to enable or disable substitute
                                   // holiday
 unsigned char holiday_w[12] ;     // Each year's day of the week information (for 12 
                                   // months)
 unsigned int holiday_d[12] ;     // Each year's date information (for 12 months)
 unsigned char holiday_m[12][6] ;  // Each year's week information (for 12 months x 6 
                                   // weeks)
 short cal_dat[3][12][31] ;        // 3 year's (from year) calendar information
 short start_y ;                   // The year of the update start date in 4 digits
 short start_m ;                   // The month of the update start date (1 to 12)
 short start_d ;                   // The day of the update start date (1 to 31)
}CALENDAR_WDAT3 ;

year

The standard year (first of the 3 years) in the Western calendar is set, with 4 digits, with 3 years calendar information.

sub_holiday

Specify whether or not the substitute holiday is enabled. Specify the following values:

Value

Substitute holiday valid/invalid

0

Invalid

1

Valid

holiday_w

This is the days of the week information for each year (12 month array). Specify the day(s) of the week of every year's holidays. Set the first bit for Sunday, the second for Monday, and the third through seventh bits for Tuesday through Saturday respectively. Of the months specified in the array, the days of the week whose bits are set to ON will be holidays.

holiday_d

This is the date information for each year (12 month array). Specify the date(s) of every year's holidays. From the top, specify the first bit for the first day, the second bit for the second day, and the third through thirty first bits for the third through thirty first days respectively. Every year, of the months specified in the array, the dates whose bits are set to ON will be holidays.

holiday_m

This is the weekly information for each year (an array of 12 months x 6 weeks). Specify the holidays for which the date changes every year. The first array specifies the month (1 to 12), the second array specifies the week number (1 to 5 is first to fifth week, n6 is the last week). Set the first bit for Sunday, the second for Monday, and the third through seventh bits for Tuesday through Saturday respectively. Every year, the days of the week whose bits are set to ON of the week specified in the second array of the month specified in the first array will be holidays.

cal_dat

This is a three-year calendar from the year specified in year. It reflects annual holiday information. Specify the following values:

Value

Calendar information

0

Impossible dates (February 30, etc.)

1

Holiday

2

Working day

start_y

Specify the update start date (from the current year to two years ahead) in 4 digits in western calendar.

Specify 0 when ignoring the update start date.

start_m

Specify the month of the update start date (1 to 12).

Specify 0 when ignoring the update start date.

start_d

Specify the day of the update start date (1 to 31).

Specify 0 when ignoring the update start date.

Program Example

Below is an example program of the calendar update API:

#include <stdio.h>
#include <string.h>
#include <f3crhcap.h>

int main( int argc,char** argv)
{
/*..........variable declaration........ */
           int ret ; 
           int count ;
           CALENDAR_WDAT3 cal_dat3 ; 

           /*..........initialization ..........*/
           memset( &cal_dat3, 0x00, sizeof( CALENDAR_WDAT3) ) ;

           /*..........set calendar information ..........*/
           /*set this year */ 
           cal_dat3.year = 2006 ;

           /*  enable substitute holiday */
           cal_dat3.sub_holiday = 1 ;

           /*setting every Saturday and Sunday as holidays */
           for ( count = 0 ; count < 12 ; count++ ){
                        cal_dat3.holiday_w[count] = (unsigned char)0x82 ;
           }
           /* set the update start date (update is applied from 2006/08/09) */
           cal_dat3.start_y = 2006 ;
           cal_dat3.start_m = 8 ;
           cal_dat3.start_d = 9 ;

           /*update calendar */
           ret = Mp_SetCalendar3( "Test Pro", "calendar_1", &cal_dat3 ) ;

           printf( "ret= %d\n", ret ) ;

           return 0 ;
}