Wednesday 9 July 2014

Function -> sum.records.in.view

Situation
Many grid sessions in Infor LN contain total fields at the bottom. In most cases, the value for this total field is calculated using a SQL statement with a SUM in the where-clause. Customers are complaining that this total field does not have the proper value if the user uses column filtering.

Solution
A new tools function from FP7 onwards is available to calculate the value of the total field. The syntax is as follows:
function void sum.records.in.view(const string column1.var, double result1.var [..., ...])
This function performs a query on the main table of the session, including all reference tables, and will sum the values of each specified column. The query will take the current view fields, active user filter and any query extensions into account. An even number of parameters must be passed and any specified column must exist in the data dictionary. If one of these two conditions is not met, an assert is given.

Note: Make sure you call this function only once by sending all pairs of fields due to performance!

Wrong usage:
sum.records.in.view("tpctm070.perc", total.percentage)
sum.records.in.view("tpctm070.flmt", total.funding.limit)
sum.records.in.view("tpctm070.apra", total.approved.amount)
Right usage:
sum.records.in.view("tpctm070.perc", total.percentage, "tpctm070.flmt", total.funding.limit, "tpctm070.apra", total.approved.amount)

TIV
This function is available from TIV level 1753 till 1800, 1802 and higher.

Implementation
This new function should be used from the current development release onwards, unless filtering should not impact the total field. The function can also be used to solve customer problems on FP7 and FP8, although we will not pro-actively implement this in these maintenance versions.

Also Check the usage of below functions:
function void display.total.fields (string fieldname1, void value1, string fieldname2,..., void value2,...)

No comments:

Post a Comment