今天上午 在.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
再次測試通過!