Replace leading Zero's

Hi ,
one of my field var = 0000501
I want to display it like var =  ****501
I want to replace all leading  zero's with ' * ' .
Replace statement replaces all zeros with  ' * ' & display var = ***51.
I want my output = ****501.
Plz help
Thanks in Advance
Sai

How about something like this?
DATA: lv_init TYPE char07 VALUE '0000501'.
DATA: lv_conv TYPE char07.
DATA: lv_star TYPE char07 VALUE '*******'.
data: lv_outp type char07.
DATA: lv_init_l type i.
data: lv_conv_l type i.
data: lv_offset type i.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
  EXPORTING
    input  = lv_init
  IMPORTING
    output = lv_conv.
lv_init_l = strlen( lv_init ).
lv_conv_l = strlen( lv_conv ).
lv_offset = lv_init_l - lv_conv_l.
lv_outp = lv_star.
lv_outp+lv_offset(lv_conv_l) = lv_conv.
WRITE:/ lv_outp.
Regards,
RIch Heilman

Similar Messages

  • Replacing leading zeroes

    The majority of members (over 1000) in one of my dimensions have a leadingzero to differentiate them from members of other dimensions (e.g. 01200,02003, etc). I would like to change the leading zero to something else,like a dash or asterisk. I can't use the Replace feature because it doesn'thave a "begins with" option, which means it would all zeroes instead of justthe leading ones. Is there a quick way of making this change? Thanks inadvance for any help you can give me.

    In your dim build, why not leave the leading zeros and use the global properties prefix feature to distinguish those members apart.Just a thought..

  • Web Services  from ABAP function modules return values- leading zeros

    I am using several web services from SAP CRM (5.0) that were created from Function modules ( I am assuming that that they are in ABAP).
    I can call the web services fine and they work as expected, but I am seeing a lot of leading zeros in the return values of fields in tables from the Web service.
    The ABAP er’s are telling me that they cannot see the leading zero’s.
    So my question is where these are appended to the values in the whole process. When I execute the Function Module in SAP CRM from transaction SE37 I can see the leading zeros. So I think that this is something that has to be handled by the ABAP er’s and not in the client consuming the web service.
    Are the functions in SAP CRM that can remove leading zeros for fields in a table (that is an export parameter?)
    Jawahar

    Hello Jawahar
    If you run your (RFC-enabled) function modules using the SAP-GUI (i.e. in dialog) then the GUI automatically replaces leading zero when the function module returns any data. However, calling the same function module remotely you will always see these leading zeros.
    These so-called conversion exits are defined as attribute of domains in the ABAP dictionary. If the function module used for the WebService is a standard fm then you have little chances to get rid of the leading zero. Perhaps the WebService has some attribute to suppress conversion exits or activate them when retrieving the data.
    Regards, 
       Uwe

  • How to delete leading zeros in sap script

    Hi
    In sapscript iam facing an issue with num4 field.
    Iam using this field to display Serial.No
    it is displaying '1' as 0001 i want to display here 1 with out leading zeros.
    If there any solution let me know

    Hi,
    Try below code
    data: w_vbeln type vbak-vbeln,
    w_char(10).
    w_vbeln = '000012345'.
    write w_vbeln to w_char no-zero.
    or
    The function Module 'CONVERSION_EXIT_ALPHA_OUTPUT' is used to remove the leading zeros in a field.
    the following is a sample code which i have used for 'Commitment item' in my report. replace the field with your required field.
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
    EXPORTING
    INPUT = IT_FMIT1-RFIPEX
    IMPORTING
    OUTPUT = IT_FMIT1-RFIPEX.
    Regards,
    Chandru

  • Leading zeroes substring query in SQL Server

    Can Someone please help me in padding leading zeroes for the months in End date
    Example: actual data is like    6222007
    ,11301998 in end date column the following query works fine for 11301998 and converts it as 19981130 which was correct.
    But 6222007
    fails because month has no leading zero and it converts it as 0076222 which is wrong.
    How can i make it as 20070622 with the following code
    select (case when replace (ltrim(rtrim(ltrim([end date]))), '|', '') in ('99999999','00000000') then NULL 
        else substring ([END DATE],5,4)+SUBSTRING([END DATE],1,2)+SUBSTRING([END DATE],3,2) end) as ConvEnd_date
    from AdventureWorks.dbo.[AccountTable]

    Something like:
    declare @i int = 6222007
    select @i%10000 year_number, @i/1000000 month_number, (@i/10000)%100 day_number
    select DATEFROMPARTS(@i%10000,@i/1000000,(@i/10000)%100)
    David
    David http://blogs.msdn.com/b/dbrowne/

  • LEADING ZERO IN MONTH

    Hi,
    is there any possibility of adding leading zero for month column in query output without writing ABAP CODE.
    SDay for March ,instead of 3 i need 03 in qury o/p.
    Thanks,
    shaw

    Hi,
    is it possible that u mean to eleminate the leading "zero" of a KF text variable?
    If yes, u can do this with the following steps:
    1. Go to query designer -> select your text variable
    2. Edit variable -> replacement path
    3. Section Offset settings-> edit offset start and offset lenght
    I dont know how 0Month is displayed, but with these two u can define at which point u the offset starts and how many text digits u want to display.
    For ex. 0FISCPER is displayed 0012008 normally, if u set offset start as 2 and offset lenght as 5 the result is 12008
    Hope it helps
    Regards

  • Grep query - optional character, leading zeros & shortening words

    I have recently been taught (thanks to this forum) how to use Grep searches (wish I’d known about it years ago!). I still can’t get my head around some of the search strings - hoping someone can shed some light & explain what the components are doing so I can further utilise them?
    I have dates for a travel brochure, given to me sometimes separated by commas without the date (2, 3, 4, 5) & I need to put each date into its own cell in a table with the month next to them (with no space & going across left to right) + with a leading zero for single digits (02Jan /t 03Jan /t 04Jan /t 05Jan).
    How can I get it to add a leading zero for single digits & add the month to the last number that doesn’t have the comma (which I otherwise utilise in the search)? (The way I get it currently is  2Jan /t 3Jan /t 4Jan /t 5).
    I can’t seem to work out the optional character command.
    The other problem I have is that the months need to be shortened to just the first 3 digits & I’m not sure how to do that, either.
    Any light shed would be appreciated!
    Using current Indd on Mac.
    Message was edited by: Alleyna Lenton I have just found (through searching IndesignSecrets) how to do the optional comma: (\d+),?    ->    $1Mar\t  (although I'm not clear whether the '+' after '\d' represents more than 1 or any number of digits?) Just the other 2 probs I have - abbreviating words to first 3 characters & adding a zero to the front of single digits.

    Very good -- GREP is a useful tool to master! If you can't work out the last few things, do let us know. Make sure to list a couple of Before-After examples.
    The + after \d is indeed for "1 or more", that is, at least one and then as much as possible (I don't think there is a realistic upper limit). Contrast with * which is "zero or more" and ? for "none or exactly 1".
    Cutting off month names after the first 3 characters was asked not too long ago, but I cannot recall what the offered solution was. Try something like this:
    (?<=\bJan)uary
    (replace with nothing). The (?<=xxx) is a positive lookbehind: it will search the text "uary" and only match it if preceded by "Jan". By writing out all months in one long string, you can change all of them:
    (?<=\bJan)uary|(?<=\bFeb)ruary|(?<=\bMar)ch|(?<=\bApr)il
    ... etc., etc., where the vertical bar is an OR operator. (It's a bit long written in full, but remember you only have to write this GREP once and then you can save it.)

  • How can I format a cell in Numbers to have leading zeros in a number?

    I imported a spreadsheet from Excel (Office 2014, Win 7) through iCloud and some numbers were formatted to have leading zeros (012358) in the original Excel file but the leading zero format was lost in Numbers.  Is there a way to format cells to have a number displayed with the leading zero in Numbers?  The leading zero is part of an identification and is important to the numbers (0027 is not the same as 27 in these records).
    thanks,
    Bob

    James has the formating part, but if you already did the import you can use the following formula to replace the zeros that were leading if you know it is a four digit reference number....
    =right("000" & A2,4)
    copy those values into your text formatted column from James' answer and you got it.
    Jason

  • Problem in XSL mapping with leading zero's

    Hi ,
    i am facing a problem in disigning a XSL mapping where one of the source field (type string ) ,and I need to remove the leading zero's to map it to target.
    we have format-numer ,but It is not working in this case ,may be because of type string.
    and the replace command is not supported .
    So can any one suggest me some way to resolve this xsl problem.
    Thanks,
    Raju.

    I write an example
    xsl file:
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
         <xsl:template match="/">
              <doc>
                   <xsl:apply-templates/>
              </doc>
         </xsl:template>
         <xsl:template match="source_field">
              <source_field>
                   <xsl:call-template name="remove_leading_zeros">
                        <xsl:with-param name="value" select="."/>
                   </xsl:call-template>
              </source_field>
         </xsl:template>
         <xsl:template name="remove_leading_zeros">
              <xsl:param name="value"/>
              <xsl:choose>
                   <xsl:when test="starts-with($value, '0')">
                        <xsl:call-template name="remove_leading_zeros">
                             <xsl:with-param name="value" select="substring($value, 2)"/>
                        </xsl:call-template>
                   </xsl:when>
                   <xsl:otherwise>
                        <xsl:value-of select="$value"/>
                   </xsl:otherwise>
              </xsl:choose>
         </xsl:template>
    </xsl:stylesheet>
    to test:
    input xml:
    <?xml version="1.0" encoding="UTF-8"?>
    <doc>
    <source_field>000000123456</source_field>
    <source_field>0987654</source_field>
    </doc>
    output xml:
    <?xml version="1.0" encoding="UTF-8"?>
    <doc xmlns:fo="http://www.w3.org/1999/XSL/Format">
         <source_field>123456</source_field>
         <source_field>987654</source_field>
    </doc>
    hope can help you.
    regards
    Bin

  • Supressing Leading Zero's

    My database has a field that has a total of 30 characters.
    Depending on the data that was entered there could be a large number of leading zero's that is displayed within that field.  How do you supress the leading zero's for that field when the number of leading zero's could fluctuate?
    In addition to that, they are also using Bar Code Scanning on that same field.  How can you suppress the Leading zero information on the same field once it has been converted to Bar Code?

    I dont think cstr(val(x)) will work if the value is "001000000000000000005147002589" as val(x) will convert it to a number and due to the number of digits, CR will convert it to scientific notation, at least CR XI converts.
    One possible solution would be to loop through the digits and extract the data by eliminating the leading zeros.  For example:
    stringvar x := "001000000000000000005147002589";
    // Example, you don't need this in your formula
    numbervar i;
    for i := 1 to length(x) do
    if x<i> NOT EQUAL TO '0' then exit for
    // use the not equal sign (greater than and less than symbols)
    x[i to length(x)];
    You can use this formula for both display and bar code purposes by replacing X with the db field.
    Edited by: Sanjay Kodidine on Oct 21, 2009 4:50 AM

  • Removing (only) leading zeros in a string

    Hello experts.
    I need to remove the leading zeros from the material name in Crystal Report for Enterprise. I stared with function Replace and Trim and it's fine in case I specify the number of zeros to be removed.
    In reality number can be 00001103 or 00455601 and there is no way to know how many leading zeros. If I choose not to specify the number of replacements, all zeros will be removed with result 113 and 445561 which is not desirable one. I should get 1103 and 455601.
    What syntax would remove only leading zeros?
    Thank you,
    Victoria

    hi Victoria,
    you could do something like
    if isnumeric({your field}) then
         totext(tonumber({yourfield}),0)
    cheers,
    jamie

  • Cuts off leading zeros in a report column when "Download to Excel" function

    Hello
    When a text column contains leading zeros for example "000250" the download to Excel stores the string as "250" in the spreadsheet. I am using a column which is a string.(varchar)
    Can somebody suggest me , how to go ahead with it
    Thanks
    Edited by: user647228 on Sep 11, 2008 1:40 PM
    Edited by: user647228 on Sep 11, 2008 1:42 PM

    (To Vins) Actually, concatenating a space doesn't do it. When the file is downloaded into Excel, the leading space is ignored and it the leading zeroes are still trimmed.
    To user647228: A non-space character needs to be concatenated. Regarding what character to append, I would give the following consideration: If the users are content with seeing an added character to the "number," you can append say an underscore "_" and Excel will download the number properly. It's fairly unobtrusive and can be "visually ignored."
    If the end user insists on gettin rid of the extra character once the file is downloaded, I would append a character that is rarely, if not never, used in the report. (This ensures or mitigates replacing other instances of the character.) Then you can do a Replace All in Excel to replace the extra character with a single apostrophe. The single apostrophe will be interpreted by Excel to mean "text" and the appearance will change to exactly what is desired.
    Note: Replacing the extraneous character with a space for example, will result in the leading zeroes being again lopped off by Excel...

  • Leading zeros to alphanumeric string

    Hello all ,
    Does anybody know any function module to put leading zeros to an alphanumeric sequence (18 characters)?
    Example : 12wer should be '000000000000012wer'
    CONVERSION_EXIT_ALPHA_INPUT only works with numbers.
    Thanks in advance ,
    Snehal

    Hi Snehal,
    <pre>
    shift [field] right deleting trailing ' '.
    replace ' ' in [field] with '0'.
    </pre>
    OK?
    Regards,
    Clemens

  • Leading zeroes - switching off ALHPA conversion doesn't work

    Hi all.
    I have an IObj ZPARENT with compounding attribute ZATTR.
    While loading data into ZPARENT I got errors regarding duplicate records. Errors occur because I got leading zeroes in ZATTR and records like "1", "01", "001" become "0001" .
    I thought it is because of ALHPA conv. in ZATTR, so I deleted ZATTR master data, removed ALPHA conv. from ZATTR and tried to reload data. I got same duplicate key error and leading zeroes.
    I also examined my transformation. It doesn't have any ALPHA conversions. I do post data into ZATTR through simple routine:
         data: CATTR type c length 35.
         CATTR = SOURCE_FIELDS-REF_INF.
         REPLACE ALL OCCURRENCES OF '#' IN CATTR WITH ':'.
         RESULT = CATTR.
    The data in PSA looks fine - it doesn't have any leading zeroes in PSA, but than it comes to IObj. I got them.
    What I supposed to do to avoid leading zeroes in ZATTR??

    Hi,
    Below SAP Note may help you out.
    Note 447341 - values for ALPHA conversion routine
    check this note also...
    Note 1242892 - Leading zeros removed from the contract number
    Veerendra.
    Edited by: denduluri veerendra kumar on Jul 1, 2009 4:02 PM

  • 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

Maybe you are looking for