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

推荐订阅源

Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
爱范儿
爱范儿
小众软件
小众软件
阮一峰的网络日志
阮一峰的网络日志
Recent Announcements
Recent Announcements
雷峰网
雷峰网
Last Week in AI
Last Week in AI
I
InfoQ
Google DeepMind News
Google DeepMind News
GbyAI
GbyAI
The Cloudflare Blog
aimingoo的专栏
aimingoo的专栏
量子位
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Blog — PlanetScale
Blog — PlanetScale
F
Full Disclosure
D
DataBreaches.Net
S
SegmentFault 最新的问题
Hugging Face - Blog
Hugging Face - Blog
MyScale Blog
MyScale Blog
美团技术团队
V
V2EX
Jina AI
Jina AI
T
The Blog of Author Tim Ferriss
T
Tailwind CSS Blog
MongoDB | Blog
MongoDB | Blog
腾讯CDC
Vercel News
Vercel News
A
About on SuperTechFans
J
Java Code Geeks
Martin Fowler
Martin Fowler
V
Visual Studio Blog
博客园_首页
酷 壳 – CoolShell
酷 壳 – CoolShell
Recorded Future
Recorded Future
M
MIT News - Artificial intelligence
WordPress大学
WordPress大学
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
U
Unit 42
Engineering at Meta
Engineering at Meta
F
Fortinet All Blogs
Microsoft Azure Blog
Microsoft Azure Blog
P
Proofpoint News Feed
人人都是产品经理
人人都是产品经理
Y
Y Combinator Blog
云风的 BLOG
云风的 BLOG
博客园 - 三生石上(FineUI控件)
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
The GitHub Blog
The GitHub Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

博客园 - 寒天飞雪

项目中用到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