dilipk.pandey
15th March 2007, 07:14
Dear Seniors,

I have a maintain session where I am displaying some records after filtering based on certain parameters...Its returning more than one records (lets say 10 records...) below, where one of those fields being displayed is an Amount field. Now, I have to display the sum this Amount of all the selected rows on a Form Display Field.As the user mark the rows or unmark the rows, the amount in that display field must get added or subtracted. I tried to do this using the below code but its not giving the desired result:

choice.mark.occur:
after.choice:

for i=1 to filled.occ
if mark.table(i) then
sel_inv_amt = sel_inv_amt + tfacp200.amth(1)
iamt = sel_inv_amt
endif
endfor
____________

Suppose user selected 5 rows, then the control flows to the after.choice each time, 1st time it assigned the first record(amount) to Display Field, but next time its adding the last selected row for "i" time, and also if user unmark/unselect any row its not updating the values in display field.

Please help me out, and do ask me if more clarification is required.

Thanks in advance.
Dilip.

mbdave
15th March 2007, 07:52
hi

why dont you try this

choice.mark.occur:
after.choice:

sel_inv_amt = sel_inv_amt + tfacp200.amth(actual.occ)

dilipk.pandey
15th March 2007, 08:26
Dear Friend,

Thanks alot for your reply, but I am using that tfacp200.amth(1) just to select the 1st element from the table that is amount in home currency, and replacing it with (actual.occ), will not solve my problem, and even if I will remove this "(1)" then it will give me the error "Operations with arrays not allowed.

"...
Please Help me...
Thanks again.
Dilip

Hitesh Shah
15th March 2007, 14:31
If u accumulate the values in a function called with do.occ.without.update , u will be able to successfully total the values .

mark_h
15th March 2007, 14:47
Hmmm- why don't you try this

choice.mark.occur:
after.choice:
sel_inv_amt = 0
for i=1 to filled.occ
if mark.table(i) then
sel_inv_amt = sel_inv_amt + tfacp200.amth(1)
endif
endfor
iamt = sel_inv_amt

Or are you trying to sum more records than are on one display? Of course I have not tried something like this and I am not sure if "unmarking" a record calls this routine.

shah_bs
15th March 2007, 19:19
Hello Dilip.

I was curious if it was possible, so I gave it a few minutes. Here is the concept - you may have to beef it up to make sure it is perfect. As you can see, the logic can be placed in any field of the table, not necessarily tctst902.amnt. Remember that if you scroll to another set of records, the total will initialize to zero, since everything on that new set is not marked.


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

table ttctst902

extern domain tcmcs.int p.totl.c


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

form.1:
init.form:
p.totl.c = 0


|****************************** field section

field.tctst902.name:
before.field:
if marked
then
if mark.table(actual.occ)
then
p.totl.c = p.totl.c + tctst902.amnt
else
p.totl.c = p.totl.c - tctst902.amnt
endif
else
p.totl.c = 0
endif
display("p.totl.c")
refresh()

dilipk.pandey
16th March 2007, 07:33
Dear Seniors,

Thanks a lot for reply...thanks to everybody...
And specially to Shah....it worked...I did it on after.choice of choice.mark.occur...

With lots of wishes,
Dilip