Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2004-08-22
5
Medium Priority
?
999 Views
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.

Baluch.
0
Comment
Question by:baluch
  • 2
3 Comments
 
LVL 15

Accepted Solution

by:
jdlambert1 earned 500 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)
   BEGIN
     --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)
   END

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...
0
 

Author Comment

by:baluch
ID: 11933704
jdlambert1,
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.
Baluch.
0
 
LVL 15

Expert Comment

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

Featured Post

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

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

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
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.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

876 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