MRPReturnWorkDays

MRP, Return Work Days

Minor Business Rule

Object Name: B3401340

Parent DLL: CMFG

Location: Client/Server

Language: C

1.Functional Description

1.1Purpose

This function will use a secondary date cache to determine work days between two dates - the Input 

DATE01 and the Type 2 date in the D2 cache. This function is used only in the MRP/MPS planning programs 

(P3482 and P3483). 


The calling application is responsible for loading all appropriate key values to the data structure 

and identifying the number of keys to use in retrieval/update processes.


1.2 Setup Notes and Prerequisites
• Function Action Codes
• 

'G' Get - retrieve a cache element matching the keys specified.
• 'R' Return Work Days, build the cache if necessary.
• 'T' Terminate - terminate/destroy cache and its contents.
• 'X' Delete - Delete all records in the cache.
• 'D' Debug Mode - Dumps the contents of the entire cache into a text file.
'b7'b7'b7'b7'b7
• 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.

• A zero may be passed to retrieve the first record.
'b7'b7'b7'b7'b7
1.3Special Logic

This function creates a unique cache for each MRP/MPS planning process.  The function appends the 

input Job Number string to the two character ID 'D2' to build the cache name used for the calling 

application.


2.Technical Specifications

Cache Layout:Cache includes all of the following fields; key fields are noted.


Data Item Data Structure DescriptionKey Field

MCUBranchY

INTType'1' - Normal Work Date 

'2' - First Work Day 

'3' - Smallest Work Day 

in CacheY

DRQJDateY


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 'G' - GET:
1.Open cursor.  
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 get fails set Cache Error Code = '2'.

5.Close cursor


B.If Cache Action Code is 'R' - RETURN Work Days:
1.Open Cursor 
2.Fetch from Cache with Input MCU, and Type = 2. Store date in Wk FirstWD

3.Fetch from Cache with Input MCU, and Type = 3. Store date in Wk SmallestWD.

4.If Input DATE01 < Wk SmallestWD

5.Load Work Days from F0007 starting with month, year of Input DATE01 to Wk FirstWD.

6.Call Internal Routine to Calculate Work Days.

7.Else

8.Call Internal Routine to Calculate Work Days.

9.End If

10.Close cursor

11.Return Work Days to Output Parm Work Days.

INTERNAL ROUTINES:
Calculate Work Days(*WkNumDays)

• 
Fetch from Cache with Input MCU, Type = 1 and Input DATE01.
• If Failed then
• Find first date in the cache >= Input DATE01.
• *WkNumDays++
• While (Date <> Wk FirstWD)
• FetchNext with Input MCU and Type = 1
• If Date <> Wk FirstWD and Fetch Succeeded
• WkNumDays++
• End If
• End While
• Else
• While (Date <> Wk FirstWD)
• FetchNext with Input MCU and Type = 1
• If Date <> Wk FirstWD and Fetch Succeeded
• *Wk NumDays++
• End If
• End While
• End If
'b7'b7'b7'b7'b7


C.If Cache Action Code is 'I' - INSERT
1.Insert the record to the cache.

D.If Cache Action Code is 'T' - TERMINATE:
1.Terminate cache and destroy all contents..

E.If Cache Action Code is 'D' - Debug:
1.Open cursor.
2.Fetch all records in the cache and dump contents to a text file.

Close cursor

Data Structure

D3401340 - MRP, Return Work Days


Data Item Data Structure DescriptionI/ORequiredNotes

JOB            Job Number                        IY      Job Number as string for 

cache name

MCU            Branch                        I/OY      Key value

INT            Type                              I/OY      Key value

DRQJ            Date                              I/OY      Key value

DATE01      Start Date                        I      Required when Action Code 'R'

INT            Work Days                        O      Required when Action Code 'R'

EV01            Action Code                        IY      'G' = Get cache element 

                                                                        'I' = Insert cache record. 

                                                                        'R' = Return work days 

                                                                        'T' = Terminate cache 

                                                                        'D' = Debug Mode

EV01            Error Code                        ON      '0' = Success Process 

                                                                        '1' = Failed to Return Work 

Days(mode 

                                                                        'R' only) 

                                                                        '2' = Fetch Failed(mode 'G' 

only) 

                                                                        '3' = Failed to Create Cache 

                                                                        '4' = Calendar Not Setup

INT01            Number of Keys                  I      Number of Keys to be used in 

the         

                                                                        cache process for action code 

'G'

SUPPS            Suppress Error Message            IN     '0'=allow runtime error 

message 

                                                                        handling. '1' = Suppress 

runtime 

                                                                        error message handling.

DTAI            Error Message Id                  ON      "   " = Success 

                                                                        "032E" = Error Processing 

Cache


^

Parameter NameData ItemData TypeReq/OptI/O/Both
szJobNumberJOBcharNONENONE

Job Number

szBranchMCUcharNONENONE

An alphanumeric code that identifies a separate entity within a business for which you want to track costs. For example, a business unit 
might be a warehouse location, job, project, work center, branch, or plant. You can assign a business unit to a document, entity, or person for 
purposes of responsibility reporting. For example, the system provides reports of open accounts payable and accounts receivable by 
business unit to track equipment by responsible department. Business unit security might prevent you from viewing information about business units 
for which you have no authority.

nTypeINT01integerNONENONE

Number of Days in Future to Query for Responses Due. 

jdDateDRQJJDEDATENONENONE

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

jdStartDateDATE01JDEDATENONENONE

Event point for JDE Date.

nWorkDaysINT02integerNONENONE

Number of Days in the Past to Query for Quote Requests Received. 

cActionCodeEV01charNONENONE

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

cErrorCodeEV01charNONENONE

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

nNumberOfKeysINT03integerNONENONE

Event point for Integer.

cSuppressErrorMessageSUPPScharNONENONE

A flag indicating whether or not runtime error messaging will occur when an error message is issued from a business function.        0 = allow 
runtime error message handling.        1 = suppress runtime error message handling.

szErrorMessageIDDTAIcharNONENONE

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.

Related Functions

None

Related Tables

F0007 Workday Calendar