Thank you Jean
this is good information.
unfortunately I do not have a box setup for this job stream just due to the nature of the process I am working with, However I end up creating a batch that helped me resolve this issue.
if any one wants to use it here is the script , they need to follow these steps :
To begin we need to have the initial job that you need to make sure it will keep rerunning until it's successful lets call it "Prim_Job" , and the next job that will follow on success of the initial job ...let call it "Next_Job", the new job that you need to introduce between them is the one that will delegate the workflow to make sure the primary job is completed successfully let call it "Validator"
the Validator job should run this command example: : D:\Validate_me_.bat <job_name_of _validator_Job> <Job_name_of_Primary_job> <Job_name_of_Next_job>
make sure the success exit code is set to example: 0,1,255 with "1" or "255" is the case of exit code that you need to rerun the job at.
make sure you run the Batch from any SQL server on the same network as your Autosys environemt
here is the Validate.BAT script:
REM****************Start***********************
D:
Set Validator=%1%
set Prim_Job=%2%
set Next_Job=%3%
set TempFolder=D:\Temp
Set TempFile=%Prim_Job%_exit_code.txt
set statuscd=0
set env=PRO
CD "%TempFolder%"
osql -S <Autosys_SQL_Database_Server> -d -w300 -h-1 -E -Q "set nocount ON; SELECT AEDB_PRO.dbo.ujo_job_status.exit_code FROM AEDB_PRO.dbo.ujo_job INNER JOIN AEDB_PRO.dbo.ujo_job_status ON AEDB_PRO.dbo.ujo_job.job_ver = AEDB_PRO.dbo.ujo_job_status.job_ver AND AEDB_PRO.dbo.ujo_job.joid = AEDB_PRO.dbo.ujo_job_status.joid where job_name like '%Prim_Job%'" >%TempFolder%\%TempFile%
if {"%errorlevel%"} NEQ {"0"} (
cd "%TempFolder%"
set msg= Failure
set statuscd=1
goto endprocessing
)
FOR /F "delims=" %%i IN (%TempFile%) DO set pf=%%i
echo %pf%
if %pf% EQU 0 (set statuscd=0
goto endprocessing
)
if %pf% NEQ 0 (
D:
CD "D:\Program Files (x86)\CA\Workload Automation AE\autosys\bin"
sendevent -E FORCE_STARTJOB -J %Prim_Job%
sendevent -J %Validator% -E CHANGE_STATUS -s INACTIVE
goto retryprocessing
)
:retryprocessing
sendevent -J %Validator% -E CHANGE_STATUS -s INACTIVE
sendevent -J %Next_Job% -E JOB_ON_HOLD
D:
CD ..
sleep 15
exit /B %statuscd%
del /Q %TempFolder%\%TempFile% 2>NUL
:endprocessing
sendevent -J %Next_Job% -E JOB_OFF_HOLD
D:
CD ..
del /Q %TempFolder%\%TempFile% 2>NUL
exit /B %statuscd%
REM ***************************END********************************************