RFC接口函数调用:

以下代码是封装好的,为了提供给UFT工具调用,使用c#写成dll。

类型项目分成两个:

1.baseConfigModel.cs  //sap配置登录信息,属性实体类

using System;
using System.Collections.Generic;
//using System.Linq;
using System.Text;
//using System.Threading.Tasks;
using SAP.Middleware.Connector;
namespace I_RFC_LIB.Model
{
public class baseConfigModel
{ public string Name { get; set; } //系统名字QH5
public string AppServerHost { get; set; }//系统ip地址
public string SystemNumber { get; set; } //系统实例
public string SystemID { get; set; }//系统id
public string User { get; set; }//用户ATPSUSER
public string Password { get; set; }//密码
public string Client { get; set; }//客户端号800
public string Language { get; set; } //语言zh en
public string IFUNC { get; set; } //接口函数名
public RfcDestination sapConfig { get; set; } //sap登录配置
public RfcRepository rfcRepository { get; set; } //Repository对象
public string resultConfig { get; set; } //配置结果
}
}

2.C_RFC.cs //具体实现

using System;
using System.Collections.Generic;
//using System.Linq;
using System.Text;
using System.Reflection;
//using System.Threading.Tasks;
///**************************************************************///
using SAP.Middleware.Connector;
///引用合名空间SAP.Middleware.Connector需要引用sapnco3.0 dll
///需要framework2.0支持
///sapnco.dll
///sapnco_utils
///**************************************************************/// namespace I_RFC_LIB
{
public class C_RFC
{
Model.baseConfigModel configModel = new Model.baseConfigModel(); //实例类 登录配置属性 /// <summary>
/// 调用rfc接口函数
/// </summary>
/// <param name="headstr">包含配置信息的头</param>
/// <param name="itemstr">接口需要参数</param>
/// <returns></returns>
public string invoke(string headstr,string itemstr)
{
string[] headArr = headstr.Split(new string[] { "@__@" }, StringSplitOptions.RemoveEmptyEntries);
string[] itemArr = itemstr.Split(new string[] { "@__@" }, StringSplitOptions.RemoveEmptyEntries); #region //head属性赋值
//rfc config var proValue = configModel.GetType(); //获取属性实例 for (var i = ; i < headArr.Length; i++)
{
var tmpVal = headArr[i].Split(new string[] { "@_@" }, StringSplitOptions.None);
foreach (PropertyInfo py in proValue.GetProperties())
{
if (py.Name.ToUpper() == tmpVal[].ToUpper())
{
proValue.GetProperty(py.Name).SetValue(configModel, tmpVal[], null);
}
}
} #endregion if (rfc_config()) //执行配置,获取对象
{
IRfcFunction rfc_invoke = configModel.rfcRepository.CreateFunction(configModel.IFUNC); //调用"ZFUC_APWZ_AP_PREVIEW"
rfc_invoke.Invoke(configModel.sapConfig); //执行函数 #region //item传参
for (var i = ; i < itemArr.Length; i++)
{
var tmpitVal = itemArr[i].Split(new string[] { "@_@" }, StringSplitOptions.RemoveEmptyEntries);
rfc_invoke.SetValue(tmpitVal[], tmpitVal[]); //设置参数 (参数名,参数值)
}
#endregion //rfc_invoke.SetValue("PSPID", ""); //设置参数 项目编号
IRfcTable rfcTable = rfc_invoke.GetTable("RETURN"); //获取内表
string message = rfcTable.GetValue("MESSAGE").ToString(); return message;
}
else
{
return "配置登录时出现问题,请查检配置!"+configModel.resultConfig;
}
} /// <summary>
/// 登录配置
/// </summary>
/// <returns>bool</returns>
public bool rfc_config()
{
try
{
//rfc配置
RfcConfigParameters argsP = new RfcConfigParameters();
argsP.Add(RfcConfigParameters.Name, configModel.Name);
argsP.Add(RfcConfigParameters.AppServerHost, configModel.AppServerHost);
argsP.Add(RfcConfigParameters.SystemNumber, configModel.SystemNumber);
argsP.Add(RfcConfigParameters.SystemID, configModel.SystemID);
argsP.Add(RfcConfigParameters.User, configModel.User);
argsP.Add(RfcConfigParameters.Password, configModel.Password);
argsP.Add(RfcConfigParameters.Client, configModel.Client);
argsP.Add(RfcConfigParameters.Language, configModel.Language);
argsP.Add(RfcConfigParameters.PoolSize, "");
argsP.Add(RfcConfigParameters.MaxPoolSize, "");
argsP.Add(RfcConfigParameters.IdleTimeout, ""); //获取rfc配置
configModel.sapConfig = RfcDestinationManager.GetDestination(argsP);
configModel.rfcRepository = configModel.sapConfig.Repository;
}
catch (RfcBaseException ex)
{
configModel.resultConfig = ex.Message;
return false;
}
return true;
} }
}

3.uft调用

需要设置,程序集com可见

4、uft调用方法:

set rfc = dotnetfactory.CreateInstance("I_RFC_LIB.C_RFC","d:\\rfc.dll")

5、c#类库调用结果。接口返回“ATPSUSER不是该步骤允许的审批人”

