简体   繁体   English

如何使用 SAP GUI 脚本自动禁用 Excel 显示

[英]How to disable the Excel display with SAP GUI Scripting automatically

I recently discovered SAP GUI Scripting.我最近发现了 SAP GUI 脚本。 First I started to record easy transactions because I wanted to test if it is possible to execute the script on different PCs with different windows and SAP users.首先,我开始记录简单的交易,因为我想测试是否可以在具有不同 Windows 和 SAP 用户的不同 PC 上执行脚本。 During the testing phase I bumped into one bigger Problem.在测试阶段,我遇到了一个更大的问题。

In my company every user has the Office Integration which allows you to display (fe a Profit Center Report as) an Excel Document in SAP.在我的公司,每个用户都有 Office 集成,它允许您在 SAP 中显示(如利润中心报告)Excel 文档。 This display setting is saved permanently.此显示设置将永久保存。

Now the main problem is that if you record the script with Excel display deactivated and some other users execute the script with Excel display actived the script will not process .现在的主要问题是,如果您在 Excel 显示未激活的情况下记录脚本,而其他一些用户在 Excel 显示激活的情况下执行脚本,则脚本将无法处理

Usually I disable the Excel display setting manually by:通常我通过以下方式手动禁用 Excel 显示设置:

  • clicking System -> User default -> Personal Settings -> Parameter -> Parameter value for G_RW_DOCUMENT_TYPE from XLS to 0点击系统 -> 用户默认 -> 个人设置 -> 参数 -> G_RW_DOCUMENT_TYPE 的参数值从 XLS 到 0

I tried to record this process with the SAP GUI Scripting recorder but it does not record the whole process.我试图用 SAP GUI 脚本记录器记录这个过程,但它没有记录整个过程。

It only records this只记录这个

session.findById("wnd[0]").maximize
session.findById("wnd[0]/mbar/menu[4]/menu[2]/menu[3]").select

the script does not record the change in parameter value脚本不记录参数值的变化

Is there a way (by adding a code line etc.) for automatically disabling the Excel display setting from active to inactive?有没有办法(通过添加代码行等)自动禁用 Excel 显示设置从活动到非活动?

SAP GUI script recorder records the commands only in 1st mode. SAP GUI 脚本记录器仅在第一种模式下记录命令。 After the command命令后

session.findById("wnd[0]/mbar/menu[4]/menu[2]/menu[3]").select

opens a new mode.开启新模式。

But you can also start the transaction directly and remain in 1st mode.但是您也可以直接开始交易并保持在第一种模式。

for example:例如:

session.findById("wnd[0]/tbar[0]/okcd").text = "/nsu3"
session.findById("wnd[0]").sendVKey 0

Now that you know that, the problem could be solved as follows:现在你知道了,这个问题可以解决如下:

session.findById("wnd[0]").maximize
session.findById("wnd[0]/tbar[0]/okcd").text = "/nsu3"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/tabsTABSTRIP1/tabpPARAM").select
session.findById("wnd[0]/usr/tabsTABSTRIP1/tabpPARAM/ssubMAINAREA:SAPLSUID_MAINTENANCE:1104/cntlG_PARAMETER_CONTAINER/shellcont/shell").pressToolbarButton "&FIND"
session.findById("wnd[1]/usr/chkGS_SEARCH-EXACT_WORD").selected = true
session.findById("wnd[1]/usr/txtGS_SEARCH-VALUE").text = "G_RW_DOCUMENT_TYPE"
session.findById("wnd[1]/usr/chkGS_SEARCH-EXACT_WORD").setFocus
session.findById("wnd[1]/tbar[0]/btn[0]").press
session.findById("wnd[1]").close

myRow = session.findById("wnd[0]/usr/tabsTABSTRIP1/tabpPARAM/ssubMAINAREA:SAPLSUID_MAINTENANCE:1104/cntlG_PARAMETER_CONTAINER/shellcont/shell").currentCellRow
session.findById("wnd[0]/usr/tabsTABSTRIP1/tabpPARAM/ssubMAINAREA:SAPLSUID_MAINTENANCE:1104/cntlG_PARAMETER_CONTAINER/shellcont/shell").modifyCell myRow,"PARVA","0"      'instead of "XLS"
session.findById("wnd[0]/usr/tabsTABSTRIP1/tabpPARAM/ssubMAINAREA:SAPLSUID_MAINTENANCE:1104/cntlG_PARAMETER_CONTAINER/shellcont/shell").currentCellColumn = "PARVA"
session.findById("wnd[0]/tbar[0]/btn[11]").press

Regards, ScriptMan问候, ScriptMan

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

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