on 12-09-2009 5:36 AM
Hi Gurus,
I have a special requirement .
The number of target segments should be created based on the source field length .
To be more precise on the requirement I have the source segment S and under that I have the field S1 . On the target side I have segment T and under that I have the target field T1 . Occurence of T segment is 0 to unbounded.
If the length of S1 is < 50 then only one T segment should be created and the S1 value should be appeared in T1 .
For eg. If the length of S1 is 110 characters long then T segment should be created 3 times and first occurence of T1 should have the first 50 characters and second occurence of T1 should have the characters from 51 to 100 and the third T1 should have the characters from 101 to 110 . Also the min length of S1 is 0 and max length is 500 . Can anyone help me out .
Thanks & Regards,
Sarat
Hi Sarat,
You need a udf for this.
inputfield --> UDF--> outputfield
Advanced udf on queue mode
String output =null;
for (int i=0;input.length;i++) {
if (input<i>.length()>0){
if (input<i>.length()<50)
result.addValue(input<i>);
else{
for (int j =0; j<input<i>.length();j++) {
result.addValue(input<i>.substring(0,50);
input<i>= input<i>.substring(50, input<i>.length());
}
result.addValue(input<i>);
}
}
}
PS: I have not tested the code there might be some syntax error
Regards
Suraj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Suraj,
Thanks for the reply . But S1 occurs only once and the key here is to create the T segments based on the length of the S1 field . Can you please tell me how can we acheive this .
I used the mapping -
S1-length---divide (constant[50] given as 2nd argument) -
> output value number of times I have to create the T segment . How can we achieve this ? And in each corresponding T segment I should have the corresponding values in T1 , T2 , . . . depending on the length of S1 .
Regards,
Sarat
Hi Suraj,
A small correction in the udf that you gave -
for (int i=0;i<input.length;i++) {
if (input<i>.length()>0){
if (input<i>.length()<50)
result.addValue(input<i>);
else{
for (int j =input<i>.length()/50; j>0;j--) {
result.addValue(input<i>.substring(0,50));
input<i>= input<i>.substring(50,input<i>.length());
}
//result.addValue(input<i>);
}
}
}
This is working correctly !!! Thanks once again for the help.
Regards,
Sarat
User | Count |
---|---|
83 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.