js 连接sap

<html>

<head>
<title>Calling SAP From Javascript</title>
<meta name="JAVASCRIPT" content="Active-X for SAP">
<meta name="AUTHOR" content="Axel Angeli Logos! Informatik GmbH">
<link rel="stylesheet" href="../../style.css" type="text/css">
<meta NAME="keywords"
CONTENT="SAP,R/3,javascript,logosworld,logos!,axel, angeli, axelangeli, activex,IDoc, IDoc, EDI, ALE,RFC, remotefunctioncall,Workflow
, ABAP IV, ABAB IV">
<meta NAME="description"
CONTENT="Axel Angeli's Logosworld - Example how to call SAP R/3 from JavaScript">
</head>

<body>

<h2>Calling SAP From Javascript</h2>

<p>This HTML document contains a small JavaScript which creates an Active-X object for SAP
Automation GUI. When you click on the button below it will try to call the transaction
VA02 using an RFC to the function RFC_CALL_TRANSACTION_USING. You must have SAP Automation
GUI DLLs installed, otherwise you will receive a message, that the Active-X object cannot
be created. To try it out you better install the complete SAP GUI including the RFC SDK. </p>

<p>You will be asked for userid and password. This example works with any ABAP function
that has RFC enabled. </p>

<hr>

<p><script language="JavaScript"><!--
retcd = 0;
exceptions = 0;

function SAPlogon()
{
fns = new ActiveXObject("SAP.Functions");
trans = fns.Transactions;
conn = fns.connection;
conn.System = "DEV";
conn.user = "FIXIONGF";
conn.password = "11894";
conn.Client = "400";
conn.Language = "E";
conn.tracelevel = 6;
conn.RFCWithDialog = 1;

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") = "VA02";
callta.exports("MODE") = "E";
retcd = callta.call;
conn.logoff();
alert(retcd);
SAPcallTransaction = retcd;
};

// --></script> Call VA02 <input TYPE="submit" VALUE="VA02"
onClick="SAPlogon(); SAPcallTransaction(&quot;VA02&quot;); SAPlogoff()"> </p>

<hr>

<h3>The following coding is contained in this HTML-Document</h3>
<div align="left">

<table border="0">
<tr>
<td colspan="2"><font FACE="Courier New" SIZE="2">&lt;script
language=&quot;JavaScript&quot;&gt;&lt;!--</font></td>
</tr>
<tr>
<td></td>
<td><font FACE="Courier New" SIZE="2">retcd = 0;</font></td>
</tr>
<tr>
<td></td>
<td><font FACE="Courier New" SIZE="2">exceptions = 0;</font></td>
</tr>
<tr>
<td colspan="2">&nbsp;<p><font FACE="Courier New" SIZE="2">function SAPlogon()</font></td>
</tr>
<tr>
<td></td>
<td><font FACE="Courier New" SIZE="2">{</font></td>
</tr>
<tr>
<td></td>
<td><font FACE="Courier New" SIZE="2">fns = new ActiveXObject(&quot;SAP.Functions&quot;);</font></td>
</tr>
<tr>
<td></td>
<td><font FACE="Courier New" SIZE="2">trans = fns.Transactions;</font></td>
</tr>
<tr>
<td></td>
<td><font FACE="Courier New" SIZE="2">conn = fns.connection;</font></td>
</tr>
<tr>
<td></td>
<td><font FACE="Courier New" SIZE="2">conn.System = &quot;DEV&quot;;</font></td>
</tr>
<tr>
<td></td>
<td><font FACE="Courier New" SIZE="2">conn.user = &quot;userid&quot;;</font></td>
</tr>
<tr>
<td></td>
<td><font FACE="Courier New" SIZE="2">conn.password = &quot;&quot;;</font></td>
</tr>
<tr>
<td></td>
<td><font FACE="Courier New" SIZE="2">conn.Client = &quot;100&quot;;</font></td>
</tr>
<tr>
<td></td>
<td><font FACE="Courier New" SIZE="2">conn.Language = &quot;E&quot;;</font></td>
</tr>
<tr>
<td></td>
<td><font FACE="Courier New" SIZE="2">conn.tracelevel = 6;</font></td>
</tr>
<tr>
<td></td>
<td><font FACE="Courier New" SIZE="2">conn.RFCWithDialog = 1; </font></td>
</tr>
<tr>
<td></td>
<td><font FACE="Courier New" SIZE="2">conn.logon(0, 0); </font></td>
</tr>
<tr>
<td></td>
<td><font FACE="Courier New" SIZE="2">exceptions = 0;</font></td>
</tr>
<tr>
<td></td>
<td><font FACE="Courier New" SIZE="2">};</font></td>
</tr>
<tr>
<td colspan="2">&nbsp;<p><font FACE="Courier New" SIZE="2">function SAPlogoff()</font></td>
</tr>
<tr>
<td></td>
<td><font FACE="Courier New" SIZE="2">{</font></td>
</tr>
<tr>
<td></td>
<td><font FACE="Courier New" SIZE="2">conn.logoff(0, 0); </font></td>
</tr>
<tr>
<td></td>
<td><font FACE="Courier New" SIZE="2">exceptions = 0;</font></td>
</tr>
<tr>
<td></td>
<td><font FACE="Courier New" SIZE="2">};</font></td>
</tr>
<tr>
<td colspan="2">&nbsp;<p><font FACE="Courier New" SIZE="2">function SAPcallTransaction(tcode)</font></td>
</tr>
<tr>
<td></td>
<td><font FACE="Courier New" SIZE="2">{</font></td>
</tr>
<tr>
<td></td>
<td><font FACE="Courier New" SIZE="2">exceptions = 0;</font></td>
</tr>
<tr>
<td></td>
<td><font FACE="Courier New" SIZE="2">callta =
fns.add(&quot;RFC_CALL_TRANSACTION_USING&quot;);</font></td>
</tr>
<tr>
<td></td>
<td><font FACE="Courier New" SIZE="2">callta.exports(&quot;TCODE&quot;) =
&quot;VA02&quot;;</font></td>
</tr>
<tr>
<td></td>
<td><font FACE="Courier New" SIZE="2">callta.exports(&quot;MODE&quot;) = &quot;E&quot;;</font></td>
</tr>
<tr>
<td></td>
<td><font FACE="Courier New" SIZE="2">retcd = callta.call;</font></td>
</tr>
<tr>
<td></td>
<td><font FACE="Courier New" SIZE="2">conn.logoff(); </font></td>
</tr>
<tr>
<td></td>
<td><font FACE="Courier New" SIZE="2">alert(retcd);</font></td>
</tr>
<tr>
<td></td>
<td><font FACE="Courier New" SIZE="2">SAPcallTransaction = retcd;</font></td>
</tr>
<tr>
<td></td>
<td><font FACE="Courier New" SIZE="2">};</font></td>
</tr>
<tr>
<td colspan="2">&nbsp;<p><font size="2">// --&gt;&lt;/script&gt;</font></td>
</tr>
</table>
</div>
</body>
</html>

你可能感兴趣的:(JavaScript,workflow,css)