CreatePlanningForecasts

MRP, Write Planning Forecasts

Major Business Rule

Object Name: B3400410

Parent DLL: CMFG

Location: Client/Server

Language: C

1.Functional Description
This business function will generate the Component requirements using the Bill of Materials and the 

requirements for the Parent.  Then it will write the requirements to the Forecast table F3460.  It will 

also update the Summary Records in the forecast table.  This function is used in MPS generation in 

MRP Planning.


1.1Purpose

This function is used to write Forecasts for Components based on the Planning Bill based on the 

Parent Forecast Requirements.


1.2Setup Notes and Prerequisites

The following activities must be done, before the function is invoked.

1.  The Parent Item F4101 data and the F4102 data must be obtained before invoking the function.


1.3Special Logic

None


2.Technical Specifications

The following actions have to be performed by the Business Function.

1.Open Tables and Initialize Data

Open F4101, F4102, F3002, and F3460 tables

If Error in Opening the Tables, Exit the function with an Error code = '1'

Create the following Arrays an Initialize them

@DT[$PND] - Date Array

@IT[$PND] - Forecast Requirements

Wk Index $X = 0

Call B3401270 with Action Code = '1' and input MCU to retrieve the first cache element 

from the 

Bucketless Date Cache matching the key
Do While not EOF
If $X > $PND

Break

Endif

$X = $X + 1 

@DT[$X] = the Date from the cache record

Call B3401270 with Action Code = '6' and input MCU to get the next Date cache 

element

EndWhile

Call B3401290 with Action Code = '1', input MCU, and Quantity Type = 'FQ' to retrieve the 

first cache 

element from the Item Quantity Cache matching the key
$X = 1

Do While not EOF

While the Date from cache record <> @DT[$X]

$X = $X + 1

EndWhile

@IT[$X] = -1 * the Quantity from the cache record

Call B3401290 with Action Code = '6', input MCU, and 'FQ' to get the next Item 

Qty cache element

EndWhile


2. Load the Sales Order Data in the Arrays

Wk First Time = ' '

Wk Exit flag = ' '.

Wk Exit flag 1 = ' '.

Do While Exit flag  <> '1'

Read F3002 Sequentially using Input KIT, MMCU, COBY (= ' ' ), TBM (= 'M') and 

BQTY (= 0)

If not found

Break and Exit the Business function.

Endif

Wk Year = 0.

Summary Qty = 0

If Wk First Time = ' '

Wk First Time = '1'

Wk Conv Factor = 1

If IXUOM <> SVUOM1 or SVOT1Y = 'Y'

Get Wk Conv Factor using B4000520 with IXUOM and Input SVUOM, 

IXMMCU, SVOT1Y,

SVSTDP, LOTN = ' '
Endif

Endif

Read F4101 using IXITM as key.

Read F4102 using IXITM and IXCMCU as keys

If F4101 or F4102 not found

Continue

Endif

Wk Conv Factor 1 = 1

If  IXUM <> IMUOM1 or IBOT1Y = 'Y'

Get Wk Conv Factor 1 using B4000520 with IXUM and IMUOM1, IXCMCU, 

IBOT1Y, IBSTDP,

LOTN = ' '
Endif

For $X = 1 to Input $$PND Do

If @IT[$X] = 0

Continue

Endif

If SVMRPP = 'F'

Wk Lead Time = SVLTLV

  Endif

If SVMRPP = 'V'

Wk Lead time = SVLTPU * @IT,$X 

If Input SVRATE <> 0

Wk Lead Time = Wk Lead Time/SVRATE

Endif

Wk Lead time = Wk Lead Time + SVSETL + SVQUED

If Input Work Hours > 0

Wk Lead Time = Ceiling(Wk Lead Time/ Input Work Hours, 0)

Endif

If $SVSTK <> '0'

If SVSTKT = P and PO $$PSLT <> 0
Wk Lead Time = Wk Lead Time + PO $$PSLT

Endif

If SVSTKT = M and PO $$MSLT <> 0
Wk Lead Time = Wk Lead Time + PO $$MSLT

Endif

EndIf

EndIf

Endif

If Wk Lead Time = 0

MFDRQJ = @DT[$X]

Else

Call B3400540 to Back Schedule flag = 'B'/Wk Lead Time/@DT[$X] 

and Calculate MFDRQJ

Input F3411 UKID = B3400540 F3411 UKID

Input Date Error Flag = B3400540 Date Error Flag

Endif

If MFDRQJ < IXEFFF or MFDRQJ > IXEFFT or IXQNTY = 0

Continue

Endif

Save Lead Time = Wk Lead Time

Wk Lead Time = IXLOVD

