pjohns
5th October 2011, 14:55
Hello,

I'm having issues with totals on a pack slip layout I've created.

I have a field called "amount" which is printed in the "after.dico.5" layout only if the pack slip is raised for a certain customer. This field is a total for each line on the pack slip.

If I print one pack slip for this customer the total is correct. If I print a number of pack slips which may or may not be for this customer the amount field ends up being a total of ALL pack slips. I've tried resetting the amount field each time on the after.dico.5 layout but it's not working. I also have a detail layout which is specific to this customer which is where I'm calculating the amount.

Can I please ask some of you clever Baan users to help me out with this?

before.program:

amount = 0

detail.20:
before.layout:

select tdsls040.cuno
from tdsls040
where tdsls040._index1 = {:tdsls040.orno}
as set with 1 rows

selectdo
endselect

if (tdsls040.cuno = "SE8900" or tdsls040.cuno = "SE2000") then
lattr.print = false

endif

detail.22:
before.layout:

amount = amount + tdsls045.amnt

select tdsls040.cuno
from tdsls040
where tdsls040._index1 = {:tdsls040.orno}
as set with 1 rows

selectdo
endselect

if (tdsls040.cuno <> "SE8900" and tdsls040.cuno <> "SE2000") then
lattr.print = false
endif


after.dico.5:
before.layout:

lattr.print = false
if tdsls040.cuno = "SE8900" or tdsls040.cuno = "SE2000" then
lattr.print = true
endif

after.layout:

amount = 0

dmcnally
5th October 2011, 16:54
Hello PJohns,

If I understand your code correctly, you are incrementing the variable "amount" every time, regardless of the value of cuno. Try putting the statement amount = amount + tdsls045.amnt within your "if" statement so it will only be incremented for the desired condition.

Best Regards,

Dave M.

mark_h
5th October 2011, 17:40
I was just posting the samething and got side tracked. The other thought I had was - should you only get the tdsls040.cuno once in the detail layouts? It should be available in the other layouts from the first select.

pjohns
5th October 2011, 18:36
Dave, Mark,

Thank you for your replies.

Putting the "amount = amount + tdsls045.amnt" within the "if" statement resolved my issue.

The first select does make cuno available in the other detail layouts.

Thanks again.

Philip