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

Similar Messages

  • SapScript problem with leading zeros

    Hi,
    I print field LTAP-NLENR.
    But when i use &LTAP-NLENR& leading zeros are cut.
    I need to display it with leading zeros. (ex. 0000000000010000000001)
    Please help.
    Regards,
    Greg.

    &LTAP-NLENR(K)& works fine for me with your requirment.
    I have defined a L_VAR like this:
    data: L_VAR type LTAP-NLENR.
    l_var = '0000000000010000000001'.
    In my script I use like this:
    P1   &L_VAR(K)&
    SO, try to pass that value to some other variable and see what happens.
    Regards,
    Naimesh Patel

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

  • EBS check number with leading zeros

    When we upload EBS, we are getting the check number in the record 16 (reference field). But unlike the check number posted in SAP, the check number in the BAI file has 2 leading zeros. Now since check number is coming in record 16, instead of record 88 we are not able to solve this problem through String configuration.
    So, we thought of following solutions(Options):
    1.    Modify the check lot numbers to have two leading zeros plus associated changes like the form and so on.
    2.    Modify the check number in the incoming file u2013 strip the check number with two leading zeros with the use of customer enhancement. (After upload and before posting)
    Can we solve the problem of leading zeros (before the check number) through any configuration steps instead of changing the SAP script form for check(Check lot) or going for customer enhancement.
    Thanks
    Ron

    You are correct, since the check numbers are coming through only in the 16 records and not in the 88 records, you cannot use a search string to resolve the issue with leading zeros.  Also, I do not know of any other configuration that can be used to reformat the reference values in the 16 records.
    The 2 solutions you have listed are both valid options.  Although with the first option (changing the check lots), you would need to make sure the business users approved of changing the check lots before going forward with that option.  And you would still have to manually clear checks that had been issued prior to the check lot change.
    At my company, we went with the second option - using ABAP code to update the check numbers from the file to match those in SAP (we actually had to add leading zeros to the check numbers).  In our case, we had already created a pre-processor program for other re-formatting of the file that was needed prior to loading it into SAP - so we added the check number logic to that.
    However, if you do not have a pre-processor program, I know there is a user exit available for EBS - exit EXIT_RFEBBU10_001, include ZXF01U01.  I have heard of others using this exit to update the check numbers from 16 records.  The exit is called during the FF.5 processing.
    Regards,
    Shannon

  • Materials with leading zeros - consequences of changes

    Hello,
    In Trx OMSL is defined that materials will be shown with leading zeros (checkbox marked).
    My client is already using logistics functions involving materials and wants to change this material representation with leading zeros to material without leading zeros (Lexicografic).
    the config setting appears quit easy but Im not sure what the effects will be - if there any!?
    Anyone has done this kind of change and what were the consecuences?
    Thanks for any answer.
    Aart

    Thanks Guys,
    Ill Try to focus my question.
    In OMSL my customer has not marked the checkbox: Lexicographic
    in OMSL my customer has marked the checkbox: Leading zeros
    my customer uses matererials with internal and external number asignment.
    Material with internal number asignment behave like this
    MM03: 000000000050000010  (and the material number is show like this in ME23N, MIRO etc.)
    MARA: 000000000050000010
    OMCV-CONVERSION_EXIT_MATN1_INPUT :  
    50000010  -> 000000000050000010
    MAterial with external number asignment behave like this
    MM03:    5101377600TF
    MARA:   5101377600TF
    OMCV-CONVERSION_EXIT_MATN1_INPUT :  
    5101377600TF  -> 5101377600TF
    The behaviour of the leading zeros is especialy a problem in trx like ME23N and MIRO.
    My question is:
    If I change in OMSL and unmark the checkbox "leading zeros" , what consecuences will this have for the materials with external number asignment - if there are any?
    Can I try this out in DEV and after this reset the flag "leading zeros"?
    Thanks for any answers.
    Aart

  • Sequence with leading zeros

    Hi,
    I have a column SRL_NUM with datatype varchar2(4 char).I have 3000 records in this table and want to make SRL_NUM like 0001,0002,0003 etc.It should increment but entire 4 characters should be filled.How do i do this?
    Thanks.

    user10698496 wrote:
    I have a column SRL_NUM with datatype varchar2(4 char).I have 3000 records in this table and want to make SRL_NUM like 0001,0002,0003 etc.It should increment but entire 4 characters should be filled.How do i do this?Why is the sequence a varchar2 and not a number?
    IMO it makes more sense to use a native number data type as that is what a sequence generator outputs - and then render that as a text string with leading zero as "+how it looks like+" is a presentation layer issue.
    I would not use a numeric sequence generator to generate unique strings as surrogate key values. There are inherent problems with mixing data types like that.

  • ABAP-based web service returns numeric values with leading zeros

    Hi SOA experts,
    I have created a web service out of an ABAP function module. Beside other values, this service returns a list of document numbers. All of these numeric values are returned by the web service with leading zeros, but we do want these values w/o leading zeros.
    Any ideas how I can tell the web service to not print any leading zeros?
    Thanks in advance for your help!
    Kind regards, Matthias
    PS: The according function module does not print any leading zeros for the numeric values

    hi,
    just a guess: I'd try to use I instead of NUMC for the document numbers.
    NUMC is no number but a character string with numeric characters only. only some display routines in SAP know that this string of numerals represents a number and omit leading zeroes.
    my 2 cents,
    anton

  • Need formula to take text from one cell, add that to a serial number with leading zeros

    I'm trying to create a spreasdheet cell that simplifies creating videotape Numbers from a job name in cell and appends a serial number with leading zeros, and that would survive an export to EXCEL.
    The result would look like
     A Column
    Job Name
    B ColumnTape #
    Formula needed for B
    ClientName-TapeType-
    ClientName-TapeType-001
    =
    ClientName-TapeType-
    ClientName-TapeType-002
    =
    I've tried using a custom cell format that had the text in front of the (Integer) drag and drop, with three integers and leading zeros.
    That worked, but requires recreating the custom cell format for each client and tape type.
    So, I've used the formula =A2& in order to play around with different things, but haven't hit on something that adjusts for increased numbers and retains the leading zeros.
    I don't mind doing a starter for the first row and then adding +1 in the formulas for the rows below.
    I've done that using the custom cell formats for the first B cell and then using =Bx+1 in the following cells.  It works, but I'm hoping to find something simpler or that can be copied and pasted in multiple rows on one paste.
    Thanks in advance.
    Suggestions much appreciated!
    Ted

    Ted,
    This expression in B will give you the pattern I believe you are looking for:
    =A&RIGHT("00"&ROW()-1, 3)
    Here's a screen shot...
    Jerry

  • Download records to EXCEL file with  Leading Zero's for numbers

    Hi All,
    I am able to download the data to EXCEL file on the presentation server.
    There are few fields (Plant,SalesOrder Number ..with Leading Zero's) in the record.
    These values are downloaded with out Leading Zero's to excel( EX: 0000004122 as 4122).
    Please help me to download the data to EXCEL file with leading zero's.
    Thanks and Regards,
    KC

    >
    Krishna Chaitanya  G wrote:
    > The excel file which is to be downloaded..will be used by some other program..to upload the values to the sap.
    > It matters there....
    > KC
    HI KC,
    then no need to download the zeros,
    after uploading, loop at that uploaded internal table and use CONVERSION_EXIT_APLHA_INPUT and pass the vbeln(without zeros) to this FM, it will return the value with added zeros.
    hope this solves your query
    a small example
    Loop at itab into is.
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
    EXPORTING
    INPUT = is-vbeln "(  this is without zeros)
    IMPORTING
    OUTPUT = is-vbeln. "( this is with leading zeros)
    modify itab from is.
    endloop.
    Edited by: Soumyaprakash Mishra on Oct 6, 2009 2:16 AM

  • SD Document flow with Leading zeros

    Hi All,
    We have issue with docuemnt flow, when we click document flow sales order or delivery or billing its showing leading zeros, My client  don't want any leading zeros in docuemnt flow.
    For example -
    if i click on document flow its showing - 00500005 (SO ) 008000674 -Delivery - - Billing - 0090000012,
    Can any other guide us what could be a issue with leading zeros or any config setting is missing.
    Regards
    Nishad

    dear friend,
    it depends on how do you set up the number ranges
    for example, run VN01 and look how your sales orders are numbered.
    regards,
    p.s. create a new number range without leading zeroes and test it
    but i suggest you will not change the current settings , it is 'too late' , so tell your client it is standard

  • How can I format a number with leading zeros?

    I need to convert an int to occupy exactly 3 positions in a StringBuffer... I need the space in the StringBuffer to be filled with leading zeros where appropriate. Can anyone show me how to do this correctly please ?
    At the moment I am using a pretty dumb workaround to fill the target with "000" first and then parse the int into either 1 2 or 3 positions depending on its value ... it works, but there must be a more correct way to do this ...
    Thanks in advance ...

    Have you had a look at the class java.text.DecimalFormat? It does exactly what you want... example:
    StringBuffer sb = new StringBuffer();
    DecimalFormat format = new DecimalFormat("000");
    format.format(2, sb, new FieldPosition(0));
    System.out.println(sb);
    prints out the string 002.

  • BPC 7.5 NW: Master Data with leading zeros

    In BPC 7.5 NW, is it still an issue to have Master data with leading zeros?
    In other words, is it still not advisable to have leading zeros in the Master data.
    Let me know your views.
    Thanks.

    I was also having the same issue almost in the same version.
    Other than what you mentioned, the master data was also jumbling up like 0120, 0130, 0145, were set up as 120, 145, 130....
    The workaround that we took was to put a leading alphabet, when the data comes into BPC.
    Try doing that, it will surely help.
    Hope this helps.
    Thanks.
    Anand

  • ** Please help urgently  ** Budget upload field with leading zeros

    We need to load a characteristic that has leading zeros.  For example 0000350.  When saving down to CSV, we lose the leading zeros (0000) so that only 350 is loaded into BW.  Saving the codes as 'text' in excel does not seem to help.
    We cannot therefore see the name for any of these codes when refreshing the workbook in BW.
    Could some please urgently tell us the correct method to save the file for loading into the BW infopackage, with all zeros intact ?
    Regards, Frederick

    Hi Frederick,
    Just some additional thoughts,
    assuming field A1 in Ecel contains 350 and you want to create a string with 8 digits, you could use formula '=text(A1;"00000000")' in an empty column and copy it back to column A. Then 00000350 should be provided in A1. This can be saved in a normal .csv file and be opened with a text editor (e.g. notepad) in order to check content.
    If you don't want to manipulate Excel data, transformation to a field with leading zeros can be easily be processed with a routine in transfer rules.
    Regards
    Joe

  • Padding a julian date with leading zeros ?

    Hi,
    I have gernerated a julian date, which I am appending to another two digit number to create a five digit serial number.
    Is there a simple way to pad the first 99 days with leading zeros ( i.e. 001, 002....025...099) so that I maintain a five digit serial number ?
    I am using   Get Date In Time/Seconds > Number To Decimal String > Unbundle >Number to Decimal String.
    Thank you in advance for any advice,
    Alan

    Here's the simplest way to do it (with he 2 digit number), I believe:
    Message Edited by Matthew Kelton on 02-21-2008 12:43 AM
    Attachments:
    Julian1.png ‏3 KB
    Julian2.png ‏2 KB

  • Export to Excel - data with leading zeros

    Does anyone have any tips or tricks for running a query then exporting to Excel without dropping leading zeros from the data?
    Examples: numeric Item codes with leading zeros, telephone numbers that have been entered with no spaces.
    Regards,
    Douglas McDove

    < Font Color="RED" Size = 3 Face=Verdana>
    I liked the challenge and therefore.......I got this for you
    </Font>
    SELECT CHAR(28) + T0.CardCode [BP Code\] FROM  [dbo\].[OCRD\] T0
    SELECT CHAR(29) + T0.CardCode [BP Code\] FROM  [dbo\].[OCRD\] T0
    SELECT CHAR(30) + T0.CardCode [BP Code\] FROM  [dbo\].[OCRD\] T0
    SELECT CHAR(31) + T0.CardCode [BP Code\] FROM  [dbo\].[OCRD\] T0
    Any of the above 4 should work.  T0.CardCode is the database field I tested, you can substitute this with any database field and it should work.
    Regards
    Suda

Maybe you are looking for

  • Printing Problem with Epson R320 (Print CD)

    Problem: I cannot print using Print CD with a new Epson Stylus Photo R320, however I can print from applications using the gimp beta driver provided in OS software, via <Print Using> dialogue box. Power Mac G4 dual 450, running 10.4.6. After phoning

  • Reg Function module for getting date

    Hi, My requirement is, If I entered some date I need to get past three months number of days. Eg: if I entered 26thDec,2007 I need to get number of days form October 1st to 26th Dec. Regards, sarath.

  • How do I Uninstall

    I need to uninstall my itunes but during the process it said Error 1402.Cannot open key.Hkey.local machine/software I cant update or uninstall either without an error occuring. Im running on windows xp.

  • IPhone 5 connection to my internet

    Trying to join my OWN network.  I keep getting the message 'unable to join network'.  My iPhones 4 and 4s had no problem, but my iPhone 5 does.  I am trying to update my software to 6.1.3.  HELP

  • No automatic prints for GR for production order

    Hi All, We have created a new Z output type by copying output type WF01 for our project. I have maintained this outpit type in the schema and mainatined a condition record for this output as well in MN21. But when we do the podcution order confirmati