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

How to genarate a random number(unique) in Cobol


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
rajesh_mbt

New User


Joined: 27 Mar 2006
Posts: 97
Location: India

PostPosted: Fri Aug 24, 2007 7:43 pm
Reply with quote

Hi
I have a request to generate a random number whenever the user access a file. I need to create(Generate) a unique number for each time the file is accessed.
I tried to create sequence number to avoid duplicates.... But when more than one user access the same time then it failed.

Can anybody throw some lights on it?
Back to top
View user's profile Send private message
rajesh_mbt

New User


Joined: 27 Mar 2006
Posts: 97
Location: India

PostPosted: Fri Aug 24, 2007 7:46 pm
Reply with quote

rajesh_mbt wrote:
Hi
I have a request to generate a random number whenever the user access a file. I need to create(Generate) a unique number for each time the file is accessed.
I tried to create sequence number to avoid duplicates.... But when more than one user access the same time then it failed.

Can anybody throw some lights on it?

Note : The size should be x(08)
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Fri Aug 24, 2007 7:50 pm
Reply with quote

Batch? On-Line? Over what timeframe must these numbers be unique? (year, week, day, forever?)
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Fri Aug 24, 2007 8:34 pm
Reply with quote

Hello,

Quote:
I tried to create sequence number to avoid duplicates....
How did you try to create this sequence number?
Back to top
View user's profile Send private message
rajesh_mbt

New User


Joined: 27 Mar 2006
Posts: 97
Location: India

PostPosted: Sun Aug 26, 2007 12:09 pm
Reply with quote

dbzTHEdinosauer wrote:
Batch? On-Line? Over what timeframe must these numbers be unique? (year, week, day, forever?)



It's for batch program. The time frame must be unique for a week....
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Sun Aug 26, 2007 4:15 pm
Reply with quote

rajesh_mbt wrote:
It's for batch program. The time frame must be unique for a week....
Some combination of date and time with the JES job number in the low order position should unique it....
If the X(8) does not need to be displayable, binary representation will allow quite a range.....
Back to top
View user's profile Send private message
stodolas

Active Member


Joined: 13 Jun 2007
Posts: 632
Location: Wisconsin

PostPosted: Sun Aug 26, 2007 7:17 pm
Reply with quote

I know its not as elegant as CICS Guy, but....

Use the date and time, but then take a binary representation of their user id. Mulitply the datetime by the userid to get your unique value.

Why does it have to be a number? Will any calculations be done on this data? If not then just do DATETIMEUSERID. So you get 2007123084512USERID
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Sun Aug 26, 2007 7:26 pm
Reply with quote

What is the purpose of this unique ID? Where will it be stored?

This is batch, you said file and not DB2, why not use SMF records (15 I think) to perform whatever audit you are performing.
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 -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Substring number between 2 characters... DFSORT/ICETOOL 2
Search our Forums:

Back to Top