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 ...
随机推荐
- Ubuntu16.04下安装QT5.8
https://blog.csdn.net/hhrock/article/details/61621044
- mysql事务及慢查询
1, 在 MySQL 中只有使用了 Innodb 数据库引擎的数据库或表才支持事务 l 原子性:构成事务的的所有操作必须是一个逻辑单元,要么全部执行,要么全部不执行. l 稳定性(一致性):数据库在事 ...
- HDU 4347 - The Closest M Points - [KDTree模板题]
本文参考: https://www.cnblogs.com/GerynOhenz/p/8727415.html kuangbin的ACM模板(新) 题目链接:http://acm.hdu.edu.cn ...
- ROADS POJ - 1724 约束最短路 暴搜 加剪枝
http://poj.org/problem?id=1724 题意:最短路的模板,不过每条边加上一个费用,要求总费用不超过k 题解:不能用dijkstra ,直接暴力,dfs维护len和cost. 普 ...
- .net WebService的使用
1. WebService可单独作为一个网站,不限平台的被调用. 2. 打开VS,选择新建 3. [WebMethod] 方法上面有这个说明,则表示此方法可被外部调用. 我们添加4个方法:加.减.乘. ...
- en-zh(社会问题)social problems
The world's richest man, Amazon founder Jeff Bezos, and his wife MacKenzie have agreed a record-brea ...
- mvc 使用Newtonsoft.Json进行序列化json数据
mvc 使用Newtonsoft.Json进行序列化json数据 JsonResult 使用js 序列号化,先集成扩展.使用newtonsoft http://blog.csdn.net/zhang ...
- kafka相关命令
查看kafka消费组对应的信息:./kafka-consumer-groups.sh --bootstrap-server 172.17.6.10:9092 --describe --group fr ...
- 【数据可视化-pyecharts】pyecharts快速入门
pyecharts快速开始 首先开始来绘制你的第一个图表 from pyecharts import Bar bar = Bar("我的第一个图表", "这里是副标题&q ...
- ubuntu windows10 in GPT HDD GRUB Boot
some thing wrong with my input, I can just use English -_-!!! The HDD have two kinds of formart, GP ...