Random no generation

Hi experts,
How to generate random number with 12 digits in ABAP?

Please [search forum for cl_abap_random|http://www.sdn.sap.com/irj/scn/advancedsearch?query=cl_abap_random] (this is the official class)

Similar Messages

  • What algorithm does Excel 2010 use for Pseudo Random Number Generation (MT19937?)

    Does Excel 2010+ use the Mersenne Twister (MT19937) algorithm for Pseudo Random Number Generation (PRNG), implemented by the RAND() function?
    This has been a nagging question for some time now, with "hints" that it indeed does.  However, a relatively thorough search turns up no definitive documentation.  The most direct indication is perhaps given by Guy Melard [Ref 9] where
    he tests Excel 2010's RAND() function using the Crush battery of tests in TestU01 by L'Ecuyer & Simard.  Melard references a "semi-official" indication that Microsoft did indeed implement MT19937 for the RAND() function in
    Excel 2010, but this reference no longer seems to be available. http://office.microsoft.com/enus/excel-help/about-solver-HP005198368.aspx?pid=CH010004571033.
    The other references below [Ref 1-10] document the history of the statistical suitability of the PRNG and probability distributions in various versions of Excel.  This includes the Wichmann-Hill PRNG implementations supposedly (arguably) used in
    Excel 2003 & 2007 for random number generation.  But still, we have no answer as to which PRNG algorithm is used in
    Excel 2010 (and 2013 for that matter).
    Microsoft indicates that RAND() has been improved in Excel 2010; Microsoft states, "...and the RAND function now uses a new random number algorithm." (see https://support.office.com/en-ca/article/Whats-New-Changes-made-to-Excel-functions-355d08c8-8358-4ecb-b6eb-e2e443e98aac). 
    But no details are given on the actual algorithm.  This is critical for Monte Carlo methods and many other applications.
    Any help would be much appreciated. Thanks.
    [Ref 1] B. McCullough, B. Wilson.  On the Accuracy of Statistical Procedures in Microsoft Excel 97. 
    Computational Statistics & Data Analysis. Vol. 31 No. 1, pp 27-37. July 1999.
    http://users.df.uba.ar/cobelli/LaboratoriosBasicos/excel97.pdf
    [Ref 2]L. Knüsel.  On the accuracy of the statistical distributions in Microsoft Excel 97. Computational Statistics & Data Analysis. Vol. 26 No. 3, pp 375-377. January 1998.
    http://www.sciencedirect.com/science/article/pii/S0167947397817562
    [Ref 3]B. McCullough, B. Wilson.  On the Accuracy of Statistical Procedures in Microsoft Excel 2000 and Excel XP. 
    Computational Statistics & Data Analysis. Vol.40 No. 4, pp 713-721. October 2002.
    https://www.researchgate.net/publication/222672996_On_the_accuracy_of_statistical_procedures_in_Microsoft_Excel_2000_and_Excel_XP/links/00b4951c314aac4702000000.pdf
    [Ref 4] B. McCullough, B. Wilson.  On the Accuracy of Statistical Procedures in Microsoft Excel 2003. 
    Computational Statistics & Data Analysis. Vol.49. No. 4, pp 1244-1252. June 2005.
    http://www.pucrs.br/famat/viali/tic_literatura/artigos/planilhas/msexcel.pdf
    [Ref 5] L. Knüsel. On the accuracy of statistical distributions in Microsoft Excel 2003. Computational Statistics & Data Analysis, Vol. 48, No. 3, pp 445-449. March 2005.
    http://www.sciencedirect.com/science/article/pii/S0167947304000337
    [Ref 6]B. McCullough, D.Heiser.  On the Accuracy of Statistical Procedures in Microsoft Excel 2007. 
    Computational Statistics & Data Analysis. Vol.52. No. 10, pp 4570-4578. June 2008.
    http://users.df.uba.ar/mricci/F1ByG2013/excel2007.pdf
    [Ref 7] A. Yalta. The Accuracy of Statistical Distributions in Microsoft<sup>®</sup> Excel 2007. Computational Statistics & Data Anlaysis. Vol. 52 No. 10, pp 4579 – 4586. June 2008.
    http://www.sciencedirect.com/science/article/pii/S0167947308001618
    [Ref 8] B. McCullough.  Microsoft Excel’s ‘Not The Wichmann-Hill’ Random Number Generators. Computational Statistics and Data Analysis. Vol.52. No. 10, pp 4587-4593. June 2008.
    http://www.sciencedirect.com/science/article/pii/S016794730800162X
    [Ref 9] G. Melard.  On the Accuracy of Statistical Procedures in Microsoft Excel 2010. Computational Statistics. Vol.29 No. 5, pp 1095-1128. October 2014.
    http://homepages.ulb.ac.be/~gmelard/rech/gmelard_csda23.pdf
    [Ref 10] L. Knüsel.  On the Accuracy of Statistical Distributions in Microsoft Excel 2010. Department of Statistics - University of Munich, Germany.
    http://www.csdassn.org/software_reports/excel2011.pdf

    I found the same KB article:
    https://support.microsoft.com/en-us/kb/828795
    This was introduced (according to the article) in Excel 2003. Perhaps the references in notes 2 and 3 might help.
    The article describes combining the results of 3 generators, each similar to a Multiply With Carry (MWC) generator, but with zero carry. MWC generators do very well on the Diehard battery of randomness tests (mentioned in your references), and have
    very long periods. But using zero carry makes no sense to me.
    Combining the three generators only helps if the periods of the 3 are relatively prime (despite what the article implies). Then the period of the result will be the product of the 3 periods. But without knowing the theory behind these generators, I have
    no idea what the periods would be. The formulas for MWC generators fail here.
    Richard Mueller - MVP Directory Services

  • Random email generation

    i need the source code of random email generation.

    Can explain How you want the random email , or you want any unrepeated emails?

  • True Random number generation in OSX

    Hi there,
    I have been trying to find some information on how to access the Intel Random number generation hardware on my Mac.
    First I would like to understand which models currently offer this, second I would like to know if there is some library available I could use from either C or any other language, even from Applescript would be good for me.
    Thanks in advance.

    Perhaps these links help:
    http://www.intel.com/software/products/mkl/docs/mklnotes_mac.htm
    (keep in mind that apple typically discourages targeting specific hardware...)
    http://forums.macosxhints.com/showthread.php?t=46359
    http://www.mactricksandtips.com/2008/03/apple-script-random-number-generator.htm l

  • Global random integer generation in a range

    Hello,
    I need a way to achieve a global random integer generation in a range.
    I tried FMs QF05_RANDOM_INTEGER and RANDOM_I4 without success because every time I call them from an object, always get the same number
    For example, FM RANDOM_I4 with RND_MIN = 1 and RND_MAX = 5 gets RND_VALUE = 1 and FM QF05_RANDOM_INTEGER with RAN_INT_MAX = 5 and AN_INT_MIN = 1 gets RAN_INT = 3.
    How can I get a global (with memory) random number generator?
    Regards and thanks in advance.

    Hey run the code below, it will give you different numbers.
    data RAN_INT like QF00-RAN_INT.
    data G_RAN_SEED like QF00-RAN_SEED.
    CALL FUNCTION 'QF05_RANDOM_INTEGER'
        EXPORTING
             RAN_INT_MAX   = 5
             RAN_INT_MIN   = 1
        IMPORTING
             RAN_INT       = RAN_INT
        EXCEPTIONS
             INVALID_INPUT = 1
             OTHERS        = 2
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    write ran_int.
    G_RAN_SEED = ran_int.
    CALL FUNCTION 'QF05_RANDOM_SAVE_SEED'
        EXPORTING
             RAN_SEED_NEXT = G_RAN_SEED

  • Problem with random number generation

    hey forum, i wonder if anyone can help me out with a small problem with my university coursework (yep its homework!!!)
    heres my problem, i am writing one of them 8 puzzle problems (the one based around sam lloyds 15 puzzler), i can successfully generate one random sequence of numbers with no duplicates, but whenever i call the random method again it keeps producing the same results
    heres the code
    in my main class file
    if(e.getSource() == randomButton) {
          new RandomPuzzle();
          System.out.println(random.randState);
          //startStateString = new RandomPuzzle();
    }heres my number generator class file
    import java.util.Random;
    import java.io.*;
    public class RandomPuzzle
         /** Base Random number generator */
        Random rn = new Random();
        /** Puzzle holder */
        byte b[];
        long number = 0;
        String randState = "";
        /** Default constructor */
        public RandomPuzzle() {
            rn.setSeed(number);
            b = new byte[9];
            randState = randomString();
        /** Provide range for generation */
        public int rand(int lo, int hi) {
            int n = hi - lo + 1;
            int i = rn.nextInt() % n;
            if (i < 0)
            i = -i;
            return lo + i;
        /** Set size for array */
        public int rand( int hi){
            int n = hi;
                return n;
        /** Check for duplicate values within the same configuration */
        boolean valueExists( byte value ) {
            int i = b.length;
            boolean exists = false;
            for( int j = 0; j < i; j++ ){
                if( b[j] == value )
                    exists = true;
            return exists;
        /** returns the actual string */
        public String randomString(int lo, int hi) {
            int n = rand( 9 );
            //boolean valueEntered = false;
            for (int i = 0; i < 9; i++) {
                boolean valueEntered = false;
                byte temp = (byte)rand('0', '8');
                while( valueEntered == false ) {
                    if( !valueExists( temp ) ) {
                         b[i] = temp;
                         valueEntered = true;
                    else
                        temp = (byte)rand('0', '8');
            return new String(b, 0);
        /** calls above function */
        public String randomString() {
            return randomString(0, 8);
    }i've tried for hours to work this out, but i am stumped. if anyone can point me in the right direction, maybe point out the problem code and give one or two tips i would be forever in your debt
    thanx in advance
    korbitz

    thanx for the help paulcw, but when i removed the seed code it done the same
    but i added this to my main class and now it works fine
    if(e.getSource() == randomButton) {
                   RandomPuzzle temp = new RandomPuzzle();
                   System.out.println(temp.randState);
                   //startStateString = new RandomPuzzle();
              }thanx again for your help

  • Five Random Number Generation between numbers 10-20

    I want to generate 5 random numbers (U32) between a range of 120 and 180 with equal distribution. Can i do it? I tried using white noise generation VI, but it gives numbers from [-a,a].
    Thanks in advance.

    stevem181 wrote:
    Note that the 120 and 180 values occur about half as often as the other values.
    To correct that flaw, multiply by 61 and round to -infinity. For example like this:
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    RandomRange.png ‏17 KB

  • A simple question on random number generation?

    Hi,
    This is a rather simple question and shows my newbieness quite blatantly!
    I'm trying to generate a random number in a part of a test I have.
    So, I have a little method which looks like this:
    public int getRandomNumber(int number){
            Random random = new Random(number);
            return random.nextInt(number);
        }And in my code I do int random = getRandomNumber(blah)...where blah is always the same number.
    My problem is it always returns the same number. What am I missing here. I was under the impression that nextint(int n) was supposed to generate the number randomly!! Obviously I'm doing something wrong or not using the correct thing. Someone please point out my stupidity and point me in the right direction? Ta

    I think the idea is that Random will generate the same pseudo-random sequence over and over if you don't supply a seed value. (The better to debug with, my dear.) When you're ready to put an app into production, the seed value should be the current system time in milliseconds to guarantee a new sequence with each run.
    Do indeed move Random outside the loop. Think of it like a number factory - instantiate it once and let it pump out the random values for you as needed.

  • OIM 11g R2 - User random password Generation

    Hi All,
    In my case users are getting created in OIM using Trusted source reconciliation and need to populate a random password for each user.
    Please suggest me which of the following methods is better and why?
    Method 1: Created a post Event Handler and populate password attribute. This case I created a custom Post event handler and populated password attribute and is success but the password stored in database is plain text and so not able login to Adminconsole with same password. So, how to encrypte password and then store in DB?
    Method 2: Create entity adapter and attach to user form using Data object manager
    Or, please suggest me any other best way.
    Thanks in advance.

    Hi,
    Users are being created thru trusted source recon and password is not automatically getting populated. I verified it, by checking USR_PASSWORD attribute in USR table and it is empty.

  • Random Code Generation

    Hi Guys,
    I'm working in a Project and i need to pass a randomcode in the query string.
    Need help in generating a random code with length greater than 32 and less than or equal to 255.
    Thanks,
    Ram.

    A quick look around these forums will disclose any amount of random code ...

  • Frequency for random no generation between 0.1 and 1.0

    how can i create a array which stores the frequency of each random no i have generated. keep having different type error messages

    If you are generating random numbers between 0.1 and 1.0 then it is extremely unlikely that you will generate the same number twice. However, if you are getting error messages it would be useful to share them with us instead of making us guess what your problem might be.

  • Disable random Password generation button on Reset Password popup window.

    Hi ALL,
    We have a new requirement when user click on reset password tab on "Modify User" page, a pop up window will open with two options :
    1) Manually change the Password
    2) Auto-generate the Password (Randomly generated)
    I want to remove or disable this 2nd option. Can you please guide me what necessary changes required?
    Thanks,
    Amit

    It's easy enough to generate a random password. Use a
    constant string containing your alphabet (different
    systems have different rules about what characters
    are allowed). Then us Random first to generate a
    suitable length, then to pick a character from your
    alphabet for each slot. If there are further rules
    (e.g. "must contain at least one digit") then check
    the password you've just generated and if it fails
    the test, simply try again.
    But this isn't a particularly good system. It allows
    anyone to harrass a user by changing their password
    if they can guess their user name.
    The approach I favour is to send the user a one-time
    click-thru URL in an e-mail which allows them to set
    their password to anything they chose. That needs a
    special table in some data base. You generate a
    random token which acts as a one-shot password on a
    special "change password" page. As soon as the click
    through has been used then the database entry is
    deleted so that the token is invalidated. You should
    also invalidate the token if they log on in the
    normal way.I agree that the 'forgot your password' feature is nasty. I mean, we are normally enjoined from saying "invalid user id" or "invalid password", we have to say "invalid user id / password combination" or something to that effect. But by providing the 'forgot your password' feature, it would be trivial to write a bot to see which sites provide this, determine a good page from a bad (e.g., valid user id) and then have an easier time brute-forcing the password. Sad.
    On the other hand, I know personally that many companies are concerned with phishing attacks on their customers. As such, they have a blanket policy prohibiting any URL that hits a secured page in any way.
    So, what to do? :^(
    - Saish

  • Random Number Generation

    According to the documentation, java makes random numbers with this algorithm.
    synchronized protected int next(int bits) {
           seed = (seed * 0x5DEECE66DL + 0xBL) & ((1L << 48) - 1);
           return (int)(seed >>> (48 - bits));
    }The purely mathematical concept is this:
    Xn = (Xn-1 * constant1  + constant2) % constant3.In other words, to find a new number, we multiply the old number with a constant, add it to another constant, and then do modulus constant3 on the sum.
    That's okay, it's the java-specific implementation im wondering a little about.
    I've also understood that you can replace (sum % constant3) with (sum % (constant3 -1)), if constant3 is a power of 2.
    But:
    1. The function returns an integer, but still, the seed is a long.
    Why? Is it to prevent (seed * 0x5DEECE66DL + 0xBL) from overflowing?
    If that's the case, wouldnt that mean this function DEPENDS on long being longer than an integer?
    2.Why do they choose exactly (1L << 48)) as modulus?
    (1L << 48) ) means we got a 1, and 48 zeroes behind it? So the modulus is a power of 2 ^ 48, using 49 bits? And then we just subtract 1 to get to use the &, instead of the % operator, for performance reasons?
    Doesent this mean that this function depends on a long being atleast 64bits?
    What's the function of the remaining bits? (since we're just using 48 / 49 bits, during the computation).
    Are they used as a "overflow-buffer"?
    Edited by: Drogin on Jun 28, 2009 5:33 PM
    Edited by: Drogin on Jun 28, 2009 5:33 PM

    Drogin wrote:
    1. The function returns an integer, but still, the seed is a long.
    Why? Is it to prevent (seed * 0x5DEECE66DL + 0xBL) from overflowing?I don't see how it would prevent it overflowing or why it would matter.
    If that's the case, wouldnt that mean this function DEPENDS on long being longer than an integer?A lot in java depends on the JLS being followed.
    2.Why do they choose exactly (1L << 48)) as modulus?
    (1L << 48) ) means we got a 1, and 48 zeroes behind it? Perhaps because this function will only generate up to 32-bit and 48-bits is more than enough.
    So the modulus is a power of 2 ^ 48, using 49 bits?No, the operation specificly limits the value to be 48-bits long.
    Doesent this mean that this function depends on a long being a tleast 64bits?At least 48-bits I imagine, but it is 64-bits and always will be.
    And then we just subtract 1 to get to use the &, instead of the % operator, for performance reasons?Perhaps, jvms are smarter than they were whent he code was written so you might not need to do this now.
    What's the function of the remaining bits? (since we're just using 48 / 49 bits, during the computation).They don't appear to be used.
    Are they used as a "overflow-buffer"?It wouldn't matter if this function overflowed, so I wouldn't think so.
    In my experience, often in simple operations like this, the bit in the middle of the number are the most random. i.e. they have slightly better statistical properties.
    It is likely that people played around with the three numbers in this equation until they got a random distribution they were happy with.

  • Random Number Generation Within An Object

    Hi, im trying to create an Arraylist containing 10 objects from class Child (see below). Each Child has an age between 1 and 30 which should be randomly generated but for some reason each one is the same. However when i use the BlueJ debugger and step through the program it creates appropriately random numbers so im assuming the problem is with the speed at which the code is run. Any ideas as to how i can combat this? Heres the code:
    Main Class:
    public static void main(String args[]) {
    int index = 0;
    while(index < 10) {
              test = new Child();
              int age = test.getAge();
              schoolbus.add(test);
              System.out.println((index + 1) + ": " + age);
              index++;
    Child Class:
    public class Child {
    private int age;
    Random r = new Random();
    public Child() {
    age = r.nextInt(30);
    public int getAge() {
    return age;
    Thanks, Nick

    You're creating 10 new Random() objects within the same millisecond, this gives them all the same seed and they produce the same first number. You could produce all ages from the same Random() outside the child class and set the age within the child's constructor e.g.
    //snip
    //This bit refers to the Main class
    Random r = new Random();
    while(index < 10) {
    test = new Child(r.nextInt(30));
    //snip- Mr K

  • Random number generation that sticks

    Hello,
    I would appreciate any help with the appropriate JavaScript to generate a random 8 digit number XXXX-XXXX on a form when the user starts to enter data. This number would need to be permanent so that it can be used as a tracking identifier later.
    Thanks for looking.
    Dawson

    If you're using Oracle8i, you can use the new SAMPLE clause in the FROM clause of the SELECT statement to query a random sample from a single table. Otherwise, just write a simple random number generator in PL/SQL (see any good algorithm book under the topic "Psuedorandom number generator"). You need to understand a bit about statistics, if being "truly" random is important, to use these tools.

  • Random Number generation within BPEL

    I am trying to embed a java-exec and trying to generate random number using a code as follows:
    int ranNumber1 = (int)(Math.random()*1000000000000000.0);
    int ranNumber2 = (int)(Math.random()*1000000000000000.0);
    setVariableData("RanNumber1",new Integer(ranNumber1));
    setVariableData("RanNumber2",new Integer(ranNumber2));
    I always get the same value for ranNumber1 and for ranNumber2 and for every instance, the value seems to be the same.. Actually the value generated is 2147483647 always..
    Am I doing anything wrong? Can anyone clarify here, please...

    // construct a bigdecimal, exaclty lenght'd 10 digits
    BigDecimal z = new BigDecimal("10000000000");
    // multiply it randomly (random returns something between 0 and 1)
    z = z.multiply(new BigDecimal(Math.random()));
    // and use the rounding ..
    BigInteger big = z.toBigInteger();
    is one option, I guess not the nicest but working ..

Maybe you are looking for