admin管理员组文章数量:1405859
I am developing an application in Delphi that needs to interact with SAP GUI via Scripting to automate some material control operations. However, I am facing difficulties in establishing the correct communication with SAP GUI Scripting and executing the desired commands.
Scenario:
- I am using Delphi 12.2 as my programming language.
- SAP GUI Scripting is enabled in the SAP GUI settings and on the server.
- The objective is to connect to SAP GUI, navigate between screens, fill in fields automatically, process transactions, and extract reports.
- I have tried using the SAP Scripting API according to documentation and examples found online, but I still encounter errors.
Issues faced:
Error when trying to access the session object: some attempts return errors like
Object required
or
ActiveX component can't create object
Code works in VBA but not in Delphi: I tested some scripts in VBA (Excel) and in a VBS file, and they work fine. However, when porting to Delphi, I cannot reproduce the same behavior.
Example of code used:
uses
ComObj, Variants;
procedure TForm1.Button1Click(Sender: TObject);
var
SAPGuiAuto, Application, Connection, Session: OleVariant;
begin
try
SAPGuiAuto := GetActiveOleObject('SAPGUI.ScriptingCtrl.1');
//SAPGuiAuto := CreateOleObject('SAPGUI.ScriptingCtrl.1');
Application := SAPGuiAuto.GetScriptingEngine;
Connection := Application.Children(0);
Session := Connection.Children(0);
// Test: Access a transaction
Session.StartTransaction('MMBE');
except
on E: Exception do
ShowMessage('Err: ' + E.Message);
end;
end;
Questions:
- Am I referencing the objects correctly?
- Is there any Delphi-specific detail I should be aware of?
- Is there any additional configuration that needs to be done in SAP GUI or Delphi to allow this communication?
本文标签: SAP GUI Scripting in DelphiStack Overflow
版权声明:本文标题:SAP GUI Scripting in Delphi - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744953088a2634196.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论