cancel
Showing results for 
Search instead for 
Did you mean: 

Append values from multimapping (Visual Mapping)

Former Member
0 Kudos

Is it possible to create the following mapping in Visual Mapping?

Source

-


<rows>

<row>

<field>Value1</field>

</row>

<row>

<field>Value2</field>

</row>

</rows>

Target

-


<data>

<field>Value1,Value2</field>

</data>

Accepted Solutions (0)

Answers (2)

Answers (2)

STALANKI
Active Contributor
0 Kudos

write simple advanced user defined function with cache entire queue which accepts field1 and then just use the "+" to concatenate into another variable and use result.addValue().

Former Member
0 Kudos

Hi Sergey

You can use the concat function.

cheers

Sameer

Former Member
0 Kudos

Hi Sergey,

It is poosible to do this mapping using user defined function. Create a user defined function and pass <field> as a input to a user defined function. with in your user definned function loop though the all <field> values and concatenate the value in position1 and position2 seperated by ',' and map it to target structure field.

There is another way you can achieve this is using standard copyValue and Conactenate functions.

you need single mapping from source field to target field

Step 1. copyValue - input source <field> and set properties position '0'

Step 2. copyValue - input source <Field> and set properties

position '1'

Step 3. Conacatenate - input = output of steps 1 and 2 and properties ','.

Step 4. target <field> - map the output of step 3 to target field.

Just make sure that you have set the context of source <field> to <rows> for both the approaches.

also check this for more info on copyValue function

http://help.sap.com/saphelp_nw04/helpdata/en/26/d22366565be0449d7b3cc26b1bab10/content.htm

Regards

Anand

Message was edited by: Anand Torgal

Former Member
0 Kudos

Row eleemnt has 0..unbounded occurecies.

I don't know exatly how many row are in XML

Former Member
0 Kudos

Then go for the first approach. In your user defined function simply loop through all the values and concateante each value to the target field seperated by comma and add to your result list after the loop.

Source <field>(context <rows>) -> User Defined Function

-> target <field> .

Regards

Anand

Former Member
0 Kudos

I have developed the code:


StringBuffer valueToConcat = new StringBuffer(""); 
for ( int i = 0; i < a.length; i++ )   {
       valueToConcat.append(a[ i]);
       valueToConcat.append(",");

}
  result.addValue( valueToConcat.toString() );

But result is

Value1,__cC_,Value2

Could you explain me what is <b>__cC_</b> ?

Message was edited by: Sergey A

Former Member
0 Kudos

Hi Sergey,

Use this code...

String str = "";

for(int p=0;p<a.length;p++)

{

str += a[p] + ',' ;

}

result.addValue(str);

Also check the context of source field if it is set properly, the context changes are also getting conactenated.

thats why you see __cC_.

__cC_ means the context change.

I hope you not checked the check box 'Save Entire Queue in Cache' while creating the advanced user defined function..

Regards

Anand

Message was edited by: Anand Torgal