简体   繁体   English

使用 C# 的 SAP GUI 自动化 - sapfewse.ocx 是否有书面的开发人员文档或 api 库?

[英]SAP GUI Automation using C# - does sapfewse.ocx have a written developer documentation or api library?

Referring to this question here a past user was able to develop some C# code to perform SAP GUI Automation.在这里参考这个问题,过去的用户能够开发一些 C# 代码来执行 SAP GUI 自动化。 However when looking online at tutorials/developer documentation for this library I was unable to find anything.但是,当在线查看此库的教程/开发人员文档时,我找不到任何内容。

There are a lot of objects like like, GuiSession , GuiApplication , GuiConnection that I can't find information to online.有很多像GuiSessionGuiApplicationGuiConnection这样的对象,我在网上找不到信息。

How would I go on to writing SAP GUI automation using C# without proper documentation?如果没有适当的文档,我将如何继续使用 C# 编写 SAP GUI 自动化?

There is very little documentation for SAP Scripting in general outside of the one resource posted in the linked question ( http://www.synactive.com/download/sap%20gui%20scripting/sap%20gui%20scripting%20api.pdf ).除了链接问题( http://www.synactive.com/download/sap%20gui%20scripting/sap%20gui%20scripting%20api.pdf )中发布的一个资源之外,SAP Scripting 的文档通常很少。

However, I also found this resource ( http://help.innowera.net/PR2008/2.00/SAP_Scripting_API.pdf ) which is similar to the one above but I think has a bit more detail.但是,我也发现了这个资源( http://help.innowera.net/PR2008/2.00/SAP_Scripting_API.pdf ),它与上面的类似,但我认为有更多细节。

Further, there is a built-in help document within SAP that you can access from the "Customize Local Layout" Menu (click the Monitor Icon in the second-from-the-top toolbar or ALT + F12 ) and then selecting "SAP GUI Scripting Help"此外,SAP 中有一个内置帮助文档,您可以从“自定义本地布局”菜单(单击顶部第二个工具栏中的监视器图标或ALT + F12 )然后选择“SAP GUI脚本帮助”

All three of these resources are primarily for VB;所有这三个资源主要用于 VB; however, the objects, methods and rules are nearly the exact same for C#.但是,C# 的对象、方法和规则几乎完全相同。

That being said, I do not know of any API Documentation specific to C# at this time话虽如此,我目前不知道任何特定于 C# 的 API 文档

How would I go on to writing SAP GUI automation using C# without proper documentation?如果没有适当的文档,我将如何继续使用 C# 编写 SAP GUI 自动化?

I suggest recording scripts in VB through SAP first so that you can at least get the IDs for each button, menu, and field you use for a particular report.我建议首先通过 SAP 在 VB 中记录脚本,以便您至少可以获得用于特定报告的每个按钮、菜单和字段的 ID。 Then you can copy the IDs from that script into your C#.然后,您可以将该脚本中的 ID 复制到您的 C# 中。 Additionally, these VB scripts can help you determine which objects and methods to use in your C#.此外,这些 VB 脚本可以帮助您确定在 C# 中使用哪些对象和方法。

You can access the script recording functionality through the same "Customize Local Layout" menu and selecting "Script Recording and Playback..."您可以通过相同的“自定义本地布局”菜单并选择“脚本录制和回放...”来访问脚本录制功能。

如何使用 SAP 脚本录制功能

This functionality records every mouse click and keyboard input inside of SAP in VB and stores the resulting script in %AppData%\\SAP\\SAP GUI\\Scripts此功能在 VB 中记录 SAP 内的每次鼠标点击和键盘输入,并将生成的脚本存储在%AppData%\\SAP\\SAP GUI\\Scripts

As I find more resources for SAP Scripting with C#, I will post them here.当我找到更多有关使用 C# 编写 SAP 脚本的资源时,我将在此处发布它们。

The documentation is in your Program Files > SAP.该文档位于您的程序文件 > SAP 中。 Then, search for this file " SAPGUIScripting.chm ".然后,搜索此文件“ SAPGUIScripting.chm ”。 This is the best documentation I've seen.这是我见过的最好的文档。 It documents all class objects with their methods, properties and events.它记录了所有类对象及其方法、属性和事件。 It will occasionally provide some direction on how to use some of the methods.它偶尔会提供有关如何使用某些方法的一些指导。

You can also click on the "SAP GUI Scripting Help" as seen below.您还可以单击“SAP GUI 脚本帮助”,如下所示。

在此处输入图片说明

As far as using C#, you would use the methods and properties just like you would for any other C# object.就使用 C# 而言,您可以像使用任何其他 C# 对象一样使用方法和属性。

Best of luck and happy scripting!祝你好运,脚本编写愉快!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM