jon_lane
15th June 2007, 17:17
For a week I've been writing this report so now I'm in need of a nudge to the solution.

I have a query that returns the eco stock. But then also the production orders that create the allocation AND the history of the usage.

My report prints the layouts correctly, but does not calculate the usage by quarter1, quarter2 etc.
Bottom line - I don't understand the scripting language

Please correct my attempt at the script or point me in direction of a good book.

The before.detail = eco stock line items
The detail is the production order information for each simular item

Hope this make sense to someone!
Many thanks

|******************************************************************************
|* tdsqlecostoc5 VRC B40P c4 JB
|* Eco Stock below re-order point
|* jlane
|* 07-06-07 [12:57]
|******************************************************************************
|Calculate the annual issue by adding up the months issues, report in 1st period and second period

declaration:
domain tcamnt quarter1
domain tcamnt quarter2
domain tcamnt quarter3
domain tcamnt quarter4
domain tcqiv1 stoc
domain tcqiv1 ordr
domain tcqiv1 allo
domain tcqiv1 reop


before.field:
quarter1=(tdinv750.aupp(1)+tdinv750.aupp(2)+tdinv750.aupp(3))
quarter2=(tdinv750.aupp(4)+tdinv750.aupp(5)+tdinv750.aupp(6))
quarter3=(tdinv750.aupp(7)+tdinv750.aupp(8)+tdinv750.aupp(9))
quarter4=(tdinv750.aupp(10)+tdinv750.aupp(11)+tdinv750.aupp(12))

mark_h
15th June 2007, 18:15
Post your actual script. It should look something like this:

after.some.field.1:
before.layout:

Where some.field is a sort field. This post should probably be in the tools forum.

mark_h
15th June 2007, 19:38
Jon,

In 4c4 on form 2 of ttadv3130m000(or ttadv3130s000) you should see a view script button. That should allow you to view a report script. Usually what you will see in a report script is a layout name - for example: header.1:, detail.1, etc. Then for each of those layouts you have before.layout and after.layout. The before.layout means do this before you actually print the layout, after.layout means after the layout do this.

Without knowing the layouts on your report my first guess is that this might work

detail.1:
before.layout:
quarter1=(tdinv750.aupp(1)+tdinv750.aupp(2)+tdinv750.aupp(3))
quarter2=(tdinv750.aupp(4)+tdinv750.aupp(5)+tdinv750.aupp(6))
quarter3=(tdinv750.aupp(7)+tdinv750.aupp(8)+tdinv750.aupp(9))
quarter4=(tdinv750.aupp(10)+tdinv750.aupp(11)+tdinv750.aupp(12))

Then just compile it in debug mode. You can step through it seeing everything that is executed.

jon_lane
18th June 2007, 13:02
Thanks,

Finally I'm getting somewhere. Now all the fields print, the sums work but..the order is incorrect.

As can be seen in the attached files after the change of each item the calculation for usage is made for Q1, Q2 etc. according to tdinv750.year, this is printed inbetween the second detail line for production usage. So the production work order lines are repeated, when the .year changes.

I have amended a txt file showing the required output - and the given output.

And in the .doc all the other sql layout and script.

Many thanks

mark_h
18th June 2007, 15:33
Okay - looks like you are using easy sql. I am not sure you can get what you want with just layouts. Here is what I think you can do:
(1) remove tisfc001,tdinv150 from the query - this will get moved to the report script.
(2) Changes to the layouts:
(a) leave current before item layout alone
(b) make detail.1 contain the quarter information
(c) create after.field layout for item. In this layout put in your tisfc001 fields
(3) Now change the report script to include the after.tiitm001.item.1 layout. Here is where you will query tisfc001 and tdinv150 for all of the production orders. You will have to use layout.again to get this to work. No promises this little script will work since I usually do not use layout.again().

declaration:
table ttisfc001
table ttdinv150
domain tcorno hold.order

before.program:
hold.order = 0

after.tiitm001.item.1:
before.layout:
select tdinv150.qana, tisfc001.orno, tisfc001.prdt
from tdinv150, tisfc001
where tdinv150._index2 = {:tditm001.item}
and tisfc001._index1 = {tdinv150.orno)
and tisfc001.orno > :hold.order
order by tisfc001.orno
as set with 1 rows
selectdo
selectempty
tisfc001.orno = 0
endselect
if tisfc001.orno = 0 then
lattr.print = false
else
hold.order = tisfc001.orno
endif

after.layout:
if tisfc001.orno >0 then
layout.again()
endif


I think this will give you first the item information, then the two yearly break down by quarters, then you can go find all the orders. Maybe somebody more familiar with layout.again can make better recommendations, I did this off the top of my head. Searching for layout.again will give more information.