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. ROS rosrun 调用 sudo 命令

    https://blog.csdn.net/qq_16775293/article/details/81138904

  2. SQL Server2012远程访问设置

    http://jingyan.baidu.com/article/a681b0de3bdb7b3b19434667.html?qq-pf-to=pcqq.group 1.打开SQL server201 ...

  3. Prometheus 函数

    函数列表 一些函数有默认的参数,例如:year(v=vector(time()) instant-vector).v是参数值,instant-vector是参数类型.vector(time())是默认 ...

  4. ubuntu登录时出现“一闪之后回到登录界面”的现象

    ubuntu登录时出现“一闪之后回到登录界面”的现象 虚拟机vmware 12.5.6 build-5528349 操作系统ubuntu 18.04 问题:登录时出现一闪之后回到登录界面的现象 解决方 ...

  5. Redis的概念及与MySQL的区别

    学了MySQL相关知识后,了解到很多公司都会用mysql+redis互补使用的,今天学习整理一下Redis的相关知识. 首先是Redis和MySQL的区别: MySQL是典型的关系型数据库:Redis ...

  6. 传统DNS的问题与HTTPDNS

    本篇学习笔记要掌握两个要点: 传统的 DNS 有很多问题,例如解析慢.更新不及时.因为缓存.转发.NAT 问题导致客户端误会自己所在的位置和运营商,从而影响流量的调度. HTTPDNS 通过客户端 S ...

  7. [development][libconfig] 配置文件库

    以前,一直用ini的配置文件. 简单清晰但是不灵活. 换一个: 试试libconfig 主页:  http://www.hyperrealm.com/oss_libconfig.shtml githu ...

  8. Cmake入门资料

    1.http://blog.sina.com.cn/s/blog_3f3422fd010009vn.html 2.http://www.cnblogs.com/coderfenghc/tag/cmak ...

  9. Python开发【笔记】:列表转字典

    列表转字典 it = [1,2,3,4] print(dict(zip(it, it))) # {1: 1, 2: 2, 3: 3, 4: 4} it = iter(it) print(dict(zi ...

  10. 手工sql注入简单入门

    1.判断是否可以注入: 数字型: 1.1在参数后面加一个引号',如果页面报数字number错误,则一定不是sql注入点:如果报数据库比如mysql.oracle之类的错误,则是一个sql注入点. 1. ...