ltannous
7th October 2004, 16:33
How can you get the running totals for a mulit occurance form field:
field: test
test =1 test=2 test=3
totl =1 totl=3 totl =6
renzosing
7th October 2004, 16:40
because i reset print.amount to 0, if i set the current value that is being stored in print.amount to another variable, i get the running total.
i.e.
print.amount = 0
select
from
where
selectdo
print.amount = x + y
sum = sum + (x+y)
endselect
ltannous
7th October 2004, 16:50
I only have one field that requires a running total
Select sum(timrp010.qana):orders
from timrp010
where timrp010.date inrange :var and :var1
and timrp010.item = :timrp943.item
The total per period is what I need the running total for
I tried the following, but the results carry over to all items.
plndinv = orders + plndinv
My form field is plndinv
renzosing
7th October 2004, 17:01
This is something I posted earlier today.
I'm trying to using the total line option. The way it is coded now, the total line will contain the value of the last total. I also have played around with it and had it code where I would get to total, but it kept a running total and I want it to list the different amounts and then display the total at the bottom. Sample script is below.
before.program:
fattr.total.line = true
print.amount = 0
field.print.amount:
before.display:
select tdsls401.oamt:print.total,
tdsls401.ldam:print.discnt
from tdsls401
where tdsls401.orno = :tdsls401.orno
and tdsls401.sqnb = 0
and tdsls401.item = :tdsls401.item
selectdo
print.amount = print.amount +
(print.total - (print.discnt(1) +
print.discnt(2) +
print.discnt(3) +
print.discnt(4) +
print.discnt(5) ))
sum = sum + (print.total - (print.discnt(1) +
print.discnt(2) +
print.discnt(3) +
print.discnt(4) +
print.discnt(5) ))
display.total.fields("print.amount",sum)
endselect
This code will give me a running total, which is not what I want.
ltannous
7th October 2004, 17:07
I saw the post earlier and fattr.total.line does not work in BaaN lV
lbencic
7th October 2004, 17:26
Yep, Baan IV does not support, it's a nice feature even if hard to use in Baan V.
I would suggest calling those fields single occurance and, if possible, putting them at the top of the form. Even in Baan V you have to calculate them yourself.
ltannous
7th October 2004, 18:42
I works as a multi occurance field, but everytime I select the last record option on the form, the values change.
This is what I have for my mulit occurance field plndinv
select sum(timrp010.qana):orders2
from timrp010
where timrp010.item = :timrp943.item
and timrp010.date inrange :var and :var1
selectdo
suma = orders2
plndinv = suma + plndinv
selectempty
suma =0
plndinv = 0
orders2 = 0
endselect
The values appear correct, until i hit the last group record for the item.
lbencic
7th October 2004, 18:54
O, I see, total on each row cumulative. Yep, that would probably work execpt each time you redisplay the form, such as during last set, you have to reset the total variables first. I would think there's a lot of things that would cause it to refresh, so take a look at the sections and see where you need to reset. Put in something like:
choice.last.view:
before.choice:
** reset total fields
ltannous
7th October 2004, 21:01
This works, but how can I keep the value until my next item appears??
What happens is the following:
I have the items seperated by item / year. I need to select the next view and hold the previous view if the item is the same.
(first group)
Item ABC
Year 2004
week 50 week51 week 52
plndinv =100 plndinv=200 plndinv=300
Next group
Year 2005
week 1 (100 pcs) week2(150)
plndinv 400 plndinv = 550
lbencic
7th October 2004, 21:43
Ugh. That's going to be fun to control. I guess you can start by conditionally resetting the totals when they do the change views (next.view / prev.view - have you considered prev.view?)...reset the totals only if the new item is different (save the item in the before.choice section..)
Having trouble visualizing your form..what are the rows? Are there rows or is this the vertical form..
Maybe a screen shot would help..?
ltannous
7th October 2004, 22:40
I have attached the session form. It seems to work now. I used some of the other choice.option.
My next delima is this:
I need to subtract the available inventory from the first occurance of plndinv only and then continue with the plndinv summation.
lbencic
7th October 2004, 23:03
Wow, that's purdy.
Not sure of all the code / sections, but is the predefined variable "actual.occ" filled when you need it? If so you can do something like:
if actual.occ = 1 then
subtract your value
endif
ltannous
8th October 2004, 18:49
My session is still not reliable. When I switch views, the data changes.
I have attached my entire code.
Any futher assistace would be appreciated.
Hitesh Shah
9th October 2004, 16:41
Not sure whether it helps or not. We generally do not do cross record/occ manipulations on variables used as input/display field in multi-occ screen. We use arrays of fattr.occurnr to track the multi-occ values. Probably this helps.
Further i did not c any multi-occ functions like do.occ , do.all.occ etc in ur script. U can use do.all.occ function to get values in all occurrence.
When u use do.occ functions , occurrence fields are actually re-displayed so before/display , after/display sections are also invoked automatically. You need to take care off them.
ltannous
12th October 2004, 18:48
I tried to use the do.occ, but no luck. It didn't do anything.
My session is working. The issue is when I select the next view option twice, the running totals change.
At first they appear ok, but selecting the next view again, the numbers change. The session is similar to timps3101m000, where my item/data continues on the next display for the following buckets.
The problem is with the frstlvl field.
Program Script:
31 before.program:
32 var1 = 0
33 var = 0
34 sfty = 0
35 orders1 = 0
36 stoc = 0
37 war = ""
38
39 form.1:
40 init.form:
41 color = 0
42 color1 = 0
43 create.frame()
44 frstlvl = 0
45 pstlvl = 0
46 stoc = 0
47 war = ""
48
65
66 field.slash:
67 before.display:
68
69 slash = "/"
70
71 field.war:
72 before.display:
73 war = ""
74 refresh()
75 if actual.occ = 1 then
76 hold.cwar = ""
77 endif
78 get.warehouse()
79
80 field.tiitm001.stoc:
81 before.display:
82 |Get total inventory from item data
83 select tiitm001.*
84 from tiitm001
85 where tiitm001.item = :timrp943.item
86 selectdo
87 endselect
88 |If inventory is less the 1 red appears
89 |Else green appears
90 if tiitm001.stoc < 1
91 then color = RGB.RED
92 else
93 color = RGB.GREEN
94 endif
95
96 change.frame()
97
98
99 field.tdpsc001.ldeq:
100 before.display:
101 select tdpsc001.*
102 from tdpsc001
103 where tdpsc001.suno = :timrp943.suno
104 and tdpsc001.item = :timrp943.item
105 and tdpsc001.cont = :timrp943.cont
106 and tdpsc001.pono = :timrp943.pono
107 selectdo
108 endselect
109
110
111 field.timrp943.dqty:
112 before.input:
113
114 if timrp943.reqf <> tdpsc.reqf.daily
115 then attr.input = false
116 endif
117
118 field.timrp943.totq:
119 before.input:
120
121 if timrp943.totq <> timrp943.dqty(1) + timrp943.dqty(2)+ timrp943.dqty(3) + timr
p943.dqty(4) + timrp943.dqty(5) + timrp943.dqty(6) +
122 and
123 timrp943.reqf = tdpsc.reqf.daily
124 then
125 message("total does not match")
126
127 endif
128
129 field.orders:
130 before.display:
131
132 orders = 0
133 sfty = 0
134 var = timrp943.dtwk
135 var1 = timrp943.dtwk + 6
136 select sum(timrp010.qana):orders
137 from timrp010
138 where timrp010.item = :timrp943.item
139 and timrp010.kotr = tckotr.requirement
140 and timrp010.date inrange :var and :var1
141 selectdo
142 endselect
143 display(orders)
144 refresh()
145
146
147 field.stoc:
148 after.display:
149 if stoc = 0
150 then
151 print.const(" ")
152 endif
153
154
155 field.frstlvl:
156 before.display:
157
158 date = date.num()
159 if actual.occ = 1
160 and timrp943.year = 0000
161 and timrp943.item = timrp943.item
162 then pstlvl = timrp943.totq
163 plndinv = 0
164 else
165
166 if actual.occ = 1
167 and timrp943.dtwk <=date
168 and timrp943.year <> 0000
169 then
170 select tiitm001.*
171 from tiitm001
172 where tiitm001.item = :timrp943.item
173 order by tiitm001._index1
174 selectdo
175 endselect
176 hold.item = timrp943.item
177 sfty = tiitm001.stoc - tiitm001.sfst
178 frstlvl = timrp943.totq + sfty - orders + pstlvl
179 plndinv = sfty - orders
180 hold.frstlvl = frstlvl
181 else
182 pstlvl = 0
183 plndinv = plndinv - orders
184 frstlvl = frstlvl+timrp943.totq - orders
185 endif
186 endif
187 sfty = tiitm001.stoc - tiitm001.sfst
188
189 if actual.occ = 1
190 and timrp943.year = 0000
191 and timrp943.item = hold.item
192 then
193 frstlvl = 0
194 frstlvl = frstlvl + timrp943.totq + sfty - orders
195 endif
196
197 field.dayoh:
198 before.display:
199
200 dayoha = (orders / 5)
201 dayoh = frstlvl / dayoha
202
203
204 choice.last.set:
205 before.choice:
206 frstlvl = 0
207 orders = 0
208 pstlvl = 0
209 plndinv = 0
210
211 choice.prev.set:
212 before.choice:
213 frstlvl = 0
214 pstlvl = 0
215 orders = 0
216 plndinv = 0
217
218 choice.prev.view:
219 before.choice:
220
221 frstlvl = 0
222 pstlvl = 0
223 orders = 0
224 plndinv = 0
230
231
232 functions:
233 function create.frame()
234 {
235 frame.id = create.object(DsCgwindow, current.mwindow(),
236 DsNx, 990, DsNy, 44,
237 DsNwidth, 12, DsNheight, 12,
238 DsNbackground, color)
239 update.object(frame.id)
240 }
241
242 function change.frame()
243 {
244 change.object(frame.id,
245 DsNbackground, color)
246 update.object(frame.id)
247 }
248
249
250 function get.warehouse()
251 {
252 war = ""
253 select tdinv001.*
254 from tdinv001
255 where tdinv001._index3 = {:timrp943.item}
256 and tdinv001.stoc > 0
257 and tdinv001.cwar > :hold.cwar
258 as set with 1 rows
259 selectdo
260 war = tdinv001.cwar
261 hold.cwar = war
262 stoc = tdinv001.stoc
263 selectempty
264 war = ""
265 tdinv001.cwar = ""
266 tdinv001.stoc = 0
267 stoc = 0
268 endselect
269 refresh()
270 }
ltannous
15th October 2004, 07:03
I posted the script and there is a print screen of the session for further clarification.
Any ideas would be helpful.
raikar_raviraj
11th January 2007, 06:42
hi,
I am facing the same problem. I want to find the running or cumulative sum in a multi occurence form. i am clueless as to how ill go forward with it. ive gone through the threads but to no avail. Im working on BAAN IV c4.
it would be great if anyone can guide me in this respect.
mark_h
11th January 2007, 17:52
Here is oneway do to something like this - I have not done this exact thing, but I think it will work. I have done things like this in other places. Lets say you have a multi-occurence form like this (make item, component are primary index):
Make item
Component Item Standard Cost
Now you want to had a running total for standard cost. Add an addition unrelated(but correct domain) table field to the form. Lets use tfsfc001.copr. Put it on the form and make it multi-occurence and display only. Next go into the script add the table ttisfc001,in the after.display section of the component item calculate the tisfc001.copr field. Something like this:
sometable.comp:
after.display:
tisfc001.copr = calc_runningtotal()
Of course you have to be able to do a query to calculate your running total and not rely on the display. Also if you are inserting records you make have to add other events to calculate running totals. I did it for grins and giggles on one of my test forms. See the attached - I did not test inserting and I covered up pieces of the tables which might be comp sensitive data.
Hitesh Shah
13th January 2007, 16:58
Running / cumulative totals are possible in outputs and are somewhat ambiguous in an UI script (in which so many user actions are possible and we dont know how u wish ur totals to behave in those circumstances ) .
However this too can be done (as we have done many places ) provided ur requirements are more detailed .