CacheCreateSpreadDates

Create Spread Dates

Major Business Rule

Object Name: B3101640

Parent DLL: CMFGBASE

Location: Client/Server

Language: C

Functional Description

Purpose

This function will validate the date range by checking the start and requested dates.  If the range 

is valid, the correct Work Day calendar will be chosen and a cache will be created for every valid work 

day within the range.  Calling functions can then loop through the cache records retrieving the work 

days.


Setup Notes and Prerequisites

Data Item Data Structure DescI/ORequiredNotes

JOBSJob NumberI/ONJob Number as string for cache name.  

Job number from the calling function can be 

sent in 

to eliminate duplicate call, but it is not 

necessary.

  Returned value is used by the calling function 

to 

retrieve records from the Date Spread Cache.

EV01SuppressErrorMessagesIN1 - Error Messages Suppressed

ERRCError CodeON'0' = No Errors '1`'= Warnings '2' = Error

DTAIErrorMessageIDONDD ID number to error Code

EV02Data Dictionary EditsIN'1' - Data Dictionary Validation will be 

performed.  

Set to '1' only if calling the function through 


third party software

SESDScheduled Start DateIYStart and Requested Dates define the range

DRQJRequested DateIY   "      "      "        "     "    "    "

MWDHPeriod IYUsed to determine the spread

SHFTShiftIYUsed to retrieve the Work Calendar

MMCUBranch/PlantIYUsed to retrieve the Work Center Data

DOCODocument NumberIYCache Key value

INT01Number Of Cache RecordsONumber of Dates added to the cache

EV01Process EditsIY'0' = No Editing 

'1' = Full Edits - writes records to cache 

'2' = Partial Edits - validates the date range 

only


Special Logic

This function creates a unique cache for each Parts List process.  The function appends the input Job 

Number string to the function name 'B3101640-' to build the cache name used for the calling 

application.


Technical Specification

NOTE: Calendar Array is defined as a 2 X 31 array.  The 2 columns are necessary when the period = Week and the spread is over 2 months.  The 

Work Day calendar must be fetched for both months.


Initialize the Cache

/******* Validate that the Start Date and Requested Date create a valid date range **********/

If the DD Validation Flag = '1'

Call DD Validation API for SESD and DRQJ

End If

If the Start Date < Requested Date 

Set Error and Return

End If

If the input Period = '1' (Month) 

If the Start Date Month does not = Requested Date Month

Set Error - Date Range not valid

End If 

Else if the input Period = '2' (Week)

If the Requested Date - Start Date > 7 days

Set Error - Date Range not valid

Else

/* Work Week defined as Sunday to Monday */

Get Day of the Week Offset for the Start Date

Get Day of the Week Offset for the Requested Date

If the Start Date Offset > Requested Date Offset

Set Error 

End If

End If

Else if the input Period = '3' (Day)

If the Start Date does not equal the Requested Date 

Set Error

End If

Else if the input Period = ' '

Work Order - no edits

Else

Set Error on invalid Period

End If

If valid Date Range and Input Process Edits = Full Edits

Call N3101670 to determine which calendar to use

Open F0007 and retrieve record using the keys determined by N3101670

If successful

Load Calendar Date values into the Calendar Array  

Calendar Array [0][0] = F0007 CZDT01

Calendar Array [0][1] = F0007 CZDT02

.

.

.

Calendar Array [30] = F0007 CZDT31

If Period = '2' Week and Start Date Month does not = Requested Date Month

Retrieve the Work Day calendar using the Requested Date

Load Calendar Date values into the Calendar Array  

Calendar Array [1][0] = F0007 CZDT01

Calendar Array [1][1] = F0007 CZDT02

.

.
.
Calendar Array [30] = F0007 CZDT31

Set Work Two Calendars Field = '1'

Calendar Index = Start Date Day

Work Date = Start Date 

If Work Two Calendars Field = '1'

/* Process the 1st  Calendar */

While the Calendar Index <= 31

If Calendar Array [0][Calendar Index] = 'W'
Add Work Date to Cache

End If

Increment the Work Date by 1

Increment the Calendar Index by 1
End While

/* Process the 2nd Calendar */

Calendar Index = 0

While the Calendar Index <= Requested Date Day

If Calendar Array [1][Calendar Index] = 'W'
Add Work Date to Cache

End If

Increment the Work Date by 1
Increment the Calendar Index by 1

End While

While the Calendar Index is less than or equal to Requested Date Day 

       and the Calendar Index <= 31
If Calendar Array [0][Calendar Index] = 'W'

Add Work Date to Cache

End If

Increment the Work Date by 1

Increment the Calendar Index by 1

End While

End If

End If




Data Structure

D3101640B - Cache, Spread Dates

Parameter NameData ItemData TypeReq/OptI/O/Both
mnJobNumberJOBSMATH_NUMERICREQINPUT

The job number must be retrieved prior to calling this function.  Job Number is retrieved in Create 
Spread Dates and this is the parameter that needs to be sent in to this function.

