Has anyone used MICROFOCUS COBOL's RETURN-CODE variable as success/failure code for SQL Server Agent Job steps.

Hi Experts,

I am trying to run number of MicroFocus COBOL program executable as daily batch job in SQL Server (2000) Agent as Job Scheduler. Problem is that when a step (COBOL process) is failed in the job. The rest of steps which are dependent on that step are getting executed. Is there any way I can pass the MicroFocus environment varaible RETURN-CODE as the sucess/failure code to SQL Server Agent in order to stop processing the steps following the failed steps.

Thanks a bunch in advance.

Who is Participating?

Improve company productivity with a Business Account.Sign Up

jdlambert1Connect With a Mentor Commented:
1. Create a step prior to the COBOL batch that creates a global temp table
   "CREATE TABLE ##Proceed(Succeeded bit)"
2. Have the last action of the COBOL batch insert a record into your temp table
   "INSERT ##Proceed VALUES(1)"
3. Create a new step after the COBOL batch to check for the existence of a record from previous step
   IF NOT EXISTS (SELECT CobolCheck FROM ##Proceed)
     --if there's no record in ##Proceed, then raise error
     DECLARE @msg varchar(88)
     SET @msg = 'The COBOL batch process failed at ' + Cast(GetDate() as varchar(23))
     RAISERROR (@msg, 16, 1)

If the COBOL batch does perform the insertion, step 3 above will fire an error. If this is in the job step after the COBOL batch, and if you set this to stop on failure, it won't execute the remaining job steps.

Remember to drop the ##Proceed temp table...
baluchAuthor Commented:
Instead of temp table, I have set the return code +16 (for abends) with STOP RUN statement in COBOL program which is working with SQL Server Agent. Thanks for ur help.
Any time. But I stopped coding COBOL a lo0ong time ago.  :)
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.