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

rexx to generate tailored jcl based on file input


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

New User


Joined: 12 Oct 2006
Posts: 32
Location: India

PostPosted: Fri Oct 05, 2007 8:03 pm
Reply with quote

Hi,

I have the below requirement.

Could you please send the REXX code please. As i am very new to REXX coding.

--------------------------------------------

First it need to read a input file which contains the below records
OSL1 ADDR
OSL2 ADDR
OSL3 ADDR
SDH ADDR
TSDH ADDR
LIMS ADDR
NCM APPE
INS APPR
NCM APPR
DUNE BKSE
NCM BKSE
NCM DOFO
NCM EQAP
BERT EQUT
NCM EQUT
SDH EQUT
TSDH EQUT
SDH EXCH
TSDH EXCH
LIMS EXCH
INS NETI
NCM NETI
INS PRTG
NCM PRTG
SDH STTN
TSDH STTN
COSX STTN
LIMS STTN
NCM ULOC
SDH ULOC
TSDH ULOC
BERT UTER
RUNNO 010608

By taking the last record RUNNO Value now ie 010608 from the input file

Then need to read a second file again the file name will be depends on the RUNNO.

In this situation the FIle name will be as DSN1AUD.ULOC.VEXTENS.A****** (* represents the runno in the first file)

Then needs to write the second file contents into the third file.


Please help in coding this.

I dont know much REXX coding.

Re-titled from "Rexx coding required for the below requirement" by dbz
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Fri Oct 05, 2007 8:14 pm
Reply with quote

don't know much about naming topics either.

whatever solution you receive, no one will ever find it with a search.

what is the size of the second file that you need to read and propogate as a third? If this is a large file (large records or many records) rexx may not be the appropriate tool.

If the second file is potentially large or of vsam type, you would be better off using a REXX script to build the appropriate jcl (dataset name) for a cobol module that would read the second file and write to a third. You could read the cryptic first file, generate the jcl and submit the job which would invoke a module that would better fit the requirements of the copy job (such as sort, iebgener, etc..or a COBOL module if something convoluted must be accomplished..).
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Fri Oct 05, 2007 8:43 pm
Reply with quote

Hi !

the question is badly described!

the content of the first file is irrelevant except for the runno record..
and the position of the aforesaid record

if it can occur in any position then an EXECIO loop is needed

if it is allways the last one and the number of record is less than 5000
reading all at one and analyzing the STEM.last record will be much faster

after this from the info posted it should be VERY simple to generate the
input dataset name and the jcl to repro it wherever this strange requirement wants


regards


e.s
Back to top
View user's profile Send private message
narasridhar

New User


Joined: 12 Oct 2006
Posts: 32
Location: India

PostPosted: Sat Oct 06, 2007 12:58 am
Reply with quote

enrico-sorichetti wrote:
Hi !

the question is badly described!

the content of the first file is irrelevant except for the runno record..
and the position of the aforesaid record

if it can occur in any position then an EXECIO loop is needed

if it is allways the last one and the number of record is less than 5000
reading all at one and analyzing the STEM.last record will be much faster

after this from the info posted it should be VERY simple to generate the
input dataset name and the jcl to repro it wherever this strange requirement wants


regards


e.s



Your understanding is correct. It has only the records mentioned in the above post. It is always the last record.

As mentioned i need a REXX code to genarate the filename and to create the IEBGENR copy jcl in the REXX code.

Thanks in advance
Sri
Back to top
View user's profile Send private message
ofer71

Global Moderator


Joined: 27 Dec 2005
Posts: 2358
Location: Israel

PostPosted: Sat Oct 06, 2007 3:56 am
Reply with quote

Just to be sure: Do you expect us to give you a ready-to-run REXX code?

O.
Back to top
View user's profile Send private message
narasridhar

New User


Joined: 12 Oct 2006
Posts: 32
Location: India

PostPosted: Sat Oct 06, 2007 4:07 am
Reply with quote

ofer71 wrote:
Just to be sure: Do you expect us to give you a ready-to-run REXX code?

O.


Yes please as i am very new to this programming.
Back to top
View user's profile Send private message
ofer71

Global Moderator


Joined: 27 Dec 2005
Posts: 2358
Location: Israel

PostPosted: Sat Oct 06, 2007 4:48 am
Reply with quote

Do you also want us to debug it for you?

O.
Back to top
View user's profile Send private message
narasridhar

New User


Joined: 12 Oct 2006
Posts: 32
Location: India

PostPosted: Sat Oct 06, 2007 5:02 am
Reply with quote

ofer71 wrote:
Do you also want us to debug it for you?

O.


Nope..

i just want to know how to submit the jcl in the rexx program
Back to top
View user's profile Send private message
saiprasadh

