Ho to Generate the Numeric Values Automatically before saving the records

Hello to everybody,
I have a data block naming “BILL” consisting of the following 3 field.
1. Sr_No
2. Bill_Amount
3. Description
This Data Block consist 10 records at a time.
I want that whenever I insert records in the above data block.
Serial No should automatically be generated.
For this I have applied the following code in “WHEN-NEW-ITEM-INSTANCE” trigger.
<CODE>
SELECT NVL(MAX(Sr_No),0)+1 INTO :BILL.Sr_No FROM BILL;
</CODE>
Whenever I insert records in the BILL data block, the first row automatically generates the “Sr_No”, but when I move to the next record, (remember currently I have not saved the record), the same value which appeared in the previous record appears in the Sr_No field.
For example, when I insert records for the first time in the BILL, the Sr_No field automatically generates value “1”, but when I move to the next record while not saving the first record the next row still generating value “1”, while it should be value “2” and so on.
Note that I want that before saving the previous record when I move to the next row, the Sr_No should generate the next continuous value like in example.
Please help me to solve out this problem.

You have practically scratched you left ear with your right foot while jumping on the left foot :-)
Seriously, you guys don't need to go to all this trouble.
If you want a serial number incrementation, all you need to do is to either select the max value + 1 from the table or select the next value from a sequence in an PRE-INSERT trigger on block level, and that's it!!!!
Tony

