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

Looping in REXX and pass data to JCL.


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
mathi.vanan

New User


Joined: 11 Jan 2012
Posts: 18
Location: INDIA

PostPosted: Wed Jan 11, 2012 6:08 pm
Reply with quote

Hi Gurus...

I am a beginner in REXX and am breaking my head to work on the following. I have two questions for which i need thoughts on. I had looked in previous posts but couldnt make out exactly for my need.

I need to build a rexx routine which would pass 2 dsn names and sort keys for a sort JCL. I believe that sort can be done within the REXX routine as well, but the JCL has few more functions as well.

The rexx routine would have N number of for DSNs and it would pass 2 DSNs every time to the sort JCL. i.e (the routine would call the JCL 'N' number of times)

Please provide me inputs or samples which i can work on. In case someone already has a snippet, please share.

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

Global Moderator


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

PostPosted: Wed Jan 11, 2012 6:43 pm
Reply with quote

Since this apppears to be a relatively simple task using a DO loop structure it would be great if you could show us what you've done so far and maybe point out where you're stuck.
Back to top
View user's profile Send private message
Pedro

Global Moderator


Joined: 01 Sep 2006
Posts: 2546
Location: Silicon Valley

PostPosted: Wed Jan 11, 2012 7:59 pm
Reply with quote

Quote:
I have two questions for which...


It is not clear what your questions are... please re-state.
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1788
Location: Bloomington, IL

PostPosted: Wed Jan 11, 2012 8:33 pm
Reply with quote

mathi.vanan wrote:
I need to build a rexx routine which would pass 2 dsn names and sort keys for a sort JCL. I believe that sort can be done within the REXX routine as well, but the JCL has few more functions as well.

The rexx routine would have N number of for DSNs and it would pass 2 DSNs every time to the sort JCL. i.e (the routine would call the JCL 'N' number of times)

It is probably preferable that you not try to write this using only Rexx, but that you also use ISPF services.

Where will you get the DSNs from? Command line, ISPF panel, a data set? Are the input data sets expected to have identical DCBs? Will the control cards be the same for every sort?

Will you want to build multiple jobs, or one job with multiple steps? Will the JCL be submitted immediately, or will the JCL be held in a data set or data sets, or in a member or members of a PDS(E), for later review?
Back to top
View user's profile Send private message
mathi.vanan

New User


Joined: 11 Jan 2012
Posts: 18
Location: INDIA

PostPosted: Thu Jan 12, 2012 12:44 am
Reply with quote

Pedro and Akatsukami:

I have a list of around 200 files to be sorted and compared. The file names would be fixed and so i can use them within the REXX routine, inside a DO loop for calling the JCL.

But, i am stuck in how the file names and the sort keys are to be sent to the JCL. Sort keys would vary for each file. Hence i would be considering the JCL proc to be called for every file from the REXX routine in a loop.

I need help in how the file names and sort keys should be sent from REXX to JCL.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Thu Jan 12, 2012 1:06 am
Reply with quote

Hello,

For each interation of the loop, generate all of the jcl needed to run the batch job for that iteration. When the jcl is built, SUBmit the jcl and continue with the next iteration of the loop.

There is no "passing to jcl" - you create it as you need it.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Thu Jan 12, 2012 1:16 am
Reply with quote

looks like the most difficult part would be to associate the proper sort cards to each dataset

is there anything in the dataset name to help You determine the sort cards

I would not have the sort cards <inlined> better store each set as a pds member and point the sort sysin to the appropriate member

no need to change the rexx if something changes

also if the datasets are fixed any reason to regenerate the jcl for each execution.

somehow the requirement does not look so clear
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1788
Location: Bloomington, IL

PostPosted: Thu Jan 12, 2012 2:48 am
Reply with quote

mathi.vanan wrote:
But, i am stuck in how the file names and the sort keys are to be sent to the JCL. Sort keys would vary for each file. Hence i would be considering the JCL proc to be called for every file from the REXX routine in a loop.