^

cCacheActionCodeEV01charOPTNONE

1 - Get Cache Record
2 - Add Cache Record

3 - Update Cache Record

4 - Delete Cache Record

5 - Delete ALL Cache Records

6 - Get Next Cache Record 

7 - Add/Update Cache Record

8 - End Cache (Terminate Cache)

9 - Close Cursor and Free Data Pointer


^

nNumberOfCacheKeysINT01integerOPTNONE

Number of Days in Future to Query for Responses Due. 

cSuppressErrorMessageSUPPScharOPTNONE

1 - Suppress Runtime Error Handling
Default - Do not suppress Runtime Error Handling

^

szErrorMessageIDDTAIcharOPTNONE

A code that identifies and defines a unit of information. It is an alphanumeric code up to 8 characters long that does not allow blanks or 
special characters such as %, &, or +. You create new data items using system codes 55-59. You cannot change the alias.

idCacheCursorPtrGENLNGIDOPTNONE

Required Input/Output for sequential fetches
^

cSequentialFetchEV02charOPTNONE

If action is Get and this is '1', function will pass back cursor pointer for Get Next operation.
^

mnDocumentNumberDOCOMATH_NUMERICOPTNONE

Key Element to cache record
^

jdWorkDateDRQJJDEDATEOPTNONE

Output
^

cCacheErrorCodeEV03charOPTNONE

A radio button that specifies the level at which trace/track result is to be displayed.  Select the Detail to display all transactions except IB, IX, 
and IZ types.  Or, select Derivative Lots Only to display only those transactions that may have created new derivative lot. 

Related Functions

None

Related Tables

None
CreateSpreadDates

CreateSpreadDates

Create Spread Dates

Major Business Rule

Object Name: B3101640

Parent DLL: CMFGBASE

Location: Client/Server

Language: C

Functional Description

Purpose

This function will allow external calls to perform all Ito the Date Cache.


Setup Notes and Prerequisites

Cache Action Codes

• '1' Get - retrieve the cache element.
• '2' Add - add a cache element.
• '3' Update - update a cache element.
• '4' Delete - delete a cache element.
• '5' Delete All - delete all cache elements
• '6' Get Next - retrieve the next cache element
• '7' Add/Update - will add if element does not exist, will change if it does exist.
• '8' Terminate - terminate cache
• '9' Release Cursor - close the input cursor
• Number of Keys 
• If the number of keys is passed as a parameter, the business function uses this value to setup key 
values for a Get, Update, Delete, Get Next, and Add/Update.

• A zero may be passed to retrieve, update, or delete the first record.
• 'b7When action code GET is used, the function saves the cache cursor pointer if the fetch is 
successful and SequentialFetch = '1'.  This allows the calling application to use GET NEXT to fetch 

elements from the cache sequentially.  If GET NEXT is called until the end of the keyed cache dataset is 

found, the function automatically closes the open cursor.  Otherwise, the calling application is 

responsible for closing the cursor using action code '9'.


Data Item DS DescI/OReq'dNotes

JOBSJob NumberIYJob Number as string for cache name

EV01Cache Action CodeIY'1' = Get cache element

'2' = Add element 

'3' = Update element

'4' = Delete cache elements

'5' = Delete All cache elements

'6' = Get Next cache element

'7'  = Add/Update cache element

'8' = End cache (terminate cache)

'9' = Close Cursor and Free Data Ptr 

EV01Cache Error CodeON'0' = Success Process

'1' = Reached End of Cache(mode 6)

'2' = Invalid Input Parameter

'3' = Failed to Create Cache

'4' = Failed to Add/Update Cache

'5' = Failed to Delete Cache

'6' = Fetch Failed(mode 1 or 9)

INT01Number of KeysIY# of Keys to be used in the cache

SUPPSSuppress Error MessageIN'0'=allow runtime error handling.

'1' = Suppress runtime error handling.

DTAIError Message IdON"   " = Success

"032E" = Error Processing Cache

GENLNGCache Cursor PtrI/ONMust be sent in for sequential fetches

EV02Sequential FetchINIf action is GET and this parm is '1',

 function will pass back cursor pointer

 for GET NEXT operation.

DOCODocument NumberIYKey value to the cache

DRQJWork DateO


Special Logic

This function creates a unique cache for each Parts List process.  The function appends the input Job 

Number string to the function name 'B3101640-' to build the cache name used for the calling 

application.


Technical Specification

I.Perform setup functions 

A.Initialize cache to get handle.
B.If not successful, set error "032E", set Cache Error Code = '3', and return failure.

C.Validate input parameters Number Of Keys, Action Code, and Comparison Flag.

D.If not valid, set error "032E", set Cache Error Code = '2', and return failure.

E.Set Cache Error Code = '0'

F.Set return code to success.


II.Processing Based on Mode.


