on 08-27-2008 4:47 PM
Hi,
In my IDOC to File interface, I have a requirement to split and format a data string which I plan to do with a UDF.
Input string would be UPTO 10 characters long.
1. I need to insert '-' exactly after the 4th character of the input string
2. Then I need to remove any leading zeroes from this new string
Example:
Input string: "001234567890"
Output:"12-34567890"
Appreciate if you could let me know of any code snippets to sort this out.
Many thanks
Shirin
Hi,
Try this.
A simple one
public String ins(String a,Container container)
{
//write your code here
if(a.length() > 0)
{
String c = a.substring(0,4);
String d = a.substring(4,a.length());
String e = c + "-"+ d;
String f = e.replaceAll("^0*","");
return f;
}
else
{
return a;
}
src->ins-->target
Edited by: malini balasubramaniam on Aug 28, 2008 8:19 AM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Int len = input.length();
If(len > 4)
{
String a1=input.subSequence(0,4).toString();
a1=a1+"-";
String a2=input.subSequence(4,len).toString();
return a2;
}
else return input;
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ramesh,
Even Im having a similar situation, Suppress leading zeroes and place a decimal before the last two digits.
Input string : 000000552
Output : 5.52
I tried the below code...but No luck ... im getting the error as shown in fig1.
Int len = input.length();
If(len > 7)
{
String a1=input.subSequence(0,7).toString();
a1=a1+".";
String a2=input.subSequence(7,len).toString();
return a2;
}
while(z.startsWith("0"))
{
y=z.replaceFirst("0","");
}
else return input;
fig1:
12:30:49 Start of test
Source code has syntax error: /usr/sap/XD1/DVEBMGS20/j2ee/cluster/server0/./temp/classpath_resolver/Mape6ad98e0745d11dd940e00144f0ed0fa/source/com/sap/xi/tf/_B2P_mm_.java:102: ';' expected { ^ 1 error Source code has syntax error: /usr/sap/XD1/DVEBMGS20/j2ee/cluster/server0/./temp/classpath_resolver/Mape6ad98e0745d11dd940e00144f0ed0fa/source/com/sap/xi/tf/_B2P_mm_.java:102: ';' expected { ^ 1 error
12:30:58 End of test
Thanks
- Ravi
User | Count |
---|---|
80 | |
9 | |
9 | |
7 | |
7 | |
6 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.