View previous topic :: View next topic
|
Author |
Message |
hariibm
New User
Joined: 05 Feb 2007 Posts: 61 Location: Chennai
|
|
|
|
Hi,
I am coding a REXX utility/macro and it creates an output file.
What would be the best approach to ensure that it creates the unique dataset every time this utility is run.
Regards,
Harikrishna. |
|
Back to top |
|
|
hariibm
New User
Joined: 05 Feb 2007 Posts: 61 Location: Chennai
|
|
|
|
Please note this utility can be run multiple times in a day. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
your ALLOCAT command will return an error when you attempt to allocate a file as new, when it already exists.
so code to re-enter you name generating algorithm.
but then again, I assume you meant 'unique dataset name'.
If not, I apologize for dropping by this thread. |
|
Back to top |
|
|
kacks7
New User
Joined: 22 Sep 2010 Posts: 33 Location: chennai(india)
|
|
|
|
hi hariibm,
use the date and time combination for the qualifiers of your dataset. |
|
Back to top |
|
|
hariibm
New User
Joined: 05 Feb 2007 Posts: 61 Location: Chennai
|
|
|
|
Hello Dick Brenholtz,
Yes, exactly. My macro is failing when I am trying to run second time.
I am creating the dataset like below:
userid.mon+days.xxx
ie, If userid = YAF8, Mon = Oct, days = 285, then the dataset would be YAF8.OCT285.XXX
I want this utility to create a different dataset next time when it is run and it should not give any error. so please let me know how to create a unique dataset.
It is ok if the existing dataset can be used. But the ALLOCAT command try to create new. please guide how to go ahead.
Regards,
Hari |
|
Back to top |
|
|
notonly4u
New User
Joined: 26 Apr 2005 Posts: 87 Location: Hyderabad
|
|
|
|
Can't GDGs be used? |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
one second you say unique - where Kacks7's suggestion is appropriate
and the next you say that you can reuse existing DS, which means you can use a disposition of MOD.
what actually is the use of the DS? and don't say output of the REXX.
USERID as HLQ isolates the DS to each user.
if there is a requirement for multiple DS to exist, date & time are easy ways to name a file.
If there is no need to maintain multiple DS for each user, make it a standard name (fixed name), and use MOD.
or you could do what many 3rd party tools do:
create a temporary dataset,
invoke a Browse or VIEW
and leave it to the user to make a copy if there is a requirement to save the file.
notonly4U,
though GDG's could be used,
a gdg base would be required for every user |
|
Back to top |
|
|
hariibm
New User
Joined: 05 Feb 2007 Posts: 61 Location: Chennai
|
|
|
|
No. GDGs can't be used. |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8796 Location: Welsh Wales
|
|
|
|
Any particular reason why a GDS is inappropriate ? |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
one of the things I enjoy about this forum is that it does reflect a microcosm of the world.
87 questions have been asked of the TS,
and what does he provide as a response?.
hariibm wrote: |
No. GDGs can't be used. |
the TS only wants suggestions that empower his solution to work.
as usual,
don't confuse me with facts,
just tell me what I want to hear |
|
Back to top |
|
|
superk
Global Moderator
Joined: 26 Apr 2004 Posts: 4652 Location: Raleigh, NC, USA
|
|
|
|
Well, if I had to do this, and I wanted to assure unique dataset names, I'd consider using some or all of the following within the nodes:
- Current Date (MMDDYY or YYYYDDD or Base Date).
- Current Time (HHMMSS or # of seconds since midnight).
- System ID if it might run on different LPAR's.
- If the process was running as a batch job, I also might include the jobname, jobid, account. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
If one becomes really really creative when generating a unique dataset name it may be very difficult to reference the dataset later. . . |
|
Back to top |
|
|
Kurt Deininger
New User
Joined: 13 Jul 2010 Posts: 19 Location: Frankfurt/Germany
|
|
|
|
Hi Hariibm,
A simple solution would be to create a file having a counter being updated each time(set it to zero after creation):
Code: |
/* REXX */
trace r
address tso "alloc fi(temp) da(version) shr reuse"
address tso "execio 1 diskr temp (open stem vers. finis)"
address tso "free fi(temp)"
vers.1=vers.1+1
version=vers.1
address tso "alloc fi(temp) da(version) shr reuse"
address tso "execio 1 diskw temp (open stem vers. finis)"
address tso "free fi(temp)"
uniqnam="whatever"right(version,4,0)
EXIT
|
which yieds:
Code: |
3 *-* address tso "alloc fi(temp) da(version) shr reuse"
>>> "alloc fi(temp) da(version) shr reuse"
4 *-* address tso "execio 1 diskr temp (open stem vers. finis)"
>>> "execio 1 diskr temp (open stem vers. finis)"
5 *-* address tso "free fi(temp)"
>>> "free fi(temp)"
6 *-* vers.1=vers.1+1
>>> "1"
7 *-* version=vers.1
>>> "1"
8 *-* address tso "alloc fi(temp) da(version) shr reuse"
>>> "alloc fi(temp) da(version) shr reuse"
9 *-* address tso "execio 1 diskw temp (open stem vers. finis)"
>>> "execio 1 diskw temp (open stem vers. finis)"
10 *-* address tso "free fi(temp)"
>>> "free fi(temp)"
11 *-* uniqnam="whatever"right(version,4,0)
>>> "whatever0001"
12 *-* EXIT
|
and so on |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8796 Location: Welsh Wales
|
|
|
|
Again I ask ................................
expat wrote: |
Any particular reason why a GDS is inappropriate ? |
|
|
Back to top |
|
|
|