I need help in how the file names and sort keys should be sent from REXX to JCL.

Again, I would not use pure Rexx, but the ISPF file-tailoring services. Assuming that your DSNs and sort arguments are in stem variables, the pseudo-code would be:
Code:
do i = 1 to lots
  dsn1 = stem.1.i
  dsn2 = stem.2.i
  etc.
  FTOPEN
  FTINCL skeleton
  FTCLOSE member-name-root || i
 
  if (desired) then "SUBMIT" JCL
end
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Thu Jan 12, 2012 10:45 am
Reply with quote

Hello,

Keeping in mind that you are very new to TSO/Online programming, what you want to do might not be the best task to do first. . . In addition to learning REXX you will probably need to learn some amount of ISPF. File Tailoring is a very good approach, but this is yet another completely new discipline to learn.

If this is wanted soon, it confuses me that the task was given to someone with no REXX experience. . . icon_confused.gif

Do you program in any mainframe languages? Long ago (before REXX on MVS) we wrote this kind of thing in COBOL (or assembler if one knew assembler).
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Thu Jan 12, 2012 3:34 pm
Reply with quote

mathi.vanan wrote:
I have a list of around 200 files to be sorted and compared.

Did you mean "100 couples" or is it "200 couples"?

Before writing even one line in REXX, you have to know exactly what program(s) you need to run for your purpose.
You also have to decide what to do with the output itself: Leave it in SDSF? Save it as members in a PDS?
Then create a job which processes one couple of files, run it until you have your desired output.

You have to decide whether you will run one job with the 200 couples in it, or 200 jobs with one couple in each.
Or, as you said, run the process from within your REXX program.
Base your decision on the expected CPU and elapse time, maybe.

Independently, create a parameter file which contains the file names.
I would use the format: dsname1 dsname2 sortinfo
It makes it easy to read in REXX:
Code:
"EXECIO * DISKR FILELIST (FINIS STEM flist."
Do ifl = 1 to flist.0
   Parse Var flist.ifl dsnleft dsnright sortkey
   Call Process_files
End
Exit

Process_files:
   Say "File one is <"dsnleft">"
   Say "File two is <"dsnright">"
   Say "Sort keys is <"sortkey">"
   /* process here */
Return


The process itself depends on what you decided earlier,
so do your thinking and checking and come back if you need more help (or rather when you need more help).
Also, start to learn about File Tailoring (4 services starting with FT in this book).
Back to top
View user's profile Send private message
Michael Jakob

New User


Joined: 13 Mar 2011
Posts: 17
Location: Switzerland

PostPosted: Wed Jan 25, 2012 3:35 am
Reply with quote

Did you check the possibility of filling and submitting by a stack?
/* create an new stack */
ADDRESS 'TSO' "NEWSTACK"

/* fill your stack with lines of jcl */
QUEUE "//XXX JOB (asdf)"
DO XX=1 TO 200;
QUEUE "//S01 EXEC PGM=ICETOOL"
QUEUE "//IN040 DD DISP=SHR,DSN="MYDSNAME.XX
...
END;

/* start your job */
ADDRESS "TSO" "SUBMIT *"
/* get rid of your private stack */
ADDRESS "TSO" "DELSTACK"

With each queue you create an line of JCL. In the queue statement, you can mix variables and constants. With this pattern, you can create easily an large JCL and submit it.

By the way with ICETOOL you can sort many datasets in one step. I would guess you could sort all 200 pairs of datasets in one step.
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Wed Jan 25, 2012 1:49 pm
Reply with quote

Why oh why oh why do people keep suggesting that JCL should be built instream by REXX.

Could someone please explain to me what the real big issue with using ISPF FT services are

Please
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2481
Location: Netherlands, Amstelveen

PostPosted: Wed Jan 25, 2012 1:59 pm
Reply with quote

There are some possibilities :

people never heard about ISPF (and its services)
ISPF is not installed

and now im terrible tired guessing for more reasons.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Wed Jan 25, 2012 2:05 pm
Reply with quote

