LoadSubstituteCache

Substitute Availability - F3002

Major Business Rule

Object Name: N3101490

Parent DLL: CMFGBASE

Location: Client/Server

Language: NER

This function will perform Substitute processing functionality.  It will read through the F3002 
substitute records based on input values for the component.  After calculating the qty ordered, the record 

will then be written to the substitute cache.  This function will process all substitutes for one 

component at a time.


PROGRAM OUTLINE

1.Initialize Variables

Saved Sub UOM = ' '
Processing Complete Flag = '0'

Sub Component Number = 0

Continue F3002 Fetch Flag = 1

WO Qty Converted = Input Qty on WO

Full Qty Picked = 0

If the input Partials Allowed Flag = blank

Input Partials Allowed Flag = Y

End If


2.Calculate percentage of quantity needed
If Input Partial Flag = 'N'
Comp % Short = 1
Open Qty  = Input Component Qty Ordered

Else
Comp % Short = Input Qty Needed / Input Component Qty Ordered

Open Qty  = Input Qty Needed
End If
 

3.Select F3002 records - use index 1
Based on Input Parent Item #, Parent Branch, Batch Qty, Batch UOM, Component Line Number and 
Substitute Component Number > 0


4.Loop through substitute records
While the fetch is successful and Processing Complete Flag does not = '1'

If the fetched record is a substitute 

AND the Input As of Date >= Effective From Date
AND the Input As of Date <= Effective Thru Date

4.1Initialize Substitute Component's Variables
Sub Qty Ordered = 0
Work Scrap = 0

Work Operation Scrap = 0


4.2Retrieve Item Master and Item Branch Information
Call X4101 and Table Ifor F4102 to retrieve the Primary UOM, Source Layer Code, 
Standard Potency, Stocking Type and Commitment Method for the item.


4.3Check if substitute is a phantom
If the stocking type does not = 0 (phantom)

4.3.1 Calculate Conversion Factors
If the Sub UOM is not the same as the Saved Sub UOM  
OR the Sub Primary UOM is not the same as the Saved Primary UOM

4.3.1.1 Initialize the Work Variables

UOM Changed Flag = '1'
Comp To Sub UOM Conversion = 1

Sub To Comp UOM Conversion = 1

Primary to Sub UOM Conversion = 1

4.3.1.2 Get the conversion factor if the UOMs are not the same
If the Input UOM is not the same as the substitute's UOM
 OR the Sub's UOM is not the same as the Primary UOM

Get UOM Conversion from Sub UOM to Comp UOM  
AND from Sub to Primary

If successful and the Sub to Comp UOM Conversion is not 0
Comp to Sub UOM = 1/ Sub to Comp UOM Conversion
Sub to Comp UOM Conversion = Returned Conversion From to To Sub 

to Primary UOM Conversion = Returned Conv from to Primary

Else
Comp to Sub UOM Conversion = 1
Sub to Comp UOM Conversion = 1
Sub to Primary UOM Conversion = 1
End If
End If

Else
UOM Changed Flag = '0'

End If


4.3.2 Determine Potency 

     If the Sub UOM is not the same as the Sub Primary UOM 
AND the UOM Changed Flag = 1
Get UDC for primary UOM
If no errors

Set Primary UOM Char 2 = 
Returned Special Handling Code 2nd Character
End If
Get UDC for Component UOM
If no errors
Set Trans UOM Char 2 = 
Returned Special Handling Code 2nd Character
End If
Potency Control = ' '
If the Primary UOM Char 2 = 'P' and Trans UOM Char 2 != 'P' 
OR Primary UOM Char 2 != 'P' and Trans UOM Char 2 = 'P'
Potency Control = Y
End If
End If 


4.3.3 Get Qty Available for the entire Substitute (all lots and locations)

Call B4101220 - Calculate Qty Available


4.3.4Continue processing if there is at least 1 qty available and the Qty Per from 
the F3002 > 0

If the Qty Available > 0 AND F3002 Qty > 0
4.3.4.1 Calculate Substitute Quantity Ordered for the Work Order
If substitute's Fixed or Variable flag = 'V'

