Mapping - leading zeros

Hello all,
I have the mapping program with simple UDF written to pad the number with ZEROS.  it is working good on the test mode, but at runtime it is not working, I am not getting leading zeros.
When I check my Input payload, I see leading zeros in the field.  But not seeing leading zeros in the target file even after using UDF.
Scenario is from ECC proxy to File, field is defined as string in the data type.
Any help is appreciated.
thanks..Hari

Hari Potti wrote:Hari,
>
> When I check my Input payload, I see leading zeros in the field.  But not seeing leading zeros in the target file even after using UDF.
I couldn't understand from the above statement. Actually the leading zeros will be padded only after the Message Mapping Pipeline , how come u able to see in Input Payload?
Can u please check the payload under Inbound Message, then check the payload under Request Message Mapping node. Reply back ur findings.
raj.

Similar Messages

  • HCI Mapping leading Zeros

    Hi, 
    I am mapping product_ID field from CRM IDoc to ReceiverID field in Cloud for customer web service field. ReceiverID is 40 character long field.
    Product_ID field is 7 to 10 characters long. I would like to append leading zeros using HCI function.
    HCI function Concat accept two static parameters index and count. I cannot append zeroes depending upon product_ID length dynamically. Is there any way I could do this mapping using HCI functions ?
    Thanks & Regards,
    Shrikant Kamble

    Hello Shrikant,
    Why don't you add number of zeros to the start of Product ID first and then use only the 10 characters from right end?
    Example: Product ID: 101, lets say we are adding 10 zeros, so the Concat 10 zeros, this will make the Product ID as 0000000000101. Then use Substring to pick on the required length string. (Note that I am just considering reqd length as 10, you can use as per your requirement).
    Hope this helps.
    Regards,
    Chandan

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

  • UDF for leading zero's in message mapping

    Dear team,
    I need UDF for leading zero's in my message mapping.
    Source and Target both structures contains matnr field.But we have to maintain total 18 chars at target matnr , because RFC in R/3 needed.So I want to add leading zero's when mapping. Can anybody provide the UDF code.
    Matnr[source]--->split by value(eachvalue) ->UDF->Matnr[Target]
    Ex::if source matnr conatains value "9846538" ; I need matnr value at target side like "000000000009846538"[total 18 chars].
    -Drumi

    Hi Ambrish,
    Good day...
    I have enterd what you said and I got below error... and I gave "input" in place of var1, 18 in place of filedlenght in below program...
    =================================
    int len = Integer.parseInt(18);
    int inputLength = input.length();
    try {
    Integer.parseInt(input);
    // If it is an integer, add 0 (len - inputLength) times
    for (int i=0; i< len-inputLength;i++)
        input = "0" + input;
    return input;
    } catch (NumberFormatException numForEx) {
    // return as it is, if alphanumeric
    return input;
    ====================================
    ERROR:
    Source text of object Message Mapping: Lubrisur_SHPMNT_SHPMNT05_TO_WMMBXY_WMMBID02_TransferPosting | urn:bp:xi:dwn:lu:common:Logistics:100 has syntax errors:
    Function LeadingZeros, Line 1:
    cannot find symbol symbol  : method parseInt(int) location: class java.lang.Integer int len = Integer.parseInt(18);                  ^ 1 error
    =======================
    Please suggest

  • 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

  • Remove leading Zeros from the mapped context node(Table)

    HI,
    I have he following requirement:
    In the Leave approval application , in the Approver worklist we have the coloumn to display the resuqester's Perner.
    The perner starts with leading zeros. We have to remove these leading zeros.
    I have refer the following threads:
    Removing leading zeros in a column
    How to remove leading zeroes of string
    and wiki document:
    https://www.sdn.sap.com/irj/scn/wiki?path=/display/java/remove%252bleading%252band%252btrailing%252bzeros%252bfrom%252ba%252bstring
    but I am not able to create the calculated attribute in the Mapped Node( NWDS is not allowing indicating it is not allowed for mapped nodes.)
    Any pointer how I can remove leading Zeros from existing column?
    If I create the calculated attribute outside the mapped node then it is taking only the first value of the mapped node.
    Please note we do not want to modify the RFC.
    _vishal

    Hi,
    Thanks for inputs,
    Now I created a test application where the original structure is as follows in the View Controller:
    1) Context -> Z_Portal_Test_Input (mapped Node/folder) -> IT_Tab_Input(mapped Node/folder) -> Eid(Mapped attribute)
    note: this attribute Eid has the values (01, 02,03,04,05)
    2)Context -> Z_Portal_Test_Input (mapped Node/folder) -> Output(mapped Node/folder) ->IT_Tab_Input(mapped Node/folder) -> Eid(Mapped attribute)
    Now as per your suggestion I created another node like this
    Context -> Z_Portal_Test_Input (mapped Node/folder) ->testnode(value node) ->testValue(value attribute)
    testnode cardinality is 1..1 and singlton = false
    In the Layout
    The tablecell editor  of one coloumn is mapped to text     Z_Portal_Test_Input.testnode.testvalue
    It is expected that this will show the values like(1,2,3,4,5) but it is showing value(1,1,1,1,1)
    The code of get method is:
      public java.lang.String getTestnodeTestvalue(IPrivateTestpernerView.ITestnodeElement element)
        //@@begin getTestnodeTestvalue(IPrivateTestpernerView.ITestnodeElement)
          String  msg =wdContext.nodeZ_Portal_Test_Input().nodeOutput().nodeIt_Itab().currentIt_ItabElement().getEid();
            return removeLeadingZeroes(msg);
        //@@end
    the functon removeLeadingZeroes(msg) is implemented as per the wiki link.
    What wrong I am doing/ missing....
    _vishal

  • Delete leading zeros for material in mapping.

    Hi,
    How to delete leading zeros for material like 0000000128736 if so I am expecting 128736 only.
    We need to consider if I get  material number is like RPG2389 .
    Thanks,
    Vinay.

    Hi,
    If you will be getting alphanumeric codes, it would be best to use a UDF with a regex-expression.
    UDF Type:
    ContextType
    imports:
    java.util.regex; (if you are using PI 7.1 you must remove the semicolon)
    arguments:
    input1
    Here's the code (courtesy of Sun Developer Network):
            Pattern p = Pattern.compile("[^a-zA-Z]");
            Matcher m = p.matcher(input1[0]);
            StringBuffer sb = new StringBuffer();
            boolean output = m.find();
            while(output) {
                m.appendReplacement(sb, "");
                output = m.find();
            m.appendTail(sb);
    result.addValue(input1[1]);
    Now to solve the leading zeroes, just add formatNumber: 0 after the UDF and it will work.
    Hope this helps,

  • 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

  • To remove leading zeroes and take directly from IDOC(Segment field) to file

    Hi SapAll.
    i have got a simple requirement in a idoc to file Interface.
    here in a sender Idoc there will be one segment with one field,the requirement is to remove leading zeroes and take directly the data from this field and map to one of the field in  reciever  file structure.
    i had used the formatnumber (under arithmatic functions)in PI 3.0 but now when iam using it in PI7.1 it was raising some jave exception error.
    it would be preferable if any body can give me the solution without user defined functions.
    regards.
    Varma.

    from your first post:
    i had used the formatnumber (under arithmatic functions)in PI 3.0 but now when iam using it in PI7.1 it was raising some jave exception error.
    use the same formatting that you used in 3.0 .... try with just a # in the FormatNum function.
    Regards,
    Abhishek.

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

  • Regarding the Elimination of leading Zeroes .

    Hi Experts,
    Iam new to XI.
    Iam doing a File to Idoc scenario (PO Response) ,
    I want to remove the leading zeroes from one of the field from file and map it to the corresponding Idoc field.
    Is there any Standard functions to do this ? If not , Can anyone pls post the code for UDF to execute this Logic.
    waiting for ur response.
    Thanks in Advance.
    Regards
    Krupa.

    say ur inptu to the udf is <b>inputVal</b> use the below code in UDF:
    String output = <b>inputVal</b>.replaceFirst("^0+","");
    return output;
    or also
    int Seq = Integer.parseInt(<b>inputVal</b>)

  • Add leading zero's function

    Hey,
    can anyone tell me what is the java function for add leading zero's in xi mapping.
    TX

    Hi Zevik,
    As other threads mentioned used FormatNum and double click and put Zeros. Like if the lenght is 10 then put 10 zeros. Here one thing you should analyse is, if your input value has a string value it will fail in FormatNum becuase it expects only the numeric value.
    So if you dont know whether your input has numeric or alphanumeric then go to UDF. So create a udf with name AddZeros and as Value with one argument as input.
    Imports:  java.*;
    Then add this code:
    int len=input.length();
    for(int i=0; i<10-len;i++)
    input="0"+input;
    return input;
    Here I am assuming the total length is 10. If yours is 20 then put 20 instead of 10 in the second line of the code.
    Regards,
    ---Satish

  • Char NUMC(5) - need to store value at database level without leading Zeros.

    Hi All
    We have 0Mat_Item like infoobjects in SAP BI, which have data type Char NUMC(5). Here if u load value '1', it would show us '1' at front end (BI or reporting level) but at database level stores as u201800001u2019.
    My requirement is to store this value without leading zeros at database level. I wrote code in transformation u201Cshift u2026 left deleting leading u20180u2019 u201C & could load the data into New data table and at database level as I was getting result without leading zero. But once I activate the request, it gives SID generation error u201CValue '1' of characteristic 0ME_XCHRATE is not a number with 000009 spaces.u201D
    How to solve this issue so that I could store u20181u2019 value instead of u201800001u2019 value in the database & could able to activate in DSO.
    Thanks....

    Hi.....
    System may be storing the data in that way to maintain consistency.
    Alpha conversion is used to store data consistently. It does this by storing numeric values prefixed with 0s Eg. If you have defined a material as length 6 (of type Numc) then material number 1 is stored as 000001 but displayed as 1; this removes inconsistencies between 01 vs. 001.
    U can add the conversion routine for this Infoobject in either below way...
    In the BW side...in the Datasource Level
    In the datasource >> Go to fields tab >> there search the R/3 field which is mapped to that Infoobject in the Transformation >> Then in the Conv.Routine column select the Alpha Conversion Routine and In the Format column select External....
    In the Transformation
    Write a field level routine for that particular field abd call the Alpha conversion routine there...
    In the R/3 side
    In the Customer exit ....Go to SE37 >> EXIT_SAPLRSAP_001 >> Double click on ZXRSAU01 >> search the datasource......write the code there....
    Hope below link helps you.
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/7108a690-0201-0010-4cbc-9bca94f9ad9c?quicklink=index&overridelayout=true
    Regards,
    Vinay.
    Edited by: Vinay Joshi on Mar 10, 2011 4:54 AM

  • 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

  • Padding with leading zeroes

    Hi All,
    I am using XSLT mapping.I want to get the field in the receiver side with the leading zeros.Source field: XSD:decimal and length is 10.If input is 12345, i have to get 0000012345.
    Can anybody please solve the problem and guide me if u know .

    Hi,
    you can use format-number function in this case...
    <xsl:template match="/">
    <number>
    <xsl:value-of select="format-number('5465','0000000000')"/>
    </number>
    </xsl:template>
    in this function first parameter is value which u want to format and second parameter is the format(in your case lenghth of ur string)
    Regards,
    Abhijeet

Maybe you are looking for

  • Windows 7 64 bit / Server 2012 R2 GUI - Type 4 Print Driver error "Cannot connect to the Printer" 0x00000002

    Hello,  We have multiple Server 2003 Print server and are working on testing a Server 2012 print server.  We have run into an issue where a PRINTER (type 4, normal) works with our Windows 7 32 bit clients, Windows 8.1 64 bit clients and the 2012 R2 s

  • Customize menu css

    I'm trying to change the background to a Menu inside a MenuBar. I was able to change the MenuItem's background, but there's this gap at the top and at the bottom of the menu which is still gray, and I can't seem to find a way to change it. This is my

  • Create cursor with data from multiple tables

    Hi, I need to create a cursor that contains fields from different tables. For example: Table 1                  Table 2                    Table 3                Table 4 Col 1 (PK)              Col 2 (Pk)                  Col 4 (Pk)            Col 9

  • ITunes has started to cause instability, help ?

    Hi, recently iTunes has started causing my Windows XP system problems. Sometimes, when I try to run it, it never opens. When that happens, I can't open other programs like Firefox or MS Word either. When I press Ctrl Alt Delete i see "iTunes.exe" is

  • Purchase Order notification

    Hi All, Whenever a supplier clicks on the reply-to in response to a purchase order notification from his mail box the mail goes to the Generic workflow mailer id. I have a requirement like whenever the supplier replies to a PO mail notification it sh