1. Go to this page and download the library: Download cti/saprfc library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
cti / saprfc example snippets
use Cti\SapRfc\Gateway;
// params for saprfc_open
// http://saprfc.sourceforge.net/src/saprfc.html#function.saprfc-open.html
$connectionParams = array(
'USER' => 'USERNAME',
'PASSWD' => 'PASSWORD',
// ...
);
$sap = new Gateway($connectionParams);
$request = array(
// use import params
'I_ID_USER' => 12345,
'I_LIMIT' => 50,
'I_OFFSET' => 25,
// fill tables
'IT_FILTER' => array(
array('FIELD' => 'STATUS', 'VALUE' => 'ACTIVE')
)
);
$response = array(
// use export params
'TOTAL_CNT', 'LAST_UPDATE',
// use table result
'IT_RECIPE_LIST'
);
$result = $sap->execute('Z_GET_RECIPE_LIST', $request, $response);
// $result contains properties TOTAL_CNT, LAST_UPDATE, IT_RECIPE_LIST.
// TOTAL_CNT and LAST_UPDATE are scalar values
// IT_RECIPE_LIST is array of data
//
echo $result->TOTAL_CNT;
foreach($result->IT_RECIPE_LIST as $recipe) {
echo $recipe->ID_RECIPE, ' ', $recipe->name, '<br/>';
}
use Cti\SapRfc\Gateway;
use Cti\SapRfc\Proxy;
// params for saprfc_open
// http://saprfc.sourceforge.net/src/saprfc.html#function.saprfc-open.html
$connectionParams = array(
'USER' => 'USERNAME',
'PASSWD' => 'PASSWORD',
// ...
);
$sap = new Gateway($connectionParams);
$proxy = new Proxy();
$proxy->processRequest($sap);
use Cti\SapRfc\Proxy;
$request = array(
// use import params
'I_ID_USER' => 12345,
'I_LIMIT' => 50,
'I_OFFSET' => 25,
// fill tables
'IT_FILTER' => array(
array('FIELD' => 'STATUS', 'VALUE' => 'ACTIVE')
)
);
$response = array(
// use export params
'TOTAL_CNT', 'LAST_UPDATE',
// use table result
'IT_RECIPE_LIST'
);
$proxy = new Proxy();
$proxy->setUrl("http://intranet_server_url/proxy.php");
$result = $proxy->execute('Z_GET_RECIPE_LIST', $request, $response);
// $result contains properties TOTAL_CNT, LAST_UPDATE, IT_RECIPE_LIST.
// TOTAL_CNT and LAST_UPDATE are scalar values
// IT_RECIPE_LIST is array of data
//
echo $result->TOTAL_CNT;
foreach($result->IT_RECIPE_LIST as $recipe) {
echo $recipe->ID_RECIPE, ' ', $recipe->name, '<br/>';
}