MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

REXX Script to submit multiple Jobs when arguments are given
Goto page 1, 2  Next
 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> TSO and ISPF
View previous topic :: View next topic  
Author Message
shiv_swami
Beginner


Joined: 29 Nov 2003
Posts: 68
Topics: 14

PostPosted: Sun Nov 30, 2003 3:58 am    Post subject: REXX Script to submit multiple Jobs when arguments are given Reply with quote

Hi ....

I have created an utility program that would take input as cobol program in a PDS & write certain statistics based on the program to OUPUT file

The template is like this :
Code:

//&&MEMBER  EXEC PGM=PMCOBCHK,PARM='YNY'
//INCOBOL  DD DISP=SHR,DSN=&PDS1(&&MEMBER)
//OUTFILE  DD DISP=SHR,DSN=&PDS2(ESTIMATE)
//SYSPRINT DD  SYSOUT=*                                     
//SYSOUT   DD  SYSOUT=*                                     
//SYSUDUMP DD  SYSOUT=*                                     

I want to run this utility program for entire PDS so that steps are generated for each PDS mmber i.e.Cobol source program.

If I give it argument as PDS1=MY.TEST.COBLIB & PDS2=MY.TEST.JCLLIB (OUTPUT file)

It should generate following steps
The step for first member will be....
Code:

//TESTPGM0  EXEC PGM=PMCOBCHK,PARM='YNY'
//INCOBOL  DD DISP=SHR,DSN=MY.TEST.COBLIB(TESTPGM0)
//OUTFILE  DD DISP=SHR,DSN=MY.TEST.JCLLIB(ESTIMATE)
//SYSPRINT DD  SYSOUT=*                                     
//SYSOUT   DD  SYSOUT=*                                     
//SYSUDUMP DD  SYSOUT=*                                     

The collected statistics will appended to the OUTPUTfile..
Also I will have consider that JCL generated can't have more than 255 jobs ..so It should generated next job card for next 255 members until all the members in the PDS are processed. Also I would like to pass this number (255 ) as an agument so that I can have jobs with say..100 steps each..

Hoping for quick response... from the REXX experts..

Regards,
Shiv
Back to top
View user's profile Send private message Yahoo Messenger
Mike
Beginner


Joined: 03 Dec 2002
Posts: 114
Topics: 0
Location: Sydney, Australia

PostPosted: Sun Nov 30, 2003 4:41 pm    Post subject: Reply with quote

