on 09-25-2008 10:15 AM
Hi,
I have the following situation.
The source structure contains a field that can be up to 4000 characters long,
The target structure contains a field than has a length of 132.
These fields have to be mapped with each other but how can I split the field of 4000 characters
into several lines of 132 characters long?
kind regards Maarten
Hi,
while (sourceStr.length()>132)
{
String resultStr=sourceStr.substring(0,132);
sourceStr = sourceStr.substring(132);
(or) sourceStr = sourceStr.substring(132,sourceStr.length());
resultList.addValue(resultStr);
// This is for checking the last characters if it is 10 or 20 or ... then we have to add that also.
if(sourceStr.length() < 132)
resultList.addValue(resultStr);
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Maarten,
Is it Fixed that you will always have 4000 Charcters in input?
If yes then i think you have to create 31 duplicates of your target Field and each will hold 132 charcters and finally you have to concate all of them.
For that you have to make the udf given bye Santosh bit generic you should take another input which will isntruct the code which part of the substring to be inserted .
For e.g if it is 1 st chunk of 132 char then give 1 as input it will pass 132 char of 4000 char to the duplicated Target field and so on...
Thanks
Sunil Singh
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 do this with a UDF.
Create a advanced UDF of type Context and use the following code.
while(a[0].length() >132)
{
String tem = a[0].substring(0,132);
a[0] = a[0].substring(132,a[0].length());
result.addValue(tem);
}
Note that this UDF splits only for the first occurance of the source field i.e. a[0] if you require for all the occurance loop through the source field and also the single target field should have a unbounded occurance.
Thanks
SaNv...
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.