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
944 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
5 Comments
 
LVL 15

Accepted Solution

by:
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)
   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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

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…
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
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.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

785 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