Generate sequence numbers

Hi,
I am looking for an algorithm to generate alphanumeric sequence numbers in ABAP.
The sequence numbers should be in the following format
AAAA
AAAB
AAAC
AAAZ
AABA
AABB
AABC
AABZ
ZZZZ
Is there any built-in function module provided by SAP to accomplish this? Or something like a FOR statement as in C/C++?
Please help.
Helpful answers will be immediately rewarded.
Thank you.

Hi,
I'm not sure, but maybe you can create a number range with SNRO for alphanumerical values
otherwise you have to create your own logic (you can use hexadecimal to ascii conversion in ABAP to increment the alphanumerical values)
Kind regards, Rob Dielemans

Similar Messages

  • Generating sequence numbers not stored in the database

    how to generate row numbers in the select statement
    I need my query to return row numbers as a column which need to be displayed in the front end reporting tool.
    should return something like this..
    RANK NO DEPTID DEPT_NAME
    1 10 SCOTT
    2 10 JAMES
    3 20 PETER

    Something like
    SELECT row_number() over (order by deptid) rank_no, deptid, dept_name
      FROM deptJustin

  • How can i generate sequence numbers to my detailed block in Oracle Forms 9i

    Hi all,
    i have a detail block.
    in that block sno (serial no) (multi row column)is one column.
    What i want is when i enter into that block sno should generate automatically....like..
    1 for first record
    2 for second record..
    i need the code for this can anybode help me.
    Venkat.

    Hello,
    You could use the current record number in a When-Create-Record trigger:
    If :block.sequence IS NULL Then
       :block.sequence := Get_Block_Property( 'block', CURRENT_RECORD ) ;
    End if ;Francois

  • How to generate random sequence numbers

    Hello experts
    Iu2019m writing a custom program and pulling data from VBAK & VBAP. As per requirement I also need to generate a sequence number randomly and finally store all data in text file and upload at server. The hiccup is I donu2019t know how to generate sequence numbers. Can somebody please show me how I can accomplish it?
    Thanks a lot in advance

    Find the below code,
      data: lv_range type datatype-char0128.
      call function 'RANDOM_C'
        exporting
          len_min   = 20
          len_max   = 20
          char_min  = 1
          char_max  = 20
        importing
          rnd_value = lv_range.
    LV_RANGE param will have a random value..
    If you need number you can use the FM "RANDOM_I4"
    Thanks,
    Prathap

  • Page item sequence numbers

    Maybe this one is for a future improvement...
    After reordering page items using the drag and drop feature the items all have a sequence number one greater than it's predecessor.
    This makes it hard to put a new item in between existing ones. Generating sequence numbers 5 or 10 apart would make this a bit easier.

    hi,
    i dont know whether you have tried this before...
    10
    10.1
    10.2
    10.3
    20
    20.1
    20.2
    30
    this is acceptable in apex item sequence number for inserting new items .
    Thanks
    Mark Wyatt
    Edited by: Websoft on Sep 30, 2009 6:33 AM

  • Recycled Sequence Numbers

    Hi,
    We have a requirement of generating sequence numbers for a table and we need to recycle them if some of them is deleted.
    For example the following tabe Employee(Id,name)
    ID NAME
    1 XXX
    2 YYY
    3 ZZZ
    4 AAA
    The ID filed should have the next sequence number generated. When I call getnextID now, it should return 5
    ID NAME
    1 XXX
    2 YYY
    3 ZZZ
    4 AAA
    5 BBB
    Now Let us assume I delete 3. The contents of the table aare
    ID NAME
    1 XXX
    2 YYY
    4 AAA
    5 BBB
    Now when getNextID, 3 should be returned.
    How to achieve this in a best performing way in Oracle? Are there any patterns around it? Please note this should run in a multi user environment.
    Thanks,
    Rama

    I think the answers were based on the fact that you call it incorrectly sequence.
    Your ConnectivityID is more as a resource that could be recycled. I see some similarities to the GSM telecom market where a resource(i.e. a phone number or a SIM card no) can be recycled when is not active anymore (under certain conditions however).
    Personally I would generate a table of resources having the resource number (ConnectivityID) and resource status.
    To simplify it, suppose that you have column status with 2 possible values, 0=available, 1=not available.
    When you want to allocate the resource number(ConnectivityId) you will set the status to 1.
    When the record is deleted then status will be updated back to 0.
    Recycling a ConnectivityID will mean searching in the table for the lowest number having status=0.
    Of course you don't expect this to be as fast as a sequence but I think this is a different requirement, IMO.
    Regards
    Al

  • Sequence numbers not generated sequentially?

    Our situation: We have encountered an issue with our database, where it appears that a sequence has generated a number out of sequence, that is, to fill in a gap left previously. That is, in the affected table, we have records like:
    Seq No Date (DD/MM/YY)
    1 29/12/08
    2 29/12/08
    3 4/1/09
    4 29/12/08
    The code that actually updates the database is from a third party, so I am unable to prove the following, but the vendor assures me that:
    1. The sequence numbers are generated using "select message_number.nextval from dual".
    2. The Date column is not modified after the record is created. ( Nor is it supposed to be )
    The sequence is created by "CREATE SEQUENCE MESSAGE_NUMBER START WITH 10000000 INCREMENT BY 1 MINVALUE 10000000 CACHE 20 NOCYCLE NOORDER"
    This was detected only yesterday, after the event, and is very uncommon ( I have not found another instance, but there are over 7,000,000 records, so I haven't performed an exhaustive search). We are relying on the sequence numbers always being generated sequentially, as in each message_number.nextval is greater than the previous one.
    I don't think that the date change was due to a user accidentaly changing the date. Related records to '3' are also dated 4/1/09, there is no facility for a user to change the date outside of accessing the database directly, and even the developers do not have write access to this database.
    My questions:
    1. Is this normal behaviour for a sequence? To go back and fill in a gap like this? If so we'll have to change one of the assumptions of one of our modules.
    2. Should the sequence be defined with 'ORDER' rather than 'NOORDER' to stop this?
    3. Could this be a bug in the sequence number generation? We are using Oracle 9.2.0.1.0.
    4. Is this situation "impossible", and therefore there is a bug in the vendor library that we need to track down.
    Thanks for your help,
    Wayne.

    wayneb wrote:
    Our situation: We have encountered an issue with our database, where it appears that a sequence has generated a number out of sequence, that is, to fill in a gap left previously. That is, in the affected table, we have records like:
    Seq No Date (DD/MM/YY)
    1 29/12/08
    2 29/12/08
    3 4/1/09
    4 29/12/08
    The code that actually updates the database is from a third party, so I am unable to prove the following, but the vendor assures me that:
    1. The sequence numbers are generated using "select message_number.nextval from dual".
    2. The Date column is not modified after the record is created. ( Nor is it supposed to be )There might be a delay between fetching the sequence and storing the sysdate? value in the database.
    maybe some user prepared a new record. Then went to some new years eve party and when he came back at the begining of next year he commited the data (record send to database, database is adding date column by some trigger...).
    >
    The sequence is created by "CREATE SEQUENCE MESSAGE_NUMBER START WITH 10000000 INCREMENT BY 1 MINVALUE 10000000 CACHE 20 NOCYCLE NOORDER"
    This was detected only yesterday, after the event, and is very uncommon ( I have not found another instance, but there are over 7,000,000 records, so I haven't performed an exhaustive search). We are relying on the sequence numbers always being generated sequentially, as in each message_number.nextval is greater than the previous one.
    I don't think that the date change was due to a user accidentaly changing the date. Related records to '3' are also dated 4/1/09, there is no facility for a user to change the date outside of accessing the database directly, and even the developers do not have write access to this database.
    My questions:
    1. Is this normal behaviour for a sequence? To go back and fill in a gap like this? If so we'll have to change one of the assumptions of one of our modules.No sequences don't fill gaps. However it is possible to fetch and cache values from a sequence for later usage. Especially in a RAC environment you can get sequence values that are not in order of time.
    2. Should the sequence be defined with 'ORDER' rather than 'NOORDER' to stop this?No.
    3. Could this be a bug in the sequence number generation? We are using Oracle 9.2.0.1.0.Extremly unlikely, but you can always check Metalink.
    4. Is this situation "impossible", and therefore there is a bug in the vendor library that we need to track down.You can create such situations programatically. Whether it is a bug depends on the specifications for the software.
    >
    Thanks for your help,
    Wayne.Edited by: Sven W. on Mar 24, 2009 5:00 PM

  • Sequence generating duplicate numbers

    Hi guys,
    this might be more of a DBA question type... we had a situation where we copied data (once full schema and other time only tables ) from one database to another but ended up having sequence problem because new sequence was generating numbers which were lower than previousley generated one !
    I wonder if anyone had similar problem or know what could be causing it.
    when we copy full schema this happens to random table/sequences.
    Thanks for reading.
    Ali

    The sequence skipping behaviour is seen when cached sequences are exported.
    From the Oracle utilities manual
    >
    If transactions continue to access sequence numbers during an export, sequence numbers might be skipped. The best way to ensure that sequence numbers are not skipped is to ensure that the sequences are not accessed during the export.
    Sequence numbers can be skipped only when cached sequence numbers are in use. When a cache of sequence numbers has been allocated, they are available for use in the current database. The exported value is the next sequence number (after the cached values). Sequence numbers that are cached, but unused, are lost when the sequence is imported.
    >
    Hope this helps
    Varad

  • Can a sequence generate negative numbers?

    Hi
    Thank you for reading my post
    i think my sequence generate negative numbers , is it possible ?or somewhere in my application is incorrect ?
      CREATE SEQUENCE  "HR"."GLOB_SEQ"  MINVALUE 1 MAXVALUE 999999999999999999999999999 INCREMENT BY 1 START WITH 5 NOCACHE  ORDER  NOCYCLE ;is there anything that i made wrong which caused the negative numbers in my edit box ?
    type of my category_ID is number.
    Thanks

    Generally speaking yes you can generate negative numbers:
    SQL> create sequence seq1 increment by -1;
    Sequence created.
    SQL> select seq1.nextval from dual;
    NEXTVAL
    -1
    SQL> /
    NEXTVAL
    -2
    But if you have defined minvalue as 1 it is impossible because:
    SQL> create sequence seq1 increment by -1 minvalue 1 maxvalue 1000000 start with 1;
    Sequence created.
    SQL> select seq1.nextval from dual;
    NEXTVAL
    1
    SQL> /
    select seq1.nextval from dual
    ERROR at line 1:
    ORA-08004: sequence SEQ1.NEXTVAL goes below MINVALUE and cannot be instantiated
    SQL>
    So most probably someone simply inserted a row with negative values knowing that they'll never be in conflict with sequence generated values, or your code is buggy :)
    Generally for surrogate keys (assuming this is your case) you don't care what values they have.
    Gints Plivna
    http://www.gplivna.eu

  • Error While Generating Sequence Number. Contact your system Administrator

    Hi All,
    I have developed a form to provide our client with 'an easy to fill' User Interface. This form will be used instead of the standard form present in Business Suite.
    Some columns of the table, on which form is based, are getting populated via generation of sequence numbers.
    Now the problem is, after deploying custom form developed by me in the instance, Standard form is showing this error
    " Error While Generating the Sequence Number. Please contact the System Administrator "
    I am unable to trace why this error had started appearing..
    Any suggestions would be of great help...
    Thanks in Advance,..

    Forms version 6i,
    Database version 9.2.0.6.0
    Sequences which I am using are used there in Standard form also..
    So evrytime i need to save the record, I am selecting NEXTVAL of it into
    the respective item of the datablock..

  • How to generate unique numbers

    hi all,
    I want to generate unique numbers always starting from 1 using a single sql query and I dont want to use a sequence and i dont think rownum will be helpful for generating unique numbers in all cases . how to do this ?
    thanks & regards,
    kumar.

    If two users get the MAX from temp, they would be updating with the same value for two different rows.If TEMP is a genuine temporary table, this is not an issue, because the data in a temporary table is only visible within a session.
    The big problem with this approach is the mutating table one: we cannot issue the requisite select statement from a BEFORE INSERT trigger. So this solution is only going to work with a view and an INSTEAD OF INSERT trigger.
    Another, more workable, solution is to use a code control table. This can be (should be) another temporary table, with one row holding one column - next value for TEMP.ID. Normally we would rule out such a solution because it serializes access to the inserted table, but as this is only on a per session basis, it doesn't matter.
    CREATE OR REPLACE TRIGGER tmp_bir BEFORE INSERT ON temp1 FOR EACH ROW
    DECLARE
      ln NUMBER;
    BEGIN
      SELECT nvl(code1.next_id,1) INTO ln
      FROM code1;
      :NEW.id := ln;
      UPDATE code1
      SET    next_id := ln+1;
    END;Beware: coded freehand, so may need debugging.
    Cheers, APC

  • Sequence numbers - with no gaps!

    I seek some advice from anyone with first hand experience in this area.
    My need is simple; generate a new ID number for every order for use as the primary key.
    Obviously this simple exercise could be a bottleneck as volumes ramp up, so I was pleased to find the Oracle feature to generate such numbers (efficiently presumably). However, upon closer reading it was apparent that aborted transactions would result in the loss of the number allocated to to that order if another transaction had obtained the next sequence number already (as one would want it to, rather than serializing transactions).
    I don't want to have gaps in the sequence as the system needs a high degree of auditability. I am thinking of utilising the Autonomous Transaction feature to write the newly acquired sequence number to the order file with a flag indicating that the record is incomplete, and that record is to be skipped by normal system applications (but available to audit reports which will interpret the reason correctly), then returning to the far more extensive main transaction which updates many tables.
    The other alternative is to control sequence numbers within the application itself, or try to get the sequence number as the very last step before writing the new order record, but this probably won't guarantee gapless reliability either. The ID itself has no significance, and it doesn't matter if an ID was used out of strict date/time sequence, so I really don't want to execute these updates serially.
    So, my question is this:
    a) do most people use the builtin sequence number feature?
    b) if so, is there a standard technique for avoiding or accounting for gaps?
    c) if the application must take over this task, should the counter for the last used ID be in a single row table to minimise bottlenecks caused by the thisrecord being locked? There will be several such counters for different aspects of the application, and i thought of having each in its own row in a small table, but I'm concerned about the whole table getting locked and freezing out otherwise-unrelated updates.
    Thanks for any advice you may have.
    CS

    user8821725 wrote:
    I seek some advice from anyone with first hand experience in this area.
    My need is simple; generate a new ID number for every order for use as the primary key.
    Obviously this simple exercise could be a bottleneck as volumes ramp up, so I was pleased to find the Oracle feature to generate such numbers (efficiently presumably). However, upon closer reading it was apparent that aborted transactions would result in the loss of the number allocated to to that order if another transaction had obtained the next sequence number already (as one would want it to, rather than serializing transactions).
    I don't want to have gaps in the sequence as the system needs a high degree of auditability. One of the very very few reasons for me to have a requirement for "gapless" sequences is if you have a kind of checking mechanism outside of the database that is implemented using this gapless number. I had such a requirement once, when exchanging files with another bank where we had to ensure that each file was transferred correctly and in the right order. Your "high degree of auditability" might be a similiar requirement. Just remember as long as you are still inside the database you can use other mechanisms to increase auditability.
    I am thinking of utilising the Autonomous Transaction feature to write the newly acquired sequence number to the order file with a flag indicating that the record is incomplete, and that record is to be skipped by normal system applications (but available to audit reports which will interpret the reason correctly), then returning to the far more extensive main transaction which updates many tables.Hm. I don't see why you want to use Autonomous Transactions for this. It might be useful to lessen locking conflicts , depending how your future sequence mechanism will be built.
    >
    The other alternative is to control sequence numbers within the application itself, or try to get the sequence number as the very last step before writing the new order record, but this probably won't guarantee gapless reliability either. The ID itself has no significance, and it doesn't matter if an ID was used out of strict date/time sequence, so I really don't want to execute these updates serially.I would go for generating the sequence as the very last step. It needs to be set to NOCACHE of cause. This will garantee that the sequence fetched from mySeq.nextval is gapless. The problem is then in your application. Your application must be built in a way that it ensures to use this sequence, or at least to create a noticable alert when this generated sequence can't be used anymore. In essence this means. Each unhandled (database) error that happens after you fetched the next sequence value must be raised in a way that informs all relevant people about this error.
    Example: It might be that you use the sequence to write an order file. What happens if halfway through writing the file your disk runs out of space? This can be such an issue where a sequenced value will be lost. Your organisation must take care of those things.
    >
    So, my question is this:
    a) do most people use the builtin sequence number feature?Yes. But for some tasks a sequence is not the best way, for example if you want a numbering for each item of your order. This "sequence" needs to restart with every new order.
    b) if so, is there a standard technique for avoiding or accounting for gaps?NOCACHE => Avoids gaps during generation
    Database Trigger => Tries to use the sequence as late as possible
    c) if the application must take over this task, should the counter for the last used ID be in a single row table to minimise bottlenecks caused by the thisrecord being locked? There will be several such counters for different aspects of the application, and i thought of having each in its own row in a small table, but I'm concerned about the whole table getting locked and freezing out otherwise-unrelated updates.This is a possibility and the issues you describe are why we avoid such a solution in general. Autonomous transactions help to reduce the locking conflict, but they increase the chance that you produce gaps.
    >
    Thanks for any advice you may have.
    CSOracle can guarantee to produce gapless sequences. But it can't guarantee that your application uses such a sequence in a gapless way.

  • Assigning sequence numbers treo cords

    Please help to understand the following, because it's a little unclear for me.. can you provide me an example?
    So, regarding to assigning sequence numbers when a new record is created, we usually use a pre-insert trigger, with this code:
    SELECT orders_seq.NEXTVAL
    INTO :orders.order_id
    FROM SYS.dual;
    But:
    You can also assign sequence numbers from a table. If you use this method, two transactional
    triggers are usually involved:
    • Use Pre-Insert to select the next available number from the sequence table (locking the row
    to prevent other users from selecting the same value), assign it to the Forms item, and
    increment the value in the sequence table by the required amount.
    • Use Post-Insert to update the sequence table, recording the new upper value for the
    sequence.So how to assign a sequence number from a ... table?
    Thanks

    You have to implement the number generator yourself; something similar to this: http://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:4343369880986
    cheers

  • Temporary sequence numbers

    Hello all,
    Is there any provision in the mobile server and mobile client to synchronize the Lite database by using temporary sequence numbers for the newly added records?
    In the application that we are involved with, we are being asked to provide this behavior.
    In details we would ensure that the sequence generation works as it works for the desktop PCs as well.
    As far as we know we should follow the following steps for the synchronization:
    1. sync new rows with the server
    1a. the server syncs with the database, replaces temporary seqnos with the ones that come from the database
    2. sync the new seqnos back to the mobile device...
    Please let me know whether it is possible or not with the Oracle Lite system,
    Thanks in advance,
    Balazs

    do you have some need to keep the range of DONOR_ID sequential?
    In our implementation we use the other method that Greg has mentioned, defining sequences within the oracle lite publication itself
    We use sequence generated ID values as the primary key on a lot of our tables, and the columns are defined as NUMBER(12) (reasons are historical, and not necessarly for any good reason - but stuck with it)
    looking at the worst case scenario (to keep things simple) in the server we have table PLOTS. The highest ID value is around 5.5 million, with an annual growth rate of 500,000 for server created records. The number of records that would be created on any particular client on an annual basis is more like 2,000.
    When you define a sequence within the mobile server you specify a 'template' for each sequence consisting of
    name (eg: PLO_ID_SEQ)
    start value
    increment
    window (number of values to assign to a particular user)
    threshold (point at which the next set of values is sent to the user)
    for PLO_ID_SEQ, the start value is set at 500 million (overkill, but server generated id values will never reach this point in practice), increment is 1, window = 100,000 and threshold is 95,000
    This in practical terms means that the sequences on the clients will never need to be re-sent as the values will never reach the threshold, and there will never be any cross over with server generated sequences
    When you add your first client to the application, the actual sequence start value will be set for that client as 500,000,000. for the second user added it will be 500,100,000, for the third 500,200,000 etc.
    On the whole the mobile server manages this ok, but we have found that if there is a need to replace a client by rebuilding the database from scratch, occasionally it does not correctly maintain the last value used. To get around this we reset the user prior to the rebuild (this resets the sequence start for that user to the next range of values)
    This works ok, and is straightforward to implement as you need no code change/data manipulation on the server, but does result in the source of the records being obviously different (can be useful), and you cannot assume that the highest id value is the most recent record (can be a problem for reports)

  • Invoice Sequence Numbers

    Version : Oracle Apps 11.5.1 OS : HP-UX 64 bit.
    Module : Order Management.
    I want to generate unique sequence numbers for my shipment documents. For example, I have 2 customers A and B. I want my invoice numbers as A-001 for first customer, and A-002 for second customer and so on.
    How to generate such a sequence (alphanumeric). Any suggestions?
    TIA.

    Version : Oracle Apps 11.5.1 OS : HP-UX 64 bit.
    Module : Order Management.
    I want to generate unique sequence numbers for my shipment documents. For example, I have 2 customers A and B. I want my invoice numbers as A-001 for first customer, and A-002 for second customer and so on.
    How to generate such a sequence (alphanumeric). Any suggestions?
    TIA.

