FrenkR
4th February 2019, 16:17
Hello,
is there any mechanism how to report error inside report script and stop generating/running report?
I would like to create an error inside report script and send it to session that runs report. Instead displaying report, underlying session should display error only.
Rgds,
Frenk
Ajesh
5th February 2019, 12:03
What errors do you mean? Compilation Errors, obviously get caught at the time of compilation and reports do not run with that.
Computational errors like division by zero etc create a Fatal error which will result in crash of the sessions..
FrenkR
6th February 2019, 11:17
Hello,
inside report script, I would like to stop further report processing and nofify parent process, that report should not be printed. E.g. if sales order has no "confirmation date" in some order line, then I would stop further report generation and show message e.g. "Position 10 has no confirmation date". No report should be printed, only message from "parent" process should be displayed.
Is this even possible?
Ajesh
6th February 2019, 12:00
One Option is to check in the Program Script itself , if report is to be printed to not? If report is not to be printed then don't call the report at all.
Other option is to check in the report (before.program section) if report is to be printed or not, If not then write exit() or end()..
FrenkR
6th February 2019, 23:34
have no code of "program script", only report. So no option to cancel reporting process. Question was, if reporting "framework" has any built-in mechanism to stop further processing and retrieve error (e.g. dal error message or similar) from report script if report script cancel report generation for some reason.
mark_h
6th February 2019, 23:42
I am not sure about LN, but in 4c4 if I started generating a report and then stopped it in the report process, when it dropped back to the parent it would still print what was already generated. I do not think it would kill it. In my case what I would do in 4c4 is in the parent session I would build code to check before I even started generating the report to make sure nothing printed. Now you probably need to wait for someone that knows more about baan 5 or LN which ever version you are on.
Ajesh
8th February 2019, 08:56
There is no processing supposed to happen in Report scripts;its just sending records and printing. That's it. All the processing is supposed to happen in the UI script or the DB layers.
vinceco252
8th February 2019, 17:31
^Tell that to the tfcmg1260 check reports. :)
FrenkR
12th February 2019, 09:42
First, thank you for your answers. My wishful thinking was that there exist some "magic" undocumented cancellation function. Actually it is quite strange that development team didn't design such functionality. Because of full scripting support inside report, I would expect that many things inside script can go wrong. So, cancellation function would be very welcome option.
tmannais
12th February 2019, 13:04
Try
message("Error Message")
stop()
In the
before.program
avpatil
12th February 2019, 18:17
Well you can try building logic say in header of report and if it is an error set variable that will not print the layout to print.
FrenkR
14th February 2019, 20:43
Hello,
message() break AFS scripts, so this is not a solution. Also idea was to cancel printing inside arbitrary section, including "end.program" section. So, inside ideal case, at least partial report generation, that should be cancelled, is always already done.
As I understand now, there is no such functionality, except post-processors in device "level".
mr_suleyman
17th February 2019, 01:16
Hello,
Why dont you create new main program in which call the program which have no source file. I think that you can make pre-check by using user inputs or range for orders or you can find which orders will be printed. If there is no error in pre-check go ahead for reporting.
bhushanchanda
19th February 2019, 11:49
Hi,
You may have to kill the report by finding it process ID.
Here's a thread (http://www.baanboard.com/baanboard/showthread.php?p=198888)with some links I posted about how to do that.
Things to take care -
Check the report script and see if there are any db transactions taking place. If there are any important tables being updated, you may have to deal with that. Also, check what tables are being updated from program script for getting the report printed, you may need to revert some of the data there too.
e.g. When you print a Purchase Orders, there's no way to reprint it without selecting "Reprint Option". It means, a table say tdpur400 or something is updated from program script when the corresponding report is printed. So, all those things needs to be manually taken care.
There is no function available to send an error code back to program script to abort all the ongoing transactions when its a standard source without source code. So, it will be tedious task to handle it if there is any complex report script and corresponding program script related to this change.
So, please consider everything before making the move.
cmartin
24th February 2019, 12:14
Hello,
message() break AFS scripts, so this is not a solution. Also idea was to cancel printing inside arbitrary section, including "end.program" section. So, inside ideal case, at least partial report generation, that should be cancelled, is always already done.
As I understand now, there is no such functionality, except post-processors in device "level".
Predefined variable api.mode
In 4GL scripts, the predefined variable api.mode is present to know whether the session is started by the AFS. If different behavior is needed for sessions that run in API-mode and sessions with a normal user-interface, this variable must be used.
If a subsession is started from the active session, this activated session is automatically also started in api.mode
garias
10th May 2019, 09:58
^Tell that to the tfcmg1260 check reports. :)
This is the best comment here.. :)