BizTalk Best Practices | Tip and Tricks


Below is a list that needs to be remembered when developing BizTalk solutions.

BizTalk Orchestration:

XPath Expressions: 1. To do an XPath count:


countVariable = System.Convert.ToInt32(xpath(yourMsg, "count({XPATH Instance path,can be copied from Schema})"));

2. To extract a value using XPath (string):

stringVar = xpath(yourMessage, "string({XPATH Instance path,can be copied from Schema})")

BizTalk WCF-SQL Adapter:

When confronted with the problem about MSDTC issue, either due to cross domain or the actual MSDTC being disabled this adapter will still work by just setting the useAmbientConnection to FALSE

BizTalk mySAP Adapter:

1. RFC/BAPI function not returning any result.

When expecting a response from SAP via RFC or BAPI you always need to supply an empty node wherein you’re expecting a result. For example if the field is under the T_QAIVCTAB, in the mapping you need to generate this field by mapping a scripting functoid that returns empty string.

2. Set EnableSafeTyping to True

To avoid nasty data type issue when sending/receiving a response set this value to true in your binding. Data type error: An error occurred when trying to convert the byte array [30-00-30-00-30-00-30-00-30-00-30-00-30-00-30-00] of RFCTYPE RFCTYPE_DATE with length 8 and decimals 0 to XML format. Parameter/field name: Error message: Year, Month, and Day parameters describe an un-representable DateTime. —> System.ArgumentOutOfRangeException: Year, Month, and Day parameters describe an un-representable DateTime. at System.DateTime.DateToTicks(Int32 year, Int32 month, Int32 day) Configuration: Schema Generation: During the schema generation (WCF Consume Adapter Service) also set the Enable Safe Typing to TRUE.

3. BAPI_SALESORDER_SIMULATE.

– Be sure to pad the material number with leading zeroes up to length of 18.

public string PadMaterialNumber(string s)
{
string val = s.PadLeft(18, ‘0’);
return val;
}

BizTalk Mapping:

Microsoft.XLANGs.Core.XTransformationFailureException: Error encountered while executing the transform. Error:Transformation failed.. —> System.Xml.XPath.XPathException: Function ‘userCSharp:ConvertToDecimal()’ has failed. —> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. —> System.FormatException: Input string was not in a correct format.

1. Be careful in data conversion inside the mapping especially when using Scripting Functiod to convert values. One prime example is when you use the Convert.ToDecimal method. If you use this method and the value contains scientific notation ( 3.71615996396169E-02) it will throw an exception. The correct way of doing it is by using the Decimal.Parse method.

decimal d = Decimal.Parse("8.71615996396169E-02", System.Globalization.NumberStyles.Float);

SAP Schema Generation Error:

Error Message:

Error while retrieving or generating the WSDL. Adapter message: Details: ErrorCode=RFC_EXCEPTION. ErrorGroup=RFC_ERROR_APPLICATION_EXCEPTION. SapErrorMessage=SEGMENT_UNKNOWN.  AdapterErrorMessage=Error returned by RfcCallReceiveEx while calling RFC: IDOCTYPE_READ_COMPLETE..

Cause:

Idoc segment in SAP is not set to Released. Ask the SAP Team to check whether all segments are released.

BizTalk Deployment

Use BizTalk Deployment Framework (BTDF) to simplify deployment. BTDF can be downloaded from here. BTDF quick tutorial: https://randypaulo.wordpress.com/2012/01/13/biztalk-deployment-framework-btdf-tutorial-walkthrough/ Automating/Silent Install of BTDF using powershell here:  https://randypaulo.wordpress.com/2012/01/31/automating-silent-install-biztalk-deployment-framework-btdf-using-powershell/