on 08-01-2011 10:24 AM
Hi,
My Interface is outbound Interface.
Suppose source field named 'Filename' is mapped with Target field named 'Filename'.Condition is AS IS(Left justified, right blank/space filled).
How should i do this mapping?
Try this UDF. Another way of doing this
public String leftJustifiedRightSpace(String input) {
int fieldLength = 20; // decide for your field length
input.trim();
for(int count=0;count<fieldLength;count++){
input=input+" ";
}
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 Sanghamitra Duttagupta,
you can try this UDF below
public static String fieldJustified(String s)
{
try
{
final int fieldLength=20;
char filler=' ';
s=s.trim();
int l=s.length();
while(l<fieldLength)
{
s=s+filler;
l++;
}
}
catch(Exception e)
{
return s;
}
return s;
}
Please reset the value of the variable "fieldLength", in code above to the field length as per your need. The right side will be filled with extra spaces since value of "filler" variable is ' '. you can set this to any character of your choice so that total field length is equal to value of variable "fieldLength" (which is 20 here).
so if input is " hi"
output "hi "
regards
Anupam
Edited by: anupamsap on Aug 1, 2011 1:53 PM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
If you do not have any specific length or white space preservation requirement, it will be a straight forward 1:1 mapping.
If you want to remove whitespace, use the standard trim function.
For left\right justify the value to a specific length. go for a simple udf, that checks the length and then adds the required number of spaces as per the requirement.
Regards
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 concatenate the needed number of spaces to your source field.
If source value starts with spaces you want to remove, use trim function before concatenation.
If length of source value is dynamic you can concatenate with enough spaces and then use substring to get the wanted target length.
Regards,
Giuseppe
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
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.