If you only want to startup a long running job it is no good idea to let your browser just wait.
A better way is to startup a second Natural Process with call ‘shcmd’ or USR1052N, with
#NATSTARTPATH := '"c:\....\nderun.exe"'
COMPRESS 'PARM=' *PARM-USER INTO #NATPARM LEAVING NO
COMPRESS #NATSTARTPATH #NATPARM ': stack=(logon mylib;' #MYPROG #FILE #DATA ';fin) SCREENIO ASYNCH' INTO USR1052L.OS-COMMAND
You can pass parameters (#DATA - my url encoded to avoid blanks), and if you create a file with an unique name
MOVE EDITED *TIMESTMP (EM=HHHHHHHH) TO #FILE
COMPRESS "C-" *HOSTNAME '_' *PID '_' #FILE '.tmp' INTO #FILE LEAVING NO
you can control the process flow.
Create a empty file with unique name (W3CHECK-RESOURCE see creation parameter) and pass this file name as parameter to the called program.
Now you can check if your program finished:
If you can access the file and the file is not empty (W3READ-RESOURCE - error parameter), you can return the generated data or just display a ready message.
Otherwise your web program returns a page containing at the a
<META HTTP-EQUIV="Refresh" CONTENT="30; URL=' #URL '">
at the section.
Now your browser is in charge to automatically reload your page after 30 seconds (the url above should contains the unique file name as parameter).
If the web program is called again with the name of the unique file just check if your other process is still running (file not accessible or not running see above), then you can return again the “wait” page, otherwise your can return a success message and delete the unique file (W3DELETE-RESOURCE) and you finished without any timeout problems form bowser tcp/ip or what’s else in between…
You can also think of a cancel button - if your background program checks from time to time if the unique file still exists. If it has been deleted - just finish.
Now you have implemented a basic ‘web batch’ - may you need a queue mechanism to avoid to much running ‘batch’ programs, or a console using
W3LIST-RESOURCE to display all ‘running’ and ‘finished’ ‘web batch’ programs…