Page 1 of 1
[RPG]offline - sum of calculation
Posted: Tue Nov 22, 2016 10:09 pm
by MegumiSawada
Hi,
I have asked how to show the result of calculation of offline table.
http://longrange.lansa.com.au/viewtopic.php?f=11&t=507
I would like to get the sum of these result and show it as a label on the offline formview.
The vaule should be get when button is clicked on the formview.
Is it possible to implement with offline formveiw?
If yes, could you please let me know how to?
Best Regards,
Megumi Sawada
Re: [RPG]offline - sum of calculation
Posted: Thu Nov 24, 2016 8:25 am
by tsupartono
Megumi,
If I understand your question correctly, the difference between this and your previous scenario is the trigger, when the calculated values will be displayed, this time the values will be calculated when a button is touched?
If that's the case, you can start with no binding for the calculated column, then as the user touched the "calculate" button, you'd use ECL to change the binding of the calculated column to SELECT number2 - number1.
ECL code snippet:
Code: Select all
lrexec
(
function()
{
// We are assuming that the calculated column is COL%4 (adjust accordingly)
// Do NOT change '$3' in the property name below, it indicates data binding
var p = "form.fields.mytable.col%4.content.value.$3.sql";
this.q_setProperty(p, ""select &(fld:number2) - &(fld:number1)");
}
}
Re: [RPG]offline - sum of calculation
Posted: Thu Nov 24, 2016 12:32 pm
by MegumiSawada
Hi Tony,
Thank you for your reply.
I would like to sum up these results when button is clicked.
Mytable.Row%1.Col%4 = 100
Mytable.Row%2.Col%4 = 200
Mytable.Row%3.Col%4 = 300
Mytable.Row%4.Col%4 = 400
Then I would liek to show the result of (100 + 200 + 300 + 400 ), i.e. 1000 as a label above the table.
I don't know how to do it with offline form...
Best Regards,
Megumi Sawada
Re: [RPG]offline - sum of calculation
Posted: Thu Nov 24, 2016 12:51 pm
by tsupartono
There is a solution where the total would be calculated automatically without the end-user having to press a button.
Because the calculated column is NUMBER2 - NUMBER1, so the sum of that calculated values would be SUM(NUMBER2) - SUM(NUMBER1)
Let's say that your table on the form is showing values from a table called VALUES, you can get the sum of the calculated field using this SQL statement:
Code: Select all
select sum(NUMBER2) - sum(NUMBER1) from VALUES
You just need to bind the label that would show the total to this SQL like so:
Code: Select all
A 3 10HTML('Type:Label
A Value.&.SQL:"
A select sum(NUMBER2)-sum(NUMBER1)
A from VALUES
A "
A ')
Re: [RPG]offline - sum of calculation
Posted: Thu Nov 24, 2016 6:30 pm
by MegumiSawada
Hi Tony,
Thank you for your reply.
The user's requirement is a bit more complex, but I think I can make it work based on your advice.
Thank you!
Best Regards,
Megumi Sawada