Question

Under z/OS, I want to write a REXX or CLIST script to copy one sequential data set to another and then run another script (REXX). The other script expects a specific SDS to exist and I want to be able to copy one of many options to that member before running the second script. This is from TSO so I don't have access to any of the fancy ISPF stuff.

So, basically:

Copy 'level1.level2.name.type1' to 'level1.level2.name'
runother p1 p2 p3

The runother Rexx script uses 'level1.level2.name' to do its own magic - I'm just providing a different one for each of my possibilities.

So I need a script called 'xx42' which copies 'level1.level2.name.42' and I can then modify that for values other than 42. Even better would be to parameterize that script so I could just use

xx 42 p1 p2 p3

or

xx 27 p1 p2 p3

rather than having a script for each value. This would copy the given SDS then pass parameters p1, p2 and p3 through to runother.

Was it helpful?

Solution 2

After a bit of fiddling around, I figured out you can manually allocate the required data sets and run IEBGENER to do the copy:

/* REXX */

"ALLOC FI(SYSPRINT) DUMMY REUSE"
"ALLOC FI(SYSIN) DUMMY REUSE"
"ALLOC FI(SYSUT1) DA('LEVEL1.LEVEL2.NAME.42') SHR REUSE"
"ALLOC FI(SYSUT2) DA('LEVEL1.LEVEL2.NAME') SHR REUSE"
"IEBGENER"
RC2 = RC
"FREE FI(SYSUT1)"
"FREE FI(SYSUT2)"
"FREE FI(SYSPRINT)"
"FREE FI(SYSIN)"
IF RC2 ^= 0 THEN DO
  SAY "IEBGENER FAILED."
  END
ELSE DO
  RUNOTHER P1 P2 P3
  END

OTHER TIPS

While searching for something else, I came across this post. (i.e. it did not take me 2 years to formulate this response) and thought future mainframians (do we still exist?) might find it useful.

You could also do a SMCOPY:

address TSO "SMCOPY FDS('LEVEL1.LEVEL2.NAME.42') TDS('LEVEL2.LEVEL2.NAME')"

FDS - from dataset, TDS - to dataset. If TDS doesn't exist, you will get a return code 4, but the copy will have been executed. You can use SMCOPY to copy library members as well.

You can also use SORT to do a copy from SORTIN to SORTOUT. You could wrap that JCL in a proc with parameters or use SET statements, etc.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top