afdeijkers
8th July 2003, 18:26
Hi there...
My sessions runs in a job.
This session runs every minute. However - there are situations (depending on the conditions) I would like to stop that session and later start the session again - without any user actions.
In other words - would it be possible to start and stop a session (running as a job) programmatically?
Are there any functions in the tools environent one can use in a session which start and / or stops a job?
Can the program / session start and stop itself (job)?
Cheers,
A.
NPRao
8th July 2003, 21:06
Please complete your user profile with regards to the Baan software version, Database software and OS version. This will help other members when diagnosing your problem.
Your requirement is still not clear... can you please more in detail? If it takes 1 minute the process is completed and waits for the next execution. If its not completed then the job is still in running process. If there is any fatal error then the job cannot restart as its not in free status.
But you can use the predefined variable - job.mode to build some logic to start/stop the session execution in a job mode
if not (api.mode or job.process or background) then
get.screen.defaults()
do.something()
endif
string job.device(14) 4
Default device used by job process.
long job.device.requested 4
Indicates whether an output device must be specified when in job mode.
long job.process 4R
Indicates if process is started by a job.
string job.report(15) 4
Report code of report to be used when in job mode.
long job.skip.date.question 4
Indicates if the question "Consider the difference between entered date and system date?" must be skipped.
Also check the 4-GL choice sections -
24 create.job Add session in job 1234 ---- 1234
40 run.job Run job of session 1234 1234 1234
afdeijkers
8th July 2003, 21:16
Hi,
Below my pseudo code: Session that runs in a job (every t1).
[For each t1 (i.e. 30 seconds) do]
1. Check Baan table
2. If Table is Populated then
3. [Stop this job - the session running under this job]
4. Perform some action (execution of another DLL)
5. [Start the job again]
6. Fi
[Endfor]
The reason I'm doing this is because the execution of the DLLs could take more than t1....
Hope this clearify my problem,
A.
Hitesh Shah
9th July 2003, 18:29
If u r in unix , u may use cron function to start a session every 30 seconds.You may put command like ba6.1 session_code .
Alternatively u may start the job in Baan and program ur periodic activity in while/endwhile loop . Use suspend(30000) function to wait for 30 seconds . When the table is populated , don't do anything (but dont stop the job).
It's advisable to keep some conditions to stop the Baan job in the sections run.job (as suggested by Prashant) through front end itself . Further a condition must be written to stop the Baan job before the same job start next time in routine periodic cycle.
afdeijkers
9th July 2003, 19:11
Thanks,
Currently the development is being done in NT/Oracle, later in Unix.
I will work out this problem, and keep you all updated about the results...
A.
NvanBeest
9th July 2003, 21:21
An easier method for disabling re-entry would be:
1. Try to create an application lock
2. If (already existing lock) then
exit
3. Else
process
4. Remove application lock
This can then be started any way you like, Baan job or cron.
Lastly:
Originally posted by NPRao
Please complete your user profile with regards to the Baan software version, Database software and OS version. This will help other members when diagnosing your problem.
Please fill out your profile!
afdeijkers
12th July 2003, 17:47
Thanks!
philpom
23rd November 2003, 04:40
Hi,
I do the same exact thing but every 2 minutes. I pause the job for cold backups and maint etc and It happens by itself.
Create your job and on the job data screen set it to "periodic"
Set the period for 1 minute
use $BSE/etc/rc.startjob to fire your job ( you may need to modify the script but it is a simple script.
Now create something like this:
while test -r /tmp/run_my_job
do
rc.startjob myjob_name
while test -r /tmp/pause_my_job
do
sleep 60
echo "Waiting for restart"
done
if test -r /tmp/end_my_job
then
exit 0
fi
done
The files in tmp are flags that you can use to send signal with. When the script sees a certain file it takes a certain branch. The baan job setting I gave you should cause the job to execute then exit baan and hand control back over to the script.
Good LUCK!