IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Unique dataset creation


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
hariibm

New User


Joined: 05 Feb 2007
Posts: 61
Location: Chennai

PostPosted: Tue Oct 12, 2010 1:19 pm
Reply with quote

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
View user's profile Send private message
hariibm

New User


Joined: 05 Feb 2007
Posts: 61
Location: Chennai

PostPosted: Tue Oct 12, 2010 1:23 pm
Reply with quote

Please note this utility can be run multiple times in a day.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Oct 12, 2010 2:01 pm
Reply with quote

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
View user's profile Send private message
kacks7

New User


Joined: 22 Sep 2010
Posts: 33
Location: chennai(india)

PostPosted: Tue Oct 12, 2010 2:05 pm
Reply with quote

hi hariibm,
use the date and time combination for the qualifiers of your dataset.
Back to top
View user's profile Send private message
hariibm

New User


Joined: 05 Feb 2007
Posts: 61
Location: Chennai

PostPosted: Tue Oct 12, 2010 2:10 pm
Reply with quote

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
View user's profile Send private message
notonly4u

New User


Joined: 26 Apr 2005
Posts: 87
Location: Hyderabad

PostPosted: Tue Oct 12, 2010 2:14 pm
Reply with quote

Can't GDGs be used?
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Oct 12, 2010 2:30 pm
Reply with quote

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
View user's profile Send private message
hariibm

New User


Joined: 05 Feb 2007
Posts: 61
Location: Chennai

PostPosted: Tue Oct 12, 2010 2:32 pm
Reply with quote

No. GDGs can't be used.
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8796
Location: Welsh Wales

PostPosted: Tue Oct 12, 2010 2:57 pm
Reply with quote

Any particular reason why a GDS is inappropriate ?
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Oct 12, 2010 3:56 pm
Reply with quote

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
View user's profile Send private message
superk

Global Moderator


Joined: 26 Apr 2004
Posts: 4652
Location: Raleigh, NC, USA

PostPosted: Tue Oct 12, 2010 4:52 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19243
Location: Inside the Matrix

PostPosted: Wed Oct 13, 2010 2:05 am
Reply with quote

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
View user's profile Send private message
Kurt Deininger

New User


Joined: 13 Jul 2010
Posts: 19
Location: Frankfurt/Germany

PostPosted: Wed Oct 13, 2010 3:00 pm
Reply with quote

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
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8796
Location: Welsh Wales

PostPosted: Wed Oct 13, 2010 4:12 pm
Reply with quote

Again I ask ................................
expat wrote:
Any particular reason why a GDS is inappropriate ?
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts combine multiple unique records into ... DFSORT/ICETOOL 2
No new posts batch SFTP job using AOPBATCH unable ... All Other Mainframe Topics 7
No new posts Reading Empty Dataset DFSORT/ICETOOL 5
No new posts Mainframe Dataset Binary or ASCII Mainframe Interview Questions 4
No new posts SPOOL to Mainframe dataset in batch mode JCL & VSAM 7
Search our Forums:

Back to Top