uft调用rfc接口
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接口的更多相关文章
- SAP ABAP RFC接口通用日志工具:abap fm logger
很早之前就想写个能记录函数模块日志的通用工具,最早尝试时,没有想清楚插入代码的体积问题.在一些群友的提醒下,了解到可以用宏来处理这一问题.不过当时比较忙,就没有动笔.最近又想起这件事,花了2天完成了一 ...
- WebApi接口 - 如何在应用中调用webapi接口
很高兴能再次和大家分享webapi接口的相关文章,本篇将要讲解的是如何在应用中调用webapi接口:对于大部分做内部管理系统及类似系统的朋友来说很少会去调用别人的接口,因此可能在这方面存在一些困惑,希 ...
- C#动态调用WCF接口,两种方式任你选。
写在前面 接触WCF还是它在最初诞生之处,一个分布式应用的巨作. 从开始接触到现在断断续续,真正使用的项目少之又少,更谈不上深入WCF内部实现机制和原理去研究,最近自己做一个项目时用到了WCF. 从这 ...
- python调用zabbix接口实现Action配置
要写这篇博客其实我的内心是纠结的,老实说,我对zabbix的了解实在不多.但新公司的需求不容置疑,当我顶着有两个头大的脑袋懵懵转入运维领域时,面前摆着两百多组.上千台机器等着写入zabbix监控的需求 ...
- HttpClient Get/Post方式调用Http接口
本节摘要:本节主要分别介绍如何用get方式.post方式向http接口发送数据. preparation 1. 项目环境如下: myeclipse6.5 .tomcat5.0.system:xp.JD ...
- Atitit 通过调用gui接口杀掉360杀毒 360卫士 qq保镖等难以结束的进程(javac# php )
Atitit 通过调用gui接口杀掉360杀毒 360卫士 qq保镖等难以结束的进程(javac# php ) 1.1. 这些流氓软件使用操作系统os提供的普通api根本就杀不掉啊1 1.2. 使用 ...
- Java调用webservice接口方法
java调用webservice接口 webservice的 发布一般都是使用WSDL(web service descriptive langu ...
- php中创建和调用webservice接口示例
php中创建和调用webservice接口示例 这篇文章主要介绍了php中创建和调用webservice接口示例,包括webservice基本知识.webservice服务端例子.webservi ...
- 调用c++接口类
调用c++接口类 public class CarDeviceDll { /*对dll库进行一些初始化*/ [DllImport("IDI.dll")] public static ...
随机推荐
- [No0000DD]C# StringEx 扩展字符串类 类封装
using System; using System.Text.RegularExpressions; namespace Helpers { /// <summary> /// 包含常用 ...
- SQL之分组排序取top n
转自:http://blog.csdn.net/wguangliang/article/details/50167283 要求:按照课程分组,查找每个课程最高的两个成绩. 数据文件如下: 第一列no为 ...
- [daily][archlinux][rsync] rsync
科普文档:https://wiki.archlinux.org/index.php/Rsync 之前改文件系统时,用过. 然而用的不太对,导致一部分文件的权限出了问题. [troubleshoot][ ...
- [security] security engine things
1. luarock luarock 之于 lua,就好比 pip 之于 python https://luarocks.org/ 2. lua的库 [root@base package]# ls ...
- Flink - Asynchronous I/O
https://docs.google.com/document/d/1Lr9UYXEz6s6R_3PWg3bZQLF3upGaNEkc0rQCFSzaYDI/edit // create the ...
- 读书笔记-iOS核心动画高级技巧
如果不使用+imageNamed:,那么把整张图片绘制到CGContext可能是最佳的方式了. 这里我们利用了CALayer的KVC来存储和检索任意的值,将图层和索引打标签. 使用KVC打标签
- 转:centos7/rhel7安装较高版本ruby2.2/2.3/2.4+
centos7/rhel7安装较高版本ruby2.2/2.3/2.4+ 环境需求: 在Centos7.3中,通过yum安装ruby的版本是2.0.0,但是如果有些应用需要高版本的ruby环境,比 ...
- ORACLE INSTANCE与EM系统
Emctl start dbconsole https://192.168.183.132:1158/em/ 复制到游览器进入到em 更改初始化参数值 静态参数: -只能在参数文件中更改 -必须重新启 ...
- LeetCode 427 Construct Quad Tree 解题报告
题目要求 We want to use quad trees to store an N x N boolean grid. Each cell in the grid can only be tru ...
- scala-高阶函数
//1类似于lambda表达式的函数直接量====================== var get = (name: String) => { println(123 + name) } g ...