Scripting for calculation of surcharges in Precalculation. Entered in Script administration > Edit > upper window
For Pre- and for Post-calculation the scripts need to be created separately.
See
Calculation objects – Scripting
Scripting
Scripting post-calculation
Create script
Three writable variables are available for marginal costs, full costs and description. Special variables are available for accessing calculation results.
Writeable variables:
Variable
|
Descriptions
|
fccost
|
Set full costs for the current object.
Example: setvar=fccost=<sum.fc.labor>
|
mccost
|
Set marginal costs
|
description
|
If values are added to the description, they will be entered regardless of the view lot size, for example: current lot size = 2, view per 10: the price for 2 pieces is entered, the remainder calculated for 10 pieces. By using <calc.lotsize> you can always scale down to 1 piece. However, the view lot size can not be considered.
Furthermore, the description for marginal and full cost view is the same. In the example above, full costs are always independent of the current view.
|
|
e_Row
|
Normally e_Row is always 1.
But if you activate "Calculation schema per Assembly", the system starts the calculation for every assembly.
In this case you must check in your script if this is for the complete calculation (e_Row=1) or for a sub-assembly (e_Row>1)
Example:
Read current ItemCode
setvar=my_ItemCode=<dw_1.item.st_itemcode:[e_Row].value>
Beas 2020.03
|
|
Example: Material cost + 5€
[vbs]
function ppercent (s)
ppercent=<sum.material,num(6)>/100*s
end function
[/vbs]
setvar=fccost=<vbs.ppercent(5)>
setvar=mccost=<fccost>
setvar=description=Material Overhead 5% from <sum.material,#0.00> = <fccost,#0.00>
|
Variables: you can access the following special variables
<sum.material>
|
Material costs without costs for external operation
|
<sum.manufacturing>
|
External operation costs
|
<sum.materialoverheads>
|
Material surcharge
|
<sum.mc.labor>
|
L+M costs at marginal costs
|
<sum.fc.labor>
|
L+M costs at full costs
|
<sum.mc.production>
|
Material + External operation + L+M cost at marginal costs
|
<sum.fc.production>
|
Material + External operation + L+M cost at marginal costs
|
<timetype.fc/mc/fx.[timetype]>
|
Example: marginal costs for time type „machine“
<timetype.mc.machine>
Configuration: <timetype.[typ].[timetype-id]>
Available tpes [typ]
fc
|
Total full costs incl. external operation
|
mc
|
Total marginal costs incl. external operation
|
fx
|
Total fixed costs (Full costs – marginal costs)
|
time
|
Total time
|
mcsurcharge
|
Total - surcharge marginal costs
|
fcsurcharge
|
Total - surcharge full costs
|
mcexternal
|
External operation at marginal costs
|
fcexternal
|
External operation at full costs. This can also be prices from external operations or tool costs
|
These costs can be split up even further into setup time, processing time etc.
Setup time
|
Time/unit 1
|
Time/unit 2
|
Time/unit 3
|
|
fctr
|
fcte
|
fctn
|
fcth
|
Full costs without external operation
|
mctr
|
mcte
|
mctn
|
mcth
|
Marginal costs without external operation
|
timetr
|
timete
|
timetn
|
timeth
|
Time in minutes
|
mcsurchargetr
|
mcsurchargete
|
mcsurchargetn
|
mcsurchargeth
|
Surcharge setup costs at full costs
|
fcsurchargetr
|
fcsurchargete
|
fcsurchargetn
|
fcsurchargeth
|
Surcharge setup costs at marginal costs
|
|
|
<calc.lotsize>
|
Currently calculated lot size
|
<calc.line>
|
Current assembly to be calculated (usually 1)
|
<calc.docentry>
|
Calculation number. If <= 0, temporary calculation
|
<calc.precalcnr>
|
Calculation number, linked to an offer, sales order or advance invoice via field „u_beas_precalcnr
There is no 1:1-linkage to a customer order. A calculation can be stored in several documents.
|
<calc.cardcode>
|
Client number, stored in calculation
|
<dw_1.item.[fieldname].value>
|
with <dw_1.xxx> you have access to all fields.
Scan all fields:
for ll_loop = 1 to <dw_1.rowcount>
ls_test=<dw_1.item.pos_text:[ll_loop].value>
next
Note:
for - next - loop is slow. It is better to work with the "find" command.
dw_1.find=pos_text='xxx'
setvar=ll_row=<value>
ls_text=dw_1.item.info:[ll_row].value
Available fields:
Open the Precalculation and check the field names with the debug window.
Batch Calculation:
The system only fills fields that are needed for calculation.
Example:
The following fields are not filled: UDF1-15, st_info, info, znr (Drawing Number), info, bez (Item Name), color, bitmap
If you need access to this field, you must activate Batch Calculation -> Extented -> Precalculation Save.
|
|
Place holders return values in Windows regional format with 6 digits.
Setup time time type „Machine“ at full costs
|
setvar=fccost=<timetype.fctr.machine>
|
Processing costs time type “Personnel” + “Labor” at marginal costs
|
setvar=mccost=%numadd(<timetype.mcte.labor>,<timetype.mcte.personell>)
|
Example with declared variables
|
// If no variable is declared with „dec“ or „decimal“,
// you can continue to calculate with these in „datawindow-Syntax“
// but a conversion into international format is necessary
dec fcsum
fcsum=<timetype.fc.machine,num(6)>
fcsum=<fcsum,num(6)> + (<fcsum,num(6)> / 100 * 5)
setvar=fccost=<fcsum,#0.000000>
|
Example with VB Script
|
// Working with beas-Script-Formula system, SQL-Script,
// VB-Script or JavaScript, variables nmeed to be converted by num(x)
[vbs]
function ppercent (s)
ppercent=<sum.material,num(6)>/100*s
end function
[/vbs]
setvar=fccost=<vbs.ppercent(5)>
setvar=mccost=<fccost>
setvar=description=Material Overhead 5% from <sum.material,#0.00> = <fccost,#0.00>
|
Complex example:
"Item amount in sales units"
* value from item value "SWW"
* Cost rate from first operation
* current lot size
|
// Amount in sales units of the item to be produced
// (First row of DW_1)
select "NumInSale" into :ll_numinsale from "OITM" where "ItemCode" = <dw_1.item.st_itemcode:1.value,dbstring>
// Position first operation
// (row type)
// "find" is easier than for - next
dw_1.find=art=52
setvar=ll_row=<value>
if <ll_row> n= 0 then
return success
end if
// Use SQL statement to compute the value, write with "into" directly to
// the correct variable
// from BEAS_DUMMY is important, as without "from" "into" does not work
// Marginal/Full costs are taken from the operation [ll_row]
select <dw_1.item.st_sww:1.value,num(6)> &
* <ll_numinsale,num(6)> &
* <dw_1.item.ag_grenzkosten:[ll_row].value,num(6)> &
* <calc.lotsize,num(6)> &
into mccost &
from "BEAS_DUMMY"
select <dw_1.item.st_sww:1.value,num(6)> &
* <ll_numinsale,num(6)> &
* <dw_1.item.ag_vollkosten:[ll_row].value,num(6)> &
* <calc.lotsize,num(6)> &
into mccost &
from "BEAS_DUMMY"
|
|
The calculation puts out the setup time of a machine + setup time of employee and processing time of machine + processing time of employee separately.
In this example 3 cost types have been registered. Also one cost type would be sufficient. Cost elements have been extended to 2, and personnel costs are valued separately. Cost types are assigned and cost centers have been stored. 2 formulas have been entered.
Setup:
// setup-time from machine and personnel
setvar=fccost=%numadd(<timetype.fctr.machine>,<timetype.fctr.personell>)
setvar=mccost=%numadd(<timetype.mctr.machine>,<timetype.mctr.personell>)
setvar=description=Total setup Time <timetype.trtime.machine,#0> Min
Processing:
// Edit-Time from labor and personnel
setvar=fccost=%numadd(<timetype.fcte.labor>,<timetype.fcte.personell>)
setvar=mccost=%numadd(<timetype.mcte.labor>,<timetype.mcte.personell>)
setvar=description=Total Processing Time <timetype.tetime.labor,#0> Min
Afterwards, surcharge objects need to be defined, in which these formulas are stored. Then, the requested result is put out correctly.
|
Help URL: https://help.beascloud.com/beas202402/index.html?scripting_precalculation.htm
|