Suppressing leading zeroes during mapping

Dear All,
I am having one requirement in which i want to compress all the leading zeroes for the material no only eg 0000123450 shuld be converted into 123450.
Is there any standard function available which compresses the leading zeroes???
Waiting for your valuable response.
Regards,
N.Jain

Write a UDF like this ..
public class test {
public static void main(String[] args) {
  System.out.println(args[0].replaceAll("^0*",""));
Also you can use XSLT for this.
Try the XPath function number($string) in your XSLT and see if it does what you want. Since it turns any XPath object into a number, the leading zeros  won't appear.
Use it ike this
<xsl:variable name="a">
         <xsl:call-template name="removeLeadingZeros">
             <xsl:with-param name="phone">
                 <xsl:value-of select="EVENT/ContactPhone"/>
             </xsl:with-param>
         </xsl:call-template>
     </xsl:variable>
<xsl:template name="removeLeadingZeros">
         <xsl:param name="phone"/>
         <xsl:message>
             <xsl:value-of select="$phone"/>
         </xsl:message>
         <xsl:choose>
             <xsl:when test="starts-with($phone,'0')">
                 <xsl:call-template name="removeLeadingZeros">
                     <xsl:with-param name="phone">
                         <xsl:value-of
select="substring-after($phone,'0' )"/>
                     </xsl:with-param>
                 </xsl:call-template>
             </xsl:when>
             <xsl:otherwise>
                 <xsl:value-of select="$phone"/>
             </xsl:otherwise>
         </xsl:choose>
     </xsl:template>
Regards
Aashish Sinha
PS : Reward Point if Helpful

Similar Messages

  • Display key and text in dropdown box & suppress leading zeros in material #

    Hi Everyone,
    I have some questions on how to ....  Can anyone help me?  Here they are:
    How to show material # and description (key and text) both in dropdown box list? 
    How to suppress leading zeros in material #, i.e. 0000000012345678 only show 12345678 ?
    How to show a date with format mm/dd/yyyy not yyyymmdd?
    Thanks alot, Jin
    Edited by: Jin Freda on Mar 25, 2008 4:47 PM

    Hi,
    What type control you are useing for date .
    If you are useing Input field of date type or Date picker control you should get this option in the control properties.
    Can you tell me what are  tabs are appaering in the conrtol properties.
    2.When you you are using the formula Round(@material) ,Are you typing it or draging Field from right side in to  the formula .If you did not drag it you will get Message:Formula has errors.
    One more probelm is there if the Data type of field where you using formula is not Number type.
    Check all above and get back to me.
    3.You are not able to give 6 points for all because its a resrticed one you execeded giving6 points option now you can give only 10 points.
    Regards,
    GOVINDU

  • How to suppress leading zeros

    Hi,
            How to suppress leading zeros in a character string.
    Thank you.

    hi,
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
                EXPORTING
                  input  = str1
                IMPORTING
                  output = str1.
    Example:
    input = 00000000000123
    output = 123
    rgds
    Anver

  • Suppressing Leading Zeroes in the Query output

    Hi,
    I have selected a data field(0MATERIAL) as a free characteristics, It displays text and key and the key has leading zeroes.
    In the infoobject 0MATERIAL, ALPHA conversion routine is not selected, I can't change and insert the ALPHA right now because it would end up with reloading a large volume of data in different targets. To avoid this or to reduce the impact, in the reverse way,
    Could it be possible to suppress this leading zeroes at the query level? I was hoping that there would be a change that I could make at the query level, since it is 0Material and am looking at the point of minimal impact.
    Thank You.

    Hi Senthil,
    create InfoObject ZMATERIAL like a copy of 0MATERIAL, delete all the attributes and insert ALPHA conversion.
    Insert this ZMATERIAL like display attribute of 0MATERIAL. In InfoSource for 0MATERIAL map also ZMATERIAL with the same field that is feeding 0MATERIAL (MATNL). In your query insert 0MATERIAL and ZMATERIAL, and then hide 0MATERIAL (you need to insert also 0MATERIAL because ZMATERIAL is only in display), you will see only the values of ZMATERIAL, that is the material without the zeros in front.
    You can also decide to transform ZMATERIAL like navigational attribute, but in this case you have to change all the structure where do you want ZMATERIAL, because you need to flag it like navigational in that specific structure.
    Ciao.
    Riccardo.

  • Suppress leading zeros for ALV column

    Hello,
    I have an ALV with a column mapped to a context attribute of type NUMC and would like to suppress the leading zeros being displayed.  My initial solution was to change the attribute to a char/string type and remove the zeros in my code, but then, the sort functionality no longer works correctly.  Any ideas if the ALV can use a 'hidden' field to do the sorting for a certain column... that way, I can display the number as a char/string without the zeros and when the user sorts the column, the ALV will use the hidden NUMC type field.
    Thanx for any directions...

    Hi,
    You can follow the following way which i implemnted for one of my application. Here i am setting this property for the context attrubute. May be this will work. But in ALV there is no separate method for this type of setting.
    **This method is used to display the Leading zeros for the Lot Number in Step-1
      DATA:
        node_do_not_change                  TYPE REF TO if_wd_context_node,
        node_d0130_sapmf05a                 TYPE REF TO if_wd_context_node,
        node_pstap                          TYPE REF TO if_wd_context_node,
        node_info                           TYPE REF TO if_wd_context_node_info,
        ls_fprops                           TYPE wdy_attribute_format_prop.
      node_do_not_change = wd_context->get_child_node( name = wd_this->wdctx_do_not_change ).
      node_d0130_sapmf05a = node_do_not_change->get_child_node( name = wd_this->wdctx_d0130_sapmf05a ).
      node_pstap = node_d0130_sapmf05a->get_child_node( name = wd_this->wdctx_pstap ).
      node_info = node_pstap->get_node_info( ).
      ls_fprops = node_info->get_attribute_format_props( 'VALUE' ).
      ls_fprops-null_as_blank = if_wd_context_node_info=>c_format_null_as_BLANK.
      node_info->set_attribute_format_props(
        name              = 'VALUE'
        format_properties = ls_fprops ).
    Warm Regards,
    Vijay

  • Suppressing Leading Zero in Date

    We are currently having a problem when running a query in BEX.  The date which displays as MM/DD/YYYY is suddenly displaying with the leading zero in the month and day supressed, for example "3/5/2006" instead of "03/05/2006".  This is interfering with macros in our workbook.  We recently implemented support packs but don't know if this is related.  Does anyone know how to fix this?  When running the same query from the Query Designer the dates display correctly, without the leading zeros suppressed.

    Hi adadms,
    Plz check ur system settings.
    Go to control panel : regional options-Date
      check with short date format.
    it may be d/m/yy.
    Thanks,
    sekhar.

  • How To Suppress Leading Zeroes

    Can someone give a new modeler a tip on how to suppress the leading zeroes in a field? Order number, for example, is returned with many leading zeroes, and each dynamic expression I choose doesn't seem to work.
    Thanks in advance!

    As I said before, the easiest way I know to do this is to take your data, order number string "0000000000001234567", translate it to an integer - 1234567 - then re-translate that to a formatted string.
    I have actually come up with an answer, but am not sure that I like how it has to be done. First, I changed the Control Type for field VBELN (order number) to "None". Then I created two additional fields in the output table view. The first is named fmtOrdNum. Its Control Type is "None", meaning it won't be displayed, and its default value is INT(@VBELN). The second field is named fmtOrdNum2. This field is displayed, and has a default value of NSTR(@fmtOrdNum, 'P'). The resulting output is what I wanted to see - leading zeroes are suppressed.
    The reason I'm not happy with this is that I'm not sure that two additional fields should have to be created. I'm looking for the place to tell VC to manipulate (format, in this case) the fields it's received from the BAPI before it places them on-screen. So additional questions remain:
    1. How do you instruct VC to apply formatting to a field before placing it on-screen? Is this done on Control Properties, and where?
    2. Can expressions be nested - e.g. NSTR( INT(@@), 'P') - and to what level?

  • Gui_Download - Suppress leading zero in EXCEL

    Hello,
    in my scenario I need to build an excel file in which some of the information they need to be displayed in excel with the leading 0 in front (type-lqua lgort 0701 ) thing does not happen in my view.
    I create the Excel file like this:
       CALL FUNCTION 'GUI_DOWNLOAD'
         EXPORTING
    = BIN_FILESIZE
           FILENAME = filename
           FILETYPE = 'ASC'
    APPEND = ''
          WRITE_FIELD_SEPARATOR = 'X'
         TABLES
           DATA_TAB = tb_out
    I have read in some posts that just insert a character " ' "   to show everything as text, however, this does not fit in my case because my file is the input to another application (not mine) that reads the file with the FM' ALSM_EXCEL_TO_INTERNAL_TABLE '
    How can I view the file directly without suppressing leading 0 ?
    Thanks in advance

    try this
    instead of gui_download use this to download into excell file.
    DATA: XL_itab type alsmex_tabline occurs 0 with header line.
    CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
        EXPORTING
          FILENAME    = FILENAM
          I_BEGIN_COL = 1
          I_BEGIN_ROW = 2
          I_END_COL   = 3
          I_END_ROW   = 5000
        TABLES
          INTERN      = xl_itab.
    * EXCEPTIONS
    * INCONSISTENT_PARAMETERS = 1
    * UPLOAD_OLE = 2
    * OTHERS = 3 .
      IF SY-SUBRC = 0.
    * MESSAGE 'DATA UPLOADED SUCCESSFULLY' TYPE 'I'.
      ENDIF.
      loop at xl_itab.
        case xl_itab-col.
          when '1'.
            <your workarea-fieldname> = xl_itab-value.
          when '2'.
             <your workarea-fieldname>  = xl_itab-value.
          when '3'.
             <your workarea-fieldname>  = xl_itab-value.
        endcase.
        at end of row.
          append<work area> to <internal table>.
          clear <workarea>.
        endat.
      endloop.
    if you have more doubts just reply me

  • Default leading zeros during loading

    Hi! I have part numbers that tend to have varying length and I have a requirement to put leading zeros before them when I load the catalog data via Import Manager. The Replace function would not work for this as the number of leading zeros is not fixed. Does anyone know o a way to do that?
    Cheers!
    SF

    Hi,
    Have a look at the below approach
    Assumption- Max Part Number length would be 10 digits.
    Create one Assignment with expression
    Mid(10000000000+PartNumber,2,10)
    Expression will first add the PartNumber with 1000000000 then using Mid function it will extract the desired result.
    E.g.
    PartNumber = 3030
    1000000000+3030 = 10000003030
    After Mid = 0000003030
    Create one workflow with the Assign step and use the assignment created above. Launch this workflow on Record Import.
    I tried this and its working fine.
    Regards,
    Jitesh Talreja

  • Suppressing Leading Zero's in an EvDRE Report

    Hello Experts,
    I am trying to create an EVDRE that suppresses any data that is less than 1 (For example, I have a .01 and a .05) and will prevent it from showing up in the report.  Does anyone know the best way of doing this?
    Thank you so much!
    David

    Dear David Flacks,
    BPC Excel could suppress null value automatically, null zero is no record in database. For your example (the signeddata=0.1), I do not think so. If you would like to suppress null value, please you give the value of Suppress Zero is Y in your Expansion settings table. And for the value 0.1 maybe you can use VBA Macro which runs after expansion all. a VBA macro contains logic for delete a particular cell base on value.
    Kind Regards,
    Wandi Sutandi

  • Truncating the leading zeros

    hi,
    Could anybody pls tell me how do i truncate the leading zeros in the incoming file structure.
    Thanks,
    Chinna

    Hi,
    Check this thread, i laready answered it there.
    Suppressing leading zeroes during mapping
    For you i pasting the solution here.
    Write a UDF like this ..
    public class test {
    public static void main(String[] args) {
    System.out.println(args[0].replaceAll("^0*",""));
    Also you can use XSLT for this.
    Try the XPath function number($string) in your XSLT and see if it does what you want. Since it turns any XPath object into a number, the leading zeros won't appear.
    Use it ike this
    <xsl:variable name="a">
    <xsl:call-template name="removeLeadingZeros">
    <xsl:with-param name="phone">
    <xsl:value-of select="EVENT/ContactPhone"/>
    </xsl:with-param>
    </xsl:call-template>
    </xsl:variable>
    <xsl:template name="removeLeadingZeros">
    <xsl:param name="phone"/>
    <xsl:message>
    <xsl:value-of select="$phone"/>
    </xsl:message>
    <xsl:choose>
    <xsl:when test="starts-with($phone,'0')">
    <xsl:call-template name="removeLeadingZeros">
    <xsl:with-param name="phone">
    <xsl:value-of
    select="substring-after($phone,'0' )"/>
    </xsl:with-param>
    </xsl:call-template>
    </xsl:when>
    <xsl:otherwise>
    <xsl:value-of select="$phone"/>
    </xsl:otherwise>
    </xsl:choose>
    </xsl:template>
    Regards
    Aashish Sinha
    PS : Reward Point if Helpful

  • Suppress leading spaces while displaying an amount field in a Smart form

    Hi all,
    In a smart form, I am using fields like KONV-kbetr and VBAP-netwr each of them currency type and 2 decimal places. I want to suppress the decimal places and also the leading spaces while displaying these fields in a smartform cause when this field is inserted in a sentence, a lot of gap is there between the field and the words of the sentence. I dont want to change the field length cause it can be that huge in some cases.
    Please help.
    Thanks ,

    Hi, if you would place it in a sentence, it would be an option to concatenate the text and values into one string and then condense it.
    concatenate <text> <value> into lv_sentence.
    condense lv_sentence.
    but another way is to use codes for displaying values in smartforms:
    This is from a smartforms PDF i have..
    Output Options for Field Contents
    Use the Formatting options to adapt the value of a field before printing it. You can enter the
    relevant parameters directly behind the field name. Make sure to write the short forms of the
    different options in uppercase letters. Some of the options can be combined.
    General Information
    The formatting options are not suited for all data types of fields (for example, for character fields
    you need no exponential representation). You must distinguish between numeric fields and
    character fields.
    Numeric Fields
      If specified, the system first evaluates the length (<length>).
      If no length is specified, the system displays the value in its overall length.
      The trailing blank indicates a positive sign. To suppress it, use formatting option S.
      Any offset <offset> specified is ignored.
    Sequence of evaluation: (<length>), sign to the left(<),Japanese date (L), suppress blanks (C),
    right-justified display (R), insert fillers (F).
    Character Fields
    By default, the system displays the value of a field in its overall length, but truncates trailing
    blanks.
    Sequence of evaluation: suppress blanks (C), <offset> and (<length>), right-justified display (R),
    insert fillers (F).
    Overview
    Formatting Options for Fields
    Syntax Description
    &field+<offset>& Skips <offset> places of the field value (character fields only). If the
    offset is greater than the length of the value, nothing is displayed.
    &field(<length>)& Sets the output length to <length>.
    &field(*)& If the field is defined by a Data Dictionary type, Smart Forms set the
    output length to the value specified there.
    &field(S)& Suppresses the sign
    &field(<)& Displays the sign to the left of the number
    &field(.<nat.number>)& Limits output of decimal places to <nat.number>
    &field(E<nat.number>)& Displays the field value with the fixed exponent <nat.number>. The
    mantissa is adapted to this exponent by shifting the decimal
    character and inserting zeros.
    SAP Smart Forms (BC-SRV-SCR) SAP AG
    Output Options for Field Contents
    72 April 2001
    &field(T)& Suppresses thousand indicators when displaying fields of types
    DEC, CURR, INT, and QUAN.
    &field(Z)& Suppresses leading zeros of numbers
    &field(I)& Suppresses display of initial values
    &field(K)& Deactivates a conversion routine specified in the Data Dictionary.
    &field(R)& Right-justified display. Use this option only when specifying an
    output length as well.
    &field(F<filler>)& Replaces left-justified blanks in the value by the fill character <filler>.
    &field(L)& Converts and a date field to a local date and displays it. The date is
    then formatted using edit mask JPDAT.
    Since this representation uses Japanese characters, use it in the
    Japanese version of the SAP System only.
    &field(C)& The system takes the field value as a sequence of words separated
    by blanks. Option C shifts these words to the left and leaves only
    one blank inbetween as separator. Any leading blanks are
    suppressed. This effect corresponds to that of the ABAP statement
    CONDENSE.

  • I want to eliminate leading zeros in a script

    Hi Friends,
    Pls guide me  iwant to eliminate the leading zeros in scipt  output pls guide me.
    Regards
    Jagadeeshwar.B
    Edited by: Alvaro Tejada Galindo on Jun 12, 2008 5:24 PM

    Hi,
    &SYMBOL(Z)&  will Suppress leading zeros in script.
    In report, In order to suppress the leading zeros of a number field the keywords used are : NO-ZERO.
    <REMOVED BY MODERATOR>
    Thanks and Rewards
    - Rishika Bawa
    Edited by: Alvaro Tejada Galindo on Jun 12, 2008 5:24 PM

  • How to remove leading zero in a inputfield

    I have a inputfield UI element which is bind to a NUM type context.  When it display a number, it always come with leading zero, like '001'. Can anyone teach me how to remove the leading zero.

    http://help.sap.com/saphelp_nw70ehp1/helpdata/en/3a/2232666aeb45f4b759848a4caf9c8b/frameset.htm
    Use the Display leading zeros formatting option in the context attribute properties.
    The other option is to use a data dictionary domain for the field that has a built in field conversion exit. The ALPHA conversion exit is commonly used on NUMC fields like Sales Order number to suppress leading zeros.  The WD runtime will automatically use the underlying DDIC Domain Field Conversion Exit.  You don't need to do anything except use that DDic to define the context.

  • SAP Script : Supresss Leading Zeros ...

    Dear All,
    In Bank Cheque SAP Script, I have to print Cheque Number, It is 13 charesters as SAP Standard, But we have only 8chars, So I have to Print only 8 chars ..remving leading zeros. Please advice me in doing that.
    Thank you.
    Regards
    Venkat

    Hi Venkat,
    Try this..
    /:  &SYMBOL(Z)&    --->Suppress leading zeros
    Or
    /: &SYMBOL(8.2)&    --->Decimal format. Length 8 decimals 2
    So you can use..
    <b>/: &SYMBOL(8.0)& Decimal format. Length 8 decimals 0</b>
    Message was edited by: Phani Kiran Nudurupati

Maybe you are looking for