see here for a working ( tested ) snippet of looping a FTINCL clause
www.ibmmainframes.com/viewtopic.php?t=55549&highlight=ftincl
Back to top
View user's profile Send private message
don.leahy

Active Member


Joined: 06 Jul 2010
Posts: 765
Location: Whitby, ON, Canada

PostPosted: Wed Jan 25, 2012 6:29 pm
Reply with quote

expat wrote:
Why oh why oh why do people keep suggesting that JCL should be built instream by REXX.

Could someone please explain to me what the real big issue with using ISPF FT services are

Please
None that I can think of.

Some aspects of FT skeleton syntax used to be somewhat arcane, but now that structures such as )IF )ELSE )ENDIF and )DO )ITERATE )LEAVE )ENDDO and )REXX )ENDREXX are supported FT much more closely resembles other programming languages.
Back to top
View user's profile Send private message
superk

Global Moderator


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

PostPosted: Wed Jan 25, 2012 7:04 pm
Reply with quote

I'll admit that I don't use File Tailoring Services much myself. I think a lot of that has to do with the fact that I'm usually writing REXX for batch processes, and that these are usually one-off single process types of exercises. Not much of an excuse, I know. I think if I was doing more foreground processing and sharing resources among a large group I'd rely much more on FT services.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Wed Jan 25, 2012 7:16 pm
Reply with quote

here is a snippet using the latest ISPF facilities

the REXX script ( save it with any name You want )
Code:
 ****** ***************************** Top of Data ******************************
 000001 /* REXX */                                                             
 000002 Trace "O"                                                               
 000003 jmax = 2                                                               
 000004 smax = 2                                                               
 000005 call $ispex "FTOPEN TEMP"                                               
 000006 call $ispex "FTINCL JSKEl2"                                             
 000007 call $ispex "FTCLOSE "                                                 
 000008 call $ispex "VGET ZTEMPF "                                             
 000009 call $ispex "VIEW DATASET('"ztempf"')"                                 
 000010 Exit 0                                                                 
 000011                                                                         
 000012 /* */                                                                   
 000013 $ispex:                                                                 
 000014    isp_0tr = trace("O")                                                 
 000015    Address ISPEXEC arg(1)                                               
 000016    isp_0rc = rc                                                         
 000017    trace value(isp_0tr)                                                 
 000018    return isp_0rc                                                       
 ****** **************************** Bottom of Data ****************************


the JOB skel ( save it as JSKEL2 )
Code:
 ****** ***************************** Top of Data ******************************
 000001 )DO JNUM = 1 TO &JMAX                                                   
 000002 //J&JNUM JOB (ACCT),'JSKEL',NOTIFY=ENRICO,                             
 000003 //             CLASS=A,MSGCLASS=X,MSGLEVEL=(1,1)                       
 000004 //* JOB  &JNUM OF &JMAX                                                 
 000005 //* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -   
 000006 )DO SNUM = 1 TO &SMAX                                                   
 000007 )IM SSKEL2                                                             
 000008 )ENDDO                                                                 
 000009 //*                                                                     
 000010 )ENDDO                                                                 
 ****** **************************** Bottom of Data ****************************


the STEP skel ( save it as SSKEL2 )
Code:
 ****** ***************************** Top of Data ******************************
 000001 //S&SNUM   EXEC PGM=IEFBR14                                             
 000002 //* JOB   &JNUM OF &JMAX                                               
 000003 //* STEP  &SNUM OF &SMAX                                               
 000004 //* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -   
 ****** **************************** Bottom of Data ****************************


have fun
( TESTED AND WORKING )

but the top skel could also be written as