Active User


Joined: 20 Sep 2006
Posts: 154
Location: US

PostPosted: Sat Oct 06, 2007 11:39 am
Reply with quote

Hi Sridhar,

I hope the below rexx code will meet your requirement.

Code:
/*****REXX******/                                                     
SAY 'ENTER THE FILE NAME'                                             
PULL PSNAME                                                           
ADDRESS TSO                                                           
"ALLOC DA('"PSNAME"') FI(MYINDD) SHR REUSE"                           
"EXECIO * DISKR MYINDD (STEM INDATA. FINIS"                           
"FREE FI(MYINDD)"                                                     
FINAL = INDATA.0                                                       
LAST_STR = INDATA.FINAL                                               
PARSE VAR LAST_STR TXT ' ' NUM .                                       
QUEUE "//JOBCARD                                                    " 
QUEUE "//*                                                          " 
QUEUE "//STEP01  EXEC  SORTD                                        " 
QUEUE "//SORTIN   DD  DSN=ADSN1AUD.ULOC.VEXTENS.A"||NUM||",         " 
QUEUE "//             DISP=SHR                                      " 
QUEUE "//SORTOUT  DD  DSN=ADSN1AUD.ULOC.VEXTENS.A"||NUM||".THR,     " 
QUEUE "//             DISP=(NEW,CATLG,DELETE),                      " 
QUEUE "//             UNIT=SYSDA,SPACE=(CYL,(800,200),RLSE),        " 
QUEUE "//             DCB=(*.SORTIN)                                "   
QUEUE "//SYSIN  DD  *                                               "   
QUEUE " SORT FIELDS=COPY                                            "   
QUEUE "/*"                                                             
QUEUE "//*"                                                             
QUEUE "$$"                                                             
X = OUTTRAP('LOG.')                                                     
"SUBMIT * END($$)"                                                     
X = OUTTRAP('OFF')                                                     
PARSE VAR LOG.2 "JOB" JOBID MESSAGE                                     
SAY 'A JOB IS SUBMITTED IN THIS '||JOBID||' FOR CREATING THE THIRD FILE'


Thanks
Sai
Back to top
View user's profile Send private message
expat

Global Moderator


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

PostPosted: Sat Oct 06, 2007 3:18 pm
Reply with quote

So being new to REXX, what have you read to find out that REXX is able to perform this function, and more importantly what have you tried for yourself and what were the results.

Have you searched the REXX libraries at your shop for examples of working code ?

Are you willing to pay the current rate for a bespoke solution ?
Back to top
View user's profile Send private message
narasridhar

New User


Joined: 12 Oct 2006
Posts: 32
Location: India

PostPosted: Sat Oct 06, 2007 6:45 pm
Reply with quote

saiprasadh wrote:
Hi Sridhar,

I hope the below rexx code will meet your requirement.

Code:
/*****REXX******/                                                     
SAY 'ENTER THE FILE NAME'                                             
PULL PSNAME                                                           
ADDRESS TSO                                                           
"ALLOC DA('"PSNAME"') FI(MYINDD) SHR REUSE"                           
"EXECIO * DISKR MYINDD (STEM INDATA. FINIS"                           
"FREE FI(MYINDD)"                                                     
FINAL = INDATA.0                                                       
LAST_STR = INDATA.FINAL                                               
PARSE VAR LAST_STR TXT ' ' NUM .                                       
QUEUE "//JOBCARD                                                    " 
QUEUE "//*                                                          " 
QUEUE "//STEP01  EXEC  SORTD                                        " 
QUEUE "//SORTIN   DD  DSN=ADSN1AUD.ULOC.VEXTENS.A"||NUM||",         " 
QUEUE "//             DISP=SHR                                      " 
QUEUE "//SORTOUT  DD  DSN=ADSN1AUD.ULOC.VEXTENS.A"||NUM||".THR,     " 
QUEUE "//             DISP=(NEW,CATLG,DELETE),                      " 
QUEUE "//             UNIT=SYSDA,SPACE=(CYL,(800,200),RLSE),        " 
QUEUE "//             DCB=(*.SORTIN)                                "   
QUEUE "//SYSIN  DD  *                                               "   
QUEUE " SORT FIELDS=COPY                                            "   
QUEUE "/*"                                                             
QUEUE "//*"                                                             
QUEUE "$$"                                                             
X = OUTTRAP('LOG.')                                                     
"SUBMIT * END($$)"                                                     
X = OUTTRAP('OFF')                                                     
PARSE VAR LOG.2 "JOB" JOBID MESSAGE                                     
SAY 'A JOB IS SUBMITTED IN THIS '||JOBID||' FOR CREATING THE THIRD FILE'


