AdvanceWorkDays

Advance Work Days

Minor Business Rule

Object Name: B0000150

Parent DLL: CALLBSFN

Location: Client/Server

Language: C

Functional Description

Purpose

This function is used to retrieve the next or previous working day from a given day, or a specific 

date based on a given date and a number of workdays to add to the given date. The function uses the 

calendar and the workday rule specified by the user to calculate the appropriate date that should be 

returned. 


Setup Notes and Prerequisites

The value of the calendar to use (MMCU) parameter must be passed to this function. A valid initial 

date (DATE01) must also be passed (this is the date the calculations are based on), along with the 

workday rule (WKDY) to be used. If the workday rule is equal to '1' then the number of days to add (DADD) 

to the initial date must also be passed.


Special Logic

If the workday rule is equal to '1' (Working Days), the function will use the calendar and the 

initial date to advance as many working days as the mnDaysToAdd variable indicates. If the workday rule is 

equal to '2' (Actual Days, Next Work Day), the function will use the calendar and the initial date to 

advance to the next workday. If the workday rule is equal to '3' (Actual Days, Previous Work Day), the 

function will use the calendar and the initial date to advance to the previous workday.



Technical Specification


Parameters

Item DescriptionI/OReq?Notes
MMCUszCalendarToUseIYThe calendar to use.
DATE01jdDateI/OYThe date that calculations should be based on.

WKDYcWorkDayRuleIYThe workday rule. Valid values are '1' for 'Working 

Days', '2' for 'Actual Days, Next Work Day', and '3' for 'Actual Days, Previous Work Day'.

DADDmnDaysToAddINRequired only if the workday rule is equal to '1'.


Related Tables

F0007Work Day Calendar


Related Functions

None.


Processing

Perform Initializations.

If (WorkDayRule is not equal to ),

Open table F0007.

If open table F0007 call failed,

Set error.

Else,

Retrieve calendar information.

If retrieval was successful,

If (WorkDayRule is equal to '1'),

Execute ActualDays.

Else If (WorkDayRule is equal to '2'),

Execute GoForward.

Else,

Execute GoBackwards.

Endif.

Else,

Set error.

Endif.

Endif.

Endif.

Perform function cleanup.


ActualDays

Perform Initializations.

While (Not finished adding days),

Fetch next day.

If next day is a workday,

Subtract a day from remaining days to add.

Endif.

End While.


GoForward

Perform Initializations.

While (NextDay is not a workday),

Fetch NextDay.

End While.


GoBackwards

Perform Initializations.

While (PreviousDay is not a workday),

Fetch PreviousDay.

End While.



Data Structure

D0000150 - Advance Work Days

Parameter NameData ItemData TypeReq/OptI/O/Both
szCalendarToUseMMCUcharNONEINPUT

A code that represents a high-level business unit. Use this code to refer to a branch or plant that might have departments or jobs, which 
represent lower-level business units, subordinate to it. For example:     o Branch/Plant (MMCU)     o Dept A (MCU)     o Dept B (MCU)     o Job 123 
(MCU) Business unit security is based on the higher-level business unit.

jdDateDATE01JDEDATENONEBOTH

Event point for JDE Date.

cWorkDayRuleWKDYcharNONEINPUT

A code that specifies whether to include nonworking days in the due date calculation and whether to change the due date if it is on a 
nonworking day. Valid values are: Blank Use the due date that the system calculates regardless of whether it is a nonworking day. 1 Do not include 
nonworking days in the due date calculation. For example, if the system adds 15 days to the invoice date to calculate the due date, and 
weekend days are specified as nonworking days, the system does not count them when it adds the 15 days. Therefore, if the invoice date is 6/01/05, 
which is a Wednesday, the system calculates the due date on 6/22/05. 2 Include nonworking days in the due date calculation, but if the due 
date is on a nonworking day, move it forward to the next working day. 3 Include nonworking days in the due date calculation, but if the due date 
is on a nonworking day, move it back to the previous working day. Note: The system considers any value entered in the calendar other than 
W to be nonworking.

mnDaysToAddDADDMATH_NUMERICNONEINPUT

The number of days that the system adds to or subtracts from, if you specify negative days, the date specified in the Based on Date field 
(DABS) to calculate the discount due date or net due date on the invoice or voucher.

cShiftCodeSHFTcharOPTINPUT

A user defined code (00/SH) that identifies daily work shifts. In payroll systems, you can use a shift code to add a percentage or amount to 
the hourly rate on a timecard. For payroll and time entry: If an employee always works a shift for which a shift rate differential is applicable, 
enter that shift code on the employee's master record. When you enter the shift on the employee's master record, you do not need to enter the 
code on the timecard when you enter time. If an employee occasionally works a different shift, you enter the shift code on each applicable 
timecard to override the default value.

szWorkDayCalendarTypeWDCTcharOPTINPUT

A user defined code (42/WD) that specifies how the calendar is used. For example, the calendar might be specific to an industry such as 
banking or it might be used to schedule delivery persons for a route.  Note: If you use the default value of *, the system updates the value to 
blank even though blank is not set up as a valid value in the UDC table.

szWorkDayCalendarKeyWDCKcharOPTINPUT

A code used to classify values within a calendar type. For example, if the calendar type is ROUTE, you can enter a code that specifies a 
particular route, such as Daily or Weekend.  Note: The system does not validate the code that you enter. 

Related Functions

None

Related Tables

F0007 Workday Calendar