Similar Messages

  • How to generate a row value automatically...(row count)

    Hi,
    I have a Table in my application with fields like
    ID     CNAME
    i should generate the values for the ID field dynamically with a Prefix..also this ID field is not visible to users, its for the database update alone...
    Thanx.
    Arjun.G

    Hi,
    Make this Id attribute calculated.
    When you make an attribute calculated you will be able to see the getter method created for the attribute
    In side the getter you can generate the value you needed.
    For Ex.
    public java.lang.String getID(IPrivateTestCompView.IContextElement element)
        //@@begin getID
        return UUID.randomUUID().toString() ;
        //@@end
    Regards
    Ayyapparaj

  • Can a cell be set to input a numeric value automatically on a predetermined date?

    Hi, I am trying to create a basic property management spreadsheet and wanted to know if it is possible to have a cell automatically input a tenants predetermined rent on a specific, predetermined date? Thanks!

    Hi Nick,
    I see two errors.
    The Syntax error is the use of periods as the argument separator in the If statement. The separator should be a comma IF your decimal separator is a period OR a semi colon if your decimal separator is a comma.
    The second error is in your statement of the date as a literal (ie. as a text string). TODAY() returns a Date and Time value, with the time portion set to 00:00:00 (midnight at the start of the date specified in the date part). A Date and Time value cannot be compared with a text string. Rather than trying to express the date within the formula, it's better to place that date in a cell, then reference the cell in your formula:
    Here, the formula in all body cells in Column B is:
    =IF(TODAY()>=A,695,"")
    "A" in the formula references the cell in column A on the same row as the formula.
    At the time of the screen shot, taken on March 17, 2012, TODAY() is greater that the Date and Time values in the first three cells showing dates in column A.
    Regards,
    Barry

  • Assigning a numerical value to the answers of a multiple choice text field

    I have searched and searched thru a million articles but there does not seem to be a simple way to do this, and I hope like heck that I am just overthinking it.  I tend to fall back on years of coding and completely miss a simple answer when doing this
    kind of thing so I hope someone can help.
    I'm developing a scorecard.  I have a list that has a form on it that asks a series of questions on it.  Some are yes/no.
    I want to assign the numerical value of "1" to "yes", and "0" to "No".
    This is so that when I create the actual scorecard, I can add up all the answers and generate a calculated score.
    Example:
    Was this incident properly classified?
    [Dropdown]
    Yes
    No
    Do I need an extra column assigning the values?  Can I assign the values within the column itself? Any assistance will be really helpful. 

    there are several options:
    - calculated column with something along the lines of =IF([dropdowncolumn] = "YES", 1, 0)
    - separate lookup list with values
    - if you're using infopath, your column could be numeric, and just use a DropDown as the visualization, and populate the DDL with key/values of "Yes"/1 and "No"/0 (though in this case, when viewing the list as a native grid, the column
    would only show 1/0, not "yes / no"
    - depending on how you're creating the scorecard, use a yes/no (boolean) column and just convert during the calculation
    lots of options come to mind.
    Scott Brickey
    MCTS, MCPD, MCITP
    www.sbrickey.com
    Strategic Data Systems - for all your SharePoint needs

  • SQLJ-JPublisher - J2T-153, Invalid value for -context:while generating the

    Hi All,
    I am trying to generate the java code for the oracle types defined for one of the module in our project.for that i have defined a new context by extending the 'DefaultContext'
    provided by SQLJ and as mentioned in the below URL.
    http://docs.oracle.com/cd/A91202_01/901_doc/java.901/a90214/jpub.htm
    Topic : JPublisher Generation of SQLJ Classes
    MyContext:-
    import java.sql.Connection;
    import java.sql.SQLException;
    import sqlj.runtime.ref.DefaultContext;
    public class MyContext extends sqlj.runtime.ref.DefaultContext{
    static {
    DefaultContext defaultContext = null;
    try {
    defaultContext = new DefaultContext(<datasource>);
    } catch (SQLException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    DefaultContext.setDefaultContext(defaultContext);
    public MyContext(Connection arg0) throws SQLException {
    super(arg0);
    public Connection getConnection(){
    Connection con = null;
    try {
    con = <datasource>getConnection();
    } catch (SQLException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    return con;
    JPub command:
    jpub -user=usr/pwd -context=com.test.context.MyContext -sql=<My Types Here> -compile=false
    I am getting the below error while running the jpub command in dos prompt.
    Error Log:
    J2T-153, Invalid value for -context: com.test.context.MyContext. This must be set to generated or to DefaultContext.
    Please let me know if anybody has come across this problem before.
    Thanks,
    Vijay
    Edited by: 905698 on 03-Jan-2012 09:53

    Hi Vijay,
    This post DOES NOT correspond to this forum.
    The current forum is for BI Publisher. Your question is for JPublisher and believe it corresponds to PL/SQL forums.
    Please close the thread
    thanks
    Jorge

  • How to generate the primary key item automatically in form region?.

    Hi,
    The primary key item is generated automatically in report region.I already give the pl/sql function for generating of primary key.but I want to generate the primary key value automatically in form region only?.how to do this?.Pls help me..
    Thanks and Regards.

    One of the guidelines when selecting column for a primary key is:
    Choose a column whose data values are never changed. A primary key value is only used to identify a row in the table, and its data should never be used for any other purpose. Therefore, primary key values should rarely or never be changed.
    Cheers!

  • Generate the primary key  automatically while records are saved

    Hi experts,
    I need to generate the primary key of a custom table automatically when a new record is saved. Pleas help asap. Urgent.

    Hi Rob and vikas,
       Thanks for your answers . Both of the solutions you mentioned were syntactically correct and activated but they are not populating the numbers.In case of Rob's soultion  I guess I am not able to catch the return number. I am giving the code below. So Please look into it,
    FORM gen_manu_siteid .
    data : number type zsiteid value 155.
    CALL FUNCTION 'NUMBER_GET_NEXT'
      EXPORTING
        NR_RANGE_NR                   = '02'
        OBJECT                        = 'zmanusite'
        QUANTITY                      = '1'
      SUBOBJECT                     = ' '
      TOYEAR                        = '0000'
      IGNORE_BUFFER                 = ' '
      IMPORTING
        NUMBER                        = number
      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.
    ztblqm_sqm-zsiteid = number .
    ENDFORM.                    " gen_manu_siteid
    When this did not work. i tried Vikas's soution and the code i used for this is
    FORM gen_manu_siteid .
    data : w_count like ztblqm_sqm-zsiteid,
           e_wa like ztblqm_sqm occurs 0 with header line.
    select max( zsiteid ) from ztblqm_sqm into w_count .
    w_count = w_count + 1.
    e_wa-zsiteid = w_count.
    modify ztblqm_sqm  from e_wa.
    ENDFORM.                    " gen_manu_siteid
    Please look into this and give me a solution.
    NB: I have tried them at the event 01 include.

  • Automatic calculation of numeric value enter in Survey

    while creating Survey in Survey Suit we enetr numeric value in field .
    my requirement is that can we do automatic calculation of these numeric
    values in Survey its self
    Regards,
    Anup Reche
    9268133864

    Hi Anup,
    Check if the following links help you:
    /people/gregor.wolf3/blog/2006/07/22/create-run-and-analyze-an-e-mail-campaign-with-a-survey-part-1
    /people/gregor.wolf3/blog/2006/05/11/advanced-campaign-automation-in-mysap-crm-40-teaser
    http://help.sap.com/saphelp_nw04/helpdata/en/02/739fe7a80746caa668958d558993ae/frameset.htm
    Hope this helps!
    Regards,
    Saumya

  • Checking the master data automatically before the payroll run...

    Hi Friends,
    Can anyone tell me that, is it possible to check the master data automatically before the payroll run.
    If any user forget to maintain any important info-type ( like Cost Distribution ) in time of master data maintenance, SAP allow the Payroll system to run the payroll for that employee. Only in time of account posting the user is able to know the problem and due to rectify the problem they have to delete the payroll.
    So, I therefore wants to know that is there any check point or can customized any such things, which will check the necessary info-types before running payroll and generate an error massage about the missing info-type and also skip the processing for that person.
    With regards,
    Diptendu

    have
    a look at this report
    but before that make sure wht are the mandatory infotypes that are maintained to the employee so that u can come to an idea what are infotypes that are maintained for the memployee
    se 38   HTWLINFO  read the documentation of the is report mmight be useful

  • How to 'Only' allow Numeric value in the Edit Box in AcroDialogs

    Hi all,
    I've create an AcroDialog wizard, I need to allow onlu numeric values in the Edit Box. Can someone please help me with this validation?
    Regards,
    Chris

    There isn't a keystroke event for custom JavaScript dialogs, or any proper interactive events for the fields.  You can validate fields when the user presses OK, and you can test fields when the user changes focus by setting the "Action" property for the field.  But the only practical way to restrict user input to numbers is to use George's suggestion.  There is a number property for the fields but it has an undesirable side affect and I never use it.
    Thom Parker
    The source for PDF Scripting Info
    pdfscripting.com
    The Acrobat JavaScript Reference, Use it Early and Often
    http://www.adobe.com/devnet/acrobat/javascript.html
    Then most important JavaScript Development tool in Acrobat
    The Console Window (Video tutorial)
    The Console Window(article)

  • How to get the numeric value of DocTotal from UI API

    When I hit the ADD button I need to get the DocTotal from the UI API !
    All I have is the EditText which gives it in string and the problem is to double.Parse it
    it's a pain to do it while there is CultureInfo related issue with it.
    So It would be wise to get the numeric value directly from the UI API instead of getting the DocTotal by string and trying to convert it.  So is there any way to get the numrci value of DocTotal from UI API ?

    Hello Marc,
    Here is a function which considering the Culture Info and always working. You can speed it up by using extending admininfo to global vairables, and loading the values at startup of the addon.
    Use the oEditText.value.ToString() to convert into into the doulbe number:
    Public Function _string2double(ByVal s As String) As Double
            Dim d As Double
    ' This part is fast, when regional settings equal to sap B1 settings:
            Try
                d = Convert.ToDouble(s)
                d = Math.Round(d, 6)
                Return d
            Catch
            End Try
    ' Speed up performance: extend CompaneService variables to global variables and query them at addon startup.
            Try
                Dim nfi As System.Globalization.NumberFormatInfo = System.Globalization.CultureInfo.CurrentCulture.NumberFormat
                Dim oCompanyService As SAPbobsCOM.CompanyService = oCompany.GetCompanyService()
                Dim oAdminInfo As SAPbobsCOM.AdminInfo = oCompanyService.GetAdminInfo()
                Dim sbodsep As String = oAdminInfo.DecimalSeparator
                Dim sbotsep As String = oAdminInfo.ThousandsSeparator
                If s.IndexOf(Space(1)) > 0 Then
                    If oAdminInfo.DisplayCurrencyontheRight = BoYesNoEnum.tYES Then
                        s = s.Substring(0, s.IndexOf(Space(1)))
                    Else
                        s = s.Substring(s.IndexOf(Space(1)), s.Length - s.IndexOf(Space(1)))
                    End If
                End If
                Dim s1 As String = s.Replace(sbotsep, nfi.NumberGroupSeparator)
                s1 = s1.Replace(sbodsep, nfi.NumberDecimalSeparator)
                d = Convert.ToDouble(s)
                d = Math.Round(d, 6)
                Return d
            Catch
                Return 0
            End Try
        End Function
    Regards,
    J.
    Edited by: János Nagy on Oct 7, 2009 8:55 AM

  • How do I copy/paste full numerical-only account strings into the Projects WebADI template when the account segment fields in the template require use of the dropdown because they're formatted as alpha-numeric values?

    How do I copy/paste full numerical-only account strings into the Projects WebADI template when the account segment fields in the template require use of the dropdown because they're formatted as alpha-numeric values? I'm using the Integrator named "Projects - Transaction Import" and a custom Layout created based on the seeded Layout named "Transaction Import - Accounted". Do I need to somehow change my Layout to make the Document accept numerical values instead of requiring alpha-numeric values? I need to be able to populate the Document with a large amount of transactions and cannot feasibly go through every transaction to add the alpha-valued name of the account segment to every segment that requires it. The segments in particular causing the problem are "Expnd Type" and "Organization Name" which are both alpha-numeric and as such contain the segment number and name; I need to be able to only have to enter the Natural Account Number (6-digit number only) and the Organization Number (5-digit number only).

    How do I copy/paste full numerical-only account strings into the Projects WebADI template when the account segment fields in the template require use of the dropdown because they're formatted as alpha-numeric values? I'm using the Integrator named "Projects - Transaction Import" and a custom Layout created based on the seeded Layout named "Transaction Import - Accounted". Do I need to somehow change my Layout to make the Document accept numerical values instead of requiring alpha-numeric values? I need to be able to populate the Document with a large amount of transactions and cannot feasibly go through every transaction to add the alpha-valued name of the account segment to every segment that requires it. The segments in particular causing the problem are "Expnd Type" and "Organization Name" which are both alpha-numeric and as such contain the segment number and name; I need to be able to only have to enter the Natural Account Number (6-digit number only) and the Organization Number (5-digit number only).

  • FM to get the month name based on numeric value

    Hi , Is there any FM which returns the month name when we enter the corresponding numeric value . E.g. if the input is 3 the output must be March

    Hi,
    Try
    DATA: mon_number TYPE numc VALUE '03',
          month_name(20).
    SELECT ltx
      FROM t247
      INTO month_name
    WHERE spras = 'EN'
       AND mnr   = mon_number.
    Hope it helps.
    Regards
    Message was edited by: Shehryar Khan

  • How to get the day as numeric value without formatting the date?

    Hello,
    to reduce the costs of a sql-statement I need to get the day of a date-value as number (to compare it to a numeric value) without any formatting. Every formatting results in a full table scan of the table with the date field. Is there any function to solve this problem?
    Oracle version is 11g.
    Thanks Carsten

    CarstenDD wrote:
    select T1.SYSID from T2,T1
    where T2.SysT1 = T1.SYSID
    and T2.Date1 < '01.03.2011' --German date format
    and to_number(to_char(T2.Date2,'DD')) = 1
    and T2.Inactive = 0
    The explain plan shows a full table scan on T2. With EXTRACT(DAY FROM T2.Date2) there is no difference.It probably would and should in any case.
    Look at your predicates, which of them would reduce the resultset to a fair size compared to the total number of records in the table?.
    - You may have a huge number of records when you say date less than
    - Of these perhaps one seventh have day = 1
    - My guess is that most have Inactive = 0
    Besides, you should not rely on implictit char to date conversion, always use TO_DATE
    How many records are in the table? - How many will that query return?
    Regards
    Peter

  • How to restrict the user to enter only numeric values in a input field

    How to restrict the user to enter only numeric values in a input field.
    For example,
    i have an input field in that i would like to enter
    only numeric values. no special characters,alphabets .
    reply ASAP

    Hi Venuthurupalli,
    As valery has said once you select the value to be of type integer,once you perform an action it will be validated and error message that non numeric characters are there will be shown. If you want to set additional constraints like max value, min value etc you can use simple types for it.
    On the project structure on left hand side under local dictionary ->datatypes->simple types create a simple type of type integer
    The attribute which you are binding to value property ;make its type as simple type which you made
    Hope this helps you
    Regards
    Rohit

Maybe you are looking for

  • How to open another iView in the same window

    Hallo, I user following code for opening iView: String iView = "http://server/irj/portal?NavigationTarget=ROLES://portal_content/example";           this.getForm().addRawText("<SCRIPT>\n");           this.getForm().addRawText("EPCM.doNavigate('" + iV

  • 2011 model with poor battery life and always says no disk space when there is nothing on it?

    I have a 2011 Mac Book Air and have noticed that the battery only lasts a couple of hours. It also constantly says I have no start up disk space available when there is nothing really on it, only a couple of photos.

  • Itunes will not read the ripped CD

    My hard drive crashed. With a new drive,I have now imported all my previously saved music into my Itunes library perfectly. Now, after having ripped a dozen full CD's, the new music has been loaded and can be played, but itunes will not read the titl

  • Mac OS batch convert .xls to .pdf not option

    Mac OS batch convert .xls to .pdf not option....WHY NOT???? This was never issue on Windows, and the software notes it supports pdf convert from .xls format (BUT NOT IN MAC VERSION) Any work arounds? Will this becoming in update? Really not acceptabl

  • [Workaround] Mouse freeze / loss of keyboard- check which logs

    I've been having an issue with my mouse freezing which is followed by the keyboard not responding. The mouse will freeze but I can usually still use the keyboard until I try and switch to TTY2, with the plan of pkilling Xorg. I have to reboot the mac