cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping Logic

Former Member
0 Kudos

Hi ,

I have scenario, where in mapping I need to have a condition.. where the fields are not mandatory.

Below is the my Source XML:

<?xml version="1.0" encoding="UTF-8" ?>

<INVENTORYINTERFACE>

<DOCUMENT>

<SAPFUNCTIONALITY>CONSUMPTION</SAPFUNCTIONALITY>

<BLDAT>07.29.2011</BLDAT>

<BUDAT>07.29.2011</BUDAT>

<FileName>test.xml</FileName>

<MATERIALDATA>

<MATNR>1000000000</MATNR>

<BATCHDATA>

<CHARG>123456789</CHARG>

<WERKS>1000</WERKS>

<ERFMG>186.10</ERFMG>

<ERFME>KG</ERFME>

<ID>1</ID>

<FLAG>Y</FLAG>

</BATCHDATA>

</MATERIALDATA>

</DOCUMENT>

</INVENTORYINTERFACE>

Here if ID or Flag is not there then I need to process.

And If ID exists then I need to check for the Flagexistsa or not... if any of then is missing then I need to fail the mapping

How can I do so?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Hareen,

id -> exits(true) -> constant(true) -> equals ->if (then)-> check -> exits -> constant(true) -> equals -> target msg

thanks,

Former Member
0 Kudos

HI Bhavanisankar,

you logic fails when ID and Flag does not exist.

Former Member
0 Kudos

hi,

first u dont write ur logic ,

u try this

1.id -> 2.exits(true) -> 3.constant(true) -> 4.equals ->5.(first)if (then)

-> 6.check -> 7.exits -> 8.constant(true) -> 9. equals -> 10.(second)if -> target

if Check fail (second)(if) then -> constant -> target msg

if Id fail (first )if-else ->constant -> target

thanks,

Former Member
0 Kudos

HI Bhavani,

Your logic worked.

Thanks a lot!!!!!

Answers (3)

Answers (3)

Former Member
0 Kudos

Resolved

PriyankaAnagani
Active Contributor
0 Kudos

Hi,

If both ID and flag exists then only map your target message type.

ID> exists->IF-true>check Flag>Exists>IFtrue-->map target message whose occurrence is 1.

Regards,

Priyanka

Former Member
0 Kudos

HI Priyanka / Ramesh,

I have 3 different conditions in my mapping.

1. If ID and Flag does not exist then I should be able to map to the target fields without those fields.

2. If ID and flag exists then I should be able to process the messages with having those fields in the target.

3. If any of the ID and Flag field is missing in the source then I need to fail the mapping.

Former Member
0 Kudos

Hi,

1. If ID and Flag does not exist then I should be able to map to the target fields without those fields.

2. If ID and flag exists then I should be able to process the messages with having those fields in the target.

3. If any of the ID and Flag field is missing in the source then I need to fail the mapping.

>>>

You write the condition for 1 and 2 one. For third one you dont need any check because you are checking for 2 possibilites out of 3.

IF (ID exists) and IF (FL exists)

OR -


> Create Target Node

IF (ID not exisit) and IF (FL not exists)

regards

Ramesh

Edited by: Ramesh P on Dec 2, 2011 4:11 PM

PriyankaAnagani
Active Contributor
0 Kudos

Hi,

It means you've perform XOR operation..... you can try with below UDF...use java XOR operator (^).

Fist use exists function for ID and flag and pass it as inputs to UDF and map the UDF to target messagetype

UDFCode:

int var1,var2;

if(input1.equals("true"))

var1 = 1;

else

var1 = 0;

if(input2.equals("true"))

var2 = 1;

else

var2 = 0;

int res = var1 ^ var2;

if(res == 1)

return true;

else

return false;

Regards,

Priyanka

Former Member
0 Kudos

Hareen,

Map your required condition to the root of the target message type.

If ID (node function) exists and If flag exists create your root target node!

Regards

Ramesh