You can use the LMMLIST ISPF service to obtain the member list (this requires use of the LMINIT and LMOPEN services prior to it's initial invocation and LMCLOSE and LMFREE after the last invocation.

Alternately you could use the LISTD TSO/E function with the MEMBERS option and in conjunction with the Rexx OUTTRAP function to obtain the member list.
_________________
Regards,
Mike.
Back to top
View user's profile Send private message
shiv_swami
Beginner


Joined: 29 Nov 2003
Posts: 68
Topics: 14

PostPosted: Mon Dec 01, 2003 4:09 am    Post subject: Reply with quote

Thanks Mike..

I am a beginner in REXX so I am looking forward to code for the entire purpose if someone has already done it or has simlar code ready..

My main purpose is to submit the job from REXX itself & create steps one each for member of PDS given as argument..

Regards,
Shiv
_________________
Regards,
Shivprakash
Back to top
View user's profile Send private message Yahoo Messenger
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Mon Dec 01, 2003 2:30 pm    Post subject: Reply with quote

Shiv,

A few clarifications. you said
Quote:

The collected statistics will appended to the OUTPUTfile..


I don't think you can append the data to PDS member.you will be overwritting the output for every run. If you really want to append the data then you need a sequential file output but not a PDS.

Quote:

Also I will have consider that JCL generated can't have more than 255 jobs


Just note that it is not JObs , but the number of EXEC statements in a single JOb cannot be more than 255. It is only 1 single job with a max of 255 steps.

I will post the solution once I get the clarification.

Btw If you are interested the same can be achieved with sort

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Mike
Beginner


Joined: 03 Dec 2002
Posts: 114
Topics: 0
Location: Sydney, Australia

PostPosted: Mon Dec 01, 2003 5:08 pm    Post subject: Reply with quote

Quote:

I am a beginner in REXX so I am looking forward to code for the entire purpose if someone has already done it or has simlar code ready


Shiv,
I, like most people here, are perfectly willing to assist you in producing a solution to your problem but actually expecting us to write the code in it's entireity is going beyond just assisting you, it is doing your job for which I assume you are paid and we would not be. I personally would expect that you at least attempt to start producing the code that you require.

My suggestion is to start your project, perhaps by producing a flow chart and to then start coding the program. If you encounter problems then ask us for help and I'm sure that you will get it.

You should also make use of the search facility on this forum. I have little doubt that there are a number of topics regarding submitting batch jobs. I think that you will get a far greater personal reward out of learning rather than simply presenting a solution provided by someone else. I also believe that a large portion of being a good programmer is to know how to locate information.

If the requirement is for a speedy solution due to business demands then you should either let your management know that you do not posses sufficient competency to complete the project within the given deadlines or I'm sure that many here would willingly supply a complete solution for a finacial reward.

I have just used the serach utility LMMLIST as the argument and it found half a dozen instances and according to the subject, the bulk of these could be of use.
_________________
Regards,
Mike.
Back to top
View user's profile Send private message
Dibakar
Advanced


Joined: 02 Dec 2002
Posts: 700
Topics: 63
Location: USA

PostPosted: Tue Dec 02, 2003 1:24 am    Post subject: Reply with quote

Shiv,

I find LMM commands a bit scary. So I would probably proceed as required in the code below.

1 Open the the dataset member list by doing a 'm' against the dataset on dslist screen. Then give command 'save aname'. This will save the member names in dataset 'ur_id_or_prof.ANAME.MEMBERS'. No need to edit this dataset.

Now execute the job below. I am presenting a similar tool. This will submit one job for every 100 mebers. Let me know if you have any problem in modifying this code.

Regards,
Diba.

Code:

/*    REXX pgm to prepare jclflow for a list of jobs.
      The job list is in 'LC.userid().WORK.INPUT(JCLFLOW)'.
      Output will be in 'LC.userid().WORK.JCLFLOW'.
      These datsets should be allocated before execution of this pgm.
*/
 msg_stat = MSG('OFF')
/*
   Allocate input file and read member names
*/
 "alloc DA('LC."USERID()".WORK.INPUT(JCLFLOW)') F(JCLFLOW) SHR REUSE"
 if RC > 0 then do
      say 'LC.'USERID()'.WORK.INPUT(JCLFLOW) not found. RC ='RC
      exit
 end
 "EXECIO * DISKR JCLFLOW (STEM member. FINIS"
 "FREE JCLFLOW"
/*
   Check output file
*/
 "ALLOC DA('LC."USERID()".WORK.JCLFLOW') F(TEMP) SHR REUSE"
 if RC > 0 then do
      say 'LC.'USERID()'.WORK.JCLFLOW' not found
      exit
 end
 "FREE F(TEMP)"
/*
 submit a job for each member
*/
 "ALLOC F(INTRDR) RECFM(F) LRECL(80) SYSOUT(A) WRITER(INTRDR)"
 jobs = 0
 do i = 1 to member.0
     /*
      create job
     */
      member = strip(left(strip((member.i,8)))
      s# = strip(right(i,2))
      if (i = 1) | (s# = '01') then do
           jobs = jobs + 1
           if (i > 1) then do
               /*
                submit a job for previous 100 member
               */
                queue ""
                "EXECIO * DISKW INTRDR (FINIS"
           end
           queue "//"userid()"G JOB  (LA00,370R),9061.TOOL,CLASS=D,"
           queue "//           MSGCLASS=Q,NOTIFY=&SYSUID"
           queue "//         SET FLOWLIB=LC."userid()".WORK.JCLFLOW"
      end
      queue "//STEP"s#"  EXEC JCLFLOW,SYSOUT=*,FLOWOUT=*"
      queue "//JCLFLOW2.REPORT DD DSN=&FLOWLIB("member"),DISP=SHR"
      queue "//JCLFLOW6.CARDIN DD *"
      queue "SELJ"member
 end
/*
 submit a job for last 100 member
*/
 queue ""
 "EXECIO * DISKW INTRDR (FINIS"
 "FREE F(INTRDR)"
 say jobs 'jobs submitted for 'member.0' job names'
 say "Thanks for using Diba's tool"
 exit

Back to top
View user's profile Send private message Send e-mail
Mike
Beginner


Joined: 03 Dec 2002
Posts: 114
Topics: 0
Location: Sydney, Australia

PostPosted: Tue Dec 02, 2003 4:27 pm    Post subject: Reply with quote

Dibakar,
how about, the following to check for each 100 members :-

Code:

jsteps = 100                          /* set number of steps per job
If i // jsteps = 1 Then Do
   ...... body of loop
End


This would allow you to do away with the s# variable and it's manipulation. If the procedure EXEC statment were changed to "//S"i" EXEC ....." then there would be very little chance of the JCL failing if there were a large number of members.

Why are you scared of LM services? they really are very useful and are easy to use.
_________________
Regards,
Mike.
Back to top
View user's profile Send private message
Dibakar
Advanced


Joined: 02 Dec 2002
Posts: 700
Topics: 63
Location: USA

PostPosted: Tue Dec 02, 2003 11:21 pm    Post subject: Reply with quote

Mike,

You do have sharp eyes!

Actually I have forgotten the mod syntax in REXX and was too lazy to look for it.

"//STEP" i have used to match current convention but I agree "//S"i" EXEC ..." is more indicative than "//STEP"s#" EXEC ...".

Regarding LM service - I find 'Open', 'Init' a bit involved. Since Rexx is not part of my job so I do them secretly and in free time, which doesn't give me much time to explore LM service.

Diba.
Back to top
View user's profile Send private message Send e-mail
shiv_swami
Beginner


Joined: 29 Nov 2003
Posts: 68
Topics: 14

PostPosted: Wed Dec 03, 2003 4:36 am    Post subject: Reply with quote

Razz
Thanks Kolusu,Mike & Diba for your inputs...

Kolusu,
You are right in both the clarifications you have sought
1) I want to append statistics to ouput file .So I will I have to a sequential file for the output purpose.
So ouptput file would not be a PDS as mentioned earlier.
2) JCL generated can't have more than 255 steps (jobs was a mistake Mad )

Mike,
I will quite try and do what you have mentioned...Learn REXX myself with inputs from you guys here at the forum..
Also as Diba pointed out, REXX is not part of my job & hence can't find I will have to learn in free time too..
The current case is also part of my initiative to run a utility program that would be invoked for entire PDS.

Diba Mr. Green ,
Thanks very much for the code....

Regards,
Shiv
Back to top
View user's profile Send private message Yahoo Messenger
Dibakar
Advanced


Joined: 02 Dec 2002
Posts: 700
Topics: 63
Location: USA

PostPosted: Wed Dec 03, 2003 7:56 am    Post subject: Reply with quote

Shiv,

If it's going to be frequently used utility then saving the list manually won't be a nice idea. I am sure you will be able to find some way around for that.

Regards,
Diba.
Back to top
View user's profile Send private message Send e-mail
Mike
Beginner


Joined: 03 Dec 2002
Posts: 114
Topics: 0
Location: Sydney, Australia

PostPosted: Wed Dec 03, 2003 3:12 pm    Post subject: Reply with quote

Thanks for the compliment Dinakar.

Here's a Rexx program that extracts the members from a PDS using the LISTD TSO function.

Code:

/* Rexx */                                 
MBRLIST:                                   
  Parse Upper Arg dset .                   
  x = Outtrap("l.","*")                   
  "LISTD '"dset"' MEMBERS"                 
  x = Outtrap("OFF")                       
  flag = 0                                 
  Do i = 1 to l.0                         
    If flag = 1 Then Do                   
      mbr = Strip(l.i)                     
      cmd.1 = " SELECT MEMBER="mbr         
      Say cmd.1                           
    End                                   
    If Pos("--MEMBERS--",l.i) > 0 Then Do 
      flag = 1                             
    End                                   
  End                                     
Exit 0                                                                                     


And here's a Rexx using LM services that will invoke an edit macro against all members of a PDS (this is not that brilliant it was just used to show the technique, I use a more superior utility I have written, that is panel driven and will run the core of the work in either batch or foreground, even dynamically generating the JCl).
Code:

/* Rexx -                                                             */
 "ADDRESS ISPEXEC"                                                     
 "CONTROL ERRORS RETURN"                                               
                                                                       
 "ADDRESS ISREDIT"                                                     
 cds = "MY.PDS.DATASET"                                                 
 macro = MYMACRO                                                       
 "LMINIT DATAID(mlist) DATASET('"cds"') ENQ(SHR)"                       
 "LMOPEN DATAID("mlist")"                                               
 mnme = ""                                                             
 Do Forever                                                             
   "LMMLIST DATAID("mlist") MEMBER(mnme) OPTION(LIST)"                 
   If Rc > 0 Then Leave                                                 
     "ISPEXEC EDIT DATAID("||mlist||") MEMBER("||mnme||") ",           
     "MACRO("||macro||")"                                               
 End                                                                   
 "LMMLIST DATAID("mlist") OPTION(FREE)"                                 
 "LMCLOSE DATAID("mlist")"                                             
 "LMFREE DATAID("mlist")"                                               

_________________
Regards,
Mike.
Back to top
View user's profile Send private message
norstrom
Beginner


Joined: 23 Dec 2003
Posts: 2
Topics: 1

PostPosted: Tue Dec 23, 2003 7:11 am    Post subject: Reply with quote

If some external REXX-function is of interest, then You can visit Rob Scott's homepage where You can download an assembler program extending Your
REXX-capability.

Rob Scott have one function called listmem, which are quite easy to use:

In his readme.txt file which also is a part of the download, You can se how easily
it is to get a stemvariable populated with the names of the members in a PDS:

Quote:

/* REXX */
rcode = LISTMEM('IBMUSER.CNTL','IPO1DL')
if rcode <> 0 then exit
i = 1
do PDS_MEMBER_NAME.0
say PDS_MEMBER_NAME.i
i = i + 1
end


You will find Rob Scott's homepage at http://www.secltd.co.uk
Back to top
View user's profile Send private message
Dibakar
Advanced


Joined: 02 Dec 2002
Posts: 700
Topics: 63
Location: USA

PostPosted: Mon Jan 12, 2004 5:50 am    Post subject: Reply with quote

Mike,

I was waiting for a chance to use your mbrlist code since I saw it, and today I got the chance.

Thnaks,
Diba.
Back to top
View user's profile Send private message Send e-mail
Mike
Beginner


Joined: 03 Dec 2002
Posts: 114
Topics: 0
Location: Sydney, Australia

PostPosted: Mon Jan 12, 2004 2:52 pm    Post subject: Reply with quote

Thanks Diba
_________________
Regards,
Mike.
Back to top
View user's profile Send private message
Dibakar
Advanced


Joined: 02 Dec 2002
Posts: 700
Topics: 63
Location: USA

PostPosted: Thu Jan 29, 2004 7:07 am    Post subject: Reply with quote

Sometime when I submit multiple jobs, it goes to queue. Then I have to change the class from C to D so that it starts sooner (and sometime other way round). Before submitting a job thru REXX, is it possible to makeout dyanamically which class will accept my jobs now.

Thanks,
Diba.
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> TSO and ISPF All times are GMT - 5 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group