Sub Qty for WO = Input Qty on WO * F3002 Qty 
Else
If the substitute's Fixed or Variable flag = '%' 

AND Batch Qty = 0

Sub Qty for WO = Input Qty on WO * F3002 Qty

Else

Sub Qty for WO = F3002 Qty

End If

End If


4.3.4.2 Add in the % Scrap and the Operation Scrap % to the total qty

If the substitute's Fixed or Variable flag does not = 'F'

If the Sub Scrap % is not 0
Work Scrap = Sub Qty for WO * (Scrap % / 100)
End If
If the Sub Scrap % is not 0
Work Operation Scrap = Sub Qty for WO * (Op Scrap % / 100)
Work Scrap = Work Scrap + Work Operation Scrap
End If
Sub Qty for WO = Sub Qty for WO + Work Scrap

End If

4.3.4.3 Calculate Substitute Quantity Ordered using Partials

If the Sub Partial Flag = 'Y' And the Potency Flag does not = '1'


4.3.4.3.1 Calculate the Work Qty needed by taking the percentage short of 
the Substitute's Qty for the WO 

If the substitute's Fixed or Variable flag  = 'F'

Work Qty Needed = Sub Qty for WO
Else
Work Qty Needed = Sub Qty for WO * Comp % Short
   End If

4.3.4.3.2 Determine Substitute Quantity Ordered
   If the Qty Avail >= Work Qty Needed
  Sub Qty Ordered = Work Qty Needed

4.3.4.3.2.1 Load all substitutes for interactive.  Stop processing only 

for blind mode

If Input Auto Mode does not equal Interactive

Processing Complete Flag = '1'
End If

4.3.4.3.2.2 Qty has been filled.  Set Qty needed to 0

Qty Open = 0

Comp % Short = 0

   Else 
Sub Qty Ordered = Qty Avail

4.3.4.3.2.3 Re-calculate Qty needed and Component % Short
Sub % Completed = Sub Qty Ordered / Work Qty Needed

Qty Open = Input Qty Needed * Sub % Completed

Comp % Short = Qty Open/Input Comp Qty Ordered

End If

4.3.4.3.3 Add record to the substitutes' cache
Add record to Substitute Cache - Call B3101500

Else
4.3.4.4 Calculate Substitute Quantity Ordered not using Partials

4.3.4.4.1 Set the Sub Qty Ordered to entire amount of the sub qty needed for 
the WO qty

Work Qty Needed = Sub Qty for WO


4.3.4.4.2 Determine Substitute Quantity Ordered
If the Qty Avail in Comp UOM >= Work Qty Needed

4.3.4.4.2.1 Load all substitutes for interactive.  Stop processing only 
for blind mode

If Input Auto Mode does not equal Interactive

Clear the Substitute Cache (In case partials were added)
Processing Complete Flag = '1'
Sub Qty Ordered = Work Qty Needed
Else
4.3.4.4.2.1.1 If the qty has been filled by another substitute, set the 
Qty Ordered to 0 but add the record to the cache

If the Qty Open = 0

Sub Qty Ordered = 0
End If
End If
4.3.4.4.2.3 Qty has been filled, set Qty needed to 0

Qty Open = 0

Comp % Short = 0

Full Qty Picked Flag = 1


4.3.4.4.2.4 Load the record to the substitutes' cache
Add record to Substitute Cache
End If

End If Partials = N
End If Qty is Available for substitute

4.3.5Save Work Variables
Saved UOM = Substitute UOM
Saved Primary UOM = Substitute Primary UOM


End If Stocking Type does not = Phantom
End If Substitute record found within effective dates
End While Fetch Successful


5.Set Return Values - Number of Cache Records Added, Qty Open
If the Input Partial Flag = 'N' OR Full Qty Picked Flag = 1

If the Qty Open > 0

5.1If the substitutes cannot fill the qty needed and partials are not allowed, don't 
use any of the substitutes.  Clear the cache and set number of substitutes to 0

Return Number of Cache Records = 0
Call B3101500 to clear all records

Else

