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.

Similar Messages

  • 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.

  • 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

  • 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.

  • 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

  • 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.

  • 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

  • Padding with zero according to field size!

    Dear All,
    I want to add leading zeros, as per numeric column width while selecting data through sql query. Kindly let me know how to do this.
    For example if in a table there is field empID number(3)
    Now if the data is
    1
    23
    999
    45
    7
    The result i should get should be:
    001
    023
    999
    045
    007
    Thanks, Imran

    If you don't mind the output being a character value then you could do either of the following:
    SQL > SELECT TO_CHAR(10,'000') FROM DUAL;
    TO_C
    010
    SQL > SELECT LPAD(10,3,'0') FROM DUAL;
    LPA
    010HTH!

  • Pad leading zeros in a string.Format function

    How could use the string.Format function and in the format text pad a leading zero? 
    Pseudo code is:
    string parm = “5”;
    string format = “Some number formatted as 3 dig: Format({0}, 000)”;
    string output = string.Format(format, parm);
    Where the output would look like this:
    “Some number formatted as 3 dig: 005”
    Thanks.

    Thanks everyone. Unfortuantly there's a constraint where the padding operation needs to be embedded in the format string. This entire operatin is being put together dynamically where the format strings are being pulled from a library of format strings stored
    in a database. at runtime we don't know how which format will be used and how many parameters will be passed in. we have logic to handle the unknown number of paramters as there is metadata which helps us with that.
    the need for leading zeros needs to be part of the overall format defined in the format string.  for example, a real format string stored in the database looks like this:
    "LINE_NO = '{0}',  AND GEO_LOCATION = 'T{1}, {2},  R{3}, {4}, , Sec. {5}'"
    and its output from the string.Function is:
    "LINE_NO = 'TG-G2469',  AND GEO_LOCATION = 'T155, N,  R93, W, , Sec. 5'"
    the last parameter (param 5) had a value of 5.  In another case the output requirement might need to look like this:
    "LINE_NO = 'TG-G2469',  AND GEO_LOCATION = 'T155, N,  R93, W, , Sec. 05'"
    note the "05" at the end...
    the logic of using the leading zero needs to be embedded in the overall format string text.
    Thank you.

  • 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

  • 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

  • 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.

  • Re: Material number with leading zeros (40 char long)

    Hello Experts,
    I am working on SAP ME 6.1.4.15.
    I am having a problem with the material number appearing in production order / planned order request document in MEINT and failing there since the material it is looking for is with leading zeros (for example 1291 appearing as 0000000000000000000000000000000000001291) - a total of 40 char long.
    But this material exists in ME as 1291 only. Can any one throw any light on this as to what could be the reason and how to solve it?
    Thanks
    Srinivas

    Dear Srinivas,
    SAP Note 1799009 - 'Presence of leading zeros is inconsistent over IDOC thus SAP MEINT cannot handle all inbound IDOC consistently' should help to resolve the problem.
    Regards,
    Alex.

Maybe you are looking for