cancel
Showing results for 
Search instead for 
Did you mean: 

mapping help

Former Member
0 Kudos

Hi all,

I am doing a message mapping with source and target as same idoc. The requirement is as follows.

The target field in the idoc has a field colno. It should be 10,20,10,20 and so on based upon the incoming idoc.

ie, if an idoc is coming in XI, then colno. should be 10.

for the next idoc, its value should be 20 and so on.

I am planning to do this logic in message mapping by taking idoc number as reference.

ie, if idocnumber divided by 2 =0, then colno=10 else colno = 20.

How can i implement this in the message mapping?

The idoc number is in EDIDC40-docnum field.

its occurence is 0..1. Its already mapped to docnum in the target.

So if i map it again with the colno, there would be an error, right? How can i resolve this?

Thanks in advance,

Deno

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Deno

You can achieve this by writing your own simple java function which will do this logic for u, in the mapping.

and u wont get an error even if u use the same field for another mapping.

Regards

Sunita

Former Member
0 Kudos

Hi all,

Thanks for all ur replies. I made a small mistake in the previous mail. I would need something like this.

Suppose an idoc which has docnum 1234 is coming into XI, then colno should be 10.

For the next idoc whose docnum would be 1235, colno should be 20.

For the next idoc whose docnum would be 1236, colno should be again 10.

and so on..

How can i write a java function or use message mapping without java function? Can anybody send some logic?

Thanks,

Deno

MichalKrawczyk
Active Contributor
0 Kudos

Hi,

try this code in the Simple java function:

=======================================================

boolean idocdocnum;

try {

int j = new Integer(a).intValue();

idocdocnum = (j % 2 == 0);

} catch (NumberFormatException e) {

idocdocnum = false;

}

if (idocdocnum)

{

return 10;

}

else

{

return 20;

}

=======================================================

I can't check this in the XI right now but I you can try it

Regards,

michal

Former Member
0 Kudos

Hi Michael,

Thanks for the code. When i put this in XI simple function, I am getting the following errors.

Source code has syntax error:

/usr/sap/DXI/j2ee/cluster/server0/./temp/classpath_resolver/Map62c4e340d81a11d993ab0002556f6363/source/com/sap/xi/tf/_test_.java:2167: incompatible types

found : int

required: java.lang.String

return 10;

^

/usr/sap/DXI/j2ee/cluster/server0/./temp/classpath_resolver/Map62c4e340d81a11d993ab0002556f6363/source/com/sap/xi/tf/_test_.java:2171: incompatible types

found : int

required: java.lang.String

return 20;

^

2 errors

Hope you can help me again..

Thanks,

Deno

MichalKrawczyk
Active Contributor
0 Kudos

try this end:

if (idocdocnum)

{

return "10";

}

else

{

return "20";

}

regards,

michal

Former Member
0 Kudos

Hi Michael,

That was a great help..Its working fine.

Thanks a lot.

Deno

MichalKrawczyk
Active Contributor
0 Kudos

no problem Deno:)

Regards,

michal

MichalKrawczyk
Active Contributor
0 Kudos

Hi,

you can do it in the "Advanced Java function" and SplitByValue for sure but I don't understand the 10,20,10,20

but try using Advanced Java function and standard if statement inside

Regards,

michal

Former Member
0 Kudos

Hi Deno,

I have implement the same using XSLT mapping. Its very easy using the 'position()' function in XSLT. With message map, you have to write a user defined function to take all the idocs as inputs and inside the 'for' loop you have to build ur logic and set the context properly.

rgds,

Sasi