Maybe you are looking for

  • Have discovered how to split visual and audio tracks. However the cut away only seems to work with still images from iPhoto!

    trying to cut away from one video clip to a second one, while keeping the original sound track, works with still images imported from iPhoto, but cant get the video to drag/drop. please help thanks

  • Cannot download (song name) because not enough access priveleges.

    I am new to this forum desperate for answers to figure out what the error message means Cannot download (song name) because you do not have enough access priveleges. Please check that the network connection is active and try again. I have been onto t

  • Excise Tables are not updating

    Hi, I have a issue in Depot sale. I created a GR against a PO. Then I posted a Excise invoice. But the excise tables are not updating. Why it so? Plz explain....... Thanks & Regards Saeed

  • Very Important - PR00 Display at line item Level

    Hii Guys,              Iam working on a upgrade project & i am facing with the below problem. In 4.5b when i create an order (va01), the condition type(PR00) displyed at line item level was in change mode. In case if i want to change it to PN00 i cou

  • 加载j2ee.jar在aix weblogic8.1.6

    j2ee.jar包加载在weblogic8.1.6 在linux系统,使用sun的jdk启动weblogic没有问题,正常运行.(jdk142_11) 在aix系统使用ibm的jdk,启动weblogic会出现下面问题. (java version "1.4.2") The WebLogic Server did not start up properly. java.lang.NoClassDefFoundError: com/sun/corba/se/internal/util/Identi