. The calculation is executed differently as in the Precalculation. That is why the script must be created separately for the post-calculation.
Note:
No all variables are available in DataWindow dw_1 if the calculation results in the background (eg. at a posting-in assembly)
Only a limited amount of fields is available if the calculation is executed in the background (Batch-post-calculation or assembly valuation) .
beas 9.2 PL: 01 and older
No information is saved.
beas 9.2 PL: 02
Bill of materials art (50) s_level, belnr_id, belpos_id, pos_id, itemcode, art, ke (=prcmntmtd) and all result values
routing: art (52),aplatz_id, s_level, belnr_id, belpos_id, pos_id and all result fields
If you activate the option "extended calculation" all fields are available, the calculation may take some more time.
Note: If you need to access material or routing positions via script, extended calculation is required.
|
Per calculation object the script is executed four times. In variable <sum.typ> is is stored, which value is calculated currently:
mc.plan
|
Planned costs at marginal costs
|
mc.actual
|
Current costs at marginal costs
|
fc.plan
|
Planned costs at full costs
|
fc.actual
|
Current costs at full costs
|
The following variables are available:
sum.typ
|
What is calculated (see above)
|
sum.material
|
Material costs without surcharges, without external operations
|
sum.labor
|
L+M costs
|
sum.manufacturing
|
Cost of external operation
|
sum.production
|
Production costs - including all surcharges until this calculation object
|
sum.quantity
|
At mc.typ = mc.plan or fc.plan the planned quantity, otherwise the current quantity
At projections always the projection quantity
|
You can set the following values:
cost
|
Surcharge costs - separately for the currently calculated value (see sum.typ).
|
description
|
Description - transferred from the latest set value.
|
Available basic variables
Note: It is not mandatory to set these variables. If empty, default values are used.
e_von
|
Valuation considered from date
|
e_bis
|
Valuation considered to date
|
e_batch
|
J = Batch-calculation - no output on screen
|
e_schema_id
|
Default - Calculation schema, if empty, automatic determination
|
e_postcalcquantity
|
set only in case of single step calculation:
Conversion to the defined quantity independent from planned or reported quantity
|
e_receiptquantity
|
Is set, if the calculation is called up at posting in goods. The quantity to post in is entered
|
e_postcalcorder
|
Determines, whether purchase orders for external operations are to be considered. True or J = consider, false or N = not to consider
|
e_costrate
|
Alternative resource cost rates
|
e_onelevel
|
Determines the extended pricing of storage related sub-assemblies in post-calculations (setup: onelevelcalc)
S=Standard, V=determine prices from last Precalculation
|
str_parm.belnr_id
|
Document number (BEAS_FTHAUPT.BELNR_ID)
|
str_parm.belpos_id
|
Document position (BEAS_FTPOS.BELPOS_ID)
If 0, all document positions
|
Furthermore, you can access all values of dw_1.
Note: Not all fields are filled for calculations running in the background ( for example, when posting in an assembly).
// Get Information from Item Master data and calculate this with udf1 from first resource
//
// Get information from item
select "NumInSale","SWW" into :ll_numinsale,:ls_meterprobox from "OITM" where "ItemCode" = <dw_1.item.itemcode:1.value,dbstring>
// search for first labor position
dw_1.find=art=52
setvar=ll_row=<value>
if <ll_row> n= 0 then
return success
end if
// get udf1 from resource
select UDF1 into :ls_meterpreis from BEAS_APLATZ where APLATZ_ID=<item.aplatz_id:[ll_row].value,dbstring>
if <ls_meterpreis,#0.000000> n= 0 then
setvar=ls_meterpreis=1
end if
// udf1 is a text field. Replace comma with dot
tools=globalreplace=ls_meterprobox=,=.
// current calc quantity
lc_qty=<sum.quantity,#0.000000>
// check null
if <lc_qty> n= 0 then
setvar=lc_qty=0
end if
// calculate and write back to variable cost (see "into cost"
select <ls_meterprobox,num(6)> * <ll_numinsale,num(6)> * <ls_meterpreis,num(6)> * <lc_qty,num(6)> into cost from BEAS_DUMMY
|
if <sum.typ> = mc.plan or <sum.typ> = mc.actual then
setvar=cost=<dw_1.item.soll_fkgk:1.value>
return success
end if
setvar=cost=<dw_1.item.soll_fkvk:1.value>
|
(beas9.1-004-064-000)
Help URL: https://help.beascloud.com/beas202402/index.html?scripting_postcalculation.htm
|