惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
SegmentFault 最新的问题
V
Vulnerabilities – Threatpost
博客园_首页
GbyAI
GbyAI
Martin Fowler
Martin Fowler
S
Secure Thoughts
Help Net Security
Help Net Security
Attack and Defense Labs
Attack and Defense Labs
大猫的无限游戏
大猫的无限游戏
量子位
腾讯CDC
博客园 - 叶小钗
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Microsoft Security Blog
Microsoft Security Blog
Cisco Talos Blog
Cisco Talos Blog
V
V2EX
P
Proofpoint News Feed
T
Tailwind CSS Blog
U
Unit 42
A
Arctic Wolf
PCI Perspectives
PCI Perspectives
B
Blog
F
Fortinet All Blogs
B
Blog RSS Feed
H
Hacker News: Front Page
P
Privacy & Cybersecurity Law Blog
Scott Helme
Scott Helme
G
GRAHAM CLULEY
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
H
Heimdal Security Blog
人人都是产品经理
人人都是产品经理
Forbes - Security
Forbes - Security
TaoSecurity Blog
TaoSecurity Blog
N
Netflix TechBlog - Medium
aimingoo的专栏
aimingoo的专栏
Security Archives - TechRepublic
Security Archives - TechRepublic
Y
Y Combinator Blog
Jina AI
Jina AI
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Latest news
Latest news
P
Privacy International News Feed
SecWiki News
SecWiki News
L
LINUX DO - 最新话题
M
MIT News - Artificial intelligence
W
WeLiveSecurity
博客园 - 聂微东
T
Tor Project blog
T
Troy Hunt's Blog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Engineering at Meta
Engineering at Meta

博客园 - 寒天飞雪

项目中用到Excel上传到Sql数据库 转载: 房贷的两种还款方式介绍 RFC访问SAP(C#) VB.net连接SAP实例(vb.net写法) Winform 树型菜单例子 - 寒天飞雪 - 博客园 介绍: MRP和MPS 收藏: SQLServer的存储结构 转载: 正则表达式介绍 .net 连接ORACLE 数据库的例子 - 寒天飞雪 转载: ReportViewer : RDLC自定义工具栏 C#调用iTextSharp组件生成PDF文件, 在VS2005下已经调试通过! SQLSERVER 2005 BI的帮助文档说明: 9.2 定义和浏览翻译 9.1 定义和浏览透视 8.1 定义操作 7.1 定义关键指标KPI 6.3使用脚本命令定义作用域分配 6.2 定义命名集 6.1 定义计算成员
VB.net连接SAP实例 - 寒天飞雪 - 博客园
寒天飞雪 · 2009-03-30 · via 博客园 - 寒天飞雪

最近在研究vb连接SAP的例子, 终于可以正常登录SAP通过RFC读取SAP中的数据。

下面是具体的代码:

vb6.0写法:

'定义公共变量

Public Connect As Object
Public Functions As Object

'登录SAP
Private Sub Command1_Click()

   '创建ocx对象
    Set Functions = CreateObject("Sap.Functions.unicode")

   'Sap.Functions.unicode 不加unicode的话无法正常显示中文。这和登录时Language的设置没有关系

   '是因为字符集的原因。

   '设置连接信息
    Set Connect = Functions.Connection
    Connect.ApplicationServer = "172.18.95.173"
    Connect.Client = "169"
    Connect.Language = "ZH"
    Connect.User = "CRMDEV69"
    Connect.Password = "654321"
    Connect.SystemNumber = 7
    Connect.System = "CD2"
   
    If Not Connect.Logon(0, True) Then
      MsgBox "登录失败"

      Command1.SetFocus
    Else 

      Command1.Enabled = False
      MsgBox "登录成功"

    End If
End Sub

'调用RFC的写法

Private Sub Command2_Click()
  Dim GetCustomers As Object
  Dim Customers As Object
  Dim i As Integer

 '所要调用的RFC名称
 Set GetCustomers = Functions.Add("ZCSMS_GET_HRINFO")

 '传递的输入参数名称并赋值

  GetCustomers.Exports("BEGDAFROM") = ""
  GetCustomers.Exports("BEGDATO") = ""
  GetCustomers.Exports("MILL") = "7960"
  GetCustomers.Exports("NUMBERFROM") = "0061500001"
  GetCustomers.Exports("NUMBERTO") = "0061500080"
 
  '执行后返回的Table,相当于二维数组
  Set Customers = GetCustomers.Tables("THR")

 '简单的MsgBox弹出以查看值 

 If GetCustomers.Call Then
    For i = 1 To Customers.RowCount
      MsgBox Customers(i, "MILL")
      MsgBox Customers(i, "PERNR")
      MsgBox Customers(i, "NAME1")
      MsgBox Customers(i, "STEXT")
    Next i
  Else
    MsgBox " 函数调用失败" + GetCustomers.exception
  End If
End Sub