Auto number generation in custom table

Hi,
Is it possible to auto generate number in custom table. My requirement is to generate the number once anyone makes entry in the table. I guess there is a way to put code in tables but I have no clue how that can be acheived. If anyone has such kind of experince please share with me.
Regards
Ria

Hi Ria Sen,
Please follow the steps as below,
1. Use Select single Max Query to select the latest maximum number
2. Check <variable> is initial or not.
3.if variable is initial assign the number which will start from your number range.
4.else increment the variable values by 1 and update the new range values.
Ex: Select Single Max ( Field for Number) from <table>
           into <variable>.
if <variable> is initial .
<variable> = 'Starting number from your range'.
else.
<variable> = <variable> + 1.
Please let me know if you have any issues.
Regards,
Gurunath Kumar D

Similar Messages

  • Double Document number Generation from Z-tables -urgent

    I have a Z table with a number range and my user performs some task and when they press save button , a number is selected from the Z table, now problem is that when two users press ave at same instant same number is assigned to both for different entries -- try to sort this urgently

    Hi Joshi,
       Use Locks or Enque and Deque statements. Refer the following link.
    http://help.sap.com/saphelp_47x200/helpdata/en/a3/df5b1ee1bed348b198719e50af835d/frameset.htm
    regards,
    Chandra.
    Note: Please reward if helpful.

  • Auto number generation

    hi experts,
                  I am working with smartforms .I want to generate numbers automatically for each form when it is executed.what shall i do .that number must be unique .
    thanks
    mani

    Hi,
    You need to pass the number range object name in "OBJECT" and also the interval in "NR_RANGE_NR" that you create using transaction SNRO.
    Also Check this documentation for the FM.
    The function module assigns the next free numbers of a number range. A number is assigned as a default if no larger number is demanded in the parameter QUANTITY. If more than one number is demanded and not enough numbers are available up to the interval limit, the numbers are only assigned up to the interval limit. If the last number was assigned, the first interval number is provided again during the next call.
    The length of the number depends on the definition of the number range object. However, the length is not determined from the definition when allocating, but is calculated from the length of th from-number of the number range.
    All exceptions are created with MESSAGE ... RAISING ... .
    Example:
    1. Object HUGO, not year-dependent, next free number searched for
    DATA: RC         LIKE INRI-RETURNCODE,
          NUMBER(10) TYPE C.
       CALL FUNCTION 'NUMBER_GET_NEXT'
            EXPORTING OBJECT          = 'HUGO'
                        NR_RANGE_NR     = '01'
            IMPORTING RETURNCODE      = RC
                        NUMBER          = NUMBER.
       CASE RC.
         WHEN ' '.
         everything o.k.
         WHEN '1'.
         the assigned number lies in the critical area.
         WHEN '2'.
         this was the last number, next time the first number
          will be assigned
       ENDCASE.
    2. Object EGON, year-dependent, next 5 free numbers for 1992 in company code 0001 searched for.
    DATA: RC         LIKE INRI-RETURNCODE,
          NUMBER(10) TYPE C,
          YEAR       LIKE INRI-TOYEAR,
          QUAN       LIKE INRI-QUANTITY.
       YEAR          = '1992'.
       QUAN          = 5.
       T001-BUKRS    = '0001'.
       CALL FUNCTION 'NUMBER_GET_NEXT'
            EXPORTING OBJECT           = 'EGON'
                        NR_RANGE_NR      = '01'
                       SUBOBJECT        = T001-BUKRS
                       TOYEAR           = YEAR
            IMPORTING RETURNCODE       = RC
                        QUANTITY         = QUAN
                       NUMBER           = NUMBER.
    the last assigned number is in NUMBER
    the number of the assigned numbers is in QUANTITY
    the first free number is calculated from:
    NUMBER - QUANTITY + 1.
       CASE RC.
         WHEN ' '.
         everything o.k.
         WHEN '1'.
         the assigned number lies in the critical area.
         WHEN '2'.
         this was the last number, next time the first number will be        assigned
         WHEN '3'.
         more numbers are demanded than are available,
         the number of the assigned numbers is in QUAN.
       ENDCASE.
    Message was edited by:
            Seshatalpasai Madala

  • To save the sales order number in custom table while creation of the order.

    Hi Experts,
    Does there exist any exit to save the sales order number in a custom table while the sales order is created in VA01. The requirement is to capture the sales order number in a Z table when a field (payment terms ) is changed during the sales order creation.
    Regards,
    Sunitha

    Hi Sunita,
    You can store your data in the User exit MV45AFZZ in the form 'userexit_save_document'.
    You can navigate to MV45AFZZ from SE38 wherein an access key needs to be generated for that program, if you know to implement enhancement points then you can create an implicit enhancement point in this form without generating an access Key.
    Regards,
    Ravi Kiran

  • "DBIF_RSQL_SQL_ERROR" "CX_SY_OPEN_SQL_DB" while updating the custom table

    hi friends...
    i am posting fico document using bapi BAPI_ACC_GL_POSTING_POST.
    after that i am updating the document number to my custom table.
    but in some cases while updating the document in my custom table i am getting the fallowing dump..
    in ST22
    How to correct the error:
    Database error text........: "[1205] Transaction (Process ID 66) was deadlocked
    on lock resources with another process and has been chosen as the deadlock
    victim. Rerun the transaction."
    Internal call code.........: "[RSQL/UPDT/ZIF004_PKT ]"
    Please check the entries in the system log (Transaction SM21).
    If the error occures in a non-modified SAP program, you may be able to
    find an interim solution in an SAP Note.
    If you have access to SAP Notes, carry out a search with the following
    keywords:
    "DBIF_RSQL_SQL_ERROR" "CX_SY_OPEN_SQL_DB"
    "ZFI_01_MONTHLY_RESULT_FRM_PKT" or "ZFI_01_MONTHLY_RESULT_FRM_PKT"
    "UPLOAD_SAP"
    Source Code Extract
    LOOP AT i_zif004_pkt_sum .
    UPDATE zif004_pkt SET xblnr = i_zif004_pkt_sum-xblnr ---> i am getting DUMP here
                              gjahr = i_zif004_pkt_sum-gjahr
                              sap_flag_posting = i_zif004_pkt_sum-sap_flag_posting
                          WHERE compcode = i_zif004_pkt_sum-compcode
                         AND ccode = i_zif004_pkt_sum-ccode
                          AND wbselement = i_zif004_pkt_sum-wbselement
                          AND kostl = i_zif004_pkt_sum-kostl
                          AND code = i_zif004_pkt_sum-code
                          AND month1 = l_ltx
                          AND year1 = p_year.
        IF sy-subrc = 0.
          WRITE :/ 'Document ', i_zif004_pkt_sum-xblnr, 'is posted for ', i_zif004_pkt_sum-code.
        ENDIF.
      ENDLOOP.
    kindly give some inputs..
    regards
    Selva

    Hi,
    You will face this issue if your oracle data base is lack of work processes. try to check the work processes and increase them if possible with the helps basis guys.
    check the below thread.
    DI job failed ORA-12537: TNS:connection closed.
    Regards,
    Venkatesh

  • Exit/Badi for Serial number generation in MIGO

    Dear ALL,
    Requirement: Based on the serial number profile i will maintian the number range in custom table and on doing MIGO system will find the serail number profile thorugh material and based on that system should generate the serial number automatically.
    Advise for the user exit /badi ... I have checked some exit starting with IQ....  .
    Please provide the exact badi or exit for this purpose.
    Regards
    Rahul

    You can see the local class lcl_migo_globals used in include LMIGOGL1 which inturn has a variable
    called kernel with reference to class lcl_migo_kernel. Here exists an example [Serial Numbers Modify in LINE_MODIFY method in MB_MIGO_BADI|http://saptechsolutions.blogspot.com/2011/11/serial-numbers-modify-in-linemodify.html]of accessing & modifying the lines by accessing the call stack using class lcl_migo_kernel and method line_get & line_modify through badi MB_MIGO_BADI .

  • Auto-numbering of item field in custom table for EEW enhancements for BUPA

    Hi Experts,
    We have a requirement to generat 3 custom tables in EEWB,for BUPA and assigned it to BP_HEAD. I have done all the generations and it works fine, the problem  is that the tables that are generated is not allowing us to have a data(material) of 0...n cardinality. 
    The table that we are aiming is to allow multiple records, so my solution is to have an extra item number field so that it will allow multiple records for a material. But users are requesting to have the item number field of the tables to be auto-numbering.
    I would like to know if this autonumbering is possible or not? what methods in BP_EEW should i use to implement this logic. I 'm very new to CRM2007, so I'm still not very familiar on how to use the objects generated by the component workbench.
    p.s.
    I've already search the forum but can find any relevant topic related to my request. If you have any known related topic, It would be highly appreciated.
    Thanks and regards,
    JP
    Edited by: John Paul Auditor on Sep 1, 2009 3:36 AM

    Dear Syed,
       You can do many things in table maintenance screen like validation of some field, making some field required or displayed etc.
       For auto increment you have to use Number-Ranges. FM NUMBER_GET_NEXT is helpful in this case.
       Where to write the code??? The Function-Group you have made. There will be includes. You can easily locate the place to write these codes.
       Caution point is that if you re-generate the table maintenance then all code will be gone.
    Regards,
    Deva.

  • Custom Employee Number Generation Using Fast Formulas

    Hi,
    I have a requirement to generate custom employee numbers like "EMP100001". we have already created a business group with the setting of Employee number generation as Automatic. but we need to generate custom employee number as Format given above instead of automatic number generation.
    I have created my own PL/SQL Package to generate custom employee number as per Person Type. Also created a Fast Formula Function with the following parameters -
    Name = Get_Custom_Number
    Data Type = Text
    Class = External Funtion
    Alias Name = NULL or what you want the alias to be
    Description = Returns the next custom number value
    Definition = CUSTOM_EMP_NUMBER_GENERATION.Get_Custom_Number (PL/SQL Function)
    Proving the following Context usages and Parameters details to the Fast Formula Function -
    Context usages:-
    Number = 1
    Context Name = BUSINESS_GROUP_ID
    Data Type = Number
    Parameters as defined in PL/SQL function
    1 p_legislation_code Text Input Only
    2 p_person_type Text Input Only
    3 p_person_number Text Input Only
    4 p_party_id Number Input Only
    5 p_person_id Number Input Only
    6 p_national_id Text Input Only
    7 p_date_of_birth Date Input Only
    Than i created a Fast Formula using the following navigation
    Total Compensation > Basic > Write Formula
    with following details -
    Name = EMP_NUMBER_GENERATION
    Type = Person Number Generation
    Description = Returns next Employee number
    and wrote my formula code.
    When i created a Employee from Enter and Maintain People screen it is showing automatic number instead of my custom employee number.
    I m not able to find where i m missing the logic or some parameters?
    If anyone has come across such situation, please provide some pointers here.
    Thanks
    Renu

    What is the application release?
    Please review these docs and see if it helps.
    Is it Possible to Update Generate Employee Number Method From Automatic to Manual? [ID 393827.1]
    Need To Change The Employee Numbering From Automatic To Manual [ID 291634.1]
    Unable to Switch From Auto to Manual for Employee Number Generation in Shared Hr [ID 452044.1]
    How to Prefix a Zero on Custom Employee Numbers [ID 822425.1]
    How To Implement Custom Person Numbering Using FastFormula Based on User Person Type Instead of System Person Type [ID 372696.1]
    Thanks,
    Hussein

  • How to "auto" generate "Primary Key" in custom table?

    Hi Folks,
    Requirement:
    I need a function module or program that can create automatically a primary key.
    Scenario:
    I have a program that creates an entries and save it to a custom table at the same time, but a primary key should always be generated respective to the entries saved.
    Example:
    Material(MATNR) 4001001, Plant(WERKS) XX01, ID[Primary Key-auto generated]
    (I'm thinking of a similar concept/logic on how a unique IDOC number is being generated or how SAP standard creates a unique entry)
    I try to look for any SAP FM that can generate a PK, but there's no luck.
    Thanks.
    Regards,
    Jun

    Hi Keshu and All,
    The links are helpful, however:
    #1. I don't have authorization to create a new object in transaction SNRO, but the way I see the objects in SNRO is just for defining the length(number of characters) for the ranges that will be use if I'm not mistaken.
    #2. FM NUMBER_GET_NEXT - yes it can populate incremental unique entries but it's only occurring at runtime ?? So when the program get terminated it's not being saved nowhere.
    So after if I use FM NUMBER_GET_NEXT, I always have to look for all the last primary key in my custom table, then target it as my starting point for creating a new PK.  I think this will give a performance issue, any comments?
    For better visualization, I have scenario:
    1.  (ZQ_CREATE_PK) Create unique incremental PK for material, batch, so on..
    2.  Append line/entries to ZQ_TABLE
    3.  Repeat #1 and #2
    4.  User exits the program
    5.  Back to 1 --> At this point, I need to get the "LATEST" PK then start this as a starting point again to generate PK and append it to ZQ_TABLE
    I'm assuming that SAP has other SAP FMs related in creating this scenario.   Similar to IDOC # creation..
    Thanks.

  • Insert into table returning primary key (auto number) in resultset

    Hi,
    I'm connecting to Oracle 10g via JDBC (ojdbc14.jar).
    My SQL statement is as follows:
    INSERT into Student (studentName, phone, email, address) values ('Jason', '12345678', 'test', 'test');
    SELECT Student_studentId_SEQ.NEXTVAL FROM DUAL;
    Fyi -The Student table has a trigger to support the generation of a primary key (integer) based on a sequence when a new record is inserted.
    What the above will do (from the Java app point of view) is to create a Student record and automatically select the student ID so that the student ID can be accessed via the resultset in Java.
    I'm getting error "ORA-00911: invalid character". Can you please help?
    Regards,
    Jason
    Edited by: user10394130 on Oct 13, 2008 2:40 AM

    Yes, I'm referring to the studentId, which is generated via the Student table trigger on insert of a new record.
    I've now verified that the following SQL works and it is "printing" the correct studentId.
    DECLARE seqNbr_studentId NUMBER(12) := 0;
    BEGIN
    INSERT into Student (studentName, phone, email, address) values ('Jason', '12345678', 'test', 'test')
    RETURNING studentId INTO seqNbr_studentId;
    dbms_output.put_line(seqNbr_studentId);
    END;
    --> This prints the correct value of seqNbr_studentId that has been generated by the trigger. This is good.
    However, I would like the studentId to be in a resultset (so that I can access this via Java Resultset.getInt(1) ), for example:
    DECLARE seqNbr_studentId NUMBER(12) := 0;
    BEGIN
    INSERT into Student (studentName, phone, email, address) values ('Jason', '12345678', 'test', 'test')
    RETURNING studentId INTO seqNbr_studentId;
    SELECT seqNbr_studentId FROM DUMMYTABLE;
    END;
    Is this possible?
    What I'm trying to do is to achieve the effect in SQL Server where I can simply do an SQL command "SELECT @@IDENTITY" where it returns the auto number from the newly inserted record.
    Regards,
    Jason
    Edited by: user10394130 on Oct 13, 2008 2:08 AM
    Edited by: user10394130 on Oct 13, 2008 2:56 AM

  • How to Create an Custom Employee Number Generation ...

    Dear Friends,
    We are Implementing HRMS Suite Version12i, for one of the Client in Middle east.
    One question about Custom Person Numbering.
    How to create custom employee numbering Based on the User Person Type?
    Example:
    Two person types
    o Permanent Employee
    o Probationary employees
    We Need to give two different numbering schemes for each person type.
    eg Permanent Employee will use a seq begin 100000 whereas Probationary employees (other user type) will use a sequence beginning 200000.. Can any pls let me know how to handle the Custom Employee Number Generation (with Setups)
    With regards
    Swpana

    Hi,
    Could you please help me to write/or send a sample of a Person Number Generation Formula.
    I don't see the noteid : 279458.1 on metalink,I get the following message:
    Article or Bug cannot be displayed. Possible reasons are:
    The article Id or bug number was entered incorrectly. Please check and try again.
    The article Id or bug number does not exist (was referenced incorrectly).
    The article or bug is not classified as publicly accessible ("non-public").
    The content is being updated and it is temporarily unavailable but will be made available again soon.
    If you still have questions about why you could not access this article or bug, please use Feedback.
    Please help!!

  • Customer number generation

    Oracle Gurus,
    Customer creation number generation as Automatic, where we are doing this setup in applications.
    For supplier we give the setup in Financial options but I am not able to trace out for customer automatic number generation.
    If anyone know the setups, please let me know the steps and setups.
    Please advise.
    Edited by: satish.ygl on 09-Sep-2012 19:21

    Hi Satish,
    Set the sequence number
    Pl. go thru following navaigation path :
    Go to Application Developer responsibility >Menu > Application> Database > Sequence
    Query on sequence RA_CUSTOMERS_NUM_S and set Start Value to 20000 .
    Retest it.
    HTH
    Sanjay

  • Form on a Table with Report - Auto Number

    Hi,
    Scenario:
    I want to create "Form on a Table with Report" that should allow my users to add records...
    Steps and issues
    I created a table in MS Access with a field called "TRACKING_NO" as type Auto Number and made it a primary key... I was planning to use it to link Report to Form
    When I uploaded the table to Oracle it changed the type to varchar2... can you please advice how to change it back to Auto number...?
    and will it work if my user add a record to the table (using APEX built in option to create a record)...?
    Thanks in advance

    Hi,
    this is what I would do.
    1. Upload the table from MS Access, lets call it TAB_A
    2. Using SQL-Workshop get the DDL (SQL statement) for this table
    3. Change any names and/or datatypes as required
    4. Create a new table with this DDL, lets call it TAB_O
    5. Copy the contents from TAB_A to TAB_O (e.g. INSERT INTO TAB_O (id, colx, coly) SELECT TO_NUMBER(tracking_no), col1, col2 FROM TAB_A;)
    6. Create a sequence which starts with the last PK + 1 of table TAB_A
    7. Add a trigger to TAB_O to use this sequence to populate it's PK
    By the way, working with APEX requires a solid understanding of Oracle SQL and PL/SQL, regardless of what anyone says, even Oracle.
    Regards Garry

  • Maximum Number of Entries for Upload in Custom Table

    Hi All,
    I have a requirement to create a custom table, and then a custom program will be used to upload the data entries. The user is expecting to upload more than 5000 entries at one load. However, the program is encontering a dump. Is there a maximum number of entries which can be uploaded via foreground execution?
    Is there any other way to upload more than 10,000 entries at one execution?
    Thanks,
    Louisse

    Hi,
    No restrictions for number of records to be upload in custom table.
    You have to go to technical settings, there select Size category for number of data records of table expected.
    Regards,
    Jyothi CH.

  • How to Track the changes made to the custom table field value

    I want to track the changes made to the custom table field value in table maintenance generator.please help me it is very urgent
    Thanks & Regards,
    Kranti

    Hi Satya,
    These are the steps you've to do.
    1. Enable the change document flag in the data element level for the fields of the tables you want to monitor.
    2. Go to transaction SCDO. Create a new change object, and add your table to this object. After generation, you'll get a function module.
    3. Call this function module in the table maintainence generator screen, after the data is saved to the database table. This function module automaticallly writes the changes, with the old and new values, and the fields that were changed to the tables CDHDR and CDPOS.
    4. You can keep track of the changes made to the table by monitoring these tables.
    Regards
    Anil Madhavan

Maybe you are looking for

  • Error while starting the AqAdapter in SOA Suite 11g Admin Console

    facing an issue with the AqAdapter(Resource Adapter) in Soa Suite 11g Admin Console. we go to Deployments --> Select Aq Adapter --> Currently it shows the status as Prepared Now we try to Start it again --> it comes back with the error message mentio

  • Save PDF-file on the application server

    Hello experts, I convert my Smartform to a PDF-File. I copied the code from  Suresh Kumar Parvathaneni (REPORT zsuresh_test). At first, thank you Suresh Kumar for that! Now, I would like to save the PDF-File on the application server and not local. C

  • Deauthorizing a computer without access to it

    I am trying to deauthorize my recent exboyfriend's computer. Clearly, I do not have access to it. I do not want to authorize 5 computers in order to deauthorize one. Any suggestions???

  • Help - Images Not Appearing

    I am having a problem with a new flash photography site that was built for me. It requires the latest version of flash - but on some computers, the images won't appear - even when the latest version is downloaded. The rest of the site does show up (t

  • UCCX 7.0 license with ICM feature

    Does anyone have the UCCX 7.0 license with 7.0 features? Thanks in advance AmIr.