IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Looping a step in JCL


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
MainB

New User


Joined: 03 Nov 2005
Posts: 17

PostPosted: Thu Dec 22, 2005 10:38 pm
Reply with quote

Does any one know of a way to loop a step in JCL. My requirement is that if I have a new version of a GDG I must run the next step else wait for it to get created.

So my JCL will have minimum two steps - first one will compare the two datasets - if they are different it will move to the next step else it needs to keep comparing.

The way I thot of doing this was to have two JCL's - first one will have 3 steps. First step will be to compare datasets and if those are same the next step will trigger the other JCL. The compare step will return 0 - so I will use the
COND=(0,EQ,STEP010) for the next step that calls the other JCL.

This other JCL will have just one step to trigger the first JCL again making a loop. This will go on till such time the DATSETS are different that is the new GDG version is available.

When this happens the second step of first JCl where it triggers other JCL will not happen because compare step will have non-zero return. So it will go to the third step (the real procees after file is rcvd) to find
COND=(0,NE,STEP010) and it will execute this step - which is required.

Is this the only way - or there is some better way - the problem with this approach is that I will get too many job outputs. Every next second I will have an output for JOB1 and JOB2 till such time the the new version is not there. If this is the only way - is there a way to avoid these outputs like a WAIT or PAUSE statement somewhere delay the execution of job?

Thanks
Back to top
View user's profile Send private message
jdavisiii

New User


Joined: 22 Dec 2005
Posts: 1

PostPosted: Thu Dec 22, 2005 11:30 pm
Reply with quote

call a COBOL module to do the compare, call an assembler module from COBOL with wait and timer macro's to try again every n minutes or seconds.

Cobol goes back when compare is not equal, with a return codes signaling compare mismatch found or cobol waited long enough and quit.

You could do it without the assembler sub routine but it's polite to wait rather then loop and chew CPU needlessly. I don't know of a COBOL "wait"
Back to top
View user's profile Send private message
MainB

New User


Joined: 03 Nov 2005
Posts: 17

PostPosted: Fri Dec 23, 2005 2:58 am
Reply with quote

I wanted to do it all in JCL only - without using a COBOL program. IEBCOMPR does the compare and returns zero or > 0 based on compare success or failure. If I can find an easy way to WAIT/PAUSE in JCL itself - that will be great.
Back to top
View user's profile Send private message
MGIndaco

Active User


Joined: 10 Mar 2005
Posts: 432
Location: Milan, Italy

PostPosted: Fri Dec 23, 2005 7:12 pm
Reply with quote

In all the shop we use scheduler to do this.
If someone create a new level of gdg, when happens an event that can be a trigger or a simple dependece will submit our job.
I mean: when I create a next level of gdg that you need to do a compare I can create a chain if we are at the same shop or I can use an event trigger to start your compare if we are from different shop or systems.
So, if I have done something wrong in my procedure and your compare is not right you can delete or rename(automatically) the last version and wait the next but completing your running job.
In this sequence you will not submit and hold your jcl freeing so the class and the file that, for the compare may be that you keep it in old disposition.

If I'm wrong or my english is not too clear, I apologize.
Back to top
View user's profile Send private message
MainB

New User


Joined: 03 Nov 2005
Posts: 17

PostPosted: Fri Dec 23, 2005 9:20 pm
Reply with quote

You are perfectly - right. In a production system scheduler takes care of most of such scenarios. I am in a non production environment where I do not have a real production scheduler.
Back to top
View user's profile Send private message
MGIndaco

Active User


Joined: 10 Mar 2005
Posts: 432
Location: Milan, Italy

PostPosted: Fri Dec 23, 2005 9:32 pm
Reply with quote

If you are not on production, why don't you use the IKJEFT01/NFTP to replicate the same scenario?
I mean the same can also be done in this way:
- Same mainframe env: insert after the allocation of new version of gdg an IKJEF01 that will submit your job
- From another system using NFTP(Netview FTP): after the allocation of new version of gdg send the file and start a trigger using the RPTJOBLB and RPTJOBOK to start your job.

Tell me your doubt.
Back to top
View user's profile Send private message
MainB

New User


Joined: 03 Nov 2005
Posts: 17

PostPosted: Wed Dec 28, 2005 9:51 pm
Reply with quote

To make this a little clearer - the GDG gets created by a production job of another system. We do not want them to change their jobs - system hours issue etc. But want to have our job (non production) some how know that the other systems prodn job has ended/created the GDG and we can begin.

Also I am not familiar w RPTJOBLB and RPTJOBOK!!
Back to top
View user's profile Send private message
Ramya A

Active User


Joined: 26 Jul 2004
Posts: 104

PostPosted: Thu Dec 29, 2005 1:15 am
Reply with quote

Please see if this solution will work for you:

You have a job with the following steps:

//Job1 ...
//
Step1: Compare the datasets and see if there is a difference. If different, RC > 0 else RC = 0
Step2: Continue process if Step1.RC is not 0
Step3: Execute Job1 if Step1.RC is 0

I've not tested this code, but a JJ didn't give error for me. Step 3 can be coded like this:

