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

Submitting a series of Jobs in REXX


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
senmainframe
Currently Banned

New User


Joined: 09 Oct 2007
Posts: 30
Location: USA

PostPosted: Thu Nov 01, 2007 1:17 am
Reply with quote

I have two jobs and when I am executing my following rexx program, only firs job is submitted and second job is not exectued.

could yu please guide me where I am wrong. What is the problem in my below code. Do I need to clear queue for every count of loop or some other error?

jcl name (with same jobcard)
JCL1
JCL2


My rexx code
Code:

/*REXX*/                                                               
 
/*Accepting the input */                                               
SAY 'ENTER A  NEW  BLOCK NAME:'                                         
                                                                       
PARSE PULL NEWBLK                                                       
                                                                       
NEWBLK1=STRIP(NEWBLK)                                                   
                                                                       
CNT = 2                                                                 
                                                                       
NEWBLK=NEWBLK1                                                         
  DO JCLNUM = 1 TO 2                                                   
     SAY JCLNUM                                                         
     CALL EDIT_JCL                                                     
                                                                       
     CALL SUB_JCL                                                       
  END
                                                                         
      CALL EXIT                                                         
                                                                         
 /* Sub-routine for editing the Job to be submitted              */     
                                                                         
 EDIT_JCL:                                                               
                                                                         
 "ALLOC DD(INDD) DA('CAA1035.REXX.JCL(JCL"JCLNUM")') SHR                 
                                                                         
                                                                   REU" 
                                                                         
    "EXECIO * DISKR INDD (STEM IN. FINI"                                 
                                                                         
    index = IN.0                                                         
                                                                         
    DO  record = 1 to index 
IF POS('OC12',IN.record) > 0 THEN DO                   
                                                       
   POS1 = POS('OC12',IN.record)                       
                                                       
   SAY POS1                                           
                                                       
   IN.record = OVERLAY(NEWBLK,IN.record,POS1,4)       
                                                       
   SAY IN.record                                       
 END                                                   
                                                       
 IF POS('DATASET(',IN.record) > 0 THEN                 
                                                       
  DO                                                   
                                                       
        TEMP = "DATASET("DSNPROF")"                 
                                                     
        IN.record = OVERLAY(TEMP,IN.record,1,80)     
                                                     
        SAY IN.record                               
                                                     
                                                     
    END                                             
                                                     
   END                                               
                                                     
   "FREE FILE(INDD)"                                 
                                                     
RETURN 0                                             


                                                                       
/* Sub-routine for submiting the Job prepared                       */ 
                                                                       
SUB_JCL:                                                               
                                                                       
DO onq = 1 to index                                                     
                                                                       
   QUEUE IN.onq                                                         
                                                                       
END                                                                     
                                                                       
QUEUE "$$"                                                             
                                                                       
CALL OUTTRAP 'out.'                                                     
                                                                       
ADDRESS TSO "SUBMIT * END($$)"                                         

CALL OUTTRAP 'OFF'                                                     
                                                                       
SAY 'Output from SUBMIT cmd...'                                         
                                                                       
  DO i = 1 TO out.0                                                     
                                                                       
  SAY i out.i                                                           
                                                                       
  END i                                                                 
                                                                       
                                                                       
                                                                       
  DO i = 1 TO out.0                                                     
                                                                       
  PARSE VAR out.i . 'JOB ' . '(' jobid ')'                             

                                                                   
  IF jobid <> '' THEN LEAVE                                       
                                                                   
  END i                                                           
                                                                   
IF jobid = ''                                                     
                                                                   
THEN SAY 'Job submission failed, rc='rc                           
                                                                   
ELSE SAY 'Job submitted successfully, job number is: 'jobid       
                                                                   
                                                                   
                                                                   
EXIT:                                                             
                                                                   
EXIT 0                                                                                 
Back to top
View user's profile Send private message
superk

Global Moderator


Joined: 26 Apr 2004
Posts: 4652
Location: Raleigh, NC, USA

PostPosted: Thu Nov 01, 2007 1:25 am
Reply with quote

I don't see a RETURN statement in SUB_JCL:.
Back to top
View user's profile Send private message
senmainframe
Currently Banned

New User


Joined: 09 Oct 2007
Posts: 30
Location: USA

PostPosted: Thu Nov 01, 2007 1:38 am
Reply with quote

I added and it is working fine. Also one more help, if first job get abends or fails, second jobs should not be run. How I can check in this?
Back to top
View user's profile Send private message
superk

Global Moderator


Joined: 26 Apr 2004
Posts: 4652
Location: Raleigh, NC, USA

PostPosted: Thu Nov 01, 2007 2:21 am
Reply with quote

Well, your code shows that you seem to be pretty adept with the typical TSO commands. Ask yourself how you would do what you want in TSO, and you'll have your answer.

As another hint, usually, when you enter the TSO HELP command without any other parameters, you'll get a list of all the TSO commands grouped by function. There should be a group for FOREGROUND INITIATED BACKGRUND COMMANDS, of which SUBMIT and STATUS and some others belong to.
Back to top
View user's profile Send private message
superk

Global Moderator


Joined: 26 Apr 2004
Posts: 4652
Location: Raleigh, NC, USA

PostPosted: Thu Nov 01, 2007 2:22 am
Reply with quote

Or, you could search the forums, as this topic is posted by someone just about every day.
Back to top
View user's profile Send private message
senmainframe
Currently Banned

New User


Joined: 09 Oct 2007
Posts: 30
Location: USA

PostPosted: Fri Nov 02, 2007 2:16 am
Reply with quote

Hi,

Thank you very mcuh. We can use TSO command STATUS, but I dont know how to use in my REXX properly. Could you guide or any other method is available?
Back to top
View user's profile Send private message
superk

Global Moderator


Joined: 26 Apr 2004
Posts: 4652
Location: Raleigh, NC, USA

PostPosted: Sat Nov 03, 2007 2:05 am
Reply with quote

Well, in your code you're capturing the jobname and jobid from the TSO SUBMIT command. Once you know both of those, you then typically use the TSO STATUS command to retrieve the current status of the job. First, TSO STATUS JOBNAME(JOBID) will return the message:

IKJ56211I JOB JOBNAME(JOBID) EXECUTING

and will keep returning that message every time you invoke the command until the job completes, at which time if will then say:

IKJ56192I JOB JOBNAME(JOBID) ON OUTPUT QUEUE

Now, you know it's completed. Then, you just need to use the TSO OUTPUT command to retrieve the job output:

TSO OUTPUT JOBNAME(JOBID) PRINT(dsname) BEGIN HOLD KEEP
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 -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts Finding and researching jobs All Other Mainframe Topics 0
No new posts Compile Several JCL JOB Through one r... CLIST & REXX 4
No new posts Running REXX through JOB CLIST & REXX 13
No new posts Error to read log with rexx CLIST & REXX 11
No new posts isfline didnt work in rexx at z/OS ve... CLIST & REXX 7
Search our Forums:

Back to Top