使用包含 SharePoint 的 SAP 适配器时的注意事项
本主题包含有关将用于 mySAP Business Suite 的 Microsoft BizTalk Adapter 与 Microsoft Office SharePoint Server 一起使用的问题以及解决方法的信息。 此问题分为两个类别:
常规问题
涉及自定义 Web 部件的问题
一般问题
本部分包含无解决方法,或者需要修改应用程序定义文件以进行解析的问题。
问题1:不显示 WCF 服务返回的简单类型数据
说明: Microsoft Office SharePoint 服务器要求 WCF 服务返回的数据仅为数据集或集合类型。 如果 WCF 服务返回的数据为简单类型,则 Microsoft Office SharePoint 服务器不会显示数据。
解决方法:无解决方法。 这是 Microsoft Office SharePoint 服务器的已知限制。
问题2:如果 WCF 服务返回的数据为 NULL,则显示一条错误消息
说明:如果 WCF 服务返回的数据为 NULL 值,则 Microsoft Office SharePoint 服务器将显示错误消息。 例如,假设您使用的是 Finder 方法实例的业务数据列表 Web 部件,并且要在 SAP 系统中搜索基于搜索表达式的客户。 指定的搜索表达式将提取 NULL 值。 在这种情况下,Microsoft Office SharePoint Server 将显示一条错误消息。
解决方法:无解决方法。 这是 Microsoft Office SharePoint 服务器的已知限制。
问题3:不显示 WCF 服务返回的简单类型的数组
说明:如果 WCF 服务返回的数据是一个简单类型的数组,Microsoft Office SharePoint 服务器不会显示该数据。 此外,在 Business 数据目录定义编辑器中执行返回简单类型数组的方法实例时,将显示以下错误消息: "后端系统适配器返回的结构与相应的元数据 (MethodInstance、Parameter 或 TypeDescriptor) 相同。"
解决方法:无解决方法。 Microsoft Office SharePoint Server 和 Business 数据目录定义编辑器具有已知的限制。
问题4:无法导入包含包含300个以上字段的复杂类型参数的应用程序定义文件
说明: Microsoft Office SharePoint 服务器无法导入在 WCF 服务返回的复杂类型参数中包含300个以上字段的应用程序定义文件,如果您尝试这样做,将显示一条错误消息。 这是因为不能显示复杂类型参数300多个字段的 Microsoft Office SharePoint 服务器的限制。
解决方法:使用 Business 数据目录定义编辑器将复杂类型参数的字段数目限制为小于或等于300。 根据您的要求,您可以在 Business 数据目录定义编辑器中删除复杂类型参数的字段,而不需要在 Microsoft Office SharePoint 服务器中显示这些字段。 另外,还可以使用所有字段从 Business 数据目录 definition 编辑器导出应用程序定义文件,然后在记事本或任何 XML 创作应用程序中修改应用程序定义文件,以删除不需要的字段,以将字段数限制为300。
涉及自定义 Web 部件的问题
本节包含需要使用自定义 Web 部件进行解析的问题。 有关使用自定义 web 部件解决在使用 sap 适配器和 Microsoft Office SharePoint 服务器时可能出现的问题的详细信息,请参阅将自定义 Web 部件与 sap 适配器配合使用。
问题1:在基于多个值 Microsoft Office SharePoint 服务器中显示单个记录的限制
说明:如果想要基于多个值在 Microsoft Office SharePoint Server 中显示单个记录 (从 SAP 系统) 输入参数,则不能使用步骤3:创建 Web 部件中指定的三个 (业务数据列表、业务数据项和业务数据相关列表中的任何一项) 用于在教程1:从 sap 系统中获取数据的应用程序在 SharePoint 站点上检索数据。
解决方法:必须使用自定义 Web 部件来执行此操作。 有关使用自定义 Web 部件的信息,请参阅 将自定义 Web 部件与 SAP 适配器配合使用。 在该主题的 "步骤1:创建自定义 Web 部件" 中,可以在步骤5中使用以下代码示例。 下面的代码示例将 BankCountry 和 BankKey 作为输入参数,然后将它们显示为 Microsoft Office SharePoint Server 中的单个记录。
namespace CustomWebPart
{
public class CustomWebPart : WebPart
{
private string displayText = "Hello World!";
[WebBrowsable(true), Personalizable(true)]
public string DisplayText
{
get { return displayText; }
set { displayText = value; }
}
protected override void Render(System.Web.UI.HtmlTextWriter writer)
{
string BankCountry = "US";
string BankKey = "134329042";
/***Step 1: Get the required entity and method.***/
LobSystem newSystem = ApplicationRegistry.GetLobSystems()["BAPI_BANK_GETDETAIL"]; // Name specified in application definition file
LobSystemInstance newSystemInstance = newSystem.GetLobSystemInstances()["BAPI_BANK_GETDETAIL_Instance"]; // Name specified in application definition file
Entity CategoryEntity = newSystem.GetEntities()["Entity"]; // Name specified in application definition file
Method newMethod = CategoryEntity.GetMethods()["BAPI_BANK_GETDETAIL"]; // Name specified in application definition file
MethodInstance methodInstance = newMethod.GetMethodInstances()["MethodInstance"]; // Name specified in application definition file
/***Step 2: Get the list of input parameters.***/
Object[] args = methodInstance.GetMethod().CreateDefaultParameterInstances(methodInstance); //Get the default values of the input parameters.
Object[] ArgsInput = new Object[args.Length];
/***Step 3: Assign them required values.***/
Type t = null;
char[] myString = BankCountry.ToCharArray();
String s = new String(myString);
t = s.GetType();
ArgsInput[0] = Activator.CreateInstance(t, myString);
myString = BankKey.ToCharArray();
s = new String(myString);
t = s.GetType();
ArgsInput[1] = Activator.CreateInstance(t, myString);
/***Step 4: Execute the particular method instance using the required value.***/
IEntityInstance IE = (IEntityInstance)CategoryEntity.Execute(methodInstance, newSystemInstance, ref ArgsInput); //Method instance of type Specific Finder is being used here.
/***Step 5: Display the output on the custom Web Part in Microsoft Office SharePoint Server.***/
writer.Write("<table>");
writer.Write("<tr>");
foreach (Field f in CategoryEntity.GetFinderView().Fields)
{
writer.Write("<td>");
writer.Write(IE[f]);
writer.Write("</td>");
}
writer.Write("</tr>");
writer.Write("</table>");
}
}
注意
应用程序定义文件必须包含 特定的 Finder 方法实例。 特定 Finder方法根据标识符查找特定记录。 有关创建特定 Finder方法实例的信息,请参阅第2步:在第2步:创建 sap Artifacts 的应用程序定义文件中的 "要求2:从客户列表中检索特定客户的详细信息" 中的步骤2:在SharePoint 站点上从 sap 系统中呈现数据。
问题2:无法指定数组元素的值
说明:如果 WCF 服务的输入参数为数组,则不能使用在使用 Business 数据目录定义编辑器创建的应用程序定义文件中定义的筛选器指定数组元素的值。 这意味着不能在 Microsoft Office SharePoint Server 中使用业务数据列表或业务数据项 Web 部件来指定这些输入参数的值 (数组) 元素到 WCF 服务。 这是因为在应用程序定义文件中定义数组的方式。
解决方法:使用自定义 Web 部件为数组元素赋值。 有关使用自定义 Web 部件的信息,请参阅 将自定义 Web 部件与 SAP 适配器配合使用。 例如,你可以在步骤3中使用以下代码示例: "问题1:在 Microsoft Office 中显示单个记录 SharePoint 服务器基于多个值",为数组元素赋值。
/***Assign required values to parameters of type array.***/
/***Assumption is that the ith parameter of Method is of type Array and all the simple type elements in the array are of string type.***/
Type t = asm.GetType(args[i].GetType().ToString()); // Get type of the parameter
Type TElement = t.GetElementType(); // Getting type of element of array
int index = 5; //Size of Array
Array ElementArray = Array.CreateInstance(TElement, index); //Creating an array of length: index
for (int ind = 0; ind < index; ind++)
{
//Creating an instance of an element of array
object ElementType = Activator.CreateInstance(TElement);
FieldInfo[] FI = ElementType.GetType().GetFields();
for (int f = 0; f \< FI.Length; f++)
{
ElementType.GetType().GetFields()[f].SetValue(ElementType, (Object)"ElementValue");
}
ElementArray.SetValue(ElementType, ind);
}
ArgsInput[i] = (object)ElementArray; // As shown in sample, ArgsInput is fed as input while executing Method Instance
问题3:将 NULL 值指定为复杂类型参数的限制
说明:如果没有从 Microsoft Office SharePoint Server 中的 Web 部件指定复杂类型参数的任何值,则应将 NULL 作为复杂类型参数的值传递给 WCF 服务。 但是,为复杂类型参数传递了一个非 NULL 值,并为其子元素 (了简单类型) 的 NULL 值。 这会导致预期消息架构和传递给 WCF 服务的消息架构不匹配。 因此,SAP 适配器可能会显示一条错误消息。
注意
若要在 SharePoint 服务器 Microsoft Office 中从 Web 部件传递无值时,查找复杂类型参数的默认值,请在 "问题1:根据多个值在 Microsoft Office SharePoint 服务器中显示单个记录的限制" 中所述的代码示例中,使用步骤2。
解决方法:使用自定义 Web 部件向复杂类型参数分配 NULL 值。 有关使用自定义 Web 部件的信息,请参阅 将自定义 Web 部件与 SAP 适配器配合使用。