Code:
 ****** ***************************** Top of Data ******************************
 000001 )DO JNUM = 1 TO &JMAX                                                   
 000002 //J&JNUM JOB (ACCT),'JSKEL',NOTIFY=ENRICO,                             
 000003 //             CLASS=A,MSGCLASS=X,MSGLEVEL=(1,1)                       
 000004 //* JOB  &JNUM OF &JMAX                                                 
 000005 //* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -   
 000006 )DO SNUM = 1 TO &SMAX                                                   
 000007 //S&SNUM   EXEC PGM=IEFBR14                                             
 000008 //* JOB   &JNUM OF &JMAX                                               
 000009 //* STEP  &SNUM OF &SMAX                                               
 000010 //* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -   
 000011 )ENDDO                                                                 
 000012 //*                                                                     
 000013 )ENDDO                                                                 
 ****** **************************** Bottom of Data ****************************
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Thu Jan 26, 2012 4:59 pm
Reply with quote

Two weeks since mathi.vanan last post.
It would be nice to hear if he finished "breaking his head"...
Back to top
View user's profile Send private message
chaoj

Active User


Joined: 03 Jun 2010
Posts: 103
Location: Dalian

PostPosted: Fri Jan 27, 2012 9:42 am
Reply with quote

expat wrote:
Why oh why oh why do people keep suggesting that JCL should be built instream by REXX.

Could someone please explain to me what the real big issue with using ISPF FT services are

Please


Some times I need call rexx code in JCL , If I use ISPF service in rexx , I need allocate many ISPF lib with DD card like ISPMLIB,ISPPLIB....

and because the ISPF lib in develop environment is different from the product environment in my side, so I need write JCL twice . This is my reason for not use ISPF service if I call rexx code in JCL.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Fri Jan 27, 2012 1:28 pm
Reply with quote

Quote:
and because the ISPF lib in develop environment is different from the product environment in my side, so I need write JCL twice . This is my reason for not use ISPF service if I call rexx code in JCL.


stupid reason not to use the ISPF functionalities
I have never seen (*) BATCH ISPF execution use nothing more than the basic ISPF libraries
and just the user load and rexx/clist libraries

(*) I have been using REXX and ISPF since their appearance on the scene
a few hundreds scripts and couple dozen customers

Code:
 000005 //ISPF    EXEC PGM=IKJEFT1A,PARM='ISPSTART CMD(YOURREXX)'               
 000006 //STEPLIB   DD DISP=SHR,DSN=YOUR.LOAD.LIBRARY                           
 000007 //SYSPROC   DD DISP=SHR,DSN=YOUR.REXX.LIBRARY                           
 000008 //ISPPROF   DD DISP=(,PASS),DSN=&&ISPPROF,                             
 000009 //             UNIT=SYSDA,SPACE=(CYL,(2,0,44)),                         
 000010 //             DCB=(RECFM=FB,LRECL=80)                                 
 000011 //ISPPLIB   DD DISP=SHR,DSN=ISP.SISPPENU                               
 000012 //ISPMLIB   DD DISP=SHR,DSN=ISP.SISPMENU                               
 000013 //ISPSLIB   DD DISP=SHR,DSN=ISP.SISPSLIB                               
 000014 //ISPTLIB   DD DISP=SHR,DSN=ISP.SISPTENU                               
 000015 //SYSPRINT  DD SYSOUT=*                                                 
 000016 //SYSTSPRT  DD SYSOUT=*                                                 
 000017 //SYSTSIN   DD DUMMY                                                   
Back to top
View user's profile Send private message
don.leahy

Active Member


Joined: 06 Jul 2010
Posts: 765
Location: Whitby, ON, Canada

PostPosted: Fri Jan 27, 2012 7:29 pm
Reply with quote

The other bogus excuse for not using ISPF facilities is: "it adds too much overhead". So they end up writing an extra 500 lines of code to do what ISPF services can do with one call. icon_rolleyes.gif
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1788
Location: Bloomington, IL

PostPosted: Fri Jan 27, 2012 8:05 pm
Reply with quote

chaoj wrote:
and because the ISPF lib in develop environment is different from the product environment in my side, so I need write JCL twice . This is my reason for not use ISPF service if I call rexx code in JCL.

Unlike every other library in your development environment?

My current client's development and test environments are on different sysplexes than its production environments. Still, the libraries (and all other data sets) have different HLQs.
Back to top
View user's profile Send private message
chaoj

