on 04-02-2008 6:07 AM
Hi Friends,
I have a requirement where i want to suppress leading zeroes of material number, when i send to external legacy system .
I can achieve this by using round function, but the problem is the material can be alphanumeric characters also. If i use Round function , it will support only in deleting leading zeroes.
How i can achieve both functionalities?
Any suggestions please..
Regards,
Vijay
Hi,
before mapping to the target field , add one UDF... and write logic to delete leading zero.
UDF: removeLeadingZero
code:
String b = a.replaceFirst("^0+", "");
return b;
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Write a UDF like this ..
public String remLeadZeros(String a,Container container){
String b = a.replaceFirst("^0+", "");
return b;
}
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I tryed with the given function, but ended with below error.
is anything missing ?
F:/usr/sap/XID/DVEBMGS02/j2ee/cluster/server0/./temp/classpath_resolver/Mapfe3717e2007511dd8649001a64268de4/source/com/sap/xi/tf/_MM_ArticleMaster_.java:202: illegal start of expression public String remLeadZeros(String a,Container container); ^ 1 error
Regards,
Vijay
Try using FormatNum
http://help.sap.com/saphelp_nw04/helpdata/en/2c/2d8c4024d26e1de10000000a1550b0/content.htm
Regards,
Prateek
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.