skip to main content

Web Direct 2.0 option : How to Handle Program Exit

How to Handle Program Exit
By default, when the program terminates due to GOBACK statement, the last screen remains in the web-browser, but is no longer active. This may result in the impression that the program hanged, while it was just terminated.
The proper way to handle the program exit, is by redirecting the browser to a different web page, that may be the page from which the application was launched or the home page of your website or whatever else.
This objective is achieved through JavaScript.
In order to make WebDirect 2.0 execute JavaScript code:
       77 MY-JAVA-SCRIPT PIC X ANY LENGTH
                         VALUE '<script type="text/javascript">
      -                        'form = document.createElement("form");
      -                        'form.method = "GET";
      -                        'form.action = "http://www.veryant.com";
      -                        'form.target = "_self";
      -                        'document.body.appendChild(form);
      -                        'form.submit();
      -                        '</script>'.
The above code redirects the browser to Veryant's home page. Change the URL according to your needs.
CALL "WD2$RUN_JS" USING MY-JAVA-SCRIPT
When a program is running and the user closes the browser window or someone stops the web or application server, an exception with value 91 in crt-status is sent to program in order to terminate the ACCEPT.
Note: always remember to use GOBACK instead of STOP-RUN to make the program exit.

Copyright (c) 2017 Veryant
Contact us
Please share your comments on this manual or on any
Veryant product documentation with the email button at the top left