Code:
//STEP1    EXEC PGM=IEBGENER,COND.STEP001=(0,NE)             
//SYSOUT   DD SYSOUT=*                                       
//SYSPRINT DD SYSOUT=*                                       
//SYSUT1   DD DSN=Your.JCL.Dataset.With.Member,DISP=SHR 
//SYSUT2   DD SYSOUT=(,INTRDR)                               
//SYSIN    DD DUMMY                                           
//*                                                           


Let me know if this works.
Back to top
View user's profile Send private message
MainB

New User


Joined: 03 Nov 2005
Posts: 17

PostPosted: Thu Dec 29, 2005 9:37 pm
Reply with quote

If I am understanding it right this will run the same JCL again and again in a loop till such time the two Datasets being compared are different.

This then is pretty much similar to the solution I had in my initial post - where I was having two jobs

JOB 1
compare datasets
if same run job 2
if different do the real processing lets say invoke job3 which has that

JOB2
only step is to invoke JOB1

JOB3
The real processing when the new dataset has come

The problem in this solution is that I will have a job outout every second after the JOB1 starts til such time the new file has come. And if that takes an hour you can se how much job output I will have.

So I was looking for a solution where there issome looping without the job out put or if there is something like a pAUSE!!!
Back to top
View user's profile Send private message
MGIndaco

Active User


Joined: 10 Mar 2005
Posts: 432
Location: Milan, Italy

PostPosted: Sat Dec 31, 2005 10:57 pm
Reply with quote

Hi MainB, a Pause in jcl exist like TYPERUN=HOLD but your problem is not only a pause.
You need pause and restart automatic, a way to avoid a lock of the Class for your job only and other...
I suggest you to talk with your system programmer or netview group(if your input is a transfer) because in many shops is installed a kind of daemon that trace many event like the allocation of a file(I don't know if trace gdg too) and allow you to do many thing( like submit job).

I hope in this help
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sun Jan 01, 2006 3:20 am
Reply with quote

Here's something I picked up on the Web that purports to do the WAIT.
Code:

       IDENTIFICATION DIVISION.                                                 
       PROGRAM-ID. WAIT.                                                       
       ***                                                                     
       *** DELAY IN COBOL VIA CALL TO ILBOWAT0                                 
       ***                                                                     
       *** USAGE:                                                               
       *** //S1 EXEC PGM=WAIT,PARM=NNNN                                         
       *** NNNN IS A NUMBER IN THE RANGE OF 0001 TO 9999 SECONDS               
       ***                                                                     
       DATA DIVISION.                                                           
       WORKING-STORAGE SECTION.                                                 
       01  DELAY-AMT              PIC S9(9) COMP.                               
       01  ILBOWAT0                PIC X(8) VALUE 'ILBOWAT0'.                   
       01  CURRENT-TIME            PIC 9(8).                                   
       LINKAGE SECTION.                                                         
       01  PARAMETER-TO-MAIN.                                                   
         05 PARM-LENGTH PIC S9(4) COMP.                                         
         05 PARM-TEXT  PIC X(100).                                             
         05 PARM-REDEF REDEFINES PARM-TEXT.                                     
           10 PARM-NUMERIC PIC 9999.                                           
           10 FILLER      PIC X(94).                                           
       PROCEDURE DIVISION USING PARAMETER-TO-MAIN.                             
       MAIN SECTION.                                                           
           MOVE PARM-NUMERIC TO DELAY-AMT                                       
           ACCEPT CURRENT-TIME FROM TIME                                       
           DISPLAY 'TIME OF DAY BEFORE ILBOWAT0: ', CURRENT-TIME       *       
           CALL ILBOWAT0 USING DELAY-AMT                                       
      *                                                                         
           ACCEPT CURRENT-TIME FROM TIME                                       
           DISPLAY 'TIME OF DAY AFTER ILBOWAT0 : ', CURRENT-TIME               
           GOBACK                                                               
           .                                                             
Back to top
View user's profile Send private message
dneufarth

Active User


Joined: 27 Apr 2005
Posts: 420
Location: Inside the SPEW (Southwest Ohio, USA)

PostPosted: Sun Jan 01, 2006 3:27 am
Reply with quote

Just curious: Which datasets are being compared? -1 and +0?

There is no looping in JCL. Do you actually want to tie up a batch initiator for an unspecified period so that it will wake up, go to sleep, wake up... If so, the assembler wait/timer is availabe as jdavisiii suggested.

LISTCAT of this GDG to a dataset will allow for a program (REXX, COBOL et al) to find the current gen and determine if it is different than prior run. If so, store gen number in a dataset and process the current GDG. You still have the issue of waiting and checking until that occurs.


Dave
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts How to get a stack trace on a looping... ABENDS & Debugging 5
No new posts Return codes-Normal & Abnormal te... JCL & VSAM 7
No new posts How to append a PS file into multiple... JCL & VSAM 3
No new posts convert file from VB to FB and use tr... DFSORT/ICETOOL 8
No new posts Forcing a step to run (even if abended) JCL & VSAM 8
Search our Forums:

Back to Top