Thanks
Sai



Thank's alot Sai.

I am getting the error while running ...

Please find the REXX code and error screen shots in the attached doc.
Back to top
View user's profile Send private message
expat

Global Moderator


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

PostPosted: Sat Oct 06, 2007 6:53 pm
Reply with quote

narasridhar

Please do not use attachments as many sites prevent these from being opened, which limits the number of people available to help you.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Sat Oct 06, 2007 6:55 pm
Reply with quote

Quote:

ofer71 wrote:
Do you also want us to debug it for you?

O.


Nope..


promises promises
Back to top
View user's profile Send private message
expat

Global Moderator


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

PostPosted: Sat Oct 06, 2007 7:01 pm
Reply with quote

Code:

PARSE VAR LAST_STR TXT ' ' NUM . 


Template parsing is great, but if there is more than the number of specified spaces between the two fields it can go horribly wrong. I know because I have spent a couple of hours debugging someone elses code using template parsing.

In this situation I would use
Code:
PARSE VAR LAST_STR TXT NUM . 
to cater for any number of spaces.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Sat Oct 06, 2007 7:33 pm
Reply with quote

I feel in a very very good mood today,
here is a WORKING and when I say WORKING it means that I have tested it,
solution ( just sketched )

here are the steps hoping that You will learn something from them :-)

1) allocate two datasets
Youruserid.MF.CLIST
Youruserid.MF.JCLLIB

Both with
recordformat FB
lrecl 80
blkize .... let the system take care of it
space :
primary cyl 2
secondary cyl 2
directory blocks 2
-enough for this simple exercise

the content should be
for the clist pds
GENJCL the rexx script
for the jcl dataset
GENJCL the jcl to run the script
CNTL your control dataset

at this point here is the content


the rexx script
Code:
 
/*REXX - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/*                                                                   */
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
Trace "O"                                                             
                                                                       
Address TSO "EXECIO * DISKR CNTL (STEM CNTL. FINIS"                   
last = cntl.0                                                         
temp = strip(cntl.last)                                               
indx = strip(word(temp,2))                                             
                                                                       
jclx.1 = "//ENRICOMF JOB (H001),'GENJCL',NOTIFY=ENRICO,"               
jclx.2 = "//             CLASS=A,MSGCLASS=X,MSGLEVEL=(1,1)"           
jclx.3 = "//             TYPRUN=HOLD"                                 
jclx.4 = "//*"                                                         
jclx.5 = "//COPY    EXEC PGM=IEBGENER"                                 
jclx.6 = "//SYSPRINT  DD SYSOUT=*"                                     
jclx.7 = "//*            INPUT DATASET"                               
jclx.8 = "//SYSUT1    DD DISP=SHR,DSN=ENRICO.MF.A" || indx             
jclx.9 = "//*            OUTPUT DATASET"                               
jclx.10= "//SYSUT2    DD DISP=SHR,DSN=ENRICO.MF.OUTPUT"               
coun     = 10                                                         
if jclx.3 <> "//*" then ,                                             
   jclx.2 = jclx.2 || ","                                             
                                                                       
Address TSO "EXECIO " coun " DISKW JCLX (STEM JCLX. FINIS"             
                                                                       
Exit                                                                   


The JCL to run it

Code:

//ENRICOMF JOB (H001),'GENJCL',NOTIFY=ENRICO,                         
//             CLASS=A,MSGCLASS=X,MSGLEVEL=(1,1)                       
//* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
//*            DSN=ENRICO.MF.JCLLIB(GENJCL)                           
//* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
//*                                                                   
//TSO     EXEC PGM=IKJEFT01,                                           
//             REGION=0M,                                             
//             DYNAMNBR=20                                             
//SYSPROC   DD DISP=SHR,DSN=ENRICO.MF.CLIST                           
//SYSABEND  DD SYSOUT=*                                               
//SYSPRINT  DD SYSOUT=*                                               
//SYSTSPRT  DD SYSOUT=*                                               
//SYSTSIN   DD *                                                       
  GENJCL                                                               
//JCLX      DD SYSOUT=(B,INTRDR),                                     
//             DCB=(RECFM=FB,LRECL=80,BLKSIZE=80)                     
//CNTL      DD DISP=SHR,DSN=ENRICO.MF.JCLLIB(CNTL)                     



here the CNTL ( snipped a few line )


Code:

OSL1 ADDR   
OSL2 ADDR   
....         
....         
TSDH ULOC   
BERT UTER   
RUNNO 010608


