on 01-08-2011 10:27 AM
Hi frnds,
i have to map to fields
Source: Target:
Texto(256 max length) -
> Txt_Line(132 max length) with occurance 0:6
If the Texto field from source side contains more than 132 chars length text then it has to create another Txt_line field on target side..
Ex: if a text of 256 chars comes it has to create two Txt_line fields on Target of 132 and 124 size resp..
Hello,
This is possible via UDF.
Texto(256 max length) -
> Txt_Line(132 max length) with occurance 0:6
Here is the mapping:
Textto --> UDF --> splitByValue:eachValue --> Txt_Line
UDF is of context type
Argument: input
StringBuffer sb = new StringBuffer(input[0]);
double cnt = Math.ceil((double)input[0].length()/132);
for(double b=0;b<cnt;b++){
if(sb.length()<132)
result.addValue(sb.toString());
else
{
result.addValue(sb.substring(0,132).toString());
sb= new StringBuffer(sb.substring(132,sb.length()));
}
}
Hope this helps,
Mark
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Mark your UDF worked thanks for that. But there was an updation in requirement now
The present reqrmnt is
the TXT_line occurance is changed to 0:1
and the node in which it comes on the output has to repeated ..
ex: If the no.of chars are greater than 132 then output should be like
>Text(Node in which the element exist)
--Txt_line(first 132 chars)
>Text
--Txt_line(Chars greater than 132 should be there)
Kindly Help me on this..
Hi,
Use UDF : Advance Type
Steps to perform in UDF is :
Find length of String ,
Substring it aftet every 124 Characters .
Then using addValue add it into ResultList Type result Element , One by One ..
So Now ur result of UDF Contains all Substring element in different Index.
Simply Pass it to Target Side , There is no need to Use SplitByValue .. Because SplitBy value is used Only When you want to change the Index.
Do You want UDF also for this ... ??
Regards
Prabhat Sharma.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi King Kiran,
Can you please follow the below Mapping for ur condition.
First duplicate the target field which u want.
Now here is the maping.
Sourcefield--->length
less(text function) if without else----
> Target Field1
Constant 132 source field
for duplicated i.e the output for more than 132 fields u have to follow below mapping
Sourcefield--->length
greater(text function) if without else----
> Target Field2
Constant 132 source field
Thanks,
Enivass
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Check the length of the string (text_to) if it is greater than 132 then use substring(0,132) and map to target1..
and substring (132,..) remaining to the another target field..
I am not sure whether lenght function is there or not ..if not UDFcan be used..
HTH
Rajesh
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 | |
6 | |
6 | |
6 | |
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.