Calculate Value hook
Use this hook to calculate the value for the calculated field. The value must be assigned to the variable with the name of the Name property. In case of an array field, when the Elements property is greater than 1.
In this hook, all fields are available that are sent from the print session to the native report. Those fields can be found in the Reports (ttadv3530m000) session, option Report Input Fields. Additionally, all fields are available of the tables read in the Table Read hooks of the Table Selections.
This hook is called by the report engine before the row of data is written to the XML data source. If the calculated field values are required in the Write Row hook, do not use the Calculate Value hook. You must calculate the value in the Write Row hook itself.
Example, no array field:
function extern void ext.no.po.calculate()
{
ext.no.po = 0
select count(tdpur400.orno):ext.no.po
from tdpur400
where tdpur400.otbp = :tccom100.bpid
selectdo
endselect
}
For performance reasons, you can decide to calculate multiple fields in one Calculate Value hook; in that case, you can omit the hooks for the other fields. You can also calculate the values in the Write Row hook. Note that the order in which the Calculate Value hooks are executed is arbitrary.
Example, array field:
function extern void ext.turnover.calculate(i.elem.number)
{
long month
month = i.elem.number
txprcdll0001.calculate.turnover(tcibd001.item, month,
ext.turnover(i.elem.number))
}