BizTalk Map error - Decimal output

Hi Everyone,

I am facing issue in a mapping. 

The schema looks as follows :

Source :

Destination :



Liv - Repeating Record

Ava, Bva - Decimal Fields

I have to implement a logic, 

If sid = AB then mapping should not happen for Ava, Bva;

If it is anyother value in sid, then mapping should happen.

Input message

<Liv>
    <Ava>10.4</Ava>
    <Bva>10.4</Bva>
    <Pdt>
      <sid>AB</sid>
    </Pdt>
  </Liv>
  <Liv>
    <Ava>10.4</Ava>
    <Bva>10.4</Bva>
    <Pdt>
      <sid>AB</sid>
    </Pdt>
  </Liv>
  <Liv>
    <Ava>10.4</Ava>
    <Bva>10.4</Bva>
    <Pdt>
      <sid>si</sid>
    </Pdt>
  </Liv>
  <Liv>
    <Ava>10.4</Ava>
    <Bva>10.4</Bva>
    <Pdt>
      <sid>si</sid>
    </Pdt>
  </Liv>

Here mapping should not happen in the first two cases and should happen in the last 2

I have tried using not equal and value mapping functoid, but i am getting some error related to conversion.

Can any one help on this.

&#

September 11th, 2015 2:45am

Hi Anand,

Please try to use Scripting functoid, Equal functoid and Value mapping functoid. with Scripting functoid check the value of sid. and if it's true then map it with destination Ava,Bva.

Your map should look like below,

Free Windows Admin Tool Kit Click here and download it now
September 11th, 2015 3:05am

Hi Kamlesh,

Thanks for your reply ! It is working for positive scenario.

If Sid is not equal to AB and Ava is empty in the incoming message, I am getting the following error

 The 'Ava' element is invalid - The value '' is invalid according to its datatype 'http://www.w3.org/2001/XMLSchema:decimal' - The string '' is not a valid Decimal value.

September 11th, 2015 3:53am

Anand,

Please correct me if I am incorrect here,

If sid not equal to AB and value of Ava, Bva are not empty then Ava, Bva should map. 

If this is scenario then you need to put one more condition here, you need to check the null value of Ava and Bva with scripting functoid.

1. If Sid=AB then not Ava, Bva not map

2. If Sid != AB and (Ava and Bva are not empty) then should map.

Free Windows Admin Tool Kit Click here and download it now
September 11th, 2015 4:07am

One more check point, please check the datatype of Ava and Bva. Is it decimal ?

Then please take care that part also.

September 11th, 2015 4:11am

Yes your understanding is correct.

The datatype of Ava and Bva are decimal. So thats why the problem. Now I am getting some conversion error.

Since the output of the value mapping functoid is a string one.

I have tried a scritping functoid to convert to decimal, but sometimes i am getting an error when the Ava node is empty. 

Any help is much appreciated

Free Windows Admin Tool Kit Click here and download it now
September 11th, 2015 6:16am

Ok, then Please try to create map like below,

Check the input string value,

public bool CheckBlankString(string input) {
    return !string.IsNullOrEmpty(input) && input.Trim() != string.Empty; }
Convert input value to decimal,
public string FormatStrVal(string strVal) {
    var retStr = String.Empty;
    decimal dcmlVal = 0.00M; //Convert.ToDecimal(strVal);
    decimal.TryParse(strVal, System.Globalization.NumberStyles.Any, null, out dcmlVal);
    var intVal = (int)dcmlVal;
    retStr = dcmlVal == intVal ? intVal.ToString() : dcmlVal.ToString();

    decimal.TryParse(retStr, System.Globalization.NumberStyles.Any, null, out dcmlVal);
    return dcmlVal.ToString();
}
September 11th, 2015 6:27am

Hi Anand,

I tried the scenario and you can check if you are getting the required output:

Input Schema Used:

<?xml version="1.0" encoding="utf-16" ?> 
- <xs:schema xmlns="http://test.Source" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" targetNamespace="http://test.Source" xmlns:xs="http://www.w3.org/2001/XMLSchema">
- <xs:element name="Root">
- <xs:complexType>
- <xs:sequence>
- <xs:element maxOccurs="unbounded" name="Liv">
- <xs:complexType>
- <xs:sequence>
  <xs:element minOccurs="0" name="Ava" nillable="true" type="xs:decimal" /> 
  <xs:element minOccurs="0" name="Bva" nillable="true" type="xs:decimal" /> 
- <xs:element name="Pdt">
- <xs:complexType>
- <xs:sequence>
  <xs:element name="sid" type="xs:string" /> 
  </xs:sequence>
  </xs:complexType>
  </xs:element>
  </xs:sequence>
  </xs:complexType>
  </xs:element>
  </xs:sequence>
  </xs:complexType>
  </xs:element>
  </xs:schema>

Output Schema Used:

 <?xml version="1.0" encoding="utf-16" ?> 
- <xs:schema xmlns="http://test.Destination" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" targetNamespace="http://test.Destination" xmlns:xs="http://www.w3.org/2001/XMLSchema">
- <xs:element name="Root">
- <xs:complexType>
- <xs:sequence>
- <xs:element minOccurs="0" maxOccurs="unbounded" name="Liv" nillable="true">
- <xs:complexType>
- <xs:sequence>
  <xs:element minOccurs="0" name="Ava" nillable="true" type="xs:decimal" /> 
  <xs:element minOccurs="0" name="Bva" nillable="true" type="xs:decimal" /> 
- <xs:element minOccurs="0" name="Pdt">
- <xs:complexType>
- <xs:sequence>
  <xs:element name="sid" type="xs:string" /> 
  </xs:sequence>
  </xs:complexType>
  </xs:element>
  </xs:sequence>
  </xs:complexType>
  </xs:element>
  </xs:sequence>
  </xs:complexType>
  </xs:element>
  </xs:schema>


Map Used: 

Mapping Details:

  • Use a Not Equal Functoid and check if node "sid" is not equal to "AB"
  • Use 2 Value Mapping functoid and it will only execute return values if Not Equal functoid returns true.

Input Used:

Output:

You can always do modifcations and remove the Empty Liv node coming in the Output

Please indicate "Mark as Answer" or "Mark as Helpful" if this post has answered the question

Rahul

Free Windows Admin Tool Kit Click here and download it now
September 11th, 2015 7:37am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics