on 12-22-2008 11:09 AM
Hi All,
From source more then 300 chars description length field receiving (Source_Description1 : 0 ....unbound ), but have to split into 60 chars for each field and map to target fields as below.
Source_Description1 -
Target Desription1 ( 1 to 60 )
Target Desriptions2 ( 60 to 120 )
Target Desriptions3 ( 120 to 180 )
Target Desriptions4 ( 180 to 240 )
Target Desriptions5 ( 240 to 300 )
I have tried using substring its fulfilling the first option only (1 to 60 ).
Can any one help to sending the JAVA mapping code for above scenario, itu2019s highly appreciated.
Thanks & Regards,
Vijay.
Standard functions are enough for your case. For rest of the target elements, you need to use "indexOf" funtion. e.g. for second target elelment, find the index of 61st character using function mentioned and then use substring till next 60 characters.
Regards,
Prateek
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
public void getSplittedText(String[[]] a,ResultList result,Container container){
for(int i = 0; i< a.length; i++)
{
String[[]] temp=new String[(a[<i>].length()/60)+1];int k=0;
for(int j=0;j<a[<i>].length();j+=60)
{
if (j+60 <= a[<i>].length())
temp[k] = a[<i>].substring(j,j+60);
else
temp[[k]] = a[<i>].substring(j,a[<i>].length());
result.addValue(temp[[k]]);
k++;
}
}
}
text->getSplittedText()>SplitByValue-->Target
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Selvam,
Thanks a lot for you help., bewlow code working fine for 1 to 60 char length , but for 60 to 120 char length where can I change the logic to read the 120 to 180 , 180 to 240 lenghts ..etc for other targets nodes . I have changed the some logic but am not fulfilling the requirement..,
//write your code here
for(int i = 0; i< a.length; i++)
{
String[ ] temp=new String[(a<i>.length()/60)+1];int k=0;
for(int j=0;j<a<i>.length();j+=60)
{
if (j+60 <= a<i>.length())
temp[k] = a<i>.substring(j,j+60);
else
temp[k] = a<i>.substring(j,a<i>.length());
result.addValue(temp[k]);
k++;
}
}
-
Requirement as like:
I would get the 100, 244, 55, 300 lengths string from a source field.
I have to chunk /divide the string length as 60, 40 (if length is 100 char) map the target fields for tstring1 (60) , tsring2(40).
If 244 length fields , tstring1(60),tstring2(60),tstring3(60),tstring4(60),tstring5(4),
If 55 length ->tstring1 (55) ,u2026etc
Thanks
Vijay.
Hi Selvam,
Thanks a lot for your help, but below code fulfilling the only for first target node.
I may get a string length from source 100, 55,244,130 chars...etc.
Have to map to target fields as
If string length is100 char Sfield (100), then map to target for Tfield1 (60), Tfield2 (40).
If source string length is Sfield(55) char, then map to target for Tfield1 (55),
If source string length is Sfield(244) char , then Tfield1(60),Tfield2(60), Tfield3(60),Tfield4(60),Tfiled5(4).
If source string length is 170 char , then Tfield1(60),Tfield2(60), Tfield3(10).
-
//write your code here
for(int i = 0; i< a.length; i++)
{
String[ ] temp=new String[(a<i>.length()/60)+1];int k=0;
for(int j=0;j<a<i>.length();j+=60)
{
if (j+60 <= a<i>.length())
temp[k] = a<i>.substring(j,j+60);
else
temp[k] = a<i>.substring(j,a<i>.length());
result.addValue(temp[k]);
k++;
}
}
--
pl let me know , in case you required more info.
Thanks
Vijay.
You should opt Advanced UDF
function myudf(String a, ResultList result, Container container)
{
String [[]] temp = null;
temp = a.split(" ");
for (int i = 0 ; i < temp.length ; i++) {
result.addValues(temp<i>);
}
make targe node as o..unbounded.
source msg> myudf>splitbyByValue(each Value)>CollapseContext>Target node
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
81 | |
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.