‎2005 Jan 13 4:49 PM
I have an issue when trying to execute some javascript (sap gui script) from a webpage.
When the javascript is executed I get the message:
automation server unable to create object.
However, this exact same javascript when placed in a text file and double-clicked executes just fine through the windows scripting host.
Does anyone have an example of gui script code executing from a webpage? Or any ideas on why it isn't working from the webpage? Both scenarios should be executing the code on the local machine through WSH.
Below is the javascript as well as the webpage executing the javascript:
SAPGUI SCRIPT
if (typeof(application) == "undefined")
{
sapgui = GetObject("SAPGUI");
application = sapgui.GetScriptingEngine;
}
if (typeof(connection) == "undefined")
{
connection = application.children(0);
}
if (typeof(session) == "undefined")
{
session = connection.children(0);
}
if (typeof(WScript) != "undefined")
{
WScript.connectObject(session, "on");
WScript.connectObject(application, "on");
}
session.findById("wnd[0]").maximize();
session.findById("wnd[0]/tbar[0]/okcd").text = "/nzsd1067";
session.findById("wnd[0]").sendVKey(0);
session.findById("wnd[0]/usr/ctxtVBAK-KUNNR").text = "6343";
session.findById("wnd[0]").sendVKey(0);
WEBPAGE
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title></title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
<! INPUT PARAMETER SETTINGS:
To Push data to Siebel or SAP the appropriate
field below must be set = TRUE.
Pop_SAP
Pop_Siebel
SIEBEL INPUT PARAMETER: When
Pushing data to a Siebel screen the Query_Type should be set based on the type
of lookup that is requested.
Query_Type = 'SAP' -presents a screen based on a customer SAP Id.
Query_Type = 'SR' -presents a screen based on a Service Request.
Query_Type = '' or null -presents a search screen to locate the proper contact in Siebel
APP_SAP_ID -SAP customer Id
APP_SR_NUM -Siebel Service Request Number
>
<SCRIPT LANGUAGE="VBScript">
Sub LoadContact()
'Siebel Application Object
Dim siebApp 'As SIEBELHTMLLib.ISiebelHTMLApplication
Dim siebSvcs 'As SIEBELHTMLLib.ISiebelService
Dim siebOutputPropSet 'As SIEBELHTMLLib.ISiebelPropertySet
Dim siebInputPropSet 'As SIEBELHTMLLib.ISiebelPropertySet
Dim bool 'As Boolean
Dim errCode 'As Integer
Dim errText 'As String
Dim QueryType 'As String
Dim PopSAP 'As String
PopSiebel = "TRUE"
If PopSiebel = "TRUE" Then
QueryType = "SAP"
If QueryType = "null" Then
QueryType = ""
End If
'Create The SiebelHTML Object
set siebApp = CreateObject("SiebelHTML.SiebelHTMLApplication.1")
If Not siebApp Is Nothing Then
'Create A New Property Set
set siebInputPropSet = siebApp.NewPropertySet
set siebOutputPropSet = siebApp.NewPropertySet
If Not siebInputPropSet Is Nothing Then
siebInputPropSet.SetProperty "ANI", "9738986011"
siebInputPropSet.SetProperty "SAP_ID", "0000516616"
siebInputPropSet.SetProperty "SR_NUM", "null"
siebInputPropSet.SetProperty "Interaction_ID", "168608840053"
siebInputPropSet.SetProperty "Query_Type", QueryType
Else
errCode = siebApp.GetLastErrCode
errText = siebApp.GetLastErrText
MsgBox "Could not Create Siebel Property Set: " & errCode & "::" & errText
End If
'Get A Siebel Service
set siebSvcs = siebApp.GetService ("TAWBS")
If Not siebSvcs Is Nothing Then
siebSvcs.InvokeMethod "TAWPresentAccount", siebInputPropSet, siebOutputPropSet
Else
errCode = siebApp.GetLastErrCode
errText = siebApp.GetLastErrText
MsgBox "Could not Get Siebel Service: " & errCode & "::" & errText
End If
set siebApp = Nothing
End If
set siebInputPropSet = Nothing
set siebOutputPropSet = Nothing
set siebSvcs = Nothing
End If
End Sub
</SCRIPT>
<SCRIPT LANGUAGE="javascript">
function loadSAP()
{
if (typeof(application) == "undefined")
{
sapgui = GetObject("SAPGUI");
application = sapgui.GetScriptingEngine;
}
if (typeof(connection) == "undefined")
{
connection = application.children(0);
}
if (typeof(session) == "undefined")
{
session = connection.children(0);
}
if (typeof(WScript) != "undefined")
{
WScript.connectObject(session, "on");
WScript.connectObject(application, "on");
}
session.findById("wnd[0]").maximize();
session.findById("wnd[0]/tbar[0]/okcd").text = "/nzsd1067";
session.findById("wnd[0]").sendVKey(0);
session.findById("wnd[0]/usr/ctxtVBAK-KUNNR").text = "0000516616";
session.findById("wnd[0]").sendVKey(0);
} // end
</SCRIPT>
</head>
<body onload="loadSAP()">
<H3><FONT face="Arial" size="5">Raytheon Integration Screen</FONT></H3>
<HR style="WIDTH: 882px; HEIGHT: 8px" color="#3366cc" SIZE="8">
<form id="ValidForm" onsubmit="LoadContact(); return false;" language="jscript">
<FONT face="Arial">Load Siebel Screen</FONT> <! <input name="Text1" TYPE="TEXT"
SIZE="10" ID="Text1"> <input name="Submit" TYPE="submit" VALUE="Submit" ID="Submit1">
</form>
<form id="Form1" onsubmit="loadSAP(); return false;" language="javascript">
<FONT face="Arial">Load SAP Screen</FONT> <! <input
name="Text2" TYPE="TEXT" SIZE="10" ID="Text2"> <input name="Submit" TYPE="submit" VALUE="Submit" ID="Submit2">
</form>
</body>
</html>
‎2005 Mar 29 2:49 PM
Hi Shaun,
the SAP GUI Scripting API adds a reference to SAP GUI to the Running Object Table. Unfortunately GetObject will not access the Running Object Table when you call it from inside IE. This only works in the Windows Script Host.
In SAP GUI 6.40 there is a way to work around this:
Set Wrp = CreateObject ("SapROTWr.SapROTWrapper")
Set SapGui = Wrp.GetROTEntry ("SAPGUI")
Best regards,
Christian
‎2005 Jan 14 6:14 PM
Hello,
I think it is a browser security issue. In what Zone is the Website you call? Internet/Intranet/Trusted Sites? And what Security settings are made for the appropiate Zone?
Regards
Gregor
‎2005 Mar 29 2:49 PM
Hi Shaun,
the SAP GUI Scripting API adds a reference to SAP GUI to the Running Object Table. Unfortunately GetObject will not access the Running Object Table when you call it from inside IE. This only works in the Windows Script Host.
In SAP GUI 6.40 there is a way to work around this:
Set Wrp = CreateObject ("SapROTWr.SapROTWrapper")
Set SapGui = Wrp.GetROTEntry ("SAPGUI")
Best regards,
Christian
‎2005 Apr 09 5:56 AM
Hi Christian,
How exactly does the syntax in the JavaSript coding need to be changed then, e.g. the following doesn't seemed to work:
if (typeof(application) == "undefined")
{
Set Wrp = CreateObject ("SapROTWr.SapROTWrapper");
Set SapGui = Wrp.GetROTEntry ("SAPGUI");
application = sapgui.GetScriptingEngine;
}
Thanks, Bernd
‎2005 Apr 11 6:56 AM
Hi Bernd,
the following code works in VBS. If you run saplogon.exe you'll get a message box saying '/app'.
Set Wrp = CreateObject ("SapROTWr.SapROTWrapper")
Set SapGui = Wrp.GetROTEntry ("SAPGUI")
Set application = sapgui.GetScriptingEngine
MsgBox application.id
I haven't tried it on a web page, but I don't see why it shouldn't work there. Ok, maybe the MsgBox is command is not available.
Best regards,
Christian
‎2005 Jun 24 1:53 PM
Is there a way (or a work arround) to do this with the SAP GUI 6.20?
‎2005 Jun 24 5:06 PM
Hi Stefaan,
there is no way to do this with a true HTML web page. However it should work if you use an HTML application file (HTA extension). It depends on your use case whether this is applicable.
Best regards,
Christian
‎2005 Jun 25 11:09 AM
Thanks,
I was not aware of the existance of .hta html applications.
By just renaming the .htm file to .hta, the script indeed worked fine!