Skip to Content

UDF to read multiple values from multiple Lineitems in source sturcture

Hi Team,

we are working on pricing structures.The Input xml file is having multiple Line Items and each Line item contains multiple or one or none of the Pricingdetails.

Logic:

1) Need to create the target structure if the Type is "New"

2) TypeCode values in the target structure be as per the below logic.

if the Eligible is "true" and Type is "New" and Amount is "200" then the TypeCode is "000001"

if the Eligible is "false" and Type is "New" and Amount is "300" then the TypeCode is "000502"

if the Eligible is " " and Type is "New" and Amount is "400" then the TypeCode is "000505"

Please share the thoughts to build the UDF logic.

Input xml:

<Transaction>

<LineItem>

<Sale>

<Eligible>true</Eligible>

<Price>

<Type>Old</Type>

<Amount>100</Amount>

</Price>

<Price>

<Type>New</Type>

<Amount>200</Amount>

</Price>

</Sale>

</LineItem>

<LineItem>

<Sale>

<Eligible> </Eligible>

<Price>

<Type>New</Type>

<Amount>400</Amount>

</Price>

</Sale>

</LineItem>

<LineItem>

<Sale>

<Eligible>false</Eligible>

<Price>

<Type>New</Type>

<Amount>300</Amount>

</Price>

</Sale>

</LineItem>

</Transaction>

Expect -Output xml :<Transaction> <TypeCode>000001</TypeCode></Transaction><Transaction><TypeCode>000505</TypeCode></Transaction><Transaction> <TypeCode>000502</TypeCode></Transaction>

Thanks,

Ravi

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Mar 06 at 11:23 PM

    Thanks Team,

    we have resolved the issue by creating the 2 udfs(1 to capture only the Type-New & 2 - to remove empty context)

    Thanks,

    Ravi

    Add comment
    10|10000 characters needed characters exceeded

  • Mar 06 at 02:16 AM

    Dear Rajesh

    You can simply build this logic using graphical mapping using "if else" and "AND" node functions, if there are only 3 conditions to be checked.

    Thanks and Regards

    Sikander

    Add comment
    10|10000 characters needed characters exceeded

    • Hello Ravi

      Then this can be achieved by making use of Value Mapping Groups in Integration Builder.

      Example will be:- Source Agency = Source System name

      Source Scheme= Combination

      Target Agency= Target System NAme

      Target Scheme= Combination

      Source Value= true-new-200

      target value= 000001

      So the source value will be combination of the input parameters like eligible, type and amount and target value will be the typecode value

      You can create Value Mapping Groups based on the conditions you have in your Business Case(30+)

      Now in the message mapping, you create a udf, take the inputs from the source XML(

      eligible, type and amount) and create a string in the same format as stored in the VMG and return the string.

      Call the VMG node function and configure the parameters of the VMG you have created in the Integration Builder.

      Result of the UDF will be an input to the VMG and output of the XMG will be the value of the typecode

      Thanks and Regards

      Sikander