Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

How to genarate a random number(unique) in Cobol

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
rajesh_mbt

New User


Joined: 27 Mar 2006
Posts: 95
Location: India

PostPosted: Fri Aug 24, 2007 7:43 pm    Post subject: How to genarate a random number(unique) in Cobol
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: 95
Location: India

PostPosted: Fri Aug 24, 2007 7:46 pm    Post subject: Re: How to genarate a random number(unique) in Cobol
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    Post subject:
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

Site Director


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

PostPosted: Fri Aug 24, 2007 8:34 pm    Post subject:
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: 95
Location: India

PostPosted: Sun Aug 26, 2007 12:09 pm    Post subject:
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: 2150
Location: At my coffee table

PostPosted: Sun Aug 26, 2007 4:15 pm    Post subject:
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    Post subject:
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Executing OO COBOL program invoking J... Virendra Shambharkar COBOL Programming 2 Tue Jan 10, 2017 6:37 pm
No new posts OO COBOL compile error Virendra Shambharkar COBOL Programming 3 Tue Jan 10, 2017 6:05 pm
No new posts Need Suggestion on COBOL program vickey_dw COBOL Programming 5 Thu Jan 05, 2017 10:55 pm
This topic is locked: you cannot edit posts or make replies. RANDOM Function in COBOL swapnil781 COBOL Programming 2 Tue Nov 15, 2016 6:17 pm
No new posts Regarding COBOL Stored Procedure opti... selvamsrinivasan85 DB2 4 Fri Nov 04, 2016 8:57 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us