Get next number in sequence

Assembled gurus...
Note that:
Table T_PROJ includes PROJID and PROJNAME.
Table T_EVAL includes PROJNAME and EVALID and five other fields.
PROJID and EVALID are 'auto-generate' keys
Selecting a 'project' from the list on Pg 40 opens Pg 41 which displays: Reg(ion) A - the selected project name (and associated projID); Reg B - the 'risks' associated with this 'project'... one 'project' and one or more 'risks'. The individual 'risks' are displayed via a query and can be edited.
Clicking a Reg B risk "edit button" opens Pg 42 -- displaying the seven risk fields. Modification of existing risk data is done using Pg 42. Reg B also has a Create button. This button opens Pg 44 which displays all seven risk fields. All fields are blank.
Upon opening Pg 44 I would like the PROJNAME textbox to contain/display the corresponding value from Pg 42 AND would like the EVALID textbox to contain/display the next autonumber. With these two values entered on Pg 44, I can complete the rest of the textboxes (fields). 'Saving Changes' would then place this informayion in T_EVAL as an appended record. [SQL 'INSERT INTO'?]
I can't figure out how to populate the Pg 44 PROJNAME and EVALID textboxes with the desired values and thus maintain the desired one-to-many relationship. Can anyone guide me down the correct path?
Thanks in advance...
gary b

Hi John,
Thanks for the feedback. An elegant solution no doubt, but I do not have an issue with the way my app works; I was merely showing how I generate "line numbers".
For my app, the line number can change, as it also signifies the order of an activity.
So I may start with:
Parent Line Activity
100 10 Fill Kettle
100 20 Boil Water
100 30 Pour into teapot
But the user may change to
Parent Line Activity
100 10 Fill Kettle
100 20 Boil Water
100 25 Put tea in teapot
100 30 Pour into teapot
or even
Parent Line Activity
100 10 Fill Kettle
100 20 Boil Water
100 30 Put tea in teapot
100 40 Pour into teapot
So whilst I do understand your point, and I do use sequences under normal circumstances, for this particular case and the environment in which it runs, this seems to be the most appropriate and workable solution for me.
Cheers,
Rob

Similar Messages

  • Func Mod to get next number for purchase order

    Hi all,
      Does any know what the function module or bapi to get the next purchase order number ?
    what would be the object number ?
    thanks
    Joyce
    Edited by: Joyce Chan on May 14, 2010 4:11 PM

    See if this helps..
    Get an accounting document number:
    CALL FUNCTION 'NUMBER_GET_NEXT'
    EXPORTING
    nr_range_nr = r_blart "type of Document
    object = 'RF_BELEG'
    SUBOBJECT = p_bukrs "Company
    IMPORTING
    number = d_belnr "Returned belnr
    document number
    EXCEPTIONS
    interval_not_found = 1
    number_range_not_intern = 2
    object_not_found = 3
    quantity_is_0 = 4
    quantity_is_not_1 = 5
    interval_overflow = 6
    OTHERS = 7

  • POPULATE NUMBER IN SEQUENCE BUTTON

    Hi All, slightly more taxing questions for you I hope.
    I have created a PDF form to be used on mobile devices. Each time the form is filled that form needs to be individually numbered with an alpha-numeric code.
    Currently I have a field that states "form number" and the user types in ABC001 (for the first time they fill it in) ABC002 the next time etc etc....
    How do I add a button so the number will auto populate with the next number in sequence, remembering they may not have internet or network connectivity? I know it's possible but don't know how to write C++ or Java (or any other code).
    Thanks in advance
    Luke

    This can be done in XSL OR in procedure on the DB side. Performance wise better to do in procedure as mentioned by other use. You can choose to go with DB or XSL approach depending on number of orders you are expecting in a single message. If it is going to be 100s or few thousand messages then keeping it in XSL is not a problem. But if you are planning tens or hundreds of thousands of orders in the same request then better do it in stored procedure.
    How do you do in XSL?
    1. Put a for each on every unique order no. You can use xsl:Key or xslt:distinct-values() for this.
    2. Within for each unique value of order no, use position() function to pass line/order no as 1,2,3... etc. As soon as the loop moves to second iteration for the next unique order no, count will automatically start again from 1,2,3... and so on.
    Apart from slightly slower processing time, another drawback from this approach is that the data in the XML you send to DB procedure will be sorted by order numbers. All orders with same number will appear together.
    Another problem with this approach is that this will work only within one request, i.e. if the next request contains an order with same no which was already sent in a previous request, for this order the count will again start from 1. So if you want to keep the sequencing maintained across multiple requests, the easiest way to do is in the DB procedure where you can lookup in the table before inserting a new row and insert with next sequence of that order no.

  • Finding next number

    hi gurus,
        what is the Fm for auto generation of numbers & how to get the number range object for date.
    thaks & regards,
    santosh.

    Hi,
    Use FM NUMBER_GET_NEXT
    see the sample code:
    *& Form GET_NEXT_NUMBER
    FORM get_next_number_class.
    DATA: inumber(10) TYPE c.
    SELECT SINGLE * FROM klah WHERE class = 'PRODUCTCODE'.
    IF sy-subrc NE 0.
    entry in KLAH is not yet exiting => get next number
    CALL FUNCTION 'NUMBER_GET_NEXT'
    EXPORTING
    nr_range_nr = '01'
    object = 'KLASSE'
    quantity = '1'
    SUBOBJECT = ' '
    TOYEAR = '0000'
    IGNORE_BUFFER = ' '
    IMPORTING
    number = inumber
    QUANTITY =
    RETURNCODE =
    EXCEPTIONS
    INTERVAL_NOT_FOUND = 1
    NUMBER_RANGE_NOT_INTERN = 2
    OBJECT_NOT_FOUND = 3
    QUANTITY_IS_0 = 4
    QUANTITY_IS_NOT_1 = 5
    INTERVAL_OVERFLOW = 6
    BUFFER_OVERFLOW = 7
    OTHERS = 8
    IF sy-subrc 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    ELSE.
    entry is already existing => take the number
    inumber = klah-clint.
    ENDIF.
    ENDFORM. " GET_NEXT_NUMBER
    Regards,
    Satish

  • How to alter sequence next number

    Can we alter sequence next number. I want to start it from minval.

    To restart the sequence at a different number, you must drop and re-create it.
    If you change the INCREMENT BY value before the first invocation of NEXTVAL, some sequence numbers will be skipped. Therefore, if you want to retain the original START WITH value, you must drop the sequence and re-create it with the original START WITH value and the new INCREMENT BY value.
    Oracle Database performs some validations. For example, a new MAXVALUE cannot be imposed that is less than the current sequence number.

  • How to get next series number for user form?

    Hi,
    I am using UDO for my form with Manage series inorder to maintain automatic documnet number.
    Like sales order screen if u open the form it should display with next generated document number.
    In my form it is not displaying the next number
    I want to display primary as selected and next series number.Please help me.
    I have used the following code
    If (FormUID = "FM_PURCHASEINDENT") And (pVal.ItemUID = "SerName") Then
                    If (pVal.EventType = SAPbouiCOM.BoEventTypes.et_COMBO_SELECT) And (pVal.Before_Action = True) Then
                        Dim oForm As SAPbouiCOM.Form
                        Dim oComboBox As SAPbouiCOM.ComboBox
                        Dim oEditText As SAPbouiCOM.EditText
                        Dim str As String
                        Dim lNum As Long
                        oForm = SBO_Application.Forms.Item(FormUID)
                        oComboBox = oForm.Items.Item("SerName").Specific
                        str = oComboBox.Selected.Value
                        'SBO_Application.MessageBox("Selected Series: " & str)
                        '// The following method provides the next value of the series
                        lNum = oForm.BusinessObject.GetNextSeriesNumber(CLng(str))
                        oEditText = oForm.Items.Item("SrValue").Specific
                        oEditText.String = lNum
                        oForm.Update()
                    End If
                End If
    Regards
    Jambu

    Hi,
    This is a little example for UDO with series (www.expertone.es/ficheros/SIMPLE_UDO.rar)
    Code in Vb6.0
    <b>Public Sub Load_UDO(ByRef rsbo As SAPbouiCOM.Application)</b>
    Dim oFormParams As SAPbouiCOM.FormCreationParams
    Dim oForm As SAPbouiCOM.Form
    Dim oCombo As SAPbouiCOM.ComboBox
       Set oFormParams = rsbo.CreateObject(cot_FormCreationParams)
       oFormParams.XmlData = DameXML(App.Path & "XMLEXO_UDO.srf")
       Set oForm = rsbo.Forms.AddEx(oFormParams)
       'Load series in combo
        Set oCombo = oForm.Items("EXO_CBO1").Specific   
        <b>oCombo.ValidValues.LoadSeries oForm.BusinessObject.Type, sf_Add</b>
        oCombo.Select 0, psk_Index
         RellenarNumDoc rsbo, oForm      
        oForm.Visible = True
    End Sub
    <b>Private Sub RellenarNumDoc(ByRef rsbo As SAPbouiCOM.Application, ByRef rForm As SAPbouiCOM.Form)</b>
        With rForm.DataSources.DBDataSources("@EXO_OUDO")
            .SetValue "DocNum", .Offset, CStr(rForm.BusinessObject.GetNextSerialNumber(rForm.Items("EXO_CBO1").Specific.Selected.Description))
        End With
    End Sub
    Private Function DameXML(ByVal vsRuta As String) As String
    Dim xmlDoc As New MSXML2.DOMDocument
       xmlDoc.Load vsRuta
       DameXML = xmlDoc.xml
    End Function

  • How do I obtain the next number for a Primary Key using an ADF View Object?

    I have two separate View Objects (A & B) for the same Entity Object. View Object A does a SELECT on all of the fields in the table. This View Object is where I execute my adds and updates. View Object B is only used to retrieve the next number for the primary key. This is done so that when I add a row to the database, I always get the max number of the primary key and add one to it. I accomplished this by setting the SQL mode to Expert and using the SQL: "SELECT MAX(NBR) AS MAX_NUMBER FROM TABLE_1". This may be overkill having a seperate View Object for this, but so far this is the only way I have found to obtain the next number. However, I have discovered that this way does not always work.
    The problem I'm running into is when I try to add multiple records to View Object A without committing the transaction between each add. Because View Object B is disconnected from View Object A, the MAX_NUMBER of View Object B comes back with the same number for each add I do on View Object A. So I know I must retrieve the MAX_NUMBER from View Object A.
    I've tried using the following code in my Table1ViewImpl class:
    this.setQuery("SELECT MAX(Table1.NBR) AS MAX_NUMBER FROM TABLE_1 Table1");
    this.executeQuery();
    The view object now has what I want, but I have yet to figure a way to extract the MAX_NUMBER out of the View Object. I've also looked into using the method addDynamicAttribute() but I can't figure out any way to set the attribute with the MAX_NUMBER.
    I can't be the only one trying to retrieve the next number from a database table using ADF. Can anyone help me with this? FYI - I'm using JDev 10.1.3 EA.

    You missing the point.
    On a multi-user db knowing the next highest number doesn't guarantee the number will be available when it comes time to commit the record. You can prove this to yourself by opening two instances of your app and do whatever you do to add a new record to your VO. Both will assume the same number, and when you commit an error will be generated
    You must use sequences to avoid the possibility of duplicate keys. If you are trying to avoid gaps in your numbering then you need to convince yourself why this is necessary.

  • How to get current value of SEQUENCE without using NEXTVAL

    Hi,
    Here is my requirement. I need to provide a screen for allowing user to change the sequence # at any given instance. If I use CURRVAL, i get error 'ORA-08002 sequence EMP_NO.CURRVAL is not yet defined in this session'
    If I use NEXTVAL and then CURRVAL it works, but i loose a sequence # which i cannot afford, since it's an employee #.
    Help required in solving the problem.
    Thanks,
    Raj

    Use this...
    select last_number from user_sequences where sequence_name = '<your-sequence>'
    to get the current sequence value. However bear in mind that on a multi-user system (and which system today is not?) there may be many users firing this query, so in case of a next sequence no. allocation request fired by more thn one of them the sequences each gets will not all be this number + 1.
    HTH,
    Mohit.

  • Next Number Maintenance - IncrementBy is used for what?

    Hello everybody,
    as I'm developing a webservice I've used the "IncrementBy" of my next number template as the value which is added to the current sequence of the number.
    Let me provide an example:
    The current sequence is 1
    The IncrementBy value is 6
    I order a new number and get 7 (current sequence + IncrementBy value)
    My problem is now that the documentation states, that the "IncrementBy" value is used to "(...) increment the minimum and maximum sequence numbers."
    Next Number Maintenance - SAP Manufacturing Execution (SAP ME) - SAP Library
    This would differ from my current usage. However, I can't see any sense in providing a "incrementby" value to manipulate static data in a table. Furthermore the name of the column would be a fail, too. May there just be a mistake in the documentation?
    If not, what's the sense behind the incrementby value then?
    Thanks and regards,
    Kai

    Kai
    The help is wrong. When you request a number from Next number, it returns the Current Sequence. It then adds the value of the Increment By to that number and stores it back to the Current Sequence, ready for the next request.
    Stuart

  • Generating next number from the SQL database using java

    Hi friends, I have a problem and need your help. I am working on a project about submitting claims form through the adobe PDF file and SQL database. I have problem working on a web service (written in java) that will generate the next Invoice Number from the SQL Database table. The field type for the column is text(var char). *Example: I first need to get into the table and search for the last Invoice number in the table and if the last invoice number in the table from the database is 3, i would want to generate the next number which is 4 and filled it up in the PDF file through web service that i am implementing. Can you all provide me some guidelines on how to implement this method in my web service?
    Thanks a lot. I need it by today. Hope someone can reply this as soon as possible.
    Lim89
    Edited by: LIM89 on Apr 2, 2008 7:10 PM

    far simpler to use a sequence generator, which most databases support.
    Suggested method to get the max value in the column is NOT secure, unless you lock the entire table for update before you do so, which is a severe performance penalty.

  • Next number

    the column in my table has datatype varchar2 where i store product_code starting with 0001 i want to generate the next number automatically. If the value in the column is null then 0001 should be generated automatically is there anyone who can help me to sort out this problem. thanks in advance

    If you're gonna use any method of incrementation that involves a SELECT statement, you should be careful with it, unless your application will be deployed in a single user environment.
    If you have two users INSERTING data at the same time, there is a high probability that they will both get the same number and I think that would result into a duplicate key. In such cases it's better to use a table where you have the last number of your ID saved and use SELECT FOR UPDATE from that table to lock the record.
    Rosario's suggestion of using :SYSTEM.TRIGGER_RECORD is interesting, but it has a pitfall in it, when you open your form and start inserting records without querying the inserted records first, the variable will always start from 1 (since it is the first record) so again you'll have duplicate key.
    Best way is to use a SEQUENCE.
    Tony

  • Next Number Generation Activity to use Base36 without I, O, Q

    Hi all,
    Need to have a Next Number Activity Hook to generate a sequence number similar to a base 36 with the exception of letters that could be confused with numbers: I, O, Q.
    I have an activity hook created that generates the number I want to use without any problems at all.
    Example:
    16 = 000G
    17 = 000H
    18 = 000J <- Skips the letter I
    19 = 000K
    20 = 000L
    But when putting the this into the inData object to be returned it is ignored.
    inData.put("CURRENT_SEQUENCE", finalValue);
    Any thoughts as a way I can get this to work?
    Thanks,
    Mike

    Ok I finally had some time to work on this.
    Within Next Number Maintenance if the Number Base is set to 34 it does exclude I and O (good), but stops at W (bad). No X, Y, or Z (bad). Plus it still includes Q (bad).
    i.e.
    TEST-000U
    TEST-000V
    TEST-000W
    TEST-0010
    TEST-0011
    If the Number Base is set to 33, I, O, and Q are included (bad) and it also stops at W (bad).
    Neither are acceptable solutions. So...
    I have figured out an ugly workaround:
    In Next Number Maintenance set Number Base to 36.
    Then insert the invalid SFC numbers into the ID_USED table.
    i.e.
    INSERT INTO ID_USED (HANDLE, SITE, ID, ID_TYPE, CREATE_DATE, ARCHIVED) VALUES ('IDUsedBO:1000,TEST-000I,S', '1000', 'TEST-000I', 'S', TO_DATE('05/04/2010','MM/DD/YYYY'), 'false');
    INSERT INTO ID_USED (HANDLE, SITE, ID, ID_TYPE, CREATE_DATE, ARCHIVED) VALUES ('IDUsedBO:1000,TEST-000O,S', '1000', 'TEST-000O', 'S', TO_DATE('05/04/2010','MM/DD/YYYY'), 'false');
    INSERT INTO ID_USED (HANDLE, SITE, ID, ID_TYPE, CREATE_DATE, ARCHIVED) VALUES ('IDUsedBO:1000,TEST-000Q,S', '1000', 'TEST-000Q', 'S', TO_DATE('05/04/2010','MM/DD/YYYY'), 'false');
    INSERT INTO ID_USED (HANDLE, SITE, ID, ID_TYPE, CREATE_DATE, ARCHIVED) VALUES ('IDUsedBO:1000,TEST-001I,S', '1000', 'TEST-001I', 'S', TO_DATE('05/04/2010','MM/DD/YYYY'), 'false');
    INSERT INTO ID_USED (HANDLE, SITE, ID, ID_TYPE, CREATE_DATE, ARCHIVED) VALUES ('IDUsedBO:1000,TEST-001O,S', '1000', 'TEST-001O', 'S', TO_DATE('05/04/2010','MM/DD/YYYY'), 'false');
    INSERT INTO ID_USED (HANDLE, SITE, ID, ID_TYPE, CREATE_DATE, ARCHIVED) VALUES ('IDUsedBO:1000,TEST-001Q,S', '1000', 'TEST-001Q', 'S', TO_DATE('05/04/2010','MM/DD/YYYY'), 'false');
    Unfortunately this will need to be done for all of the potentially bad SFC's. I will defiantly need to write a small app for that.
    Then when the Next Number is called for the SFC, the system would notice that that number is already used and jump to the next available number.
    Also by using the ID_USED table should anyone want reports there would not be any bogus SFC data in the system.
    This work exactly as I want on our test server.
    So before I truly implement this on our Production server does anyone see any potential downfalls to this workaround? Questions and/or comments welcome.
    Thanks,
    Mike

  • How to find next number range for project definition in tcode CJ20N

    Hai Experts,
          Please help me 'How to find next number range for project definition in tcode "CJ20N". I was trying in function module NUMBER_GET_NEXT. Is it right function module? If its right what input i need to give for this tcode and for the field project definition?
    Note: I searched in forum before posting, but couldn't find the solution.
    Thanks
    Regards,
    Prabu S.

    Hi,
    For project defination internal number is assigned by system.
    When you saves's project then system allocate one number to project defination, you can view it,
    SE11 >>> table  PROJ >> Click on contents >>> execute,
    here you will get your project defination & number is assigned to project defination.
    kapil

  • Any table or program to get the number of records in P, A and F tables

    HI all
    any table for program to get the number of records in P, A and F tables. I want to create SQ01 queries to get the status of number of records. We are gng for a production cutover next week. Want to capture all the data before and after Upgrade cutover.
    Also suggest me how to create sq01 queries.
    Thanks in advance
    regards
    Janardhan KUmar K.

    Use Transaction LISTSCHEMA to see all the tables assosciated with ur cube
    Total number would be what you find in both the E & F fact tables. If there is no compression in the cube then E table will be empty.
    Alternatively u can use se16 transaction and enter E table and F table manually
    E table - /BIC/E(Cube name) and Ftable -  /BIC/F(Cube name)
    Or else u can go to the manage of the cube and without selecting any field for O/P and ticking the option output number of hits execute. The total of Row Count will give u the total no of records in the cube.

  • How to get the number of days of February.....

    Hi ,
    how can I get the number of days (28 or 29) of February of the current year or the next...????
    Or is there any other way to find that a year is a leap or not (i mean the year has 365 or 366 days).??
    Thanks
    Simon

    select add_months(to_date('&v_year', 'YYYY'), 12) -
    to_date('&v_year', 'YYYY') from dual;Jens, it seems we have made the same mistake, trunc usage seems mandatory :
    SQL> ed
    Wrote file afiedt.buf
      1* select add_months(to_date('2007', 'YYYY'), 12) - to_date('2007', 'YYYY') from dual
    SQL> /
    ADD_MONTHS(TO_DATE('2007','YYYY'),12)-TO_DATE('2007','YYYY')
                                                             366
    SQL> ed
    Wrote file afiedt.buf
      1* select add_months(trunc(to_date('2007', 'YYYY'), 'YYYY'), 12) - trunc(to_date('2007', 'YYYY'), 'YYYY') from dual
    SQL> /
    ADD_MONTHS(TRUNC(TO_DATE('2007','YYYY'),'YYYY'),12)-TRUNC(TO_DATE('2007','YYYY')
                                                                                 365
    SQL> Just to clarify my past doubt.
    Nicolas.

Maybe you are looking for

  • Is there a way that to make text look like it is being written on the screen?

    I once saw a tiltle (using the font edwardian script) that looked like it was being written on the screen. I tried using the linear wipe transition, but this does not make the full effect i want.. for instance, when you make a letter "t" in cursive,

  • Can't setup gmail account

    doing whatever says here and still it says "can't connect using SSL" 3g, 2.2 thank you

  • Firefox 14 - How to have my start page launched when clicking on the 'new tab'-button?

    I want to my startpage (Google) launched with clicking on the + Tab at the top. However,I donot want another plug-in added. Can this be configured one way or the other? TIA =

  • "Edit Personal Profile" - ESS Benefits

    Hi We have a requirement to open the "Edit Personal Profile" in ESS Benefits "New Hire Enrollment" (GAF) in place rather opening in external window. I changed the property in the launchpad ESS/MENU for the "Personal Profile" under Benefits Enrollment

  • Where/How Report Problems?

    Where/How do we report problems? I exported a small set of photos from LR3 to my desktop and then imported them into LR4. All the photos are there.  When I take a photo to the develop module, LR4 crashes.  I must be a slow learner, since I did this 4