A.If Cache Action Code is '1' - GET:
1.Open cursor.  If the input Cursor Pointer is not NULL, retrieve the existing cursor and reset it.
2.Retrieve the first element on the cache matching the key values passed as input.  If the input Number of Keys is zero, fetch the first element in 

the cache.

3.Load the values from the retrieved element into the data structure to be passed back to the calling program.

4.If SequentialFetch = '1', return cursor pointer to calling application.  Otherwise, close the cursor.

5.If get fails set Cache Error Code = '6'.


B.If Cache Action Code is '2' - ADD:
1.Insert a new cache element with values from data structure.
2.If add fails set error "032E", set Cache Error Code = '4', and return failure.


C.If Cache Action Code is '3' - UPDATE:
1.Update existing cache element with values from data structure.
2.If update fails set error "032E", set Cache Error Code = '4', and return failure.


D.If Cache Action Code is '4' - DELETE:
1.If the Number of Keys is not 0, delete all elements in the cache matching the key values passed as input.
2.If the number of keys is 0, delete the first cache element.

3.If delete fails, set Cache Error Code = '5'.


E.If Cache Action Code is '5' - DELETE ALL:
1.Delete all elements in the cache.
2.If delete fails, set Cache Error Code = '5'.


F.If Cache Action Code is '6' - GET NEXT:
1.Using the input cursor pointer from the previous GET action, retrieve the next element in the cache matching the key values passed 
as input (the cursor should have been set through a previous "Get" action, i.e. action code '1'.  If the Number of Keys is zero then fetch 

the next record without using any key).

2.Load the values from the retrieved element into the data structure to be passed back to the calling program.

3.If there are no more elements, close the cursor and set Cache Error Code = '1'.


G.If Cache Action Code is '7' - ADD/UPDATE:
1.Delete Record , if one exists,  that matches the full key from Input.
2.Insert a new cache element with values from data structure.

3.If add fails set error "032E", set Cache Error Code = '4', and return failure.


H.If Cache Action Code is '8' - END
1.If the input CacheCursorPtr is not zero, retrieve the pointer and close the cursor.
2.Perform cleanup functions (Terminate cache).


I.If Cache Action Code is '9' - CLOSE CURSOR:
1.Retrieve the Data Ptr (Cache Cursor Ptr must not be Zero).
2.Close cursor.

3.Free Data Ptr and Set Cache Cursor Ptr to 0.


J.If Cache Action Code is 'N' - GET NEAREST:
1.Open cursor.
2.Retrieve the first element in the cache matching the key values passed as input.  The input Number of Keys must be 2.

3.If successful, load the values from the retrieved element into the data structure to be passed back to the calling program and return success.

4.If not successful, Reset cursor.

5.Using just the input Branch as the key, search for the cache element with the desired date based on the input Direction Flag:

'B' = retrieve the cache element occurring just before the input Date
'A' = retrieve the cache element occurring just after the input Date

6.Load the values from the retrieved element into the data structure to be passed back to the calling program.
If get fails set Cache Error Code = '6'.



Data Structure

D3101640A - Create Spread Dates

Parameter NameData ItemData TypeReq/OptI/O/Both
mnJobNumberJOBSMATH_NUMERICOPTNONE

The job number (work station ID) which executed the particular job.

cSuppressErrorMessagesEV01charOPTNONE

An option that specifies the type of processing for an event.

cErrorCodeERRCcharOPTNONE

This error code indicates if any errors occurred during the creation of the Trip Document Detail (F4914) records by the Delivery Document 
Set Server program (XT4914).

szErrorMessageIDDTAIcharOPTNONE

A code that identifies and defines a unit of information. It is an alphanumeric code up to 8 characters long that does not allow blanks or 
special characters such as %, &, or +. You create new data items using system codes 55-59. You cannot change the alias.

cDataDictionaryEditsEV02charOPTNONE

An option that specifies the type of processing for an event.

jdScheduledStartDateSESDJDEDATEOPTNONE

The calendar date that an operation or rate is scheduled to begin.

jdRequestedDateDRQJJDEDATEOPTNONE

The date that an item is scheduled to arrive or that an action is scheduled for completion.

cPeriodMWDHcharOPTNONE

A code that determines the frequency of the schedule. Valid values are:    1   Monthly    2   Weekly    3   Daily    4   Per Shift (for future use)

cShiftCodeSHFTcharOPTNONE

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.

szBranchPlantMMCUcharOPTNONE

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.

mnDocumentNumberDOCOMATH_NUMERICOPTNONE

A number that identifies an original document. This document can be a voucher, a sales order, an invoice, unapplied cash, a journal entry, 
and so on.

nNumberOfCacheRecordsINT01integerOPTNONE

Number of Days in Future to Query for Responses Due. 

cProcessEditsEV01charOPTNONE

An option that specifies the type of processing for an event.

szWorkDayCalendarTypeWDCTcharOPTNONE

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.

szWorkDayCalendarKeyWDCKcharOPTNONE

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

None