Active User


Joined: 03 Jun 2010
Posts: 103
Location: Dalian

PostPosted: Mon Jan 30, 2012 7:45 am
Reply with quote

enrico-sorichetti wrote:
Quote:
and because the ISPF lib in develop environment is different from the product environment in my side, so I need write JCL twice . This is my reason for not use ISPF service if I call rexx code in JCL.


stupid reason not to use the ISPF functionalities
I have never seen (*) BATCH ISPF execution use nothing more than the basic ISPF libraries
and just the user load and rexx/clist libraries

(*) I have been using REXX and ISPF since their appearance on the scene
a few hundreds scripts and couple dozen customers

Code:
 000005 //ISPF    EXEC PGM=IKJEFT1A,PARM='ISPSTART CMD(YOURREXX)'               
 000006 //STEPLIB   DD DISP=SHR,DSN=YOUR.LOAD.LIBRARY                           
 000007 //SYSPROC   DD DISP=SHR,DSN=YOUR.REXX.LIBRARY                           
 000008 //ISPPROF   DD DISP=(,PASS),DSN=&&ISPPROF,                             
 000009 //             UNIT=SYSDA,SPACE=(CYL,(2,0,44)),                         
 000010 //             DCB=(RECFM=FB,LRECL=80)                                 
 000011 //ISPPLIB   DD DISP=SHR,DSN=ISP.SISPPENU                               
 000012 //ISPMLIB   DD DISP=SHR,DSN=ISP.SISPMENU                               
 000013 //ISPSLIB   DD DISP=SHR,DSN=ISP.SISPSLIB                               
 000014 //ISPTLIB   DD DISP=SHR,DSN=ISP.SISPTENU                               
 000015 //SYSPRINT  DD SYSOUT=*                                                 
 000016 //SYSTSPRT  DD SYSOUT=*                                                 
 000017 //SYSTSIN   DD DUMMY                                                   


Sometimes people should say something stupid , or they can not learn from others

You're right enrico , I used basic ISPF libraries , it's working icon_redface.gif

my code is below
Code:
//RUNREXX EXEC PGM=IKJEFT01                   
//SYSEXEC  DD  DSN=PK80I.EV6946.EXEC,DISP=SHR
//ISPPROF  DD  DISP=(,PASS),DSN=&&ISPPROF,   
//            UNIT=SYSDA,SPACE=(CYL,(2,0,44)),
//            DCB=(RECFM=FB,LRECL=80)         
//ISPPLIB  DD  DSN=SYS1.SISPPENU,DISP=SHR     
//ISPSLIB  DD  DSN=SYS1.SISPSENU,DISP=SHR     
//ISPTLIB  DD  DSN=SYS1.SISPTENU,DISP=SHR     
//ISPMLIB  DD  DSN=SYS1.SISPMENU,DISP=SHR     
//SYSPRINT DD  SYSOUT=*                       
//SYSTSPRT DD  SYSOUT=*                       
//SYSTSIN  DD  *                             
ISPSTART CMD(%ZREXXBAT)                       
/*                                           
Back to top
View user's profile Send private message
Pedro

Global Moderator


Joined: 01 Sep 2006
Posts: 2546
Location: Silicon Valley

PostPosted: Mon Jan 30, 2012 11:05 pm
Reply with quote

Quote:
So they end up writing an extra 500 lines of code to do what ISPF services can do with one call.


Actually, I think that in some instances the overhead is a valid concern (though your results may vary). If the program is doing something repeatedly, then your 500 lines of code may be better than one call to ISPF services. That one call to ISPF services may result in executing thousands of lines of ISPF's code.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Mon Jan 30, 2012 11:16 pm
Reply with quote

if there are overhead and performance concerns REXX,ISPF and friends should not be used FULL STOP
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 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
No new posts run rexx code with jcl CLIST & REXX 15
No new posts Execute secondary panel of sdsf with ... CLIST & REXX 1
Search our Forums:

Back to Top