on 06-03-2015 9:17 AM
Hi Experts,
I have a requirement where i need to concat 4 fields as an input to get the desired reuslt.
Input1- fix length
Input2 - fix length
Input3- Variable length
Input4- Variable length.
I want the desired output of input3 to be of length 10 and and of input4 to be of length 18.
If the length is less than the desired output it should add spaces in the end.
For eg;
Input1-3300
Input2-01
Input3-JPOW
Input4-SEMISOFT COAL
Than utput need to be 330001JPOW SEMISOFT COAL
Can you please suggest how to achieve this?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Eng,
The logic worked for me .
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Try the below UDF
input - input field
length - what length you need
int l = Integer.parseInt(length);
int itf = 0;
if(input.length<l)
{
itr = l - input.length;
for(int i=0;i<itr;i++)
{
input = input + " ";
}
}
return input;
Check the syntax as I did not wrote the code in editor.
regards,
Harish
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
80 | |
24 | |
11 | |
9 | |
7 | |
6 | |
5 | |
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.