/* rexx */ /*-------------------------------------------------------------------*/ /* */ /* REXX Exec : CLONE */ /* */ /* Description : Create a copy of a dataset. Invoke by typing */ /* CLONE next to the dataset name on the ISPF 3.4 menu*/ /* */ /* Syntax : CLONE dsn newdsn VOL(vvvvvv) */ /* */ /* Created on : 31 Mar 2018 */ /* Created by : Kevin Ferguson */ /* : Userid(MIT001) */ /* : using ABBYDALE.XFER.REXX(CLONE) */ /* */ /* Called by : */ /* */ /* Calls : REPRO, IEBCOPY, LISTDSI, CHECKDSN, ASLVTOC */ /* */ /* Change Activity : */ /* */ /* Fix Date By Description */ /* ------ ----------- ---- ---------------------------------------- */ /* NEW 15 Aug 2022 KEF Changed to allow quotes around the new */ /* name. */ /* FIX 20 Oct 2023 KEF Fix issue when there is no answer given */ /* for new volume definition */ /* WIM001 2 Feb 2026 WIM Allow new name and volser to be passed */ /* to the exec. Change to not use VALIDVOL */ /* */ /* ©Copyright of Abbydale Systems LLC. */ /* */ /*-------------------------------------------------------------------*/ parse upper arg dsn nme vol /* WIM001 */ done = 'N' if dsn = '' then do /* WIM001 */ say 'No input dsname passed' /* WIM001 */ exit(16) /* WIM001 */ end /* WIM001 */ checkdsn dsn /* WIM001 */ if RC <> 0 then do /* WIM001 */ say 'invalid input dataset name' /* WIM001 */ exit(16) /* WIM001 */ end /* WIM001 */ if substr(nme,1,4) = 'VOL(' then do /* WIM001 */ vol = nme /* WIM001 */ nme = '' /* WIM001 */ end /* WIM001 */ if vol <> '' then do /* WIM001 */ if length(vol) <> 11 then do /* WIM001 */ say 'Invalid passed volume format' /* WIM001 */ exit(16) /* WIM001 */ end /* WIM001 */ if substr(vol,4,1) <> '(' then do /* WIM001 */ say 'Invalid passed volume format' /* WIM001 */ exit(16) /* WIM001 */ end /* WIM001 */ if substr(vol,11,1) <> ')' then do /* WIM001 */ say 'Invalid passed volume format3' /* WIM001 */ exit(16) /* WIM001 */ end /* WIM001 */ vol = substr(vol,5,6) /* WIM001 */ done = 'Y' /* WIM001 */ end /* WIM001 */ if nme <> '' then do /* WIM001 */ checkdsn nme /* WIM001 */ if RC <> 12 then do /* WIM001 */ if RC = 0 then do /* WIM001 */ say 'New dataset 'nme 'already exists. Exit 4' /* WIM001 */ exit(4) /* WIM001 */ end /* WIM001 */ else do /* WIM001 */ say 'Invalid new dataset name' nme /* WIM001 */ exit(16) /* WIM001 */ end /* WIM001 */ end /* WIM001 */ end /* WIM001 */ dsn = strip(dsn,b,"'") new = dsn if nme = '' then do /* WIM001 */ do while new = dsn say 'Enter new name' pull new nme = new /* WIM001 */ iterate end end /* WIM001 */ nme = strip(nme,b,"'") /*NEW*/ DSN_STATUS = LISTDSI(''''dsn'''' smsinfo) volume = sysvolume reask: /* WIM001 */ if vol = '' then do /* WIM001 */ do until done = 'Y' say 'Allocate to a new volume? (Y, N or QUIT)' pull ans UPPER ans select when ans = 'Y' then do say 'Enter target volume' pull volume if LENGTH(volume) = '6' then do TrapON=OutTrap('out.') /* WIM001 */ aslvtoc volser 'status' /* WIM001 */ TrapON=OutTrap('OFF') /* WIM001 */ if POS('not',out.1) = 0 then do /* WIM001 */ vol = volume /* WIM001 */ done = 'Y' end /* WIM001 */ else do /* WIM001 */ say 'volume 'volume 'not online' /* WIM001 */ end /* WIM001 */ end end when ans = 'N' then do vol=sysvolume /* WIM001 */ done = 'Y' end when ans = 'QUIT' then exit(4) /* WIM001 */ otherwise nop end end end /* WIM001 */ TrapON=OutTrap('out.') /* WIM001 */ aslvtoc vol 'status' /* WIM001 */ TrapON=OutTrap('OFF') /* WIM001 */ if POS('not',out.1) > 0 then do /* WIM001 */ say 'Voline' vol 'not online' /* WIM001 */ vol = '' /* WIM001 */ signal reask /* WIM001 */ end /* WIM001 */ volume = vol /* WIM001 */ say nme 'will be allocated on' volume /* TrapON=OutTrap('ON') */ "ALLOC F(DATAOUT) DATASET('"nme"')" , "SHR VOL("volume") UNIT(SYSALLDA) REUS" if kf = 0 then do say nme "already exists on" vol ". Do you want to overwrite it?" pull ans if ans <> "Y" then exit(8) end else do If sysstorclass = '' then do "ALLOC F(DATAOUT) DATASET('"nme"') NEW CATALOG VOL("volume")" , "UNIT(SYSALLDA) LIKE('"dsn"') REUS" end else do say dsn ' is SMS Managed' TrapON=OutTrap('OFF') "ALLOC F(DATAOUT) DATASET('"nme"') NEW CATALOG" , " LIKE('"dsn"') REUS", " STORCLAS("sysstorclass")" /* " MGMTCLAS("sysmgmtclass")" , " DATACLAS("sysdataclass")" */ end end /* if empty <> '' then exit */ DSN_STATUS = LISTDSI(''''dsn'''' DIRECTORY) SELECT WHEN sysdsorg = 'PS' then do "Alloc F(DATAIN) da('"dsn"') SHR REUS" "repro infile(DATAIN) outfile(DATAOUT)" kef = rc 'FREE F (DATAIN DATAOUT)' say "Copy ended Return code" kef end WHEN sysdsorg = 'PO' then do TrapON=OutTrap('Off') "Alloc F(DATAIN) da('"dsn"') vol("sysvolume") SHR REUS" "Alloc F(DATAOUT) da('"nme"') vol("volume") SHR REUS" "FREE FI(SYSIN,SYSPRINT,SYSUT3,SYSUT4)" "ALLOC FILE(SYSIN) SPACE(1,1) TRACK LRECL(80) RECFM(F) BLKSIZE(80) REU" "ALLOC FILE(SYSPRINT) da(*) BLKSIZE(121)" "ALLOC FILE(SYSUT3) UNIT(SYSDA) SPACE(1,1) CYLINDERS REU" "ALLOC FILE(SYSUT4) UNIT(SYSDA) SPACE(1,1) CYLINDERS REU" SYSIN.1 = " COPY OUTDD=DATAOUT,INDD=((DATAIN,R))" 'EXECIO * DISKW SYSIN (STEM SYSIN. FINIS' "CALL 'SYS1.LINKLIB(IEBCOPY)' 'SIZE=512K'" kef = rc say "Copy ended Return code" kef end otherwise do say sysdsorg " Files are not supported" exit(12) end end TrapON=OutTrap('On') "free f(DATAIN DATAOUT)" exit(0) /*-------------------------------------------------------------------*/ /* End of CLONE */ /*-------------------------------------------------------------------*/