|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Sub export()
- Set R3 = CreateObject("SAP.Functions.unicode")
- R3.Connection.System = "XXX"
- R3.Connection.ApplicationServer = "XXXXXXX"
- R3.Connection.Client = "XXXX"
- R3.Connection.SystemNumber = "00"
- R3.Connection.User = "XXXXXXX"
- R3.Connection.password = "XXXXXXX"
- R3.Connection.Language = "ZH"
- ''有中文汉字或中文字符的话,需要设置代码页,否则可能出现乱码
- 'R3.Connection.Codepage = "8400″"
- If R3.Connection.logon(0, True) = False Then
- MsgBox "连接失败"
- Exit Sub
- End If
- '添加RFC名称
- Set MyFunc = R3.Add("Z_WFM_GET_VENDOR_DETAIL")
- '设置输入参数
- Set oParam1 = MyFunc.exports("VENDOR_NUMBER")
- oParam1.Value = [A2].Value
- Set oParam2 = MyFunc.exports("BUKRS")
- oParam2.Value = "ZS10″"
- Set oParam3 = MyFunc.exports("EKORG")
- oParam3.Value = "ZS10″"
- '执行远程调用
- Result = MyFunc.CALL
- If Result = True Then
- '设置table参数
- Set VENDOR = MyFunc.Tables("VENDOR")
- ' Set bank = MyFunc.Tables("BANK")
- '设置返回参数
- ' Set oParam2 = MyFunc.exports("E_RETURN")
- Else
- MsgBox MyFunc.EXCEPTION
- R3.Connection.LOGOFF
- Exit Sub
- End If
- '注销登录
- R3.Connection.LOGOFF
- '使用循环处理table参数
- For i = 1 To VENDOR.RowCount
- Set Row = VENDOR.Rows(i)
- Cells(4, 1) = Row.Value("KTOKK")
- Cells(4, 2) = Row.Value("VENDOR")
- Cells(4, 3) = Row.Value("BUKRS")
- Cells(4, 4) = Row.Value("EKORG")
- Cells(4, 5) = Row.Value("NaME")
- Cells(4, 6) = Row.Value("NaME2")
- Cells(4, 7) = Row.Value("STREET")
- Cells(4, 8) = Row.Value("COUNTRY")
- Cells(4, 9) = Row.Value("CITY")
- Cells(4, 10) = Row.Value("SORT1")
- Cells(4, 11) = Row.Value("SORT2")
- Cells(4, 12) = Row.Value("LaNGU")
- Cells(4, 13) = Row.Value("POSTL_COD1")
- Cells(4, 14) = Row.Value("aDR_NOTES")
- Cells(4, 15) = Row.Value("TEL_NO")
- Cells(4, 16) = Row.Value("TELEX_NO")
- Cells(4, 17) = Row.Value("E_MaIL")
- Cells(4, 18) = Row.Value("FaX")
- Cells(4, 19) = Row.Value("STCEG")
- Cells(4, 20) = Row.Value("WaERS")
- Cells(4, 21) = Row.Value("INCO1")
- Cells(4, 22) = Row.Value("INCO2")
- Cells(4, 23) = Row.Value("ZTERM")
- Cells(4, 24) = Row.Value("LFaBC")
- Cells(4, 25) = Row.Value("EKGRP")
- Cells(4, 26) = Row.Value("aKONT")
- Next
- End Sub
复制代码 |
|