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

Posted on 2004-08-22
Last Modified: 2008-02-26
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.

Question by:baluch
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 15

Accepted Solution

jdlambert1 earned 125 total points
ID: 11866712
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...

Author Comment

ID: 11933704
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.
LVL 15

Expert Comment

ID: 11933843
Any time. But I stopped coding COBOL a lo0ong time ago.  :)

Featured Post

Turn Insights into Action

Communication across every corner of your business is essential to increase the velocity of your application delivery and support pipeline. Automate, standardize, and contextualize your communication processes with xMatters.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Viewers will learn how the fundamental information of how to create a table.

695 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question