uft调用rfc接口的更多相关文章

  1. SAP ABAP RFC接口通用日志工具:abap fm logger

    很早之前就想写个能记录函数模块日志的通用工具,最早尝试时,没有想清楚插入代码的体积问题.在一些群友的提醒下,了解到可以用宏来处理这一问题.不过当时比较忙,就没有动笔.最近又想起这件事,花了2天完成了一 ...

  2. WebApi接口 - 如何在应用中调用webapi接口

    很高兴能再次和大家分享webapi接口的相关文章,本篇将要讲解的是如何在应用中调用webapi接口:对于大部分做内部管理系统及类似系统的朋友来说很少会去调用别人的接口,因此可能在这方面存在一些困惑,希 ...

  3. C#动态调用WCF接口,两种方式任你选。

    写在前面 接触WCF还是它在最初诞生之处,一个分布式应用的巨作. 从开始接触到现在断断续续,真正使用的项目少之又少,更谈不上深入WCF内部实现机制和原理去研究,最近自己做一个项目时用到了WCF. 从这 ...

  4. python调用zabbix接口实现Action配置

    要写这篇博客其实我的内心是纠结的,老实说,我对zabbix的了解实在不多.但新公司的需求不容置疑,当我顶着有两个头大的脑袋懵懵转入运维领域时,面前摆着两百多组.上千台机器等着写入zabbix监控的需求 ...

  5. HttpClient Get/Post方式调用Http接口

    本节摘要:本节主要分别介绍如何用get方式.post方式向http接口发送数据. preparation 1. 项目环境如下: myeclipse6.5 .tomcat5.0.system:xp.JD ...

  6. Atitit 通过调用gui接口杀掉360杀毒 360卫士  qq保镖等难以结束的进程(javac# php )

    Atitit 通过调用gui接口杀掉360杀毒 360卫士  qq保镖等难以结束的进程(javac# php ) 1.1. 这些流氓软件使用操作系统os提供的普通api根本就杀不掉啊1 1.2. 使用 ...

  7. Java调用webservice接口方法

                             java调用webservice接口   webservice的 发布一般都是使用WSDL(web service descriptive langu ...

  8. php中创建和调用webservice接口示例

    php中创建和调用webservice接口示例   这篇文章主要介绍了php中创建和调用webservice接口示例,包括webservice基本知识.webservice服务端例子.webservi ...

  9. 调用c++接口类

    调用c++接口类 public class CarDeviceDll { /*对dll库进行一些初始化*/ [DllImport("IDI.dll")] public static ...

随机推荐

  1. 配对堆优化Dijkstra算法小记

    关于配对堆的一些小姿势: 1.配对堆是一颗多叉树. 2.包含优先队列的所有功能,可用于优化Dijkstra算法. 3.属于可并堆,因此对于集合合并维护最值的问题很实用. 4.速度快于一般的堆结构(左偏 ...

  2. [No000018F]Vim自动缩进配置、原理和tab键替换空格-Vim使用技巧(4)

    一.Vim缩进介绍 在没有设置Vim自动缩进的条件下,可以手动使用Vim命令对特定行进行缩进处理.在Vim插入模式下,按下 Tab 键时默认会输入一个制表符,可通过Vim配置项将 Tab 替换为空格, ...

  3. [No0000E6]C# 判断与循环

    判断语句 语句 描述 if 语句 一个 if 语句 由一个布尔表达式后跟一个或多个语句组成. if...else 语句 一个 if 语句 后可跟一个可选的 else 语句,else 语句在布尔表达式为 ...

  4. gensim Word2Vec 训练和使用(Model一定要加载到内存中,节省时间!!!)

    训练模型利用gensim.models.Word2Vec(sentences)建立词向量模型该构造函数执行了三个步骤:建立一个空的模型对象,遍历一次语料库建立词典,第二次遍历语料库建立神经网络模型可以 ...

  5. Flink - FlinkKafkaProducer010

    https://ci.apache.org/projects/flink/flink-docs-release-1.3/dev/connectors/kafka.html 使用的方式, DataStr ...

  6. 【LBS】基于地理位置的搜索之微信 附近的人 简单实现

    缘由 本周技术群有一个同学说我们该怎么实现 由近到远的基于地理位置的搜索,我创业做电商的系统做过类似这样的服务,我把我们以前的操作给大家分享下 什么是LBS LBS 全称是 Location  Bas ...

  7. Nginx之基本介绍(一)

    这是一篇介绍Nginx基本信息和配置文件详情的文章,适合入门者,如果你想深入了解Nginx请绕道 什么是Nginx? Nginx是轻量级,高性能,跨平台的web服务器 Nginx的特点 更快 单个请求 ...

  8. 关于byte[]与string、Image转换

    byte[]与string转换 参考网址:https://www.cnblogs.com/xskblog/p/6179689.html 1.使用System.Text.Encoding.Default ...

  9. javascript面向对象中继承实现?

    面向对象的基本特征有:封闭.继承.多态. 在javascript中实现继承的方法: 1.原型链(prototype chaining) 2.call()/apply() 3.混合方式(prototyp ...

  10. @property专题

    “属性” (property)作为 Objective-C 的一项特性,主要的作用就在于封装对象中的数据. Objective-C 对象通常会把其所需要的数据保存为各种实例变量.实例变量一般通过“存取 ...