5.2 Return a negative amount to parts list to remove qty ordered from the original 
component.  NOTE: Phas already removed the qty needed from the qty ordered, so add it back in to 

the return qty needed

Return Qty Needed = Qty Open - Input Comp Qty Ordered + Comp Qty Needed

Call B3101500 to retrieve number of cache records

End If

Else

5.3 Partials allowed so return the open qty that remains
Return Qty Needed = Qty Open

Call B3101500 to retrieve number of cache records
End If


Data Structure

D3101490A - Get Substitute Item

Parameter NameData ItemData TypeReq/OptI/O/Both
szJobNumberJOBcharREQINPUT

Job Number in string format to the original Parts List Cache^

cCoByProductsCOBYcharREQINPUT

Component CoProducts Flag - F3002 Key Field^

szBranchPlantMMCUcharREQINPUT

Component Parent Branch Plant - F3002 Key NOTE: Most likely this field will be populated with the WO Header Branch/Plant.  In the case 
that the component is part of a phantom, you must send in the phantom's Branch/Plant.^

mnParentItemNumberKITMATH_NUMERICREQINPUT

Component Parent Item number - F3002 Key NOTE: Most likely this field will be populated with the WO Header Item Number.  In the case 
that the component is part of a phantom, you must send in the phantom's item number.^

mnBatchQuantityBQTYMATH_NUMERICREQINPUT

Component Parent Batch Quantity - F3002 Key NOTE: Most likely this field will be populated with the WO Header Qty Ordered or 0 if a zero 
batch bill is being used.  In the case that the component is part of a phantom, you must send in the phantom's component qty ordered.^

mnOperationSequenceOPSQMATH_NUMERICREQINPUT

Component's Operation Sequence Number - F3002 Key Field^

szTypeOfBillTBMcharREQINPUT

Component Bill Type - F3002 Key field^

jdAsOfDateSTRTJDEDATEREQINPUT

Component As Of Date - used in effective date checking NOTE: This field is generally the component's start date.  Except in the case where 
a prior revision level is being used.   Then the field is the As Of Date.^

mnCompQuantityNeededUORGMATH_NUMERICREQBOTH

Component Qty Backordered  NOTE: This qty will be re-calculated in the function and returned. ^

mnQuantityOnWorkorderQOWOMATH_NUMERICREQINPUT

F4801 Work Order Header Qty Ordered^

nNumberCacheItemsINT01integerOPTOUTPUT

Number of cache records added to the substitutes' cache^

cAutoModeEV01charREQINPUT

Processing Option - Blind or Interactive ^

szComponentUOMUOMcharREQINPUT

Component's UOM^

cPartialsAllowedYNPRTAcharREQINPUT

F3002 Partials Allowed Flag for the component.^

mnCompQtyOrderedUORGMATH_NUMERICREQBOTH

Component's Qty Ordered NOTE: This qty will be re-calculated in the function and returned.^

szWorkOrderUOMUOMcharOPTINPUT

F4801 Work Order Header UOM.^

mnComponentLineNumberCPNBMATH_NUMERICREQINPUT

A number that specifies how the system displays the sequence of components on a single-level bill of material. This number initially 
indicates the sequence in which a component was added to the bill of material. You can modify this number to change the sequence in which the 
components appear.

szOrderTypeDCTOcharOPTNONE

A user defined code (00/DT) that identifies the type of document. This code also indicates the origin of the transaction. J.D. Edwards has 
reserved document type codes for vouchers, invoices, receipts, and time sheets, which create automatic offset entries during the post 
program. (These entries are not self-balancing when you originally enter them.) The following document types are defined by J.D. Edwards and 
should not be changed: P Accounts Payable documents   R Accounts Receivable documents   T Payroll documents   I Inventory documents  
O Purchase Order Processing documents   J General Accounting/Joint Interest Billing documents   S Sales Order Processing documents

szLotGroupLOTGRPcharOPTNONE

Lot Group is the name of a user defined list of allowed non-blank lot status codes.  Entry of a Lot Group name in the Processing Option will 
allow this Application to process lots whose lot status code is defined within the specified Lot Group Name.  

Related Functions

None

Related Tables

None