misi01 Advanced
Joined: 02 Dec 2002 Posts: 624 Topics: 175 Location: Stockholm, Sweden
|
Posted: Mon Oct 15, 2018 6:32 am Post subject: Use Rexx to copy a member from CA librarian to a PDS/file |
|
|
I'm including this solution simply because it's taken me a while to get where I wanted to be. Basically, because where I'm working using CA Librarian, I wanted a method of copying/extracting source code from Librarian to a simple sequential file/PDS member. Somewhere or other, I found references to using SORT and subsys(LAM) to do so (see https://www.mvsforums.com/helpboards/viewtopic.php?t=12922), but now I found a "better" example which I'll include here).
In the code below: -
memb is the member name I want to extract from librarian,
temp_ds is the fully qualified (pre-allocated) output dataset to receive the extracted source code (without quotes)
pds_name is the LIBRARIAN dataset name that might/might not contain the source code
Code: |
address TSO
x = outtrap('alloc.')
/* Specify the member to copy/extract */
sin.1 = '-SEL 'memb',EXEC(R)'
/* Now allocate SYSIN as a temporary file .... */
"alloc f(sysin) unit(vio) new sp(1 1) block(1)",
"recfm(f b) lrecl(80) reuse"
"execio 1 diskw sysin (stem sin. finis"
/* but DON'T free it */
/* Allocate the output file */
"alloc f(OSJOB) da('"temp_ds"') shr reuse"
/* ... and the LIBRARIAN "PDS" */
"alloc f(MASTER) da('"pds_name"') shr reuse"
"alloc file(sysprint) dummy shr reuse"
/* Call LIBRARIAN to extract the file */
address ispexec "select pgm(AFOLIBR) parm('NRJS,NJTA')"
save_rc = rc
"free f(SYSIN SYSPRINT MASTER OSJOB)"
x = outtrap('OFF')
|
Hope this helps someone else.
(Edited -added SHR REUSE to SYSPRINT allocation, otherwise CA messages splattered on screen first time in) _________________ Michael |
|