HOW TO GENERATE RANDOM SEQUENCE NO



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

HOW TO GENERATE RANDOM SEQUENCE NO

Postby Alan1208 » Wed Oct 22, 2014 9:25 am

H Team can you please help me in below requirement -->

Requirement ==>

Need to generate Random sequence no of 8 digits.

Constraints ==>
1. Every generated random seq no. should be greater than previous generated no (No duplicates as well).
2. It will not be one time run program, it will keep running every day to generate few random seq nos. Sequence no generated on any particular day should be greater than sequence no generated on previous days.

Can you please tell me if it possible by any function or 100% full proof is not there to generate random seq no with this constraint.

Thank you very much.
Alan1208
 
Posts: 10
Joined: Tue Aug 05, 2014 1:27 pm
Has thanked: 0 time
Been thanked: 0 time

Re: HOW TO GENERATE RANDOM SEQUENCE NO

 

Re: HOW TO GENERATE RANDOM SEQUENCE NO

Postby enrico-sorichetti » Wed Oct 22, 2014 10:29 am

NO.
better review the whole approach.
what if at some time You get 99999999 ???

Why random? just use a sequence
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2643
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 130 times

Re: HOW TO GENERATE RANDOM SEQUENCE NO

Postby Alan1208 » Wed Oct 22, 2014 10:50 am

Hi Enrico, Thanks you for your reply.
99999999 is the biggest no possible so if it will generate then it will be problem for us.

As of now we are generating this no sequentially only but recently one requirement came that is it possible to generate random seq nos. for different run. As this no is key for one of the KSDS file, we want to generate unique and in ascending order, something like this -->

XXXXXXXX00001237 --> May be on 21st OCT 14
XXXXXXXX00003456 --> May be on 21st OCT 14
XXXXXXXX00007891 --> May be on 22nd OCT 14
XXXXXXXX00234567 --> May be on 23rd OCT 14
I think it's not possible to keep random nos in sequence along with no duplicates. Can you please give me your view as well.

Thanks
Alan
Alan1208
 
Posts: 10
Joined: Tue Aug 05, 2014 1:27 pm
Has thanked: 0 time
Been thanked: 0 time

Re: HOW TO GENERATE RANDOM SEQUENCE NO

Postby enrico-sorichetti » Wed Oct 22, 2014 10:55 am

I guess that my previous post expressed my point of view ;)

also from a logic point of view RANDOM clashes wit SEQUENCE

we want to generate unique and in ascending order,


so since sequence numbers are unique, and up to now You used sequence numbers
WHY CHANGE ?
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2643
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 130 times

Re: HOW TO GENERATE RANDOM SEQUENCE NO

Postby Alan1208 » Wed Oct 22, 2014 11:27 am

Haha..Thanks again...yes I checked your "NO".. :) :)
Actually these nos are encryption of some other no. now if we keep it in sequence, main no can also be easily tracked..

But no problem I have got a work around for this.. :) :)
Alan1208
 
Posts: 10
Joined: Tue Aug 05, 2014 1:27 pm
Has thanked: 0 time
Been thanked: 0 time

Re: HOW TO GENERATE RANDOM SEQUENCE NO

Postby BillyBoyo » Wed Oct 22, 2014 11:46 am

Random Numer 1
Random Numer 2
Random Numer 3


Known to be unique and ascending (trhough understanding on inspection). If someone wants to treat it as an ordinary sequence number, it is very, very easy.

To do work for something that can be "cracked" in 4/9th of a second, even without computer aid, is absurd, as enrico has been indicating.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post