on 08-04-2009 1:09 PM
Hi Experts,
I am doing proxy to file scenario.
my requirement is like this, i need to add ~ symbol for each fieldbefore sending to receiver.
if the field length eqal to 12 the target field must be like this.
if the field is contains 6 characters the remaining characters must be filled with spaces and after hat i need to add ~ symbol.
~978976 ~
How can achieve this, can anyone help me.
Kind regards,
Praveen.
Edited by: Praveen Kumar on Aug 4, 2009 1:09 PM
I am not sure if I understood it correctly but can't you use Concat function directly?
Can you explain further your requirement?
Regards,
Prateek
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
if the field length is 12, but the value is 123456
concat is adding the symbol like this tilt123456tilt
but i want like this : ~123456 ~ (~123456 four spaces ~)
is concat possible to do this???
Edited by: Praveen Kumar on Aug 4, 2009 1:21 PM
Edited by: Praveen Kumar on Aug 4, 2009 1:21 PM
Edited by: Praveen Kumar on Aug 4, 2009 1:21 PM
i am getting this error when i use this code.
return ("" + String.format("%10s" , a) + "");
Source code has syntax error: /usr/sap/CXD/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Map9b43d3a081b911dea2f200144f2b5900/source/com/sap/xi/tf/_MM_SapIsuToFile_.java:101: cannot resolve symbol symbol : method format (java.lang.String,java.lang.String) location: class java.lang.String return ("" + String.format("%10s" , a) + ""); ^ 1 error
Hi,
In my understand String.format standard function will support JDK1.5 onwards. Lower version will not support. So,check in your jdk version before use that standard function.
So another way use this code,
UDF header like this,
Public String <udf name>(String a, Container container))
Inside UDF put this code:
int strLen = a.length();
for(int i=strLen;i<12;i++)
{
a = a + " ";
}
return "~" + a + "~";
Note: . Example: in this code field length is using 12. becaz we mentioned that loop i<12. If what you need put it instead of 12.
Hope It's working fine .
Regards
Vijaykumar
Hi
You can use Format num standard function and concat function along with some mapping manipulation.
Format num function will help to define lenght of 12
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
FormatNum is not supported to this requirement. Becaz Number format is Right justified, how to put extra spaces in right side.
So , only solution is to achieve this issue for using UDF. Your jdk version is 1.5 or above means using String.format which is given by praveen or else using my above code.
Regards
Vijaykumar
Hi Praveen,
You create one UDF using this code.
int strLen = a.length();
for(int i=strLen;i<12;i++)
{
a=a+" ";
}
return ""a"";
Sourcefield -
> UDF -
> TargetField.
I hope it's help for you.
Regards
Vijay
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
You can use string concat standard function
~SaNv..
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.