MRPWriteSalesOrderQtyToCache

MRP, Write Sales Order Qty To Cache

Major Business Rule

Object Name: B3400390

Parent DLL: CMFG

Location: Client/Server

Language: C

1.Functional Description
This business function will read the Sales Order table (F4211) and write Open Quantities to the MRP 
Item Quantity Cache in the primary unit of measure.  Calculate quantities are written to the cache with 

Quantity Type 'SOU' (Sales Order Unadjusted).


1.1Purpose
This function is used to obtain data from the F4211 table for the MRP Planning Program P3482. The 
function will return error codes necessary. Adjustments to order quantities according to time fence rules 

will be performed in the B3400400 BsFn.


1.2Setup Notes and Prerequisites

The MRP Item Quantity Cache must be created using Business Function B3401270.
Note: When this function is called from in $$CONS = '2', it will also write 'SOT' quantities. These 

'SOT' quantities are used in B3400400 to adjust sales orders qtys. They will be used in place of 'SOU' 

quantities in B3400400. 

What are 'SOT' qtys? They are sales order quantities but if the Sales Order has a related order 

number and type, we will search the F3411 table for the related order and use the MMTRQT value from F3411 

as the 'SOT' qty


1.3Special Logic
None

2.Technical Specifications

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

Open tables F4211 and F4108
If Error in Opening the Tables, Exit the function with an Error code = '1'


2. Load the Sales Order Data in the Cache

Switch (Input Number of Past Due Periods $PDUE)

Case 0

If Input Forecast Consumption Flag($$FCP) = '1'

Wk From Date = Input Forecast Beginning Date($$FBDT)

Else

Wk From Date = Input Begin Date ($$BEG)

End If

Select Records from F4211 Using SDITM=Input Item(SVITM), SDMCU=Input 
Branch(SVMCU), and Wk From Date <= SDPDDJ <= Input Thru Date($$ENDD)

Case 1
If Input Forecast Consumption Flag($$FCP) = '1'

Select Records from F4211 Using SDITM=Input Item(SVITM), SDMCU=Input 
Branch(SVMCU), and Input Forecast Beginning Date($$FBDT) <= SDPDDJ <= Input Thru Date($$ENDD) 


Else

Select Records from F4211 Using SDITM=Input Item(SVITM), SDMCU=Input 
Branch(SVMCU) and SDPDDJ <= Input Thru Date ($$ENDD)

End If

Case 2
Select Records from F4211 Using SDITM=Input Item(SVITM), SDMCU=Input 
Branch(SVMCU) and SDPDDJ <= Input Thru Date ($$ENDD)

End Switch

Wk Exit Flag = '0'

If Input Consolidation Branch = " "

Wk Cache Branch = Input Branch

Else

 Wk Cache Branch = Input Consolidation Branch
End If

While Wk Exit flag <> '1'

Fetch the record from F4211

If Fetch Failed

Break

Endif

If SDPDDJ = 0 then 

Continue

End If

Call B3401300 in 'GET' mode to fetch the MRP Inclusion Rule Cache using 
SDDCTO, SDLNTY, and SDNXTR.

If Cache Error Code <> '0' (Record not found)

Continue

EndIf

Wk Quantity = SDUORG - SDQTYT - SDSOCN

If SDUOM <> Input Primary UOM1 Or SDUOM4 <> SDUOM Or Input Potency Control flag 

'Y'

Convert Wk Quantity from SDUOM to Input Primary UOM1 using B4000520.
Endif

If Input Potent Unit <> '1' and Input Potency Control = 'Y'

Get F4108 row using SDITM, SDMCU and SDLOTN as keys.

If Found and Input Standard Potency <> 0

Wk Quantity = (Wk Quantity * IOLOTP)/Input Standard Potency

Endif

Endif

If Wk Quantity <= 0

Continue

EndIf

Call B3401290 in 'GET' mode to get the Item Quantity Cache record using Wk Cache 
Branch
, SDPDDJ, and Quantity Type = 'SOU'.
If Cache Error Code = '0'

Add Wk Quantity to the record Quantity and,

Call B3401290 in 'UPDATE' mode to update the record.

Else
Call B3401290 in 'ADD' mode to Add a new cache record using the Wk Cache
Branch
, SDPDDJ, 'SOU', and Wk Quantity
EndIf

If Input Consolidation Method = '2' then

