Do random number generators (RNGs) depend on sequential number generation?

Hi,
I know that random number generators (RNGs) are guaranteed to be random as N (the number of numbers generated) approaches infinity, but what does the specification say about throwing away the RNG after a single use?
That is, is there a difference between generating 1000 numbers using the same generator versus generating 1000 generators and reading at one number from each?
Is there a difference between the normal RNGs and the cryptographically-strong ones for this?
I ask because I am wondering whether a web server needs to maintain a RNG per client session, or whether it can share a single generator across all clients, or whether it can create a new generator per HTTP request. Does any of this affect how random the resulting numbers will be (from the client point of view, as T approaches infinity)?
Thank you,
Gili

ghstark wrote:
cowwoc wrote:
I know that random number generators (RNGs) are guaranteed to be random as N (the number of numbers generated) approaches infinityHow do you know this? it is a challenge just to come up with a formal definition for the "random" in "random number generators".
Wasn't this covered in your [earlier thread|http://forums.sun.com/thread.jspa?threadID=5320382&messageID=10369834] ?
You're right, but what bothered me about that thread is that the replies concluded that since there is no practical proof that SecureRandom has a problem that should be good enough. I'm looking for a code sniplet guaranteed by the specification (hence portable across implementations) to generate random numbers. No one has yet to provide such an answer.
What's to guarantee that if I move to a different platform, vendor or even a different version of Sun's JVM that my code won't magically break? Verifying randomness isn't a trivial matter.

