shuzheng
17th October 2005, 13:53
Hi,everybody:
I want put a sum field on the bottom of a form, but not like a report, there is no after.field to add.
how can I do it, thanks!

As this picture:
-----------------------------------------------------------------
|table field name|table field name|......................................
|table field value|table field value|.......................................
|. |.
|. |.
|. |.
|_________________________________________________________
|sum(field value)|sum(field value)|............................
|------------------------------------------------------------------

v_chandra
17th October 2005, 15:24
Hi

May be this can help you :

Syntax

void display.total.fields( string fieldname1, long value1 [, string fieldname2, long value2 ] ... )

Description

When a total line is included in a form, this function displays total values for specified fields in the grid. The function takes one or more pairs of arguments. In each pair, the first argument is the field name; the second argument is the total value for that field.
The fields must be defined on the form as multioccurrence form fields. They must also be declared in the UI script. Alternately, the fields can be table fields.
To add a total line to a grid, add the following code to the UI script:

before.program:

fattr.total.line = true

Then for every update that effects the total fields, call display.total.fields() to display the new totals.
The total line can display an enum value. To do this, the description of the enum must be passed using enum.descr$() . For example:

display.total.fields( "tffbs.dbcr", enum.descr$( "tfgld.dbcr",
tfgld.dbcr.debit ) )

Notes

Total fields are always read-only. They cannot be disabled or enabled.
Total fields have the same display properties as the fields above them.
If a field specified by the function is an array field, the total value is displayed in the first field of the array. Subsequent fields in the array cannot be addressed by the function.

Context

4GL library function.

Example

before.program:
fattr.total.line = true

choice.first.set:
after.choice:

display.total.fields( "whwmd000.amnt1", tot_1, "whwmd000.amnt2", tot_2 )

shuzheng
17th October 2005, 16:26
thanks a lot ,V Chandra
I have got it!

kiran kumar
14th October 2009, 16:08
Hi,

I got the Total Line in Display form. But how to get the total. I wrote the same script as suggested by V Chandra. Is there any problem in start command of session. I have given start command as "Start Set" and script is as shown below.Is the total value of price will store in "tot_1" variable? i have to show all the prices and at last total of that prices.

choice.first.set:
after.choice:
display.total.fields( "tdsls401.pric",tot_1)

Regards

Kiran kumar

vahdani
14th October 2009, 18:06
Hi Kiran,

you have to calculate the total yourself. Here is a programm template that I use:

|******************************************************************************
|* tiabc1500 0 VRC B61U a rq01
|* Total Fields Template
|* vahdani
|* 2005-07-18
|******************************************************************************
|* Main table tiabc100 Maintable TEST, Form Type 1
|******************************************************************************

|****************************** declaration section ***************************
declaration:

table ttiabc100 | Maintable TEST
table ttcmcs048 | Cost Components

domain tccopr amount.total
domain tcdsca total.desc

|****************************** program section *******************************

before.program:
fattr.total.line = true
total.desc = "Total:"

before.display.object:
if actual.occ = 1 then
on.main.table(calculate.total.fields)
endif

|****************************** zoom section **********************************

|****************************** form section **********************************

|****************************** choice section ********************************
choice.start.set:
before.choice:
init.total.fields()

choice.first.view:
before.choice:
init.total.fields()

choice.next.view:
before.choice:
init.total.fields()

choice.prev.view:
before.choice:
init.total.fields()

choice.last.view:
before.choice:
init.total.fields()

choice.find.data:
before.choice:
if not background then
init.total.fields()
endif
|****************************** function section ******************************

functions:

function calculate.total.fields()
{
amount.total = 0
select amnt
from tiabc100
where _index1 = {:tiabc100.item, :tiabc100.indt}
selectdo
amount.total = amount.total + tiabc100.amnt(1)
endselect

display.total.fields("tiabc100.amnt", amount.total,
"tcmcs048.dsca", total.desc)
}

function init.total.fields()
{
amount.total = 0
display.total.fields("tiabc100.amnt", amount.total,
"tcmcs048.dsca", total.desc)
}
|************************* end of source ***************************************