Page 1 of 1

Generate a ddname dynamically

PostPosted: Mon Sep 29, 2008 6:46 pm
by Gilles
In a typical batch job, all temporary datasets are allocated to system generated ddnames that look like SYS00098. Is there a built in function you can call in REXX, either batch or interactive, that will return you a unique ddname not in use in the current job/environment ? I know I could try to write a simple function that would return a random string of numbers I could append to the SYS prefix and check if it's in use but I was wondering if it's already built in and I've never found it.

Thanks.

Re: Generate a ddname dynamically

PostPosted: Mon Sep 29, 2008 8:22 pm
by Bill Dennis
Not sure about any existing service but if you do your own I'd suggest using a prefix other than SYS to avoid confusion and possible duplication.

Re: Generate a ddname dynamically

PostPosted: Tue Feb 10, 2009 12:41 pm
by ritwik.das
Hi Gilles,

I was going through old posts and found your one. Not sure whether you still need this but here is a solution that worked for me -

DDNAME = "SYS" || RANDOM(1,99999)

RAN is a built-in function that'll generate a random number between 1 and 99999.

Re: Generate a ddname dynamically

PostPosted: Tue Feb 10, 2009 7:44 pm
by Bill Dennis
Just do an ALLOC giving only DSNAME and the system assigns the next SYSxxxxxx DDname for you.

Re: Generate a ddname dynamically

PostPosted: Wed Feb 25, 2009 5:10 am
by latfgtot
I always use the time offset in seconds to do this e.g. ddname = "D"||TIME("s")