Skip to Content
0
Sep 21, 2020 at 11:31 AM

Connection with SAPRFC using PHP

939 Views

I want to do a connection with SAP-RFC using PHP. I have installed 'Wamp' server with PHP 5.2.8, Apache 2.0.54 and SAP-RFC 1.4.1. I am using old version of PHP because I could not find much of help for PHP version 7.2.

I have done the following steps:

1. Changed in parameters like Host/server IP, System number, R3 name, client, username and password.
2. Put DLL files in the extension folder and mentioned it in the PHP.ini file.
3. Added librfc32.dll file in the system32 directory.

$LOGIN = array ( // Set login data to R/3"ASHOST"=>"xx.xxx.x.xxx", // application server host name
"SYSNR"=>"00", // system number
"CLIENT"=>"130", // client"USER"=>"xxxx", // user
"PASSWD"=>"xxxx", // pasword
"CODEPAGE"=>"1404"); // codepage

$rfc = saprfc_open ($LOGIN);
if (! $rfc )
{
echo "RFC connection failed with error:".saprfc_error();
exit;
}

--------------------------------------------------------------------------------------------

include_once ("../sap.php");
$sap = new SAPConnection();
// Params: hostname sysnr $sap->ConnectToApplicationServer ("xx.xxx.x.xxx ", "00");
// Params: client username password language $sap->Open ("130", "xxxx","xxxxx","EN");

// Login credentials have been added in the code.
$sap->PrintStatus();
$sap->GetSystemInfo();
echo "<BR><PRE>"; print_r ($sap); echo ("</PRE>");
$sap->Close();

------------------------------------------------------------------------------------------------------

Output - "SAP RFC extension is not installed. Exiting...."

Your help would be highly appreciated.