baan2ion
24th September 2012, 12:29
AFS to run the customized Print report. I am not able to capture the message / error " No Data within Selection "

When the data is not found in the particular selection the baan report give by default the message that "No Data within Selection " I wanted to capture this message in the AFS.

coding is :
stpapi.put.field("whprn2400m002", "spool.fileout", trim$(file.name))
stpapi.put.field ("whprn2400m002", "repo", str$(etol(tcyesno.yes)))
stpapi.set.report("whprn2400m002", "rwhprn2400m0021", "ASCIF" , error.msg)
stpapi.print.report("whprn2400m002", error.msg)
stpapi.end.session("whprn2400m002", error.msg)

The above coding does not capturing these message . Also checked with
stpapi.continue.process("session code", error message) but with no use.

Any other coding required to capture the message/error.

thanks

mark_h
24th September 2012, 15:35
First are you sure spool.fileout is really a form field ont he session? I usually just set spool.fileout before running the report.

Anyway this is a warning and not really an error. After the continue.process statement try stpapi.get.mess.code("whprn2400m002", msg) to see if it gets the warning. That is how I trap it. Something like this:


| calling code
print_tisfc0418m000(zoom.orno, zoom.orno,errmsg)
if errmsg(1;14) ="No data within" then

|Last lines from the library
stpapi.continue.process("tisfc0418m000",msg)
stpapi.get.mess.code("tisfc0418m000",msg)
stpapi.end.session("tisfc0418m000")

baan2ion
24th September 2012, 15:54
thanks for your reply.

I have tested with that also but the message comes is "Command disabled" in

stpapi.get.mess.code("whprn2400m002", error.msg). If i directly run the print session the "No Data within selection" comes.

pasting the code.

-------

stpapi.set.report("whprn2400m002", "rwhprn2400m0021", "ASCTXT" , error.msg)
stpapi.continue.process("whprn2400m002", error.msg)
ret.str = stpapi.get.mess.code("whprn2400m002", error.msg)
stpapi.print.report("whprn2400m002", error.msg)
stpapi.end.session("whprn2400m002", error.msg)

mark_h
24th September 2012, 16:07
Well you should only need the continue or the print.report command - I don't think both. Maybe if you remove the continue and use the print.report followed by the get.mess.code.

Is this LN or Baan 5? The document I have says for BaanERP use the stpapi.form.command. In either case the print.report should work - at least I think so.

BaanInOhio
24th September 2012, 22:49
I don't think that you can trap that error in AFS since it is a warning / result of an 'rprt_close' (where you can use the argument to disable it) or 'brp.close'. You have an option when printing to a file to simply see if the file is present where you directed it to go when setting 'spool.fileout' using something like 'seq.fstat.local'. Easier to find the file if you use a specific directory/folder when setting it (like $BSE_TMP" - set with bse.tmp.dir$ call). This works for standard and custom report sessions.

Since you are running a custom report, you can add logic to provide your own message when no data found when you never call 'rprt_send' or 'brp.ready'.

cte sistemas
25th September 2012, 01:58
This is a warning.
The form to do that is using the function stpapi.get.mess.code() and with a debugger you'll see the error code generated.

baan2ion
25th September 2012, 07:38
thanks all,

The "No data within selection " message is not captured in any set of command. Tested with all combination using stpapi.get.mess.code syntax after print.report/ continue. It gives blank in error message.

I have already done the alternative by checking the file size of txt report generated. But I wanted to capture the the message via AFS. So to reduce the processing and time.

mark_h
25th September 2012, 16:23
stpapi.get.mess.code is how I trap this - if this is not working it could be because of several reasons. The first is some how another message makes it into the buffer - I have never used this, but something else that might work is below. I got this from the documentation.


stpapi.put.field("dtfsa1101s000", "dtfsa101.seno", str$(i.seno))
stpapi.put.field("dtfsa1101s000", "dtfsa101.name", name)
retval1 = stpapi.insert("dtfsa1101s000", true, error.msg)
if not retval1 then
while true
error.code = stpapi.get.mess.code("dtfsa1101s000", true, error.msg)
if isspace(error.msg) then
break
endif
rep.message = error.msg
rprt_send()
endwhile
retval2 = stpapi.recover("dtfsa1101s000", recover.msg)
endif


If the above does not work then you might need to update to the latest stpapi components. Not sure how big a deal that would be, because even then it could be the session itself.

baan2ion
26th September 2012, 08:25
thanks mark,

But not working. The message is not captured in "stpapi.get.mess.code".

Everything working expect capturing message, So empty file generated in fileout. So i have gone alternative by checking file size after file generated.