VB.NET 连接 SAP RFC(SAP Connection 3.0)

  

SAP 3.0 定义: 

    引用:SAP.Middleware.Connector

    引用文件:sapnco,sapnco_utils

    Public Destination As RfcDestination     'SAP Connector3.0 的RFC源
    Public SapFunction As IRfcFunction       'SAP RFC函数调用

    Public table As IRfcTable                          '调用到的RFC SAP table

 

SAP 3.0 配置连接类:(也可以放在APP.Config里面)

  Public Class MyConfig
        Implements IDestinationConfiguration   '继承接口

        Public Function ChangeEventsSupported() As Boolean Implements SAP.Middleware.Connector.IDestinationConfiguration.ChangeEventsSupported
            Return False
        End Function

        Public Event ConfigurationChanged(destinationName As String, args As SAP.Middleware.Connector.RfcConfigurationEventArgs) Implements SAP.Middleware.Connector.IDestinationConfiguration.ConfigurationChanged  '事件

        Public Function GetParameters(destinationName As String) As SAP.Middleware.Connector.RfcConfigParameters Implements SAP.Middleware.Connector.IDestinationConfiguration.GetParameters
            Dim parms As RfcConfigParameters = New RfcConfigParameters()
            If ("dev_000".Equals(destinationName)) Then
                parms.Add(RfcConfigParameters.AppServerHost, "11,11,11,11")  'SAP主机IP
                parms.Add(RfcConfigParameters.SystemNumber, "00")  'SAP实例
                parms.Add(RfcConfigParameters.User, "user")      ' 用户名
                parms.Add(RfcConfigParameters.Password, "123")  '密码
                parms.Add(RfcConfigParameters.Client, "300")       ' Client
                parms.Add(RfcConfigParameters.Language, "EN")      '登陆语言
                parms.Add(RfcConfigParameters.PoolSize, "5")
                parms.Add(RfcConfigParameters.MaxPoolSize, "10")
                '  parms.Add(RfcConfigParameters.IdleTimeout, "60")

               parms.Add(RfcConfigParameters.Codepage, "8400")   ‘中文编码
                Return parms
            ElseIf ("prd_000".Equals(destinationName)) Then
                parms.Add(RfcConfigParameters.AppServerHost, "11,11,11,11")  'SAP主机IP
                parms.Add(RfcConfigParameters.SystemNumber, "00")  'SAP实例
                parms.Add(RfcConfigParameters.User, "user")      ' 用户名
                parms.Add(RfcConfigParameters.Password, "123")  '密码
                parms.Add(RfcConfigParameters.Client, "800")       ' Client
                parms.Add(RfcConfigParameters.Language, "EN")      '登陆语言
                parms.Add(RfcConfigParameters.PoolSize, "5")
                parms.Add(RfcConfigParameters.MaxPoolSize, "10")
                '  parms.Add(RfcConfigParameters.IdleTimeout, "60")

             parms.Add(RfcConfigParameters.Codepage, "8400")   ‘中文编码
                Return parms
            Else
                Return Nothing
            End If
        End Function

    End Class

 

SAP3.0 连接SAP

    Public Sub ConnectSAP()

        Dim ID As IDestinationConfiguration = New MyConfig()         '继承
        RfcDestinationManager.RegisterDestinationConfiguration(ID)

        Try
            If GetSapValue = "DEV" Then
                Destination = RfcDestinationManager.GetDestination("dev_000")          '连接SAP, SAPConnector 3.0方式 DEV SYSTEM

            ElseIf GetSapValue = "PRD" Then
                Destination = RfcDestinationManager.GetDestination("prd_000")          '连接SAP, SAPConnector 3.0方式 PRD SYSTEM
            End If
        Catch ex As Exception
            MyMsgBox("提示", ex.Message.ToString)
            Exit Sub
        End Try

    End Sub

 

SAP 3.0 使用:

        Try
            SapFunction = Destination.Repository.CreateFunction("YRFC001")     '建立一个函数对象
            SapFunction.SetValue("P_MATNR", txtMaterialNo.Text)                    '传递参数
            SapFunction.SetValue("P_WERKS", "1000")

            SapFunction.Invoke(Destination)                                        '激活提交

            GetTable = SapFunction.GetTable("YTABLE")                   '返回表 The backend has added one more line to it.
                Catch ex As Exception
            MyMsgBox("提示", ex.Message.ToString)

            Exit Sub
        End Try

 

SAP 3.0客户端运行库:

     NCo303_Net40_x86    FOR.NET 4.0

 

相关文档:NCo_30_ProgrammingGuide

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
.NET 4.0 是微软公司开发的一种应用程序框架。它提供了开发和运行多种类型应用程序的环境,包括 Web 应用程序、服务、Windows 应用程序等。它是微软所提供的一种全面的开发平台,并提供了丰富的类库和工具,支持多种编程语言,如C#、VB.NET等。.NET 4.0 可以帮助开发人员快速、高效地开发应用程序,并提供了良好的可扩展性和性能。 SAP RFCSAP(系统、应用与产品)公司提供的一种远程功能调用接口(Remote Function Call)。它允许外部系统通过远程方式与SAP应用程序进行通信和交互。通过SAP RFC,外部系统可以调用SAP应用程序中的功能模块,并传输相关的数据。这样,外部系统可以与SAP系统集成,实现数据的共享和交换。同时,SAP RFC也可以用于在SAP系统内部进行模块之间的通信。 .NET 4.0 和 SAP RFC 可以结合使用,以实现.NET应用程序与SAP系统之间的集成。通过.NET 4.0所提供的丰富功能和灵活性,可以使用.NET编程语言(如C#)开发用于与SAP系统进行通信和交互的应用程序。同时,通过使用SAP RFC,可以调用SAP系统中的功能,并在.NET应用程序中处理相关的数据。这样,可以实现.NET应用程序与SAP系统之间的数据共享和交换,实现系统间的无缝集成。 总之,.NET 4.0 是一种开发框架,用于开发各种类型的应用程序,而SAP RFC 则是用于实现与SAP系统的远程通信的接口。两者可以结合使用,实现.NET应用程序和SAP系统之间的数据共享和交互。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值