If IXLOVD <> 0

If IXLOVD < 0

Wk Lead Time = Wk Lead Time * (-1)

Back Schedule flag = 'B'

Else

Back Schedule flag = 'F'

Endif

Ceiling (Wk Lead Time, 0)

If Back Schedule Flag = 'F' and Wk Lead Time > Save Lead Time

Wk Lead Time = Save Lead Time

EndIf

Call B3400540 with Back Schedule flag/Wk Lead Time/MFDRQJ and 

Calculate MFDRQJ

Input F3411 UKID = B3400540 F3411 UKID

Input Date Error Flag = B3400540 Date Error Flag

Endif

If IXFORQ = '%' or 'F'

Wk Quantity = IXQNTY * Wk Conv Factor 1* IXFTRP/100

If IXFORQ = '%'

Wk Quantity = Wk Quantity/100

Endif

Else

Wk Quantity = -1 * IXQNTY * Wk Conv Factor 1 * IXFTRP/100 * 

@IT[$X] /Wk Conv Factor

Endif

If IMSNS = 'R'

Ceiling(Wk Quantity, 0)

EndIf

If Wk Quantity > 0

Write/Update F3460 with MFITM( IXITM), MFMCU(IXCMCU), 

MFTYPF($$MTYF), MFDCTO("FR"), MFPID($$PID), MFFQT, MFUORG(Wk Quantity), 

MFLITM(IMLITM),MFAITM(IMAITM) and MFYR (0)

Summary Qty = Summary Qty + Wk Quantity

Endif

If  Year in MFDRQJ <> Wk Year

Summary Qty = Summary Qty  - Wk Quantity

If Summary Qty > 0

If Wk Year = 0
Wk Year = Year in MFDRQJ

Endif

Write/Update  F3460 using with MFYR(Wk Year), MFITM( 

IXITM),MFMCU(IXCMCU),MFTYPF($$MTYF), MFDCTO("FR"), MFPID($$PID) MFFQT,MFUORG(Summary Qty),MFLITM(IMLITM), 

MFAITM(IMAITM)

Endif

Wk Year = Year in MFDRQJ

Summary Qty = Wk Quantity

Endif

EndDo

If Summary Qty > 0

Write/Update F3460 using with MFYR(Wk Year), MFITM( IXITM), 

MFMCU(IXCMCU), MFTYPF($$MTYF), MFDCTO("FR"), MFPID($$PID) MFFQT,MFUORG(Summary 

Qty),MFLITM(IMLITM), MFAITM(IMAITM)

Endif

  Enddo


3 Close all Tables and Release the Memory 

Close all Tables and Deallocate memory for Arrays

Exit the function with Error Code = 0


Data Structure

D3400410 - MRP, Write Planning Forecasts

Parameter NameData ItemData TypeReq/OptI/O/Both
mnParentItemNumberKITMATH_NUMERICNONENONE

The system provides for three separate item numbers.    1.   Item Number (short) - An eight-digit, computer assigned, completely 
non-significant item number.    2.   2nd Item Number - The 25-digit, free form, user defined alphanumeric item number.    3.   3rd Item Number - Another 
25-digit, free form, user defined alphanumeric item number.

szParentBranchMMCUcharNONENONE

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.

nElementsInDateArrayINT01integerNONENONE

Number of Days in Future to Query for Responses Due. 

szParentPrimaryUOMUOM1charNONENONE

A user defined code (00/UM) that identifies the unit of measure that the system uses to express the quantity of an item, for example, EA 
(each) or KG (kilogram).

cLeadTimeTypeMRPPcharNONENONE

A code that determines whether the system uses fixed or variable leadtimes. This code works in conjunction with the value from either the 
Level Leadtime field or the Leadtime Per Unit field. Valid codes are:    F Fixed leadtime - The system calculates work order start dates using the 
value from the Leadtime Level field.    V Variable leadtime - The system calculates work order start dates using the value from the Leadtime 
Per Unit field.

mnLeadTimeLevelLTLVMATH_NUMERICNONENONE

A value that represents the leadtime for an item at its assigned level in the production process, as defined on Plant Manufacturing Data. 
The system uses this value to calculate the start dates for work orders using fixed leadtimes. Level leadtime is different for purchased and 
manufactured items: Purchased - The number of calendar days required for the item to arrive at your branch/plant after the supplier receives your 
purchase order. Manufactured - The number of workdays required to complete the fabrication or assembly of an item after all the 
components are available. You can enter level leadtime manually on Manufacturing Values Entry, or you can use the Leadtime Rollup program to 
calculate it. To calculate level leadtime using the Leadtime Rollup program, you must first enter a quantity in the Manufacturing Leadtime Quantity 
field in the Item Branch table (F4102).

