R30812 (Cost Simulation) - Technical Troubleshooting

Purpose of Document

This note is to discuss technical troubleshooting in running R30812 (Cost Simulation).
Related documents

Table of Contents:


R30812 (Cost Simulation) - Simplified routine

Apps Function Purpose Note
R30812 - Cost Simulation
1. B3003810 - CostBuildBOMExplosion (Cost Build BOM Explosion) Explode BOM and set BEXP to '2' for data selected item or its coby
2. N3003760 - CostSimulationFileReset (Cost Simulation File Reset) to clear costs in F30026
3. B3004020 - CalculateSimulatedRoutingCosts (Calculate Simulated Routing Costs) when PO cRoutingCalc is equal to "1,2,3" Replace R30818
4. N3003800 - CostingImplosionBOM (Costing Implosion BOM) Process A1, A2, & Simulated Total Costs Replace R30820

Business Functions related with Cost Simulation

This is in alphabetical order rather than actual calling sequence. For the actual sequence, refer to routine section.

Source BSFN Table Reference Purpose Others
B3000060 CheckForOperationResources (Check For Operation Resources) F3002 Check for Consumed Resources, Produced Resources, and/or Intermediate Operations that are associated with an Operation. CONS = Consumed Resources, PROD = Produced Resource, BOTH = Consumed & Produced Resources, Intermediates (Y/N). 1. Check for Ingredients at the Operation
2. Check for Co-/By-Products at the Operation
3. Check for Intermediates at the Operation
B3000160 ConvertBatchQuantity (Convert Batch Quantity) F4101 If Mode is equal to '1', it will Convert the Batch Quantity from File UOM to Display UOM. If Mode is equil to '2', COnvert the Batch Quantity from Display UOM to File UOM. Call GetItemUoMConversionFactor to get conversion factors and result
B3000330 ConvertTimeBasisCodetoQuantity (Convert Time Basis Code to Quantity) F0005 DD Alias TIMB (UDC 30/TB - Time Basis Code)
B3000400 VerifyAndGetWorkCenterMaster (Verify And Get Work Center Master) F30006 Read data from F30006 (Work Center Master File)
B3000460 VerifyAndGetWCRates (Verify And Get W C Rates) F30008 cCallType 1 is used to get a record
cCallType 2 is used to check if there is a record
cReturnPointer will return a pointer to an F30008 record structure.
Read data from F30008 (Work Center Rate File). It is the responsibility of the calling program to free this memory if it asked for it.
B3000470 CalculateRoutingCosts (Calculate Routing Costs) F3009, F30006, F30008 This business function will calculate costs for all cost types (B1, B2, B3, B4, C1, C2, C3, C4); however, only one cost type cost will be calculated at a time based on the cost type parameter DS COST passed in.
All “intermediate” costs calculated to come up with the final cost will be passed back to the calling program if DS VC01A parameter is set to ‘Y’. The calculated cost will be sent back in DS XSMC parameter.
1. Setup Labor Calculation
2. Machine Labor Calculation
3. Labor Efficiency Calculation
4. Variable Machine Overhead Calculation
5. Fixed Machine Overhead Calculation
6. Variable Labor Overhead Calculation
7. Fixed Labor Overhead Calculation
B3000520 VerifyAndGetRouting (Verify and get routing) F3003 Verify that the Routing Master (F3003) record exists and return a pointer to the Routing Master Record.
Return Pointer: 1=Return Pointer, 0=Do not return pointer.
Call Type: 1=Verify that record exists,
2=Verify that record does not exist.
To read data from F3003 (Routing Master File) using 8 different keys
B3000580 CalculateComponentQuantity (Calculate Component Quantity) This business function will calculate the quantity of a component item needed to produce a specific quantity of a parent item. 1. Determine if a unit of measure conversion needs to be performed
2. Check for variable component item
3. If needed, inflate quantity for step scrap percent
4. Consider feature cost percent
5. If a variable component consider parent requested quantity
B3000600 VerifyAndGetItemCostComponent (Verify And Get Item Cost Component) F30026 cCallType 1 is looking for a record to match the key values cCallType 2 is looking for a record to NOT match the key values

