Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Looping in REXX and pass data to JCL.
Goto page 1, 2  Next
 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX
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    Post subject: Looping in REXX and pass data to JCL.
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

Moderator Team Head


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

PostPosted: Wed Jan 11, 2012 6:43 pm    Post subject: Reply to: Looping in REXX and pass data to JCL.
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

Senior Member


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

PostPosted: Wed Jan 11, 2012 7:59 pm    Post subject: Reply to: Looping in REXX and pass data to JCL.
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: 1738
Location: Bloomington, IL

PostPosted: Wed Jan 11, 2012 8:33 pm    Post subject: Re: Looping in REXX and pass data to JCL.
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    Post subject:
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

Site Director


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

PostPosted: Thu Jan 12, 2012 1:06 am    Post subject:
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10203
Location: italy

PostPosted: Thu Jan 12, 2012 1:16 am    Post subject: Reply to: Looping in REXX and pass data to JCL.
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: 1738
Location: Bloomington, IL

PostPosted: Thu Jan 12, 2012 2:48 am    Post subject:
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

Site Director


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

PostPosted: Thu Jan 12, 2012 10:45 am    Post subject:
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: 1219
Location: Israel

PostPosted: Thu Jan 12, 2012 3:34 pm    Post subject: Reply to: Looping in REXX and pass data to JCL.
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    Post subject: Create JCL by REXX without ISPF-File-Tailoring services.
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: 8593
Location: Back in jolly old England

PostPosted: Wed Jan 25, 2012 1:49 pm    Post subject:
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: 2422
Location: Netherlands, Amstelveen

PostPosted: Wed Jan 25, 2012 1:59 pm    Post subject:
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10203
Location: italy

PostPosted: Wed Jan 25, 2012 2:05 pm    Post subject: Reply to: Looping in REXX and pass data to JCL.
Reply with quote

see here for a working ( tested ) snippet of looping a FTINCL clause
http://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: 641
Location: Whitby, ON, Canada

PostPosted: Wed Jan 25, 2012 6:29 pm    Post subject:
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

Moderator Team Head


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

PostPosted: Wed Jan 25, 2012 7:04 pm    Post subject: Reply to: Looping in REXX and pass data to JCL.
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10203
Location: italy

PostPosted: Wed Jan 25, 2012 7:16 pm    Post subject: Reply to: Looping in REXX and pass data to JCL.
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: 1219
Location: Israel

PostPosted: Thu Jan 26, 2012 4:59 pm    Post subject:
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    Post subject:
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10203
Location: italy

PostPosted: Fri Jan 27, 2012 1:28 pm    Post subject: Reply to: Looping in REXX and pass data to JCL.
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
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX All times are GMT + 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
This topic is locked: you cannot edit posts or make replies. Unwrap the data based on delimiter X'25' bhavana yalavarthi DFSORT/ICETOOL 30 Fri Dec 09, 2016 10:25 am
No new posts Is the 'prompt' data for the DSLIST p... Willy Jensen TSO/ISPF 2 Tue Dec 06, 2016 4:38 am
This topic is locked: you cannot edit posts or make replies. How to move a long alphanumeric data ... lind sh COBOL Programming 8 Mon Dec 05, 2016 7:51 pm
No new posts What is the command to check MODE of ... rohanthengal CLIST & REXX 6 Fri Nov 18, 2016 1:48 pm
No new posts ODPP(Optim Data privacy Provider) Iss... Rama kishore IBM Tools 1 Mon Nov 07, 2016 5:46 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us