Leading Zero w/ variable field length...

I'm creating a form in which I need a particular field to:
- Accept/Display a leading zero (or multiple leading zeros);
- Accept numbers numbers;
- Have a maximum field length of six numerals, but with the ability to accept fewer;
- Display an error message if the above criteria are not met.
I have some code (see below), but don't know how to make the field length variable.
var fmt = /^\d\d\d\d\d\d$/;
if(event.value != "")
if(!fmt.test(event.value))
app.alert("Incorrect format, field must contain numbers only.");
event.rc = false;
Make sense...? Can anyone help...?
Thank you.

This drops the leading zero(s) and does not display the error message.
Adjustments...?
Thank you for your promp reply.

Similar Messages

  • How to remove leading zeros from variable

    hi,
       how to remove leading zeros from variable like it_vbap-matnr.
    value in it_vbap-matnr is 000000000000000358
    i want to remove leading zeros so that it become 358
    regards
    deepak

    You can use Function Module <b>'CONVERSION_EXIT_MATN1_OUTPUT'</b>
    This Function Module will eliminate leading Zeros.
    For each MATNR Value read form DB Table,u can eliminate Leading zeros and then modify ur Internal table.
    I think u will not get leading Zeros into utr Internal table when u read from VBAP.
    Bcoz MATNR in VBAP itself have Conversion routine.
    If u r getting leading zeros,U can use following Logic.
    tables:
      vbap.
    data:
       t_vbap like standard table of vbap.
    select matnr
    from vbap
    into corresponding fields of table t_vbap.
    loop at t_vbap into vbap.
      CALL FUNCTION 'CONVERSION_EXIT_MATN1_OUTPUT'
          EXPORTING
            INPUT         =  vbap-matnr
          IMPORTING
            OUTPUT        =  vbap-matnr
      modify t_vbap from vbap transporting matnr.
    endloop.
    Hope this will work.....

  • How to add leading zeros to kunnr field

    Hi All,
    I need to add leading zeros to KUNNR field runtime.
    i.e for some customer it is displaying '2001084606'
    some customer's it si displaying '10434'.
    I want add leading zeros when customer length is
    not equal to ten '10'.
    plz kind let me know this is urgent.
    Regards
    Bhaskar

    Hi there,,
    Kunnr is using a dataelement with Char 10.
    You can do in this fashion to resolve your issue.
    len = strlen (itab-kunnr).
    len is having the lenght of the customer number.
    if len < 10..
       while len < 10.
          concatenate '0'  itab-kunnr into temp_text.
          add 1 to len.
       endwhile.
    endif.
    now finally you can assign temp_text to your itab-kunnr.
    hope this way you can resolve your issue.
    if found helpful,, don't forget to reward points.
    Thanks-
    Rahul.

  • How can i avoid leading zeros for a field in smartform?

    how can i avoid leading zeros for a field in smartform?

    Hi,
    Using the Symbols.
    &symbol(Z)&  Omit Leading Zeros  &symbol(S)&  Omit Leading Sign 
    &symbol(<)&  Display Leading Sign to the Left 
    &symbol(>)&  Display Leading Sign to the Right 
    &symbol(C)&  Compress Spaces 
    &symbol(.N)&  Display upto N decimal places 
    &symbol(T)&  Omit thousands separator 
    &symbol(R)&  Right justified 
    &symbol(I)&  Suppress output of the initial value 
    Regards,
    Shiva Kumar

  • Leading Zeros for variable vlaues(Date)

    Hi,
    How to remove leading zeros for variable values.
    For example;
    Comapny Code by Auth: 007.2004(July 2004)
    How to take out the first two zeros or first zero.
    Any suggestions would be of great help.
    Regards,
    Suresh

    How is that related to sql develper?
    Did you read the forum title? - SQL Developer (Not for general SQLl/PLSQL questions)

  • Need to add leading zeros to the field if field length is less than 6

    Actually the field length is 16.
    But for some manual entries it is comming as 4 chars.
    so if field length is less than 6 then it should be replaced by leading zeros.
    Moderator message: very basic, please (re)search yourself before asking, @all: please do not reply to basic questions, points removed.
    locked by: Thomas Zloch on Sep 9, 2010 11:43 AM

    Hi Ravi,
    Do it in 2 steps.
    1. check the length of your entry by strlen function and get the length.
    2. If the output is less than 6 call the FM CONVERSION_EXIT_ALPHA_INPUT to get leading zero
    Regards,
    anirban

  • Leading zero on char field

    I have what would be a simple thing.  A need to have leading zero retained on a variable..that holds a month.
    I have a field that is 20090501 and I want to make it 20090401...  that is take 1 month off
    But problem is the calculation does not give leading zeros
    ... here is very cut down version of what I am doing
    DATA:  lv_Period(8) type c,
          lv_mm(2) type c.
    lv_mm = '05'.
    lv_mm = lv_mm - 1.   "becomes 4.    " how do I make it "04".
    concatenate '2009' lv_mm '01' into lv_Period.    " this becomes  2009401  and not 20090401

    DATA: lv_Period(8) type c,
    lv_mm(2) type c.
    lv_mm = '05'.
    lv_mm = lv_mm - 1. "becomes 4. " how do I make it "04".
    if lv_mm is LT  '10'.
    concatenate '2009' '0' lv_mm '01' into lv_Period. 
    else.
    concatenate '2009' lv_mm '01' into lv_Period. " this becomes 2009401 and not 20090401
    endif.

  • Padding leading zeros to char field

    Hi Gurus,
    user enter number in the field which is char 10, and if they enter any value which is lesser than 10 then i have to pad leading zeros to cusno.
    i am using following logic but its displaying error saying unable interpret 'v'.
    any hep in this regard really appreciated.
    data : cusno type char10 value 'PADA'.
    Data : l type i.
    data : v type c value '0'.
    l = STRLEN( cusno ).
    while l < 10.
    concatenate v into cusno.
    endwhile.

        Add Leading Zeroes
          CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
            EXPORTING
              input  = cusno
            IMPORTING
              output = cusno.
    This will add leading zeroes to cusno if its length is less than 10.

  • Adding leading zeros in a field mapping

    Hi,
    I am getting account as a 5 char field in the input file. I need to map this to a 10 char field in XI and add leading zeros in case the value is all numeric. Is there any standard data type/ mapping that can achieve this or I need to write a UDF.
    Thanks,

    formatNum field will cause an exception if your input isnt all numeric...
    I'd go for UDF id your input isnt always numeric.
    Regards,
    Henrique.

  • Delete leading zeros for a field on the pdf form

    Hi,
    i know it is possible to delete leading zeros via abap coding in the interface.
    But is it also possible to this directly on the pdf form - scripting or a setting?
    Thank you
    Kind regards
    Manfred

    I believe you can set this up as a field display pattern (if you use LCD 8.1 or something like that).
    Or you can script that out. In formcalc you can easily process characater by character, test if that is zero and remove it.
    http://help.adobe.com/en_US/livecycle/es/FormCalc.pdf
    Otto

  • Leading zeros in Numc field

    Hi all,
            help me in  the issue . I am passing  value to a numc(3) field . lets take the value as '073' but it is showing as 073 in the output . How to acheive leading zero for the same in the output for a standard field.
    Thanks in advance

    data : num(3) TYPE C VALUE '073',
           val(3) type N.
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
    EXPORTING
    input = num
    IMPORTING
    OUTPUT = val .
    write : val
    No Eric FM CONVERSION_EXIT_ALPHA_INPUT also work. Try the above code.
    /Edit: Ohh.. Go as per my earlier post.
    Edited by: Mishra.Manas on May 5, 2010 1:39 PM

  • How to remove leading Zeroes in all fields in Payload

    Hi,
    How can I remove the leading Zeroes in every Filed I have in whole Payload Structure.there are around 10000 fields that have to be removed the leading Zeroes.any good idea please.
       <POSNR>000010</POSNR>
      <MATNR>000002465640</MATNR>
      <ARKTX>000012 KG D107</ARKTX>
      <MATKL>00030010000</MATKL>
      <WERKS>0000ORGC</WERKS>
      <LGORT>0000GC55</LGORT>
      <CHARG>000TEST</CHARG>
    like this mutliple segments and multiple Fields.so  I can take as whole payload with multiple fields should not have leading Zeroes.I can handle if they are 10 0r 20 fileds,but not like whole pay load/1000 fields right.
    thank you,
    Prem

    Hi
      You can have an additional XSLT mapping, to your existing one..
    use copy-of & apply-templates to copy the whole tree & make changes recursively.
    below is a sample code , the marked line is where you need to try your logic of trimming Zeros. (this code does upper case)
    add this below code in your interface mapping object, as XSLT mapping, which does the job (only try putting your logic)
    <xsl:stylesheet
                      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                      version="2.0">
                <xsl:output  method="xml"
                            indent="yes"
                            omit-xml-declaration="yes"/>
                <xsl:template  match="*">
                      <xsl:copy>
                            <xsl:copy-of  select="@*"/>
                            <xsl:apply-templates/>
                      </xsl:copy>
                </xsl:template>
                <xsl:template  match="text()">
                      <xsl:value-of  select="upper-case(.)"/>
                </xsl:template>
          </xsl:stylesheet>
    hope this fixes your issue
    Regards
    Vishnu

  • Add leading zero for character field on ALV

    hi all , 
        i am currently making an ALV report. i have a field which is 'rassc' char(6) in the internal table which should be shown on the report.
    before i use function to show alv report , i saw the value of this field is '080' , but what i get on the report is '80'.  i want the leading zero . but i don't know how .
    plz guide me.
    regards
    Kevin

    hi,
    check this.
    DATA:
    var TYPE matnr.
    WRITE '80' TO var RIGHT-JUSTIFIED.
    TRANSLATE var USING ' 0'.
    WRITE: var.

  • Leading zero's for field Serial Number

    Hi All,
    I need to be able to have leading zero's for the serial number field (GERNR). I have found a few notes for the industry solution for A&D but does anyone know if there is a solution for normal ECC?
    Cheers
    Chris
    Edited by: Chris March on Sep 16, 2008 2:49 PM

    Hi Chris
    Did you manage to get a solution for this?
    Regards
    Anant

  • How to delete leading zeros for amount  fields

    Hi all,
    I have problem with the leading zeros, where I am populating nearly 30 amount fileds in my  statement.i want to delete leading zeros.
    I have tried with shift and pack.
    and I cannot call every time the function module *alpha_output or input.
    can anybody suggest me the better solution.
    Regards,
    Sre

    You could use a syntax like 
    SHIFT: w10a LEFT DELETING LEADING '0',
           w10b LEFT DELETING LEADING '0',
           w10c LEFT DELETING LEADING '0',
           w10d LEFT DELETING LEADING '0'.
    or using macros like
    DEFINE delzero.
      shift &1 left deleting leading '0'.
    END-OF-DEFINITION.
    delzero: w10a, w10b, w10c, w10d.
    Regards

Maybe you are looking for

  • My second BT ordeal in six months - second attempt

    Oops.. I think I may have only posted the title of this message first time around. Earlier this year, I made what I thought was a simple request to BT to upgrade my broadband from Option 1 to Option 3. This they did, but at the same time they cancell

  • Tabstrip creation & use.

    I am new to tabstrip. I have tried to create a tabstrip in an existing screen. I wanted to know step wise of using a tabstrip. I have created subscreen areas under two tabs naming the areas as tab1-ref1 & tab2-ref2 but here i am confused as to what s

  • Invoice distributions  not displaying

    hey we have a situaion where invoice distribution form is supposed to show 3 invoice distributions lines ,but there is only 1 distribution line is displaying in the form. However invoice header shows the total amount of the distributions lines. Check

  • Make Check Box Input Inactive.

    Hi Friends, I had created a check box and make the input off by setting the properties. But when I do this the text label left to the check box also becomes inactive. How can I resolve this Problem. Thanks in advance.

  • Unshuttable built-in microphone

    Hi everybody! (specially the hyper frustrated ones...) I found out the way to shut off the built-in microphone in my MacBook Pro (later 2009, 2.66mghz). Maybe the question has been answered before, but just in case... Go to the Applications folder, i