cPointerReturnCode of 1 with cCallType 1 will cause the program to return a pointer ID to a block of memory that holds an F30026 record structure. It is the responsibility of the calling program to see that this memory gets freed.
B3000680 UpdateTotalCostInformation (Update Total Cost Information) F3002, F30026, F300261 This function will take an item's costs and roll them up to any parent items' simulated total (xscr) 1. Loading and calling CalculateComponentQuantity
2. Calculate Parent Cost
3. if scrap, update / write scrap cost type record(A2)
B3000880 UpdateCostRollupRouting (Update Cost Rollup Routing) F30026 cCallType Valid Values:
O = Open Table
F = Fetch Table
U = Update Table
A = Insert Table (Add)
1. If DS Outside Operation cost Type is blank process all standard cost types (B1, B2, B3, B4, C1, C2, C3, and C4.
2. bOutsideOperation == TRUE) If Parent Cost Percent is 0, multiply it out. If the discrete method is planned at 0%, then no costs from the discrete method should be added to the item.
B3001460 UpdateCurrentLevelCosts (Update Current Level Costs) F30026, F300261, F41021, F4105, F4102 Calculated purchased costs, outside op costs, and extra costs (all non-labor) for net added amounts then roll all cost types up to the item's simulated total amounts. Fetching a record in the Linked list that matches the Cost Component from the F30026 record and the Work Center from the F300261, if detailed costing.
* 1.2 Amount - Simulated Manufacturing Costs (Xsmc)
* 1.2.1 from Specs
* 1.2.3 Check to see if cost above C is outside op
* 1.2.4 compute Phantom Item
<Internal_Only>Check routine again</Internal_Only>
B3001610 InitializeCoByProductCache (Costing, Initialize CoBy Product Cache) F3002, F30026, F3404, F4101 This funcion will do the initial loading of the co/by-products cache for a specific process. Calling function Convert Batch Quantity (B3000160) Converting the Batch Quantity from File to UOM in BOM
B3001620 CostingCalculateCoByProductCosts (Costing Calculate CoBy Product Costs) F3002, F30026, F300261 This function distributes accumulated costs of a process to its co/bys using feature cost percent.
B3001640 CostingProcessWhereUsed (Costing Process Where Used) F3002, F30026, F300261 This function distributes the cost of a process to its cobys.
B3001650 CacheProcessCoByProduct (Cache, Process CoBy Product) This business function is the server for the co/by product cache.
This cache holds information on the co-products and by-products that come out of a process at a given step.
cProcessMode (refer #1)
cCacheCodeError (Refer #2)
B3001670 CalculateParentCostPercent (Costing, Calculate Parent Cost Percent) F3404 Read F3404 to get percent
B3003010 CacheProcessCoByAccumCosts (Cache Process Co By Accum Costs) This function is the server for the co/by accumulated costs cache which holds costs by cost type. There is no business logic in this function. It is simply a cache server. Same with B3001650
cProcessMode (refer #1)
cCacheCodeError (Refer #2)
B3003770 CostItemInformationCache (Cache Process Cost Item Information) F30UI011 This business function is used to manipulate Costing Item Information CACHE data. B3003770_CACHE_TOTAL_CURSORS = 10 (this is maximum cursor can be stored in running R30812)
Refer #1 for cCacheActionCode
If input parameter of cUseWorkFile = '1' then it writes F30UI011 (Work File for Cost Component)
<Internal_Only>*** To Do: Specify Errors ***</Internal_Only>
B3003780 CostParentAndChildCache (Cache Process Cost Parent And Child) F30UI012 This business function is used to manipulate Costing Parent and Child relationship CACHE data B3003780_CACHE_TOTAL_CURSORS = 10
F30UI012 (Work File for Parent Child)
f30ui012.h
Calling B3004090 - CacheManageCostRollupWorkFile
Cache-key (index): szItemBranch, ItemNumber, szParentBranch, ParentItemNumber, mnSequenceNoOperations, mnComponentNumber
B3003810 CostBuildBOMExplosion (Costing Build BOM Explosion Source File) F4101, F4102, F3002, F3003, F3009 The purpose of B3003810 is to explode BOM for selected items and store the item information into Cache B3003770 and store Parent/Child relationship into Cache B3003780.

1. B3003770 - CostItemInformationCache (To initialize cache)
2. I3003810_GetDataSelectedItem: insert a blank record into the cache. This record, which will have a mnLowLevelCode of 0, becomes the separator between the items that were in the data selection and the items that are a result of exploding a data selected item. The items that were in the data selection have a positive mnLowLevelCode which came from F4101.imllx. The items that are a result of exploding or that have already been exploded will have a negative mnLowLevelCode.

When the program needs another item from the data selection, it will seek in the cache for the blank record, then step to the next record (which will have a positive mnLowLevelCode because the first column in the cache index in mnLowLevelCode and it is ascending). If there is not another record after the blank record, then the job is complete.

3. search for all children of one Item
4. find all coby item and add to caches
5. find the outside operation
6. It is acceptable to fail if record exists in Parent And Child CACHE
Ref#3. cItemTypeInfo
<Internal_Only>Check this function again</Internal_Only>

B3003820 CostGetwhereUsed (Cost Get Where Used) This function loops through the item and parent child cache gathering parent information for children and calling B3000680 - Update Total Cost to roll the costs up Repeating below,
1. CostParentAndChildCache
2. CostItemInformationCache
3. UpdateTotalCostInformation
B3004020 CalculateSimulatedRoutingCosts (Calculate Simulated Routing Costs) F3003 This routine is compute routing cost (where item which stocking type is 'R - process item.'
If an item is an ingredient for one process and a coby for another, and the processing option was set to not clear and calculate it, then skip it.
If this is a purchased item, then skip it.
Read F3003 with ACQ (if it does not have data then without ACQ).
<Internal_Only>Check this routine again</Internal_Only>
N3003760 CostSimulationFileReset (Cost Simulation File Reset) To Clear Item Cost Component Add Ons File(F30026)
0024 // before doing a Simulated Cost Rollup
1. Retrieve Item Cost Information from Cache
2. Reset Processing Flag
3. ItemTypeInfo = '3' when an Ingredient is a CoBy Product in another Process no costs get cleared for items with cItemTypeInfo of 3
4. Reset Simulated Cost Amount
5. Clear 'A2' for all records that exist in Cache
6. All records that exist in Cache will get cleared, only if the Ingredient is not a COBY in another Process (ie. ItemTypeInfo is not = 3)
7. Clear XSMC for Outside Operations
8. cItemTypeInfo 2 indicates that the item is a co/by in a process. In this case, clear the extra costs because they come from the process that produces this co/by
9. Update F30026
10. Update the F300261 detail simulated net added and total amounts If an amount is cleared at the summary level, clear it here at the detail level. This keeps the files in sync and the clearing logic in one place.
N3003800 CostingImplosionBOM (Costing Implosion BOM) Write cost information based on BOM Exploded 1. Read cache created in Explosion
2. Process
Costing, Initialize CoBy Product Cache
Costing, Calculate Parent Cost Percent
3. Write F30026 record item dows not have A1
4. Update current level




Ref #1: (Input) B3001650.cProcessMode

cProcessMode Description Others
0 Create Cache Only for B3003770, B3003780
1 Get Cache Record (Fetch First Record)
Keyed for specific or keyless for 1st records
2 Add Record
3 Update Record
4 Delete records that matches Key
5 Delete all records
6 Get next cache record (Fetch Next)
user after mode 1 with pointer as input value
7 Add or update cache
8 Terminate all references to this cache and the cache itself
9 Close Cursor



Ref #2: (Output) B3001650.cCacheCodeError

cCacheCodeError Description Others
0 No Error
1 Mode is 6 but no cursor pointer was passed in
1 mode was 6, end of cache reached
2 invalid mode used (not in 1 ~ 9)
3 unable to initialize cache
4 failed to add or update record to cache
5 failed to delete record from cache
6 failed to get first cache



Ref #3. cItemTypeInfo is used to designate what cost types will or will not get cleared and recalculated for an item

cItemTypeInfo Explanation Others
<blank> item was data selected; change to 0, 1, or 2
1 outside op; clear and calculate all but extra costs
2 co/by-product; clear and calculate all cost components
3 co/by-ingredient or child in single level rollup; clear and calculate none of the cost components

Note: