|
View previous topic :: View next topic
|
| Author |
Message |
ideas
New User

Joined: 25 May 2005 Posts: 52 Location: India
|
|
|
|
Hi Frank & users,
I have 2 queries:
A) Is it possible to execute a JCL step in a Loop having some condition.
B) Do you have any info about a FTP Step with PGM=SELCOPY.
Thanks. |
|
| Back to top |
|
 |
MGIndaco
Active User

Joined: 10 Mar 2005 Posts: 432 Location: Milan, Italy
|
|
|
|
a) I think that a logic loop in a JCL is possible but to help you with a sample I must study your case and I need more informations....
b) I don't think that SELCOPY belong to the family of systems or application utility(usually they begin with IEH* or IEB*) |
|
| Back to top |
|
 |
ideas
New User

Joined: 25 May 2005 Posts: 52 Location: India
|
|
|
|
Its like this..
Let us assume that my program name is PGM1.
Now my JCL should execute the program 10 times,but i should not write 10 exec statements like this
//STEP1 EXEC PGM = PGM1
..
//STEP2 EXEC PGM = PGM1
..
//STEP3 EXEC PGM = PGM1..
Is it possible to put this in a loop.... |
|
| Back to top |
|
 |
superk
Global Moderator

Joined: 26 Apr 2004 Posts: 4652 Location: Raleigh, NC, USA
|
|
|
|
| Sure. Your STEP2 step should run conditionally and simply submit the job again. After 10 iterations, your program PGM1 will have to change the condition code so that the STEP2 process will be bypassed. |
|
| Back to top |
|
 |
ideas
New User

Joined: 25 May 2005 Posts: 52 Location: India
|
|
|
|
dear moderator, when you say "your program PGM1 will have to change the condition code so that the" does it implies that PGM1 needs to have a counter set(in PARM) in it which checks for the # of times its run?...and using the CC in the cobo, register it changes the value after certain # of runs...this would be intervening in the code..is there a way which avoids this way too.
Is there any way in JCL that a counter can be SET in a step. |
|
| Back to top |
|
 |
dneufarth
Active User

Joined: 27 Apr 2005 Posts: 420 Location: Inside the SPEW (Southwest Ohio, USA)
|
|
|
|
No on looping in JCL
JCL is executed sequentially, but allows you to execute/skip steps conditionally (COND=).
Dave |
|
| Back to top |
|
 |
superk
Global Moderator

Joined: 26 Apr 2004 Posts: 4652 Location: Raleigh, NC, USA
|
|
|
|
Ashutosh, basically, your process will need the following:
1. An external location to store the value of the iteration counter (database, VSAM, PDS, sequential file).
2. A program/utility that can retrieve the iteration counter, interrogate its value, perform the necessary calculation to increment it, and store the iteration counter back to its repository. Also, this program/utility should set it's return-code value based on the value of the counter.
It seems to me that a relatively simple solution is to append a record to a sequential dataset (with DISP=MOD) on each execution of the job and then check it for the total number of records. When the dataset contains 10 records, then the job will stop re-submitting itself. There are a couple of ways to handle this:
| Code: |
//MYJOB JOB (......)
//*
//STEP1 EXEC PGM=PGM1
//*
//STEP2 EXEC PGM=IEBGENER
//SYSUT1 DD *
NEW RECORD
//SYSUT2 DD DSN=&SYSUID..COUNTER,DISP=(MOD,CATLG,DELETE),
// UNIT=SYSDA,SPACE=(TRK,(1,1),RLSE)
//SYSPRINT DD SYSOUT=*
//SYSIN DD DUMMY
//*
//STEP3 EXEC PGM=IDCAMS
//SYSUT1 DD DSN=&SYSUID..COUNTER,DISP=SHR
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
PRINT IFILE(SYSUT1) COUNT(10)
//*
// IF (STEP3.RC > 0) THEN
//STEP4 EXEC PGM=IKJEFT01,PARM='SUBMIT ''&SYSUID..JCL(MYJOB)'''
//SYSTSPRT DD SYSOUT=*
//SYSTSIN DD DUMMY
//*
// ELSE
//STEP5 EXEC PGM=IEFBR14
//DELETE DD DSN=&SYSUID..COUNTER,DISP=(MOD,DELETE,DELETE),
// UNIT=SYSDA,SPACE=(TRK,(1,0),RLSE)
// ENDIF
//*
|
or
| Code: |
//MYJOB JOB (......)
//*
//STEP1 EXEC PGM=PGM1
//*
//STEP2 EXEC PGM=IEBGENER
//SYSUT1 DD *
NEW RECORD
//SYSUT2 DD DSN=&SYSUID..COUNTER,DISP=(MOD,CATLG,DELETE),
// UNIT=SYSDA,SPACE=(TRK,(1,1),RLSE)
//SYSPRINT DD SYSOUT=*
//SYSIN DD DUMMY
//*
//STEP3 EXEC PGM=ICETOOL
//INFILE DD DSN=&SYSUID..COUNTER,DISP=SHR
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//TOOLIN DD *
COUNT FROM(INFILE) NOTEQUAL(10)
//*
//*
// IF (STEP3.RC > 0) THEN
//STEP4 EXEC PGM=IKJEFT01,PARM='SUBMIT ''&SYSUID..JCL(MYJOB)'''
//SYSTSPRT DD SYSOUT=*
//SYSTSIN DD DUMMY
//*
// ELSE
//STEP5 EXEC PGM=IEFBR14
//DELETE DD DSN=&SYSUID..COUNTER,DISP=(MOD,DELETE,DELETE),
// UNIT=SYSDA,SPACE=(TRK,(1,0),RLSE)
// ENDIF
//*
|
|
|
| Back to top |
|
 |
dneufarth
Active User

Joined: 27 Apr 2005 Posts: 420 Location: Inside the SPEW (Southwest Ohio, USA)
|
|
| Back to top |
|
 |
ideas
New User

Joined: 25 May 2005 Posts: 52 Location: India
|
|
|
|
| Thank you very much superK! |
|
| Back to top |
|
 |
MGIndaco
Active User

Joined: 10 Mar 2005 Posts: 432 Location: Milan, Italy
|
|
|
|
If you want to execute 10 times the same program you can use a PROC as you can see below and so you don't need a jcl loop:
| Code: |
//MYJOB JOB (......)
//*--------------------------- begin of proc ------------------------*
//MYPROC PROC
//PRCSTP01 EXEC PGM=PGM1
// PEND
//*--------------------------- end of proc --------------------------*
//*------------------EXECUTION OF IN-STREAM PROC------------*
//STEP001P EXEC MYPROC
//STEP002P EXEC MYPROC
...other steps....
//STEP010P EXEC MYPROC
//*--------------------------- end of job -----------------------------*
|
In any way...if you don't want create a proc then you can use a loop jcl or as Superk's sample or as you can see below; U need 3 files:
1) 1 Counter
2) 1 member of partitioned to put there a simple source of REXX(Don't be afraid... It's easy and if you have some questions I will be here!)
3) 1 MainJcl
4) 1 SubJcl
Specific:
- (1)Counter: Sequential or member(is the same) and the length is not important but its record format must be FB; Put in this a zero '0'.
- (2) Put this rexx in a partitioned and name the program as you like but
be sure that from col 72 to 80 no number were specified and if it happen(usually they are formed when you paste your record in insert line mode):
| Code: |
/*% NOCOMMENT REXX */
/* PROGRAMMA: xxxxxxxx */
/* AUTORE : MGIndaco */
/* ENV. : BATCH */
Address TSO
Parse Arg Limit
Say '-----------------------------------------'
Say '- Begin ---------------------------------'
Say '-----------------------------------------'
/*---------------------------------------*/
/*- Accept of dsname of DD JOB ---------*/
/*---------------------------------------*/
List = LISTDSI(JOB FILE)
Jcl = sysdsname
Say ' Path of JCL to submit : ' Jcl
/*---------------------------------------*/
/*- Open File Counter -------------------*/
/*---------------------------------------*/
"ExecIO 0 DiskR COUNTER(Open"
"ExecIO 1 DiskR COUNTER"
Pull Record
/*---------------------------------------*/
/*- Close File Counter ------------------*/
/*---------------------------------------*/
"ExecIO 0 DiskR COUNTER(Finis"
Record = Strip(SubStr(Record,1,10)) + 1
/*---------------------------------------*/
/*- Test of Limit -----------------------*/
/*---------------------------------------*/
If Record <= Limit Then Do
Say Record
/*---------------------------------------*/
/*- Open file Counter for write new value*/
/*---------------------------------------*/
"ExecIO 0 DiskW COUNTER(Open"
Push Record
"ExecIO 1 DiskW COUNTER"
/*----------------------------------------*/
/*- Close file Counter for write new value*/
/*----------------------------------------*/
"ExecIO 0 DiskW COUNTER(FINIS"
/*----------------------------------------*/
/*- Submit the job and get the message ---*/
/*----------------------------------------*/
X = OUTTRAP('SubTrap.')
"SUBMIT '" !!Jcl!! "'"
X = OUTTRAP('OFF')
JobIx = 0
JobIx = index(SubTrap.1,'(')
NomJob = substr(SubTrap.1,15,JobIx-15)
NumJob = substr(SubTrap.1,JobIx+1,8)
/*----------------------------------------*/
/*- Display of jobname and jobnumber -----*/
/*----------------------------------------*/
Say ' Job submitted: 'NomJob
Say ' Job number : 'NumJob
End
Else Do
/*----------------------------------------*/
/*- Limit reached.... reset of Counter ---*/
/*----------------------------------------*/
Say ' No more job will be submitted'
Say ' File Counter resetted '
Push 0
"ExecIO 0 DiskW COUNTER(Open"
"ExecIO 1 DiskW COUNTER"
"ExecIO 0 DiskW COUNTER(FINIS"
End
Say '-----------------------------------------'
Say '- End -----------------------------------'
Say '-----------------------------------------'
Exit Record
|
- (3)MainJcl: as above... sequential or member is the same... code
Pay attention to substitute
NAMEofPGM - member name of rexx source
2 - Limit of loop:
MyRexxLib - where you have inserted the rexx source
MyCounter - File counter
MySubJcl - your jcl..
| Code: |
//*-------------------------------------------------------------------*
//STEPREXX EXEC PGM=IKJEFT01,PARM='NAMEofPGM 2'
//SYSEXEC DD DISP=SHR,DSN=MyRexxLib
//COUNTER DD DISP=SHR,DSN=MyCounter
//JOB DD DISP=SHR,DSN=MySubJcl
//SYSTSPRT DD SYSOUT=B
//SYSPRINT DD SYSOUT=B
//SYSTSIN DD DUMMY
//*-------------------------------------------------------------------*
//*--------------------- END OF JOB ----------------------------------*
//*-------------------------------------------------------------------* |
- (4)SubJcl: as above... sequential or member is the same... and end of code must be:
| Code: |
//SUBMIT EXEC PGM=IKJEFT01,PARM='',DYNAMNBR=50,
// REGION=4096K
//SYSTSPRT DD SYSOUT=*
//SYSTSIN DD *
PROF PREFIX(Myuserid)
SUBMIT My.JCLMAIN' |
|
|
| Back to top |
|
 |
MGIndaco
Active User

Joined: 10 Mar 2005 Posts: 432 Location: Milan, Italy
|
|
|
|
I have tried all and I want to assure you that it funtion very well.
The best in this way is that, if you want, you can read your subjcl before submit and change all you want and have in this way not only a loop but a full control of parameter, dataset names, program names, step names and so on...
If you look well and you need more info about rexx put your request in rexx forum... It's a great language. |
|
| Back to top |
|
 |
SteveConway
New User
Joined: 26 May 2005 Posts: 28 Location: Northern VA, USA
|
|
|
|
Looping in a classic programming sense is not possible with batch JCL. It is a top-down flow.
About the closest you can come is to add steps to the end of your job to a) submit this same job again or b) submit another job, based on condition codes or abend status. The submit steps can be set up with IF-THEN or COND= parameters, whatever works in your particular case.
Cheers,,,Steve |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|