Skip to Content
avatar image
Former Member

Mapping Logic

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?

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Best Answer
    avatar image
    Former Member
    Dec 02, 2011 at 10:31 AM

    Hi Hareen,

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

    thanks,

    Add comment
    10|10000 characters needed characters exceeded

  • Dec 02, 2011 at 10:18 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

    • 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

  • avatar image
    Former Member
    Dec 02, 2011 at 10:15 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Dec 02, 2011 at 10:57 AM

    Resolved

    Add comment
    10|10000 characters needed characters exceeded