Similar Messages

  • Multiple Random Number Generators

    I'm writing a program to simulate the tossing of two coins: a nickel and a dime. I want each coin to have its own independently generated set of outcomes. At the core of my logic is a call to one of two random number generators.
    http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Math.html#random() says that "...it may reduce contention for each thread to have its own pseudorandom-number generator." It also makes reference to Random.nextDouble.
    If the first call to random() creates the random number generator, and any subsequent calls to random() supply the next number in the series, what code do I use to setup multiple generators? I want each coin to have its own series.
    What is the need for nextDouble()? Should I be using nextDouble() or random() to get subsequent numbers from these generators?
    Thanks for you help.
    Jim

    Random rnd1 = new Random(7);
    Random rnd2 = new Random(17);Unfortunately, the close seed states will make for
    very closely related sequences from each.And you base that statement on what?Close seeds make for close sequences with lcprng's.
    It's less obvious for these:
    // First ten calls to nextInt()
    -1156638823
    -1149713343
    -1552468968
    -876354855
    -1077308326
    -1299783908
    41356089
    -1761252264
    1495978761
    356293784
    2107132509
    1723477387
    -441191359
    -789258487
    -1105573998
    -46827465
    -1253369595
    190636124
    -1850488227
    -672335679But that's because the generator is 48 bits.
    If you look at sequential seeds you get really bad results...
    // first 50 seeds, [0, 50), one call to nextInt
    0  -1155484576
    1  -1155869325
    2  -1154715079
    3  -1155099828
    4  -1157023572
    5  -1157408321
    6  -1156254074
    7  -1156638823
    8  -1158562568
    9  -1158947317
    10 -1157793070
    11 -1158177819
    12 -1160101563
    13 -1160486312
    14 -1159332065
    15 -1159716814
    16 -1149328594
    17 -1149713343
    18 -1148559096
    19 -1148943845
    20 -1150867590
    21 -1151252339
    22 -1150098092
    23 -1150482841
    24 -1152406585
    25 -1152791334
    26 -1151637087
    27 -1152021836
    28 -1153945581
    29 -1154330330
    30 -1153176083
    31 -1153560832
    32 -1167796541
    33 -1168181290
    34 -1167027043
    35 -1167411792
    36 -1169335537
    37 -1169720286
    38 -1168566039
    39 -1168950788
    40 -1170874532
    41 -1171259281
    42 -1170105035
    43 -1170489784
    44 -1172413528
    45 -1172798277
    46 -1171644030
    47 -1172028779
    48 -1161640559
    49 -1162025308

  • Ideas on generating seeds for random number generators?

    Does anyone here have any ideas or know of any good links to articles that discuss how to generate good seeds for random number generators?
    I am aware that I could always probably call SecureRandom.generateSeed as one technique.
    The major problem that I have with the above is that I have no idea how any given implementation of SecureRandom works, and whether or not it is any good. (For instance, Sun seems to hide their implementation outside of the normal JDK source tree; must be in one of their semi-proprietary sun packages...)
    I thought about the problem a little, and I -think- that the implementation below ought to be OK. The javadocs describe the requirements that I am looking for as well as the implementation. The only issue that still bugs me is that maybe the hash function that I use is not 1-1, and so may not guarantee uniqueness, so I would especially like feedback on that.
    Here's the code fragments:
         * A seed value generating function for Random should satisfy these goals:
         * <ol>
         *  <li>be unique per each call of this method</li>
         *  <li>be different each time the JVM is run</li>
         *  <li>be uniformly spread around the range of all possible long values</li>
         * </ol>
         * This method <i>attempts</i> to satisfy all of these goals:
         * <ol>
         *  <li>
         *          an internal serial id field is incremented upon each call, so each call is guaranteed a different value;
         *          this field determines the high order bits of the result
         *  </li>
         *  <li>
         *          each call uses the result of {@link System#nanoTime System.nanoTime}
         *          to determine the low order bits of the result,
         *          which should be different each time the JVM is run (assuming that the system time is different)
         *  </li>
         *  <li>a hash algorithm is applied to the above numbers before putting them into the high and low order parts of the result</li>
         * </ol>
         * <b>Warning:</b> the uniqueness goals cannot be guaranteed because the hash algorithm, while it is of high quality,
         * is not guaranteed to be a 1-1 function (i.e. 2 different input ints might get mapped to the same output int).
         public static long makeSeed() {
              long bitsHigh = ((long) HashUtil.enhance( ++serialNumber )) << 32;
              long bitsLow = HashUtil.hash( System.nanoTime() );
              return bitsHigh | bitsLow;
         }and, in a class called HashUtil:     
         * Does various bit level manipulations of h which should thoroughly scramble its bits,
         * which enhances its hash effectiveness, before returning it.
         * This method is needed if h is initially a poor quality hash.
         * A prime example: {@link Integer#hashCode Integer.hashCode} simply returns the int value,
         * which is an extremely bad hash.     
         public static final int enhance(int h) {
    // +++ the code below was taken from java.util.HashMap.hash
    // is this a published known algorithm?  is there a better one?  research...
              h += ~(h << 9);
              h ^=  (h >>> 14);
              h +=  (h << 4);
              h ^=  (h >>> 10);
              return h;
         /** Returns a high quality hash for the long arg l. */
         public static final int hash(long l) {
              return enhance(
                   (int) (l ^ (l >>> 32))     // the algorithm on this line is the same as that used in Long.hashCode
         }

    Correct me if I'm incorrect, but doesn't SecureRandom just access hardware sources entropy? Sources like /dev/random?What do you mean by hardware sources of entropy?
    What you really want is some physical source of noise, like voltage fluctuations across a diode, or Johnson noise, or certain radioactive decay processes; see, for example
         http://www.robertnz.net/true_rng.html
         http://ietfreport.isoc.org/idref/draft-eastlake-randomness2/
         this 2nd paper is terrific; see for example this section: http://ietfreport.isoc.org/idref/draft-eastlake-randomness2/#page-9
    But is /dev/random equivalent to the above? Of course, this totally depends on how it is implemented; the 2nd paper cited above gives some more discussion:
         http://ietfreport.isoc.org/idref/draft-eastlake-randomness2/#page-34
    I am not sure if using inputs like keyboard, mouse, and disk events is quite as secure as, say, using Johnson noise; if my skimming of that paper is correct, he concludes that you need as many different partially random sources as possible, and even then "A hardware based random source is still preferable" (p. 13). But he appears to say that you can still do pretty good with these these sources if you take care and do things like deskew them. For instance, the common linix implementation of /dev/random at least takes those events and does some sophisticated math and hashing to try to further scramble the bits, which is what I am trying to simulate with my hashing in my makeSeed method.
    I don't think Java can actually do any better than the time without using JNI. But I always like to be enlightened; is there a way for the JVM to generate some quality entropy?Well, the JVM probably cannot beat some "true" hardware device like diode noise, but maybe it can be as good as /dev/random: if /dev/random is relying on partially random events like keyboard, mouse, and disk events, maybe there are similar events inside the JVM that it could tap into.
    Obviously, if you have a gui, you can with java tap into the same mouse and keyboard events as /dev/random does.
    Garbage collection events would probably NOT be the best candidate, since they should be somewhat deterministic. (However, note that that paper cited above gives you techniques for taking even very low entropy sources and getting good randomness out of them; you just have to be very careful and know what you are doing.)
    Maybe one source of partial randomness is the thread scheduler. Imagine that have one or more threads sleep, and when they wake up put that precise time of wakeup as an input into an entropy pool similar to the /dev/random pool. Each thread would then be put back to sleep after waking up, where its sleep time would also be a random number drawn from the pool. Here, you are hoping that the precise time of thread wakeup is equivalent in its randomness to keyboard, mouse, and disk events.
    I wish that I had time to pursue this...

  • Support for hardware random number generators?

    Can a hardware random number generator be easy integrated into Solaris so that it is accessed via /dev/urandom or /dev/random?
    Hardware Random Number Generators such as (just googling "usb hardware random number generator")
    http://true-random.com/
    http://www.protego.se/
    http://www.araneus.fi/products-alea-eng.html
    http://www.westphal-electronic.de/zranusbe.htm
    Is it possible to have a generic framework which can work with all these devices?

    This is a forum specifically for Java, not Sun products in general. You might try one on the Solaris forums.

  • Sequential Number SharePoint List

    Hi
    We are attempting to create a custom number that will automatically increment and decrement depending on the position of a new list item.
    For example, if I have a custom column named Sequence No. and I create a new item number 3, then all items from number 3 onwards should be automatically +1. The user should be able to capture the sequence number and have this value recalculated
    for other list items.
    The ID of the item cannot be used because there may be a situation where a user deletes an item. We have used this URL{SiteUrl}/_layouts/Reorder.aspx?List={ListId} for the reordering of items and we made the hidden order column
    available however if we change the position the order number is not always consistent - 200,250,275,300,400,450.
    We assume that an additional list to contain the numbering maybe a solution. Any suggestions for workflow and Jquery would be greatly appreciated.
    Thanks
    Mark

    Try below:
    https://www.nothingbutsharepoint.com/sites/eusp/pages/sharepoint-how-to-create-an-auto-incrementing-number-field-for-use-in-a-custom-id-part-1.aspx
    Or
    try below Script
    http://sharepoint.stackexchange.com/questions/88340/how-to-auto-populate-a-list-column-with-a-sequential-number
    ​<script src="/Shared%20Documents/jquery-1.10.2.min.js"></script>
    <script src="/Shared%20Documents/sputility.min.js"></script>
    <script>
    // Get the current Site
    var siteUrl = '/';
    function retrieveListItems() {
    var clientContext = new SP.ClientContext(siteUrl);
    // Get the liste instance
    var oList = clientContext.get_web().get_lists().getByTitle('sequential number');
    var camlQuery = new SP.CamlQuery();
    // Get only the last element
    camlQuery.set_viewXml('<Query><OrderBy><FieldRef Name=\'ID\' Ascending=\'False\' /></OrderBy></Query><RowLimit>1</RowLimit></View>');
    this.collListItem = oList.getItems(camlQuery);
    clientContext.load(collListItem);
    clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
    function onQuerySucceeded(sender, args) {
    var listItemInfo = '';
    var listItemEnumerator = collListItem.getEnumerator();
    while (listItemEnumerator.moveNext()) {
    var oListItem = listItemEnumerator.get_current();
    var listItemInfovalue = oListItem.get_item('Occurrence_x0020__x0023_');
    // Based in you request the id is : 14-00001
    // Split the first
    var res = listItemInfovalue.split("-");
    console.log(res[1]);
    // increment the index
    var newId = parseInt(res[1])+1;
    // create the new id
    SPUtility.GetSPField('Occurrence #').SetValue(res[0] + '-' + pad(newId, 5) );
    console.log(listItemInfo.toString());
    function onQueryFailed(sender, args) {
    alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
    // Create new id with fixed size :
    // exp : 00001, 00001
    // num : is the number
    // size : is the number size
    function pad(num, size) {
    var s = num+"";
    while (s.length < size) s = "0" + s;
    return s;
    $(document).ready(function(){
    ExecuteOrDelayUntilScriptLoaded(retrieveListItems, "sp.js");
    </script>
    If this helped you resolve your issue, please mark it Answered

  • Can I set up a master page to show custom alternating footer text dependant on page number?

    Hi,
    Is it possible to set up a master page to show different messages in the footer of a brochure dependant on page number? For example;
    Page 1: Buy from us because...
    Page 2: Our website address is...
    Page 3: Here's a special offer...
    Page 4: Our website address is...
    Page 5: Buy from us because...
    Page 6: Our website address is...
    ...and so on, repeating until the end of the brochure. The intention is for the footers to update automatically if the pagination of the brochure in question needs moving around - or if the messages need changing.
    Thanks!

    Thanks, but the text needs to be on a single master page which every page is assigned to. This is so the text alternates correctly regardless of whether new pages are inserted or moved. If I assigned separate master pages to individual pages and then moved the pages to a different location, the alternating footer text would then fall out of sync. I hope that made sense!

  • How to add 16 bit message sequential number to the byte array

    hi
    iam trying to implement socket programming over UDP. Iam writing for the server side now.I need to send an image file from server to a client via a gateway so basically ive to do hand-shaking with the gateway first and then ive to send image data in a sequence of small messages with a payload of 1 KB.The data message should also include a header of 16 bit sequential number and a bit to indicate end of file.
    Iam able to complete registration process(Iam not sure yet).I dnt know how to include sequential number and a bit to indicate end of file.
    I would like to have your valuable ideas about how to proceed further
    package udp;
    import java.io.*;
    import java.net.*;
    import java.util.*;
    public class Sender  {
        protected BufferedReader in = null;
        protected FileInputStream image=null;
        protected static boolean end_of_file=true;
    /** pass arguments hostname,port,filename
    * @param args
    * @throws IOException
       public static void main(String[] args) throws IOException{
            DatagramSocket socket = new DatagramSocket(Integer.parseInt(args[1]));
            boolean more_messages = true;
              String str1=null;
                * gateway registration
                try{
                     //send string to emulator
                    String str="%%%GatewayRegistration SENDER test delay 10 drop 0 dupl 0 bandwidth 1000000";
                    byte[] buff=str.getBytes();
                    InetAddress emulator_address = InetAddress.getByName(args[0]);
                    DatagramPacket packet = new DatagramPacket(buff, buff.length,emulator_address,Integer.parseInt(args[0]));
                    socket.send(packet);
                        // figure out response
                    byte[] buf = new byte[1024];
                    DatagramPacket recpack=new DatagramPacket(buf,buf.length);
                    socket.receive(recpack);
                   // socket.setSoTimeout(10000);
                    String str2=str1.valueOf(new String(recpack.getData()));
                    if(socket.equals(null))
                         System.out.println("no acknowledgement from the emulator");
                        socket.close();
                    else if(str2=="%%%GatewayConfirmation")
                    //     String str1=null;
                         System.out.println("rec message"+str2);
                    else
                         System.out.println("not a valid message from emulator");
                         socket.close();
                catch (IOException e) {
                    e.printStackTrace();
                      end_of_file = false;
         /**create a packet with a payload of 1     KB and header of 16 bit sequential number and a bit to indicate end of file
      while(end_of_file!=false)
          String ack="y";
          String seqnum=
           File file = new File(args[2]);                               
                    InputStream is = new FileInputStream(file);                 
            socket.close();
      private byte[] byteArray(InputStream in) throws IOException {
             byte[] readBytes = new byte[1024]; // make a byte array with a length equal to the number of bytes in the stream
          try{
             in.read(readBytes);  // dump all the bytes in the stream into the array
            catch(IOException e)
                 e.printStackTrace();
            return readBytes;
      

    HI Rolf.k.
    Thank you for the small program it was helpfull.
    You got right about that proberly there  will be conflict with some spurios data, I can already detect that when writing the data to a spreadsheet file.
    I writes the data in such a way, that in each line there will be a date, a timestamp, a tab and a timestamp at the end. That means two columns.
    When i set given samplerate up, that controls the rate of the data outflow from the device, (1,56 Hz - 200 Hz),   the data file that i write to , looks unorderet.
     i get more than one timestamp and severel datavalues in every line and so on down the spreadsheet file.
    Now the question is: Could it be that the function that writes the data to the file,  can't handle the speed of the dataflow in such a way that the time stamp cant follow with the data flowspeed. so i'm trying to set the timestamp to be  with fractions of the seconds by adding the unit (<digit>) in the timestamp icon but its not working. Meaby when i take the fractions off a second within the timestamp i can get every timestamp with its right data value. Am i in deeb water or what do You mean!??
    AAttached Pics part of program and a logfile over data written to file
    regards
    Zamzam
    HFZ
    Attachments:
    DataFlowWR.JPG ‏159 KB
    Datalogfile.JPG ‏386 KB

  • Tax report for Spain - Sequential Number

    The layout that I have prepared for the Tax report (RFUMSV00, Tx: S_ALR_87100833) shows the column "Sequential number." Thus, I have a relationship without jumping straight to the numbering of all invoices with VAT.
    The system assigns a "Sequential number" for SAP document number. The "problem" arises when there is a bill, a SAP document, with more than one tax indicator of VAT. Then some lines appear in the Declaration of VAT with the Sequential number field in blank and that is because the number of the document (this bill) is already listed in the Declaration in another line with its own Sequential number .
    How do you work with it? Can I somehow avoid that remove this Sequential number blank?

    Hi (again)
    After reading the SAP note number 1628714 ( https://websmp107.sap-ag.de/~form/handler?_APP=01100107900000000342&_EVENT=REDIR&_NNUM=1628714&_NLANG=E ), I think that there isn't an SAP-standard solution.
    Best regards.
    Paco M

  • How I can change sequential number in RFUMSV00 (Spanish declaration of VAT)

    Hi!
    How I can change sequential number of Output /Input Tax in RFUMSV00 transaction (Spanish declaration of VAT)?
    In input declaration I would like to have one sequential number for input tax and for output tax that appears on in.  Is possible with standard Sap or I need a Z-transaction?
    Thanks

    Dear friend,
    Please refer the below note.
    SAP Note 849459
    Reg
    Madhu M

  • Can Aperture Read the camera's sequential number metedata when naming files

    Before I started using Aperture I would use this naming convention in Bridge to batch rename files and It works great because it avoids duplicate file names and the files are in sequential order
    my last name(Blake)YYYYMMDDfour digit NON RESETTING sequential number, generated by my Nikon D2X. I don't have any duplicate file names unless I shoot more that 9999 images in one day.
    Has anybody found the option to use the camera's generated sequence number in Aperture's file naming scheme. I sure can't. I know that you can set a four digit sequence but that sequence doesn't start where the sequence leaves off in the previous import.
    Thanks
    John
    G4 Powerbook   Mac OS X (10.4.8)  

    I have two workarounds
    1. Rename the files in bridge after like I have always done and then import the folder as an Aperture project without changing the file names. I use photo mechanic to download the files from the card.
    2. Go to the library smart folders to see what was the last project I imported and check the four digit sequence before the file name extension. Set the sequential counter in Aperture to start at the next sequential number where the last file left off.
    I have to use the four digit sequence instead of using the date and Time sequence. It is very convenient for my clients to give me the four digit sequence when telling me what images they want prints from,etc. Avoids any confusion.
    I did request this feature of using the camera's generated file name in Apple's feedback link for future inhancements.
    thanks for your responses
    John
    G4 Powerbook   Mac OS X (10.4.8)  
    G4 Powerbook   Mac OS X (10.4.8)  

  • Sequential number

    Hi All,
    What is the importance of  Sequential number for condition exclusion in Pricing Proce. where we assign one exclusion grp to other? How should i arrange the sequence of assignements of different exclusion groups?
    Can a exclusion group  contains more than one conditon type for comparision?
    Thanks,
    Pramod

    Hi madhu aaryaa,
    I think that you have some problem with you.
    You had posted similar question for the past 2 or 3 times and I had replied for them. You have not even rewarded points or closed them.
    Check these threads for your reference...
    logic generation
    number generation
    batch number
    batch number
    I have even posted the code for this. Hoping that you will do the needy...
    PARAMETERS p_i TYPE i.
    DATA d_i1 TYPE i.
    DATA d_i2 TYPE i.
    DATA d_i3 TYPE i.
    DATA d_i4 TYPE i.
    DATA code(4).
    DATA num(36) VALUE '0123456798ABCDEFGHIJKLMNOPQRSTUVWXYZ'.
       d_i4 = p_i MOD 36.
       p_i = p_i DIV 36.
       d_i3 = p_i MOD 36.
       p_i = p_i DIV 36.
       d_i2 = p_i MOD 36.
       p_i = p_i DIV 36.
       d_i1 = p_i MOD 36.
       code+0(1) = num+d_i1(1).
       code+1(1) = num+d_i2(1).
       code+2(1) = num+d_i3(1).
       code+3(1) = num+d_i4(1).
       WRITE code.
    Message was edited by: Wenceslaus G

  • Sequential Number for Non-Approved Forms

    Hello-
    I'm building an InfoPath form that is submitted to a SharePoint library.  There is an approval workflow created in SP Designer.  Once the form is approved, it is moved to another document library and then deleted from the current one.  Our
    goal is to assign a sequential number (RQNumber) to each form.  In InfoPath I have created 2 fields:  One that looks in the initial form library and grabs the max RQNumber and another that looks in the other form library and grabs the max
    RQNumber.  Then I have a field that takes the max of those two numbers and adds 1.
    The issue I'm having is I can't get the formula to grab the max RQNumber from the first form library.  I'm guessing this is because the form hasn't been approved yet, so it doesn't pull from the form until it's approved.  Is that correct? 
    Is there any way around that?
    Thanks! 

    Hi Nivek,
    Question: At what stage is the RQNumber assigned to the form in the first form library? Is it during submission of the form or during approval? If you are deleting the document from the first form library, arent you getting the max RQNumber same everytime?
    If this number is assigned during form creation, you should be able to lookup in the form library from a data connection to the same form library. During Form load, set a field to have max of RQNumber. Hope it helps.
    Regards, Kapil ***Please mark answer as Helpful or Answered after consideration***

  • Sequential Number into Dimension BPC NW

    Hi expert
    i hope that you can help me, i need to create a sequential number as a Member into a one Dimension in order to identify any load data in our planning process, this number have to be create when the user send data to applitation by data input schedule.
    Please any idea to do that.
    Regards

    Thanks again,
    I have also created another property in order to group all the values I want to consider, but the script logic delivers an exception and it does not work.
    Example:
    Dimension: DIM
    ID       PROP1    GROUP
    A        10           Y
    B        13           Y
    C        17           Y
    If I need to multiply by 2 the value in the dimension PROP1, I have tried the following:
    *SELECT(%VAR%,"[PROP1]",DIM,"[GROUP]="Y"")
    *WHEN DIM
    *IS<>""
    REC(EXPRESSION=%VAR%2)
    *ENDWHEN
    However, the system delivers an exception error: UJK_VALIDATION_EXCEPTION: Unknown DImension Name in Keyword:¨3
    In the other hand the following gets saved and processed correctly:
    *SELECT(%VAR%,"[PROP1]",DIM,"[PROP1]="10"")
    *WHEN DIM
    *IS<>""
    REC(EXPRESSION=%VAR%2)
    *ENDWHEN
    I am using BPC NW 7.5 SP03 but I was not able to find an OSS Note regarding this.
    Many thanks in advance
    Regards
    Dani

  • O.T. Sequential Number Text Overlay On Photos In A Batch Process

    As ACDSee crops up on the forum from time to time, I thought this posting
    on Photo.net on using ACDSee to put a "sequential number" text overlay on photos in a batch process might be of interest.
    http://photo.net/bboard/q-and-a-fetch-msg?msg_id=00PRhf

    I don't think it's possible to manually add OCRd text, but you can add form
    fields with the text in them. And yes, it is possible to search the content
    of form fields, using a script.

  • Assigning sequential number from number range

    Hi All,
    My Zreport is updating Ztable with sequential number field assigned for each document numbers for each period. Below are the numbers assigned for period 5 in Ztable.
    00001000000000000000
    00001000000000000001
    00001000000000000002
    00001100000000000000
    00001200000000000000
    00001200000000000001
    00001200000000000002
    00001200000000000003
    When I ran for period 6 the sequence number is coming as below.
    00001000000000000003
    00001000000000000004
    00001100000000000001
    00001200000000000004
    00001200000000000005
    00001200000000000006
    It should give me the below.
    00001000000000000003
    00001000000000000004
    00001100000000000000
    00001200000000000004
    00001200000000000005
    00001200000000000006
    I am fetching the data from Ztable and sorting in descending order. Below is the data in my internal table in debugging.
    bukrs belnr           blart   monat   numkr      zsequence
    2700 |1700002431 |KA   |05         |03         |00001200000000000003
    2700 |5100000804 |RE   |05         |02         |00001100000000000000
    2700 |2200000004 |P2   |05          |01         |00001000000000000002
    Below is my code.
          loop at t_ztable.
            clear w_zsequence.
            unpack t_table-zsequence to t_ztable-zsequence.
            if (t_ztable-zsequence = '00001200000000000000' or
                 t_ztable-zsequence = '00001100000000000000' or
                 t_ztable-zsequence = '00001000000000000000' ).
            w_zsequence = t_ztable-zsequence
            else.
              w_zsequence = t_ztable-zsequence + 1.
              unpack w_zsequence to w_zsequence.
            endif.                                              "BK003
    *   shift w_zbelnr left deleting leading space.
            loop at t_bkpf
                  where bukrs = t_ztable-bukrs
                    and groupnumber = t_ztable-numkr.
              move-corresponding t_bkpf to t_ztable_load.
              t_ztable_load-zsequence = w_zsequence.
              t_ztable_load-numkr = t_ztable-numkr.
              append t_ztable_load.
              w_zsequence = w_zsequence + 1.
    *         shift w_zsequence left deleting leading space.
              unpack w_zsequence to w_zsequence.
            endloop.
          endloop.
    How to acheive this. Please help me.
    Thanks,
    VBK

    Hi Haritha,
    Can you show us the table t_bkpf dataon which you are looping?
    Regards,
    Sudeesh Soni

Maybe you are looking for