If SDRORN <> 0 And SDRCTO <>  " " then

While Wk Exit 2 <> '1'

Wk Qty 2= Wk Quantity 

Call B3401270 in mode '9' using Input Date Branch and 

SDPDDJ and Comparison = 'B'.

Wk SDPDDJ = Date from B3401270.

Wk Skip = ' '


Read F3411 using MMDOCO=SDRORN and MMDCTO=SDRCTO.
If Read Fails

Exit While Wk Exit 2 loop

End If

If MMMSGT = 'M' Or MMKCOO <> SDRKCO Or MMLNID <> SDRLLN

Continue

End If 

MMITM=SDITM, MMMMCU=MMMCU, MMMCU=SDMCU, MMDOCO=SDDOCO, 
MMDCTO=SDDCTO, MMHCLD='A', MMUSER, MMPID, MMUPMJ, MMJOBN, MMLNID=SDLNID, 

MMVEND=SDAN8, MMSTRT=0, MMRSTJ=0.

Case MMMSGT = 'L'

* Decrease

MMMSGT='A' 

Wk Qty 2 = MMTRQT

MMDRQJ= Wk SDPDDJ, MMRRQJ=0, MMDSC1=Input Decrease 

SO Qty Desc

If Input Warning Msg Flag = '1' And MMTRQT <> 0 

then

Write to F3411and Increment Input F3411 UKID.

Input Display Code = '2'

End If

End Case

Case MMMSGT = 'G'

* Increase

MMMSGT='A' 

Wk Qty 2 = MMTRQT

MMDRQJ= Wk SDPDDJ, MMRRQJ=0, MMDSC1=Input Increase 

SO Qty Desc

If Input Warning Msg Flag = '1' And MMTRQT <> 0 

then

Write to F3411and Increment Input F3411 UKID.

Input Display Code = '2'

End If

End Case

Case MMMSGT = 'D'

* Defer

MMMSGT='A' 

Wk Offset = MMRRQJ - MMDRQJ

MMDRQJ= Wk SDPDDJ, MMDSC1=Input Defer SO Desc

Wk SDPDDJ = Wk SDPDDJ + Wk Offset

MMTRQT = Wk Qty 2

Call B3401270 in mode '9' with Input Date Branch 
and Wk SDPDDJ and Comparison Flag = 'B'

MMRRQJ = Date from B3401270

If Input Warning Msg Flag = '1' And MMTRQT <> 0 

then

Write to F3411and Increment Input F3411 UKID.

Input Display Code = '2'

End If

End Case

Case MMMSGT = 'C'

* Cancel

Wk Skip = '1'

MMMSGT = 'A'

MMTRQT = Wk Qty 2

MMDRQJ = Wk SDPDDJ

MMRRQJ=0

MMDSC1 = Input Cancel SO Desc

If Input Warning Msg Flag = '1' And MMTRQT <> 0 

then

Write to F3411and Increment Input F3411 UKID.

Input Display Code = '2'

End If 

End Case

Case MMMSGT = 'E'

*Expedite
MMMSGT='A' 

Wk Offset = MMDRQJ - MMRRQJ

MMDRQJ= Wk SDPDDJ, MMDSC1=Input Expedite SO Desc

Wk SDPDDJ = Wk SDPDDJ - Wk Offset

MMTRQT = Wk Qty 2

Call B3401270 in mode '9' with Input Date Branch 
and Wk SDPDDJ and Comparison Flag = 'B'

MMRRQJ = Date from B3401270

If Input Warning Msg Flag = '1' And MMTRQT <> 0 

then

Write to F3411and Increment Input F3411 UKID.

Input Display Code = '2'

End If

End Case

End While

Else

Wk Skip = ' '

Wk Qty 2 = Wk Quantity

Wk SDPDDJ = SDPDDJ

End If

* Write the 'SOT' quantity into the cache.

If Wk Skip <> '1'

Call B3401290 in 'GET' mode to get the Item Quantity Cache 
record using Wk Cache Branch,  Wk SDPDDJ, and Quantity Type = 'SOT'.

If Cache Error Code = '0'
Add Wk Qty 2 to the record Quantity and,

Call B3401290 in 'UPDATE' mode to update the record.
Else
Call B3401290 in 'ADD' mode to Add a new cache record 
using the Wk Cache Branch, SDPDDJ, 'SOT', and Wk Qty 2

EndIf
End If

End IF

EndWhile


3 Close all Tables

Close all Tables
Exit the function with Error Code = 0





^

Data Structure

D3400390 - MRP, Write Sales Order Qty To Cache


Data Item Data Structure DescriptionI/ORequiredNotes


JOB            Job Number                        IY      Used when accessing cache 

bsfn.

ITM            Short Item Number                  IY      SVITM

MCU            Branch                        IY      SVMCU

EFFF            Begin Date                        IY      Loaded with $$BEG

DATE04      Forecast Beginning Date            IY       Loaded with $$FBDT

EFFT          Thru Date                     IY        @DT[$PND] = $ENDD

OT1Y            Potency Control flag              IY      From Item Bal IBOT1Y

STDP            Standard Potency Value            IY         From Item Bal IBSTDP

EV01            Potent Unit flag               IY     $$PUFG

UOM1            Primary UOM1                        IY        From F4101 IMUOM1

EV01        Suppress Error Message           I        ' ' - Display Errors '1' - 

Suppress                                                                                                 

                                                Error Messages

ERRC          Error Code                    O       '0' - Success (Default) '1' - 

Error                                                                                                 

                                                in Function

DTAI            Error Message ID                O      Blanks - Success '3143' - 

Errors

TFLA            Std UOM Conversion            IY     SVTFLA

INT01       Number of Past Due Periods    I         $PDUE, which is the integer   

                                                                                                      

                                          representation of $$PSTD.

EV03        Forecast Consumption Flag        I         '1' if FC is On, $$FCP

EV02         Consolidation Method          I       '2' to write 'SOT' 

quantities.

DSC1         Decrease SO QtyDesc              I      VTX field - Required if 

Consolidation                                                                                               

                                                  Method is '2'

DSC1Increase SO QtyDesc                       I      "VTX field - Required if      

                                                                   Consolidation Method is '2'

DSC1Defer SODesc                                 I      VTX field - Required if 

Consolidation                                                                         Method is '2'

DSC1Cancel SO Desc                                  I      VTX field - Required if 

Consolidation                                                                         Method is '2'

DSC1Expedite SO Desc                          I      VTX field - Required if 

Consolidation                                                                         Method is '2'

EV01Warning Msg Flag                              I          $@A - Required if 

Consolidation                                                                         Method is '2'

UKIDF3411 Unique ID                             I/O       $SKUID - Required if 

Consolidation                                                                         Method is '2'

MRPDMRP Display Code                          I/O         $$MRPD - Required if 

Consolidation                                                                          Method is '2'

MCUDate Branch                                    I      Branch to get dates from. If 

$$CONS =                                                                         '1', it must equal to 

Consolidation                                                                         Branch

PIDProgram ID                                I      Required if Consolidation 

Method is                                                                         '2'

MCUConsolidation Branch                      I      $CMCU


^

Parameter NameData ItemData TypeReq/OptI/O/Both
mnShortItemNumberITMMATH_NUMERICNONENONE

An inventory item number. The system provides three separate item numbers plus an extensive cross-reference capability to other item 
numbers (see data item XRT) to accommodate substitute item numbers, replacements, bar codes, customer numbers, supplier numbers, and 
so forth. The item numbers are as follows:   o Item Number (short) - An eight-digit, computer-assigned item number     o 2nd Item Number - The 
25-digit, free-form, user defined alphanumeric item number     o 3rd Item Number - Another 25-digit, free-form, user defined alphanumeric item 
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.

jdBeginDateEFFFJDEDATENONENONE

A date that indicates one of the following:     o When a component part goes into effect on a bill of material     o When a routing step goes into 
effect as a sequence on the routing for an item     o When a rate schedule is in effect The default is the current system date. You can enter 
future effective dates so that the system plans for upcoming changes. Items that are no longer effective in the future can still be recorded and 
recognized in Product Costing, Shop Floor Management, and Capacity Requirements Planning. The Material Requirements Planning system 
determines valid components by effectivity dates, not by the bill of material revision level. Some forms display data based on the effectivity 
dates you enter.

cPotencyControlFlagOT1YcharNONENONE

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

mnStandardPotencyValueSTDPMATH_NUMERICNONENONE

The percentage of active ingredients normally found in an item.

cPotencyUnitFlagEV01charNONENONE

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

