the.oetjoen
19th June 2009, 05:53
Hi Master,
I'm trying to make repeat printing in detail report. Any idea how to implement this in report script.
Here is my script:
declaration:
...
table ttiitm001 | Item
extern domain tcmcs.str16 itemtmp |report desc-dm (ttyp)
extern domain tcmcs.str300m text.note, temp.note |text
extern domain tfgld.quan itemquan
extern domain tcpono lineno
long i, lpos, itemtot
...
before.program:
...
itemtot = 4
lineno = 0
...
detail.10:
before.layout:
...
text.note = "A0001;2|A0002;3|A0003;100|A0005;9"
temp.note = ""
for i = itemtot to 1 step -1
lineno = lineno + 1
lpos = pos(text.note,"|")
if lpos > 0 then
temp.note = text.note(1;lpos-1)
text.note = text.note(lpos+1;len(text.note))
endif
if i = 1 then
temp.note = text.note
endif
ret = string.scan(temp.note,"%s;%d",itemtmp,itemquan)
if not isspace(itemtmp) then
select tiitm001.item, tiitm001.dsca
from tiitm001
where tiitm001._index1 = {:itemtmp}
selectdo
endselect
| message ("no=%d, item=%s, qty=%d", lineno,tiitm001.item,itemquan)
{ what is the code put in here to repeat printing?? }
endif
endfor
...
And this is will be print in report like this:
...
No Item Description Quantity
1 A0001 Item A 2
2 A0002 Item B 3
3 A0003 Item C 100
4 A0005 Item E 9
...
TIA :)
Oetjoen
MilindV
19th June 2009, 06:31
Hi Oetjoen
Give a look at this report script function.
LAYOUT.AGAIN() Evaluate and print layout again.
This may help you.
Thanks & Regards
MilindV
the.oetjoen
19th June 2009, 07:03
I've added the layout.again() function, still does not effect the result. only the last data is shown..
...
No Item Description Quantity
4 A0005 Item E 9
...
Or I'm miss where should I put that function.
Thanks
Oetjoen
MilindV
19th June 2009, 08:06
before.program:
again = false
...
itemtot = 4
lineno = 0
...
detail.10:
before.layout:
if not again then
...
text.note = "A0001;2|A0002;3|A0003;100|A0005;9"
temp.note = ""
endif
|* for i = itemtot to 1 step -1
lineno = lineno + 1
lpos = pos(text.note,"|")
if lpos > 0 then
temp.note = text.note(1;lpos-1)
text.note = text.note(lpos+1;len(text.note))
endif
|* if i = 1 then
if itemtot = 1 then
temp.note = text.note
endif
ret = string.scan(temp.note,"%s;%d",itemtmp,itemquan)
if not isspace(itemtmp) then
select tiitm001.item, tiitm001.dsca
from tiitm001
where tiitm001._index1 = {:itemtmp}
selectdo
endselect
| message ("no=%d, item=%s, qty=%d", lineno,tiitm001.item,itemquan)
{ what is the code put in here to repeat printing?? }
endif
|* endfor
...
after.layout:
if itemtot > 1 then
itemtot = itemtot - 1
layout.again()
again = true |* define some boolean variable
esle
again = false
endif
Refer to this, check the changes that i have made(in red).
You may need to do some changes.
Thanks & Regards
MilindV
the.oetjoen
19th June 2009, 09:20
Hi MilindV,
Thanks for your script. It is work for me. Great Script.
Thanks for your help :)
Oetjoen
mrreds
16th August 2010, 06:39
MilindV ,
I really like your script, it is very clear but, I need now something similar with a dynamic record count number (itemtot = N)
Is there a way to use a count in a select statement? saving it in a variable?
mast_aadmi
16th August 2010, 07:02
MilindV ,
I really like your script, it is very clear but, I need now something similar with a dynamic record count number (itemtot = N)
Is there a way to use a count in a select statement? saving it in a variable?
select count(*):variable_name
from table_name
where [conditions]
selectdo
endselect
This will store the row count in the variable_name.
mrreds
16th August 2010, 07:35
Thank you mast_aadmi!
I'm trying to figurate out how layout.again() works.
While you were replying to his thread I was simulating the script with itemtot = 2.
It is always displaying the last record. I know I´m close to resolve it.
This is my code:
Declaration:
table twhinr150
extern domain tccwar ohcwar
extern domain whloca ohloca
extern domain tcqiv1 ohqty
long itemtot
before.program:
itemtot = 2
detail.1:
before.layout:
detail.2:
before.layout:
if itemtot = 2 then
select *
from whinr150
where whinr150._index1 = {:whinh215.item}
selectdo
ohcwar = whinr150.cwar
ohloca = whinr150.loca
ohqty = whinr150.stks
selectempty
endselect
endif
after.layout:
if itemtot > 1 then
itemtot = itemtot - 1
layout.again()
endif
Could you please help me?
mast_aadmi
18th August 2010, 07:00
Have you written the code properly in the before.layout section?
The condition will only match if "itemtot = 2". layout.again() placement seems fine. This is getting reduced in the in the after.layout section. But check the code in the before.layout section. That doesn't look alright.
Working of layout.again()
When this function is called an internal variable r.layout.again is set to true which results in the entire layout being entered and evaluated again.
sameer.don
18th August 2010, 07:43
Hi mrreds,
you can try following in your report script
detail.2:
before.layout:
if itemtot = 2 then
select *
from whinr150
where whinr150._index1 = {:whinh215.item}
as set with :itemtot rows
selectdo
ohcwar = whinr150.cwar
ohloca = whinr150.loca
ohqty = whinr150.stks
selectempty
endselect
endif
As value of itemtot reduces during every layout.again(), at first iteraion it reads just 2 records and will print ont the report 2nd record.
During secong iteration, when itemtot = 1, it just reads 1 records (2nd last) and prints on the report.
Hence this will print data but in descending order. So to print in ascending order you can use following code:
detail.2:
before.layout:
if itemtot = 2 then
select *
from whinr150
where whinr150._index1 = {:whinh215.item}
order by whinr150._index1 desc
as set with :itemtot rows
selectdo
ohcwar = whinr150.cwar
ohloca = whinr150.loca
ohqty = whinr150.stks
selectempty
endselect
endif
mark_h
18th August 2010, 16:46
This was a duplicate post by mrreds. The problem was resolved in this thread (http://http://www.baanboard.com/baanboard/showthread.php?t=58982).