Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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: 6970
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: 6970
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 How to display offset thru cobol prog... tvinodkumar7 CICS 2 Sun Apr 22, 2018 8:42 pm
No new posts Linkage editor is part of COBOL, z/OS... ankit.jain COBOL Programming 4 Fri Apr 20, 2018 4:17 pm
This topic is locked: you cannot edit posts or make replies. Difference between EQUAL and EQUAL TO... jithinraghavan COBOL Programming 3 Thu Apr 19, 2018 2:22 am
No new posts Call COBOL or PLI with a click from w... vaibhav gs All Other Mainframe Topics 1 Mon Apr 16, 2018 7:29 pm
No new posts COBOL MVS options BiswajitDG COBOL Programming 8 Fri Apr 06, 2018 12:35 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us