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

推荐订阅源

爱范儿
爱范儿
T
Troy Hunt's Blog
B
Blog
N
Netflix TechBlog - Medium
H
Help Net Security
PCI Perspectives
PCI Perspectives
罗磊的独立博客
SecWiki News
SecWiki News
S
Security Affairs
Webroot Blog
Webroot Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Hacker News: Ask HN
Hacker News: Ask HN
Google Online Security Blog
Google Online Security Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
V
Visual Studio Blog
V2EX - 技术
V2EX - 技术
Recorded Future
Recorded Future
Schneier on Security
Schneier on Security
The Last Watchdog
The Last Watchdog
博客园 - 【当耐特】
Attack and Defense Labs
Attack and Defense Labs
S
Secure Thoughts
Hugging Face - Blog
Hugging Face - Blog
Forbes - Security
Forbes - Security
Application and Cybersecurity Blog
Application and Cybersecurity Blog
TaoSecurity Blog
TaoSecurity Blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main
M
MIT News - Artificial intelligence
博客园_首页
A
About on SuperTechFans
Microsoft Azure Blog
Microsoft Azure Blog
T
Tailwind CSS Blog
The Cloudflare Blog
P
Proofpoint News Feed
D
DataBreaches.Net
N
News and Events Feed by Topic
G
Google Developers Blog
B
Blog RSS Feed
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
MyScale Blog
MyScale Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
AI
AI
O
OpenAI News
雷峰网
雷峰网
C
Check Point Blog
大猫的无限游戏
大猫的无限游戏
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Blog — PlanetScale
Blog — PlanetScale
有赞技术团队
有赞技术团队

博客园 - 寒天飞雪

项目中用到Excel上传到Sql数据库 转载: 房贷的两种还款方式介绍 VB.net连接SAP实例(vb.net写法) VB.net连接SAP实例 - 寒天飞雪 - 博客园 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 定义计算成员
RFC访问SAP(C#)
寒天飞雪 · 2009-03-30 · via 博客园 - 寒天飞雪

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using SAPFunctionsOCX;
using SAPLogonCtrl;
using SAPTableFactoryCtrl;

namespace SAPFunction
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

      
        private void BtnConn_Click(object sender, EventArgs e)
        {  
               //设置登录连接的类
                DataSet dset = new DataSet();
                SAPLogonCtrl.SAPLogonControlClass logon = new SAPLogonCtrl.SAPLogonControlClass();
                //连接参数设置
                logon.ApplicationServer = "172.18.95.173";
                logon.Client = "164";
                logon.Language = "ZH";
                logon.User = "CRMDEV69";
                logon.Password = "654321";
                logon.SystemNumber = 7;
               
                //实例化连接对象
                SAPLogonCtrl.Connection Conn;

                Conn = (SAPLogonCtrl.Connection)logon.NewConnection();
                //Conn.CodePage = "8400";
                //调用登录方法
                if (Conn.Logon(0, true))
                {
                    label1.Text = "登录成功!";
                }

               //实例SAPFunction对象

                SAPFunctionsOCX.SAPFunctionsClass func = new SAPFunctionsClass();

                //设置连接
                func.Connection = Conn;
               
                SAPFunctionsOCX.IFunction ifunc = (SAPFunctionsOCX.IFunction)func.Add("ZCSMS_GET_HRINFO");
                //设置输入参数
                SAPFunctionsOCX.IParameter BEGDAFROM = (SAPFunctionsOCX.IParameter)ifunc.get_Exports("BEGDAFROM");
                BEGDAFROM.Value = "";
                SAPFunctionsOCX.IParameter BEGDATO = (SAPFunctionsOCX.IParameter)ifunc.get_Exports("BEGDATO");
                BEGDATO.Value = "";
                SAPFunctionsOCX.IParameter MILL = (SAPFunctionsOCX.IParameter)ifunc.get_Exports("MILL");
                MILL.Value = "7960";
                SAPFunctionsOCX.IParameter NUMBERFROM = (SAPFunctionsOCX.IParameter)ifunc.get_Exports("NUMBERFROM");
                NUMBERFROM.Value = "0061500001";
                SAPFunctionsOCX.IParameter NUMBERTO = (SAPFunctionsOCX.IParameter)ifunc.get_Exports("NUMBERTO");
                NUMBERTO.Value = "0061500020";
                //调用RFC方法
                ifunc.Call();
                SAPTableFactoryCtrl.Tables ENQs = (SAPTableFactoryCtrl.Tables)ifunc.Tables;
                SAPTableFactoryCtrl.Table ENQ = (SAPTableFactoryCtrl.Table)ENQs.get_Item("THR");

                int j = ENQ.RowCount;
                DataTable dt = new DataTable();
                for (int i = 1 ;i<=ENQ.RowCount; i ++)
                {
                    DataRow dr = dt.NewRow();
                    if (i == 1)
                    {
                        dt.Columns.Add("MILL");
                        dt.Columns.Add("PERNR");
                        dt.Columns.Add("NAME1");
                        dt.Columns.Add("STEXT");
                    }
                   
                    dr["MILL"] = (String)ENQ.get_Value(i, "MILL");
                    dr["PERNR"] = (String)ENQ.get_Value(i, "PERNR");
                    dr["NAME1"] = (String)ENQ.get_Value(i, "NAME1");
                    dr["STEXT"] = (String)ENQ.get_Value(i, "STEXT");
                    dt.Rows.Add(dr);
                }
                dataGridView1.DataSource = dt.DefaultView; 
        }  
    }
}

当然, RFC连接SAP只是其中的方法之一, BAPI等多种方式.