Svidos29
14th September 2018, 13:50
Hi all,
i've a problem in a after field custom that i've created, it is sorted by a field that i've inserted in input fields and i want that if that field is blank, the report mustn't print that row. How can i manage it ?
this is my function :
after.orco.1:
before.layout:
select tdsls401.*
from tdsls401
where tdsls401._index1 = {:tdsls400.orno}
and tdsls401.pono > :r.pono
as set with 1 rows
selectdo
get.ccde()
get.item.count()
get.item.wght()
get.ccde.dsca()
r.pono = tdsls401.pono
selectempty
lattr.print = false
endselect
after.layout:
if lattr.print = true then
layout.again()
endif
In this way it prints all the rows that it finds, but also the one's with the blank record.
mark_h
17th September 2018, 16:36
I am not sure I get your request. From the looks of the code it continues to print until it finds an empty records. If you are not wanting to print based off an input field then just put an if then around the select statement and make lattr.print = false. Then in the after layout put another if then around the layout. again. I typically do no use lattr.print to see if I need print a layout again - I usually use a variable of some sort.
Svidos29
17th September 2018, 16:44
Hi,
sorry but i should explain better, my problem is in the get.ccde() function that is this:
function void get.ccde()
{
r.ccde = ""
no.ccde = false
select tcibd001.ccde:r.ccde
from tcibd001
where tcibd001._index1 = {:tdsls401.item}
group by tcibd001.ccde
selectdo
if isspace(r.ccde) then
no.ccde = true
endif
selectempty
endselect
}
There i group my codes by the field .ccde, there i want that if a .ccde is empty, the system have to skip the record to the next that is not empty. The problem is that if i put lattr.print = false ( in this function get.ccde) it will not print the last record that is NOT empty..
I hope explained myself, in case, answer to the thread. I will give u any information..
Thanks!
mark_h
17th September 2018, 17:03
Rather than using lattr.print for the layout again. Can you use something else? Then inside the get.ccde you could set lattr.print to false. to just skip this records. I mean if just check to see if another r.pono exists before the layout again. Something like this - probably needs some tweaks since I was winging it.
after.orco.1:
before.layout:
select tdsls401.*
from tdsls401
where tdsls401._index1 = {:tdsls400.orno}
and tdsls401.pono > :r.pono
as set with 1 rows
selectdo
get.ccde()
if no.ccde then
lattr.print = false
continue
else
lattr.print = true
endif
get.item.count()
get.item.wght()
get.ccde.dsca()
r.pono = tdsls401.pono
selectempty
lattr.print = false
endselect
after.layout:
select tdsls401.*
from tdsls401
where tdsls401._index1 = {:tdsls400.orno}
and tdsls401.pono > :r.pono
as set with 1 rows
selectdo
found.one = true
selectempty
found.one = false
endselect
if found.one then
layout.again()
endif
Svidos29
18th September 2018, 10:30
I'll try it today, thanks. I have some doubts for the use of lattr.print = false in the before.layout, because if i pass by the lattr.pint = false, it would not pass by the after.layout.
I will update the post asap.
Thanks again.
Svidos29
18th September 2018, 10:47
It seems it's not working. Because (via debug) i see that if the system passes through the lattr.print= false , it will exclude all the thing after and it passes directly to the next layout..
mark_h
18th September 2018, 14:33
So it skips the after layout?
mark_h
18th September 2018, 14:40
I wonder if something like this might work - notice I commented out the as set with 1 rows. For some reason in all my years of coding I do not think I have used break inside a selectdo statement.
after.orco.1:
before.layout:
select tdsls401.*
from tdsls401
where tdsls401._index1 = {:tdsls400.orno}
and tdsls401.pono > :r.pono
| as set with 1 rows
selectdo
get.ccde()
if no.ccde then
continue
endif
get.item.count()
get.item.wght()
get.ccde.dsca()
r.pono = tdsls401.pono
break
selectempty
lattr.print = false
endselect
after.layout:
select tdsls401.*
from tdsls401
where tdsls401._index1 = {:tdsls400.orno}
and tdsls401.pono > :r.pono
as set with 1 rows
selectdo
found.one = true
selectempty
found.one = false
endselect
if found.one then
layout.again()
endif
bdittmar
18th September 2018, 14:58
As Mark said, should have a strange behavior.
Index 1 of tdsls401 is orno , pono , sqnb
so the select should be inrange.
[/QUOTE]
Regards
Svidos29
18th September 2018, 15:48
Finally i did it ! Thanks Mark! Here below i'm attaching the code!
after.orco.1:
before.layout:
select tdsls401.*
from tdsls401
where tdsls401._index1 = {:tdsls400.orno}
and tdsls401.pono > :r.pono
| as set with 1 rows
selectdo
lattr.print = true
get.ccde()
if no.ccde then
lattr.print = false
continue
endif
get.item.count()
get.item.wght()
get.ccde.dsca()
r.pono = tdsls401.pono
break
selectempty
lattr.print = false
endselect
after.layout:
select tcibd001.ccde:r.ccde
from tcibd001
where tcibd001._index1 = {:tdsls401.item}
and tcibd001.ccde <> ""
group by tcibd001.ccde
selectdo
found.one = true
selectempty
found.one = false
endselect
| if lattr.print = true then
if found.one then
layout.again()
endif