szPrimaryUom1UOM1charNONENONE

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

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.

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

szJobNumberJOBcharNONENONE

Job Number

jdThruDateEFFTJDEDATENONENONE

A date that indicates one of the following:     o When a component part is no longer in effect on a bill of material     o When a routing step is no 
longer in effect as a sequence on the routing for an item     o When a rate schedule is no longer active The default is December 31 of the 
default year defined in the Data Dictionary for Century Change Year. You can enter future effective dates so that the system plans for upcoming 
changes. Items that are no longer effective in the future can still be recorded and recognized in Product Costing, Shop Floor Management, 
and Capacity Requirements Planning. The Material Requirements Planning system determines valid components by effectivity dates, not by 
the bill of material revision level. Some forms display data based on the effectivity dates you enter.

jdForecastBeginningDateDATE04JDEDATENONENONE

Event point for JDE Date.

nNumberPastDuePeriodsINT01integerNONENONE

Number of Days in Future to Query for Responses Due. 

cForecastConsumptionFlagEV03charNONENONE

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. 

cConsolidationMethodEV02charNONENONE

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

szDecreaseSOQtyDescDSC1charNONENONE

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

szIncreaseSOQtyDescDSC1charNONENONE

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

szDeferSODescDSC1charNONENONE

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

szCancelSODescDSC1charNONENONE

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

szExpediteSODescDSC1charNONENONE

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

cWarningMsgFlagEV01charNONENONE

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

mnF3411UniqueIDUKIDMATH_NUMERICNONENONE

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

cMRPDisplayCodeMRPDcharNONENONE

This code may be used as an additional field to select Item information to print on reports.  Once values are loaded into this field, The 
DREAM Writer may be set up to select these values. Valid values are:    blank Items NOT processed by the generation.    1       Items processed by 
the generation WITHOUT outstanding messages.    2       Items processed by the generation WITH outstanding messages.

szDateBranchMCUcharNONENONE

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.

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.

szConsolidationBranchMCUcharNONENONE

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.

mnUniqueKeyIDOffsetMATH01MATH_NUMERICOPTNONE

- - - Good Performance Low Value. 

cSalesOrderIncludedEV01charOPTNONE

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

cProjectPlanningEV01charOPTNONE

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

mnSequenceNumberSEQNMATH_NUMERICOPTNONE

A number used to organize the table into a logical group for online viewing and reporting.

mnCustomerNumberAN8MATH_NUMERICOPTNONE

A number that identifies an entry in the Address Book system, such as employee, applicant, participant, customer, supplier, tenant, or 
location.

cModeEV01charOPTNONE

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

cCustomerAddressRltnshipFCCRcharOPTNONE

Related Functions

B3401270 Cache, Process MRP Bucketless Dates
B3401290 Cache, Process MRP Item Quantities
B3401300 Cache, Process MRP Inclusion Rules
B4000520 Get Item UoM Conversion Factor

Related Tables

F3411 MPS/MRP/DRP Message File
F4108 Lot Master
F4211 Sales Order Detail File
tyle="position: absolute; left: 0.500000in">

then

Write to F3411and Increment Input F3411 UKID.

Input Display Code = '2'

End If

End Case

Case MMMSGT = 'G'

* Increase

MMMSGT='A' 

Wk Qty 2 = MMTRQT

MMDRQJ= Wk SDPDDJ, MMRRQJ=0, MMDSC1=Input Increase 

SO Qty Desc

If Input Warning Msg Flag = '1' And MMTRQT <> 0 

then

Write to F3411and Increment Input F3411 UKID.

Input Display Code = '2'

End If

End Case

Case MMMSGT = 'D'

* Defer

MMMSGT='A' 

Wk Offset = MMRRQJ - MMDRQJ

MMDRQJ= Wk SDPDDJ, MMDSC1=Input Defer SO Desc

Wk SDPDDJ = Wk SDPDDJ + Wk Offset

MMTRQT = Wk Qty 2

Call B3401270 in mode '9' with Input Date Branch 
and Wk SDPDDJ and Comparison Flag = 'B'

MMRRQJ = Date from B3401270

If Input Warning Msg Flag = '1' And MMTRQT <> 0 

then

Write to F3411and Increment Input F3411 UKID.

Input Display Code = '2'

End If

End Case

Case MMMSGT = 'C'

* Cancel

Wk Skip = '1'