mnLeadTimePerUnitLTPUMATH_NUMERICNONENONE

The total number of hours required to build one unit as specified on the routing. This value is factored by the time basis code. You can enter 
this value manually or you can have the system calculate it when you run the Leadtime Rollup program. The system overwrites this value 
when you run the Leadtime Rollup program. The system uses this field to calculate start dates for work orders when you use variable leadtimes.

cParentStockingTypeSTKTcharNONENONE

A user defined code (41/I) that indicates how you stock an item, for example, as finished goods or as raw materials. The following stocking 
types are hard-coded and you should not change them:    0   Phantom item    B Bulk floor stock    C Configured item    E Emergency/corrective 
maintenance    F Feature    K Kit parent item    N Nonstock  The first character of Description 2 in the user defined code table indicates if the item 
is purchased (P) or manufactured (M).

mnParentSetupLaborSETLMATH_NUMERICNONENONE

The standard setup hours that you expect to incur in the normal completion of this item. This value is not affected by crew size.

mnParentQueueTimeQUEDMATH_NUMERICNONENONE

The total hours that an order is expected to be in queue at work centers and moving between work centers. The system stores this value in 
the Item Branch table (F4102). You can calculate this value using the Leadtime Rollup program or you can enter it manually. When you run the 
Leadtime Rollup program, the system overrides manual entries and populates the table with calculated values.

mnParentTimeBasisRateMATH01MATH_NUMERICNONENONE

- - - Good Performance Low Value. 

nMfgSafetyLeadTimeINT02integerNONENONE

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

nPurchSafetyLeadTimeINT03integerNONENONE

Event point for Integer.

szForecastTypeTYPFcharNONENONE

A user defined code (34/DF) that indicates one of the following:     o The forecasting method used to calculate the numbers displayed about 
the item     o The actual historical information about the item 

szProgramIDPIDcharNONENONE

The number that identifies the batch or interactive program (batch or interactive object). For example, the number of the Sales Order Entry 
interactive program is P4210, and the number of the Print Invoices batch process report is R42565. The program ID is a variable length value. 
It is assigned according to a structured syntax in the form TSSXXX, where: T The first character of the number is alphabetic and identifies the 
type, such as P for Program, R for Report, and so on. For example, the value P in the number P4210 indicates that the object is a 
program. SS The second and third characters of the number are numeric and identify the system code. For example, the value 42 in the number P4210 
indicates that this program belongs to system 42, which is the Sales Order Processing system. XXX The remaining characters of the numer are 
numeric and identify a unique program or report. For example, the value 10 in the number P4210 indicates that this is the Sales Order Entry 
program.

cSuppressErrorMessageEV01charNONENONE

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

cErrorCodeERRCcharNONENONE

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).

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.

cDateErrorFlagEV01charNONENONE

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

szDateErrorMsgDescDSC1charNONENONE

Brief information about an item; a remark or an explanation.

mnF3411UniqueIDUKIDMATH_NUMERICNONENONE

This field is a unique number used to identify a record in a file.

mnWorkHoursWRHRMATH_NUMERICNONENONE

The number of work hours that the manufacturing plant operates per day.

szStandardUOMConversionTFLAcharNONENONE

Allows you to bypass the item-specific unit of measure and use the standard unit of measure. Valid values are:    blank Use the item-specific 
unit of measure    1       Bypass the item-specific unit of measure and use the standard unit of measure

mnStandardPotencySTDPMATH_NUMERICNONENONE

The percentage of active ingredients normally found in an item.

cPotencyControlOT1YcharNONENONE

A code that indicates whether you control the item by potency.

szJobNumberJOBcharNONENONE

Job Number

cActualStockingTypeSTKTcharNONENONE

A user defined code (41/I) that indicates how you stock an item, for example, as finished goods or as raw materials. The following stocking 
types are hard-coded and you should not change them:    0   Phantom item    B Bulk floor stock    C Configured item    E Emergency/corrective 
maintenance    F Feature    K Kit parent item    N Nonstock  The first character of Description 2 in the user defined code table indicates if the item 
is purchased (P) or manufactured (M).

mnUniqueKeyIDOffsetMATH01MATH_NUMERICOPTNONE

- - - Good Performance Low Value. 

Related Functions

B3400540 MRP, Calculate Schedule Dates for Planning
B3401270 Cache, Process MRP Bucketless Dates
B3401290 Cache, Process MRP Item Quantities
B4000520 Get Item UoM Conversion Factor
B9800100 Get Audit Information

Related Tables

F3002 Bill of Material Master File
F3460 Forecast File
F4101 Item Master
F4102 Item Branch File