外部程序调用BAPI应注意输入参数的位数...

今天上午 在.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


再次测试通过! 

posted on 2007-12-26 10:33  封起De日子  阅读(91)  评论(0编辑  收藏  举报

导航