on 11-16-2007 6:58 AM
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI Nishu,
Can you please mark this thread as answered if the purpose is done?
Also reward points.
Regards
Aashish Sinha
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Agreed with you but it depends upon the requirement you have. I guess we can also provide the more fields if it the same or may be we can reuse it if it happening regularly.
Writing an UDF is always a good solution but why don't we try some different solutions also to check the performance of system?
Regards
Aashish Sinha
Hi nishu,
I dont think ther is any standard function for this , but u can write ur <b>User Defined Function</b> or u can use <b>If Else</b> condition or apply some logic for this .
hope this will help
regards
HONEY
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI Nishu.
You just defined the maximum permissible length of that field as you requirement.
Then test it.
The values specified for the size category and data class are mapped to database-specific values via control tables.
for your knowlegge base
*rewards pointsif you thing it will help you.*
Regards
Sumit Gupta
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
Use format number or write a udf for the same.
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Write Simple UDF:
Steps Create the UDF : <b>removeLeadingZeros</b> with one parameter (String a)//
and paste the below code in that and save it. then map
source -removeLeadingZeros-target
if (a == null)
{
return null;
}
char[] chars = a.toCharArray();
int index = 0;
for (; index < a.length(); index++)
{
if (chars[index] != '0')
{
break;
}
}
return (index == 0) ? a : a.substring(index);
It will solve your problem:)
Thanks
*Rewards Points if you find it useful*
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.