Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Several REXX Batch Questions

Status
Not open for further replies.

jimlocigno4

Programmer
Aug 8, 2007
3
US
Hi I'm a little rusty on Rexx but have written A REXX program that reads two input files, does some manipulation on them and writes a third file. The rexx works fine when executed in the forground. My question is about Running REXX in batch.

1) Currently I have the rexx coded to allocate the two input files and one output file in the rexx script using ALLOC command. I thought that when I ran REXX in batch I would use normal JCL commands to allocate the files and just use the DDNAME specified in the JCL in my rexx program. This does not appear to work. I thought there would be no need to re-allocate the files that are allready allocated in JCL. Am I missing something here? The ultimate question is how to you allocate files (input and output) in Batch Rexx

2) If I use the say commmand in batch rexx - does it write the output anywhere? If so, why don't I see it?

Thanks
Jim
 
1) I thought that when I ran REXX in batch I would use normal JCL commands to allocate the files and just use the DDNAME specified in the JCL in my rexx program.

That is exactly the correct method to use in batch. You'll have to provide more details for us to know why it doesn't work the way it should.

2) If I use the say commmand in batch rexx - does it write the output anywhere?

To the terminal, which in the case of a batch job will be the SYSTSPRT DD.
 

"normal JCL commands"? If the exec is doing its own allocates, why is there any need to modify this for batch?

I would say that an (address TSO) exec that runs correctly in the TSO foreground should run as well in the background. There is no need to modify the process.


Frank Clarke
Tampa Area REXX Programmers' Alliance
REXX Language Assn Listmaster
 
I use the following subroutines to read data into a stem variable
and write from a stem.

When executed from TSO they allocate datasets, in batch they use
the DD defines in the JCL. This allows me to leave test dataset
names in the REXX for future modification and testing.

RxUsr


/* ** REXX @IO ******************************************* */
/* ********** Read / Write Routines ********** */
/*
* DSNin = HLQ.TEST.DATA
* DSNin = HLQ.TEST.DATA(Member)
* DSNin = GOOVOO('HLQ.TEST.DATA(0)')
*
* Call ReadStem 'InRec.' 'ddin' DSNin
* DSNin is only used in TSO mode
**
* DSNout = HLQ.TEST.DATA
* DSNout = HLQ.TEST.DATA(Member)
* DSNout = GOOVOO('HLQ.TEST.DATA(+1)')
* Example values for Attrb
* 1) "TRACKS SPACE(5,3) RELEASE UNIT(SYSDA)",
* "RECFM(F B) LRECL(80) DIR(20)",
* "MGMTCLAS(MCTEST) STORCLAS(SCTEST)"
* 2) "LIKE ('"DSNin"')"
*
* Call WriteStem 'OutRec.' 'ddout' DSNout Attrb
* DSNout and Attrb are only used in TSO mode
* */
/* ********************************************************* */
/* ********** Read Input Record into Stem ********** */
ReadStem:
Parse upper Arg StemID DDid DSNid
RC = 0
If sysvar(SYSENV) <> 'BACK' then
"ALLOC DA('"DSNid"') F("DDid") SHR REUSE"
IF RC <> 0 THEN
Call Exit8 'Error allocating ddname='DDid 'dataset='DSNid 'rc='rc

"EXECIO * DISKR "DDid" (STEM" StemID "FINIS"
IF RC <> 0 THEN
Call Exit8 'Error reading file ddname='DDid 'dataset='DSNid 'rc='rc

"FREE F("DDid")"
IF RC <> 0 THEN
CAll Exit8 'ERROR deallocating ddname='DDid 'dataset='DSNid 'rc='rc
Return

/* ********** Write Output Record from Stem ********** */
WriteStem:
Parse upper Arg StemID DDid DSNid Attrb
RC = 0
If sysvar(SYSENV) <> 'BACK' then Do
If LISTDSI("'"DSNid"'") = 0 then Do
If SysDSorg = 'PS' then Do
"ALLOC DA('"DSNid"') F("DDid") SHR DELETE"
"FREE F("DDid")"
"ALLOC DA('"DSNid"') F("DDid") NEW CATALOG" Attrb
End
Else Do
"ALLOC DA('"DSNid"') F("DDid") SHR REUSE"
End
End
Else Do
"ALLOC DA('"DSNid"') F("DDid") NEW CATALOG" Attrb
End
End
IF RC <> 0 THEN
Call Exit8 'Error allocating ddname='DDid 'dataset='DSNid 'rc='rc

"EXECIO * DISKW "DDid" (STEM" StemID "FINIS"
IF rc <> 0 THEN
Call Exit8 'Error writing file ddname='DDid 'dataset='DSNid 'rc='rc

"FREE F("DDid")"
IF RC <> 0 THEN
Call Exit8 'ERROR deallocating ddname='DDid 'dataset='DSNid 'rc='rc
Return

/* ********** Error Exit ********** */
Exit8:
Arg ErrMsg
Say Errmsg
Exit 08
/* */
 
Does anyone here think that
Code:
"ALLOC DA('"DSNid"') F("DDid") SHR REUSE"
does anything different than
Code:
//DDID   DD DSN=<dsnid>,DISP=SHR
?

Does anyone here think that writing a DD statement and adding code to check whether the routine is running foreground or background represents effort that will ever be paid back by the efficiency of that method?


Frank Clarke
Tampa Area REXX Programmers' Alliance
REXX Language Assn Listmaster
 
Hi All,

Thanks a bunch for your help. I'm sorry I didn't respond sooner but I was on vacation today.

Anyway, all of a sudden it works with allocating the fienames through JCL - don't really know why it didn't work before - although I think it might have been the way I was calling it. I didn't realize the library the REXX was in had to be specified in the SYSEXEC DDNAME.

Anyway to answer Frank's question? Why do I want to allocate the datasets in JCL - as opposed to within the REXX. Well, I am fairly sure that our JCL Promotion procedures would not allow for files to be allocated 'behind the scenes - so to speak'. When we promote jobs to production the change control software automatically runs JOBSCAN (or some equivilent) and I don't believe the JCL would pass JOBSCAN if I allocated the files in the REXX. I am intending to use the REXX as ONE step in a multi-step job. I hope that helps. Again thanks for your very quick responses.

Jim Locigno
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top