change all the occurrences of "ENRICO" ( that' s my userid ) with Your userid

after running it You should find into the input queue ( SDSF I)
the copy job

I WILL NOT ANSWER ANY QUESTIONS RELATED TO THIS POST
...
THE USUAL LEGALESE DISCLAIMER ABOUT DAMAGES, MERCHANTABILITY, FITNESS, IMPLIED, ..... AND SO ON

the rexx script was kept to a working minimun it's up to You to learn and document Yourself

regards

e.s
Back to top
View user's profile Send private message
narasridhar

New User


Joined: 12 Oct 2006
Posts: 32
Location: India

PostPosted: Sat Oct 06, 2007 9:01 pm
Reply with quote

enrico-sorichetti wrote:
I feel in a very very good mood today,
here is a WORKING and when I say WORKING it means that I have tested it,
solution ( just sketched )

here are the steps hoping that You will learn something from them :-)

1) allocate two datasets
Youruserid.MF.CLIST
Youruserid.MF.JCLLIB

Both with
recordformat FB
lrecl 80
blkize .... let the system take care of it
space :
primary cyl 2
secondary cyl 2
directory blocks 2
-enough for this simple exercise

the content should be
for the clist pds
GENJCL the rexx script
for the jcl dataset
GENJCL the jcl to run the script
CNTL your control dataset

at this point here is the content


the rexx script
Code:
 
/*REXX - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/*                                                                   */
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
Trace "O"                                                             
                                                                       
Address TSO "EXECIO * DISKR CNTL (STEM CNTL. FINIS"                   
last = cntl.0                                                         
temp = strip(cntl.last)                                               
indx = strip(word(temp,2))                                             
                                                                       
jclx.1 = "//ENRICOMF JOB (H001),'GENJCL',NOTIFY=ENRICO,"               
jclx.2 = "//             CLASS=A,MSGCLASS=X,MSGLEVEL=(1,1)"           
jclx.3 = "//             TYPRUN=HOLD"                                 
jclx.4 = "//*"                                                         
jclx.5 = "//COPY    EXEC PGM=IEBGENER"                                 
jclx.6 = "//SYSPRINT  DD SYSOUT=*"                                     
jclx.7 = "//*            INPUT DATASET"                               
jclx.8 = "//SYSUT1    DD DISP=SHR,DSN=ENRICO.MF.A" || indx             
jclx.9 = "//*            OUTPUT DATASET"                               
jclx.10= "//SYSUT2    DD DISP=SHR,DSN=ENRICO.MF.OUTPUT"               
coun     = 10                                                         
if jclx.3 <> "//*" then ,                                             
   jclx.2 = jclx.2 || ","                                             
                                                                       
Address TSO "EXECIO " coun " DISKW JCLX (STEM JCLX. FINIS"             
                                                                       
Exit                                                                   


The JCL to run it

Code:

//ENRICOMF JOB (H001),'GENJCL',NOTIFY=ENRICO,                         
//             CLASS=A,MSGCLASS=X,MSGLEVEL=(1,1)                       
//* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
//*            DSN=ENRICO.MF.JCLLIB(GENJCL)                           
//* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
//*                                                                   
//TSO     EXEC PGM=IKJEFT01,                                           
//             REGION=0M,                                             
//             DYNAMNBR=20                                             
//SYSPROC   DD DISP=SHR,DSN=ENRICO.MF.CLIST                           
//SYSABEND  DD SYSOUT=*                                               
//SYSPRINT  DD SYSOUT=*                                               
//SYSTSPRT  DD SYSOUT=*                                               
//SYSTSIN   DD *                                                       
  GENJCL                                                               
//JCLX      DD SYSOUT=(B,INTRDR),                                     
//             DCB=(RECFM=FB,LRECL=80,BLKSIZE=80)                     
//CNTL      DD DISP=SHR,DSN=ENRICO.MF.JCLLIB(CNTL)                     



here the CNTL ( snipped a few line )


Code:

OSL1 ADDR   
OSL2 ADDR   
....         
....         
TSDH ULOC   
BERT UTER   
RUNNO 010608


change all the occurrences of "ENRICO" ( that' s my userid ) with Your userid

after running it You should find into the input queue ( SDSF I)
the copy job

I WILL NOT ANSWER ANY QUESTIONS RELATED TO THIS POST
...
THE USUAL LEGALESE DISCLAIMER ABOUT DAMAGES, MERCHANTABILITY, FITNESS, IMPLIED, ..... AND SO ON

the rexx script was kept to a working minimun it's up to You to learn and document Yourself

regards

e.s



Hi E.S

Thanks alot for your help and for your valuable time

It worked successfully.

No questions again for your answer as you given answer in such a way to unserstand by anyone.
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 How to split large record length file... DFSORT/ICETOOL 10
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 Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
Search our Forums:

Back to Top