今天上午 在.net 中创建 Bapi_Customer_Getdetail2 再读取sap 的customer的相关信息,测试不成功,Customer 10030 在SAP SE37 中没问题,但在.net 的web page 测试页却拿不到数据,原因是在调用BAPI 的过程中能输入的参数有严格的位数限制, 在SAP 的表 KNA1 中 KUNNR, Customer 的位数是10 位,所在就要写采用在前面补0 的功能,
.net 的class 中创建如下function 将参数进行格式化:
Private Function FormatStringZW(ByVal p_str As String, ByVal p_len As Integer) As String
Dim len As Integer
len = p_str.Length
FormatStringZW = p_str
While len < p_len
FormatStringZW = "0" + FormatStringZW
len = len + 1
End While
End Function
再次测试通过!
本文介绍了解决在.NET中调用SAP BAPI_Customer_Getdetail2时遇到的参数位数不足的问题。通过在.NET代码中实现字符串前导补零功能,确保了与SAP中KNA1表KUNNR字段位数一致,最终实现了从SAP成功获取客户信息。
3556

被折叠的 条评论
为什么被折叠?



