Create a dataset if it doesn't exist before copying a member



IBM's Command List programming language & Restructured Extended Executor

Create a dataset if it doesn't exist before copying a member

Postby NoSleep319 » Wed Oct 23, 2013 7:27 pm

I'm copying a member from one library to another 'temp' library before I modify it, but I can only do this if the second location is already created...This is the rexx code I'm workin with:

ADDRESS ISPEXEC
"LMINIT DATAID("DDI") DATASET('"FROMPDS"') ENQ(SHRW)"
"LMINIT DATAID("DDO") DATASET('"TOPDS"') ENQ(SHRW)"
"LMCOPY FROMID("DDI") FROMMEM("M1") TODATAID("DDO") REPLACE"

How would I go about verifying whether 'xxxx.REXXTEMP' exists, and creating if it doesn't?

Here's the dataset information if it helps with a creation statement:

Data Set Name . . . . : xxxx.REXXTEMP

General Data Current Allocation
Management class . . : MCPDS Allocated cylinders : 10
Storage class . . . : SCDFAULT Allocated extents . : 1
Volume serial . . . : DSM561
Device type . . . . : 3390
Data class . . . . . : DEFAULT
Organization . . . : PO Current Utilization
Record format . . . : VB Used cylinders . . : 1
Record length . . . : 255 Used extents . . . : 1
Block size . . . . : 27998
1st extent cylinders: 10
Secondary cylinders : 0 Dates
Data set name type : PDS Creation date . . . : 2013/10/22
Referenced date . . : 2013/10/22
Expiration date . . : 2050/12/25

Also, it seems to start erroring when I use all cylinders allocated, but when I clear the members out that have been moved, I noticed the Current Utilization doesn't change back to 1...is there a delayed response, or how do the cylinders work in regards to storage space?
NoSleep319
 
Posts: 21
Joined: Tue Aug 27, 2013 12:45 am
Has thanked: 0 time
Been thanked: 0 time

Re: Create a dataset if it doesn't exist before copying a me

Postby NicC » Wed Oct 23, 2013 7:31 pm

You can do a listdsi to see if the dataset exists. If it does then allocate with a DSIP of SHR and if it does not exist allocate it with all the required parameters for a new dataset.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times

Re: Create a dataset if it doesn't exist before copying a me

Postby Peter_Mann » Wed Oct 23, 2013 8:09 pm

you can use TSO services to check if the dataset and member for that fact exists ....

SET &SYSIN=&SYSDSN('userid.CATLIST.SYSIN')
IF &SYSIN ¬= OK THEN DO
ATTR F80 RECFM(F) LRECL(80) BLKSIZE(80)
ALLOC F(SYSIN) DA('userid.CATLIST.SYSIN') NEW SP(1) TRA US(F80)
END
ELSE DO
Peter
Peter_Mann
 
Posts: 145
Joined: Fri Jun 24, 2011 7:37 pm
Location: Lowell,AR
Has thanked: 15 times
Been thanked: 3 times

Re: Create a dataset if it doesn't exist before copying a me

Postby Peter_Mann » Wed Oct 23, 2013 8:14 pm

One other thing that occured to me, LMINIT will set a return code you can interegate
from the LMINIT
ADDRESS ISPEXEC
"LMINIT DATAID("DDI") DATASET('"FROMPDS"') ENQ(SHRW)"
If rc ¬= 0 Then /* Return codes */
Do /* 8 - Data set or file not */
End /* allocated */
Else /* - DDname not found */
/* - Data set or file */
/* organization not supported */
/* 12 - Invalid parameter value */
/* 16 - Truncation or translation */
/* error in accessing dialog */
/* variables */
/* 20 - Severe error */
this may be better that my previous suggestion
Peter
Peter_Mann
 
Posts: 145
Joined: Fri Jun 24, 2011 7:37 pm
Location: Lowell,AR
Has thanked: 15 times
Been thanked: 3 times

Re: Create a dataset if it doesn't exist before copying a me

Postby NoSleep319 » Wed Oct 23, 2013 8:35 pm

ok, what if I have the dataset saved in a variable? I have MY = USERID(), then TOPDS = MY".REXXTEMP"
How do I transition that into the ALLOC example you gave me? I tried the following:

SET &SYSIN=&SYSDSN(&TOPDS)                         
IF &SYSIN ¬= OK THEN                               
  DO                                               
    ATTR F80 RECFM(F) LRECL(80) BLKSIZE(80)       
    ALLOC F(SYSIN) DA(&TOPDS) NEW SP(1) TRA US(F80)
  END                                             
ELSE DO                                           


I getting an invalid expression error
NoSleep319
 
Posts: 21
Joined: Tue Aug 27, 2013 12:45 am
Has thanked: 0 time
Been thanked: 0 time

Re: Create a dataset if it doesn't exist before copying a me

Postby Peter_Mann » Wed Oct 23, 2013 9:14 pm

if you have the dataset stored in a variable you'll need to use ispf services VGET ?
you'll need to test different options, but I belive your missing the single quotes around the dsn is adding your ID on top of the fully qualtified dataset you've provided.
you can also trace the rexx to see exactly what dataset is being allocated
Peter
Peter_Mann
 
Posts: 145
Joined: Fri Jun 24, 2011 7:37 pm
Location: Lowell,AR
Has thanked: 15 times
Been thanked: 3 times

Re: Create a dataset if it doesn't exist before copying a me

Postby Pedro » Thu Oct 24, 2013 1:20 am

I getting an invalid expression error


I think you are mixing languages. You seem to have CLIST statements in your rexx exec.
Pedro Vera
User avatar
Pedro
 
Posts: 684
Joined: Thu Jul 31, 2008 9:59 pm
Location: Silicon Valley
Has thanked: 0 time
Been thanked: 53 times

Re: Create a dataset if it doesn't exist before copying a me

Postby Akatsukami » Thu Oct 24, 2013 1:31 am

Pedro wrote:
I getting an invalid expression error


I think you are mixing languages. You seem to have CLIST statements in your rexx exec.

Yes; the equivalent Rexx would be:
sysin = sysdsn(topds)
if (sysin¬="OK") then
do
  "ATTR F80 RECFM(F) LRECL(80) BLKSIZE(80)"
  "ALLOC F(SYSIN) DA("topds") NEW SP(1) TRA US(F80)"
end
else do
  :       

Note, incidentally, that an unblocked data set with LRECL=80 is horribly wasteful of DASD; I'd make it fixed blocked and leave off the BLKSIZE parameter; under z/OS it's unnecessary.
"You have sat too long for any good you have been doing lately ... Depart, I say; and let us have done with you. In the name of God, go!" -- what I say to a junior programmer at least once a day
User avatar
Akatsukami
Global moderator
 
Posts: 1058
Joined: Sat Oct 16, 2010 2:31 am
Location: Bloomington, IL
Has thanked: 6 times
Been thanked: 51 times

Re: Create a dataset if it doesn't exist before copying a me

Postby Peter_Mann » Thu Oct 24, 2013 1:42 am

'I think you are mixing languages. You seem to have CLIST statements in your rexx exec."

that's my bad, I overlooked the ADDRESS ISPEXEC in the OP's post.
Peter
Peter_Mann
 
Posts: 145
Joined: Fri Jun 24, 2011 7:37 pm
Location: Lowell,AR
Has thanked: 15 times
Been thanked: 3 times


Return to CLIST & REXX

 


  • Related topics
    Replies
    Views
    Last post