cancel
Showing results for 
Search instead for 
Did you mean: 

Which node function should I use in this mapping?

xinjiang_li
Active Participant
0 Kudos

Hi,gurus:

Our source data structure is like below

-


MT_SOURCE

--row <1..unbounded>

-


fileldA <1..1>

-


And the target data structure is like below

-


MT_TARGET

---record <1..unbounded>

-


item <0..unbounded>

-


fieldB <1..1>

-


fieldC <1..1>

-


If we have the following source data:

-


1001

1002

-


Then we want to have the following target data:

-


m

1001

n

1001

m

1002

n

1002

-


So,what node function should I use during graphic mapping?

Accepted Solutions (1)

Accepted Solutions (1)

jyothi_anagani
Active Contributor
0 Kudos

Hi ,

for this You need UDF's...

Map like this....


fieldA--->removeContext--->UDF1 ---->item
fieldA---->removecontext--->UDF1-->splitByvalue(each Value)---->fieldB
fieldA------->UDF3-------->fieldc

Code for UDF1


for( int i=0;i<filedA.length;i--)
{
result.addValue("m");
result.addValue("n");
}

Code for UDF3 is


result.addValue(fieldA);
result.addContextChange();
result.addValue(fieldA);

For these 3 UDFs select Context while creating

And for UDF1 & UDF2 , there is no input...

For UDF3 fieldA is input...

I have tested this code..Working fine...

You can use this now...

Sorry for before reply...I have changed my code now...

Use this code...

Thanks.

Edited by: Jyothi Anagani on Aug 20, 2009 2:41 PM

jyothi_anagani
Active Contributor
0 Kudos

Sorry for my modifications. By mistake I have Given some other code previously...

Now the code and Mapping are perfect...

Thanks.

xinjiang_li
Active Participant
0 Kudos

Hi,Jyothi ,

Thank you very much.

I will have a try this.

jyothi_anagani
Active Contributor
0 Kudos

In for loop instead of using i-- Use i++ and in UDF3 reult.addValue(fieldA[0]) ....

xinjiang_li
Active Participant
0 Kudos

Hi,Jyothi ,

I have tested the UDF 3, but it throwed errors like:

-


addValue(java.lang.String) in com.sap.aii.mappingtool.tf3.rt.ResultList cannot be applied to (java.lang.String[]) result.addValue(a);

-


And could you tell me the code of UDF2?

FOR UDF1 AND UDF2 ,there are no input parameters,but in your code there are input parameters,I don't know how to deal with it.

Thanks .

jyothi_anagani
Active Contributor
0 Kudos

Hi xinjiang li ,

Please check my code properly, There is no UDF2 only UDF1 and UDF3 are there..and for these 2 UDF's input is there that is fieldA....Please look at my previous replies....I have tested today also...That is working fine...Let me know for any other issues...

Thanks.

Former Member
0 Kudos

Hi Xin,

Jyothi code looks proper try it onec again with modification .

Answers (2)

Answers (2)

markangelo_dihiansan
Active Contributor
0 Kudos

Hi XinJiang,

Actually, the mapping is just one-to-one. No need to use node functions unless the actual structure you've provided is different.

For the item use this mapping:

row --> item

For field b, use this mapping:

fieldA --> fieldB

hope this helps,

xinjiang_li
Active Participant
0 Kudos

Hi,Mark,

They are not one-to-one.

I have fiieldB and fieldC in target data structure,and a record of source data generate two record of target data.

Any ideas?

markangelo_dihiansan
Active Contributor
0 Kudos

Hi XinJiang,

The mapping for item is correct, it should be creating two items, As for the other values, use the node function splitByValue(each Value) when trying to map them to fieldB or field C.

Hope this helps,

xinjiang_li
Active Participant
0 Kudos

Any one can help me ?Thanks in advance.

former_member181962
Active Contributor
0 Kudos

Where are the values m and n coming from?

xinjiang_li
Active Participant
0 Kudos

Hi,

m and n are constants.

Actually,they are "WE" and "AG",that means partner role.