ltannous
16th January 2003, 16:00
I have written in my report script the following:
before.layout:
select tiitm001.*
from tiitm001, tdsls045
where tiitm001.item = :tdsls045.item
selectdo
endselect
if tiitm001.hatc = " "
and tiitm001.item = tdsls045.item then
message("Warining HS code not found for %s",tdsls045.item)
endif
exit()
What happens is that there are 2 items with no HS codes, the message displays one item then exits. How can I display all items then exit, without printing?
dbclark79
16th January 2003, 18:06
Couple of recommendations for your script:
1. You have "tdsls045" in your FROM clause but not in your WHERE clause. This may be confusing to the database driver.
2. Put the block of code containing your message in the SELECTDO section of your script (after SELECTDO and before ENDSELECT). This section of code will execute for every record selected in the SELECT statement.
3. Avoid using "exit()" in scripts. It is best to program the code such that it naturally completes execution of the script and empties the stack gracefully.
Good Luck!
-David
ltannous
16th January 2003, 23:08
I have put the if statment within the select statement, however, the message appears, but the report is still printed. I need the report not to send if any item is missing the hs code.
Basically display the items that have no hs code, then exit instead of print.
evertsen
17th January 2003, 02:51
I take it that the program source is not available? I don't think you can get away with not printing anything unless you put your code there.
ltannous
17th January 2003, 05:31
I have the session code. I will try to enter it there.
mark_h
17th January 2003, 06:32
Just thought I would mention that you could have used the after.receive.data event in the script - see this post (http://www.baanboard.com/baanboard/showthread.php?s=&threadid=7020&highlight=Report). You could have read through the records and if that field was empty then you could have exited the report. BUT the best solution is to change the session script - a lot easier and cleaner.
Mark
ltannous
17th January 2003, 20:10
I have added the following to my sesison script, but the session does not exit properly.
.......................
selectdo
select tiitm001*
from tiitm001
where tiitm001.item = :tdsls045.item
selectdo
if tiitm001.hatc ="" then
message("NO HS CODE")
exit()
endif
rprt_send()
endselect
endselect
}
mark_h
17th January 2003, 20:52
Without knowing the rest of the script - you could try execute(end.program). That should take care of it - BUT be aware that if the rprt_send has executed this may leave a report hanging for the user. If this is the case then check your data before opening the report or sending anything to the report.
Mark
evertsen
17th January 2003, 21:09
I never had any luck with exit() but always used end() instead (though they are supposed to behave the same).
lbencic
17th January 2003, 22:44
The exit() command is for 3GL scripts, end() and execute(end.program) should be used for 4GL.
dnnslbrwn
18th January 2003, 00:17
Don't know what this will do to performance, but why don't you validate that the data is clean before printing anything?
'
HC.problem = false
select tdsls045.item
from tdsls045
where [some rules that you choose]
and tiitm001._index1 = { tdsls045.item }
and tiitm001.hatc = ""
group by tdsls045.item
selectdo
message("Item has no HC" & tdsls045.item)
HC.problem = true
endselect
if HC.problem = false then
[perform original select statement with send_rprt()]
endif
'
Cheers,
-Dennis
PS: Noticed that code gets prettied up... but only after a while. Is the moderator doing this for us? I tried adding the same strings around my code here.... but doesn't seem to work in the preview reply
mark_h
18th January 2003, 00:22
Sometimes the moderator does edit the post and put in the code tags. If you can edit your post then you can see where I put in code=baan and /code tags - do not forget these are enclosed in []'s. So you can do this your self sometimes I just like to cleanup the code. :)
Mark