cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping issue: Split a string to multiple strings in an idoc

Former Member
0 Kudos
235

Hi,

I need to split a string with an undefined length into strings of 132 chars. The problem is, how to map from the source field to the target field,

which belong to an idoc segment. The segment has the occurence 1 to unbounded, and the field 0 to 1. Simplifying, i need to map one source field split it in 132

chars block and put the resultant blocks into an idoc field (maxLength = 132).

-


IDoc

-


Segment X

-


...

-


Segment (occurence 1..unbounded)

-


Field X

Source field SourceA (undefined length)----->-----Field TargetA (occurence 0..1) (maxLength = 132)

-


Segment Y

-


...

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Ok...here is one way of achiving what u want - hope ur comfortable with working with context mapping...

Raise the context of ur source field one level higher and write a UDF funtionto do this -

Declare an array list

Read the source string and append it to the arraylist.

Then when u map ur target IDOC text...read from this array list and created ...By maintaining the context...there will be as many segments in the idocas there are in the arraylist..

regards,

arvind R

Former Member
0 Kudos

Hi Jose,

You can achieve this via writing a simple UDF in your mapping.

Thx

Pooj

Former Member
0 Kudos

I developed a UDF, that returns an array with multiple blocks of 132 char, however, only the first one map wtih the target.

Can you give me some more information to solve my problem?

Thanks.

Former Member
0 Kudos

Jose,

Create a Context user defined function AddNode. Have one argument input and add this code:

String str=input[0];

while(str.length()>132)

{

result.addValue(str.substring(0,132));

str=str.substring(132,str.length());

}

result.addValue(str);

Also check this thread for more information:

Regards,

---Satish

Former Member
0 Kudos

Combine the Arvind Ravindran answer with Satish Reddy answer and we have the solution.

Thank you both.