cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping, splitting linen in several lines

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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);

}

Answers (2)

Answers (2)

sunil_singh13
Active Contributor
0 Kudos

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

santhosh_kumarv
Active Contributor
0 Kudos

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...