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

推荐订阅源

P
Proofpoint News Feed
H
Hacker News: Front Page
C
CXSECURITY Database RSS Feed - CXSecurity.com
C
Cisco Blogs
P
Palo Alto Networks Blog
Know Your Adversary
Know Your Adversary
D
Darknet – Hacking Tools, Hacker News & Cyber Security
C
Cybersecurity and Infrastructure Security Agency CISA
AWS News Blog
AWS News Blog
Spread Privacy
Spread Privacy
S
Schneier on Security
The Hacker News
The Hacker News
Cyberwarzone
Cyberwarzone
T
Tenable Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
T
Tailwind CSS Blog
S
Secure Thoughts
N
Netflix TechBlog - Medium
T
The Exploit Database - CXSecurity.com
I
Intezer
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Help Net Security
Help Net Security
K
Kaspersky official blog
Google Online Security Blog
Google Online Security Blog
L
LangChain Blog
Martin Fowler
Martin Fowler
L
LINUX DO - 热门话题
Hacker News: Ask HN
Hacker News: Ask HN
www.infosecurity-magazine.com
www.infosecurity-magazine.com
有赞技术团队
有赞技术团队
P
Privacy International News Feed
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Recent Announcements
Recent Announcements
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
The Register - Security
The Register - Security
云风的 BLOG
云风的 BLOG
Google DeepMind News
Google DeepMind News
阮一峰的网络日志
阮一峰的网络日志
WordPress大学
WordPress大学
Recorded Future
Recorded Future
The Last Watchdog
The Last Watchdog
G
Google Developers Blog
T
Threatpost
小众软件
小众软件
S
Securelist
Recent Commits to openclaw:main
Recent Commits to openclaw:main
O
OpenAI News

博客园 - 寒天飞雪

项目中用到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等多种方式.