cancel
Showing results for 
Search instead for 
Did you mean: 

Map entries of a table on several 0..1 nodes

Former Member
0 Kudos

Hello Gurus!!

I have to map the next structures, I hope somebody could guide me.

Source

<FIELDS> 0..2

-


<NAME>

-


<VALUE>

</FIELDS>

Target

<DATA> 0..1

-


<NAME1>

-


<VALUE1>

-


<NAME2>

-


<VALUE2>

<DATA>

An example could be:

Source

<FIELDS>

-


<NAME>COLOUR</NAME>

-


<VALUE>Green</VALUE>

</FIELDS>

<FIELDS>

-


<NAME>SIZE</NAME>

-


<VALUE>9X12</VALUE>

</FIELDS>

Target

<DATA> 0..1

-


<NAME1>COLOUR</NAME1>

-


<VALUE1>Green</VALUE1>

-


<NAME2>SIZE</NAME2>

-


<VALUE2>9X12</VALUE2>

<DATA>

I hope will be clear enough.

Thanks and regards,

Manuel.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Why don't you go for XSLTor an UDF

Thanks,

Vijaya.

Former Member
0 Kudos

write it this way..

write an UDF...

select context among value context and queue...

and declare 'a' as a string array..

Since you used context you get names into 'a'.

udf1:

String code = new String();

code = a[0];

result.addValue(code);

udf2:

String code = new String();

code = a[1];

result.addValue(code);

so now map name-udf1-name1.

and now map nameudf2name2.

Check if it works..

Reward if helps..

Thanks,

Vijaya.

Former Member
0 Kudos

Hello Vijaya,

Your answer sounds very well, but there is a thing that I don´t understand:

'select context among value context and queue'.

Could you explain me this phrase, please??

Thank you very much,

Manuel.

Former Member
0 Kudos

Hi,

While creating the UDF..

You have those radio buttons..

Value,context and queue..

Value is opted for simple udfs and remaining are for advanced UDfs..

Hope its clear..

reward if helps..

Thanks,

Vijaya.

Former Member
0 Kudos

Hello Vijaya,

In the UDF2 I have coded this:

String code = new String();

code = a[1];

result.addValue(code);

And I got the next exception:

RuntimeException in Message-Mapping transformation: Runtime exception during processing target field mapping /ns0:Messages/ns0:Message1/D32_MATERIAL/MATERIAL/UNIDPR. The message is: Exception:[ java.lang.ArrayIndexOutOfBoundsException: 1] in class com.sap.xi.tf._MM_MAT_IDoc_2_Necora_ method GetUnidpr$[ ]

The UDF1 has been sucessfully executed.

Do you know what could be the error?

I guess must be a problem with the cardinality.

Thanks and regards,

Manuel.

Former Member
0 Kudos

Hi Manuel..

This might be because there is no second value(a[1]) .i.e..

only one occurance of fields node..

<FIELDS>

-


<NAME>COLOUR</NAME>

-


<VALUE>Green</VALUE>

</FIELDS>

not present

*<FIELDS>*

*----<NAME>SIZE</NAME>*

*----<VALUE>9X12</VALUE>*

*</FIELDS>*

*so add a condition in th second udf..*

If (a.length = 2)

then only return a[1].

Hope this is clear..

please reward if helps...

thanks,

Vijaya

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Manuel,

Have u tried with the above udf's ?

I'm not getting the output.Could u pls suggest vijaya.....Where is the problem..

Regards,

Radhika.

Former Member
0 Kudos

have ypu imported java.lang.*;

Thanks,

Vijaya.

Former Member
0 Kudos

Hi Manuel,

Have u tried with the above udf's ?

I'm not getting the output.Could u pls suggest vijaya.....Where is the problem..

Regards,

Radhika.

Former Member
0 Kudos

Hi Mauel,

U have to select context.Since there is a return value, result should be there.

Regards,

Radhika.