‎2006 Jun 15 3:55 PM
Hi,
I would like to call SAP from JavaScript using ActiveX "SAP.Functions". I manage it all the way with the following JavaScript code (same thing can be done using Visual Basic) :
var retcd = 0;
var exceptions = 0;
function SAPlogon() {
fns = new ActiveXObject("SAP.Functions");
var trans = fns.Transactions;
var conn = fns.connection;
conn.ApplicationServer = "xxxx"
conn.System = "xx"
conn.SystemNumber = "00"
conn.UseSAPLogonIni = "false"
conn.user = "smith";
conn.password = "azerty";
conn.client = "200";
conn.language = "E";
conn.tracelevel = 6;
conn.RFCWithDialog = true;
conn.logon(0,0);
exceptions = 0;
}
function SAPlogoff() {
conn.logoff(0, 0);
exceptions = 0;
}
function SAPcallTransaction(tcode) {
exceptions = 0;
callta = fns.add("RFC_CALL_TRANSACTION_USING");
callta.exports("TCODE") = tcode;
callta.exports("MODE") = "E";
retcd = callta.call;
conn.logoff();
SAPcallTransaction = retcd;
}But, i am facing 2 issues:
1) I would like to have <b>silent logon</b>, and somehow, the <i>RFCWithDialog = False</i> approach triggers an error
2) To <b>avoid placing credentials "hard-coded"</b> (not the best especially in a Web environment), I would like to <b>use the SAP Logon Ticket</b> the BSP page has generated
Thanks in advance!!
Best regards,
Guillaume
PS : I have already read really useful "SAP Automation RFC and BAPI Interfaces (BC-FES-AIT)" http://help.sap.com/saphelp_46c/helpdata/en/39/7e11e0ac6011d189c60000e829fbbd/frameset.htm
‎2006 Nov 23 11:58 AM
The "True" parameter in the command below will result in supprising the logon window.
sapConn.Connection.logon(0, True)
The following example should work:
sapConn.Connection.ApplicationServer = "10.241.1.20"
sapConn.Connection.Client = "200"
sapConn.Connection.System = "C10"
sapConn.Connection.SystemNumber = "00"
sapConn.Connection.User = "USERNAME"
sapConn.Connection.Password = "password"
sapConn.Connection.tracelevel = "6"
If sapConn.Connection.logon(0, True) <> True Then 'Try Logon
MsgBox "Cannot Log on to SAP"
End If
‎2006 Jun 15 4:21 PM
‎2006 Nov 23 11:58 AM
The "True" parameter in the command below will result in supprising the logon window.
sapConn.Connection.logon(0, True)
The following example should work:
sapConn.Connection.ApplicationServer = "10.241.1.20"
sapConn.Connection.Client = "200"
sapConn.Connection.System = "C10"
sapConn.Connection.SystemNumber = "00"
sapConn.Connection.User = "USERNAME"
sapConn.Connection.Password = "password"
sapConn.Connection.tracelevel = "6"
If sapConn.Connection.logon(0, True) <> True Then 'Try Logon
MsgBox "Cannot Log on to SAP"
End If