public function testReadTable()
 {
     try {
         $conn = new sapnwrfc($this->config);
         $h = $conn->function_lookup('RFC_GET_TABLE_ENTRIES');
         $parms = array('BYPASS_BUFFER' => 'X', 'MAX_ENTRIES' => 1, 'TABLE_NAME' => 'T005ZR');
         $h->invoke($parms);
     } catch (sapnwrfcCallException $e) {
         //echo "Exception type: ".$e."\n";
         echo "Exception key: " . $e->key . "\n";
         echo "Exception code: " . $e->code . "\n";
         echo "Exception message: " . $e->getMessage() . "\n";
         $this->assertTrue(true);
     } catch (Exception $e) {
         echo "Exception type: " . $e . "\n";
         echo "Exception key: " . $e->key . "\n";
         echo "Exception code: " . $e->code . "\n";
         echo "Exception message: " . $e->getMessage() . "\n";
         throw new Exception('Connection failed.');
     }
     echo "I am a happy piece of code that carried on....\n";
 }
Beispiel #2
0
 public function testConnectionThrow3()
 {
     try {
         $conn = new sapnwrfc($this->config);
         $h = $conn->function_lookup('RFC_READ_TABLE');
         $h->invoke(array('DATA' => array(array('NOT_THERE' => 1))));
     } catch (sapnwrfcCallException $e) {
         echo "Exception type: " . $e . "\n";
         echo "Exception key: " . $e->key . "\n";
         echo "Exception code: " . $e->code . "\n";
         echo "Exception message: " . $e->getMessage();
         $this->assertTrue(true);
     } catch (Exception $e) {
         echo "Exception type: " . $e . "\n";
         echo "Exception key: " . $e->key . "\n";
         echo "Exception code: " . $e->code . "\n";
         echo "Exception message: " . $e->getMessage();
         throw new Exception('Connection failed.');
     }
 }
<?php

/**
 * Alternative ping the SAP system
 */
if (!extension_loaded('sapnwrfc')) {
    throw new \Exception('Extension "sapnwrfc" not loaded. Please see https://github.com/piersharding/php-sapnwrfc#installation');
}
// @see the available connection paraemters here
// http://help.sap.com/saphelp_nwpi711/helpdata/en/48/c7bb09da5e31ebe10000000a42189b/content.htm
$config = ['MSHOST' => '...', 'CLIENT' => '...', 'R3NAME' => '...', 'GROUP' => '...', 'CODEPAGE' => '...', 'LANG' => 'en', 'LCHECK' => true, 'TRACE' => true, 'user' => '...', 'passwd' => '...'];
// change the directory for logging
$cwd = getcwd();
chdir('my/log/dir');
try {
    $conn = new sapnwrfc($config);
} catch (Exception $ex) {
    throw $ex;
} finally {
    // change the cwd always back to the previous value
    chdir($cwd);
}
$func = $conn->function_lookup('RFC_PING');
$result = $func->invoke([]);
// is an empty array
if (is_array($result)) {
    echo 'Successfully pinged the SAP system';
} else {
    echo 'Could not ping the SAP system';
}
$conn->close();
<?php

/**
 * Get some system informations
 */
if (!extension_loaded('sapnwrfc')) {
    throw new \Exception('Extension "sapnwrfc" not loaded. Please see https://github.com/piersharding/php-sapnwrfc#installation');
}
// @see the available connection paraemters here
// http://help.sap.com/saphelp_nwpi711/helpdata/en/48/c7bb09da5e31ebe10000000a42189b/content.htm
$config = ['MSHOST' => '...', 'CLIENT' => '...', 'R3NAME' => '...', 'GROUP' => '...', 'CODEPAGE' => '...', 'LANG' => 'en', 'LCHECK' => true, 'TRACE' => true, 'user' => '...', 'passwd' => '...'];
$conn = new sapnwrfc($config);
$func = $conn->function_lookup('RFC_SYSTEM_INFO');
$result = $func->invoke([]);
// is an empty array
if (is_array($result)) {
    var_dump($result);
} else {
    echo 'Could not ping the SAP system';
}
$conn->close();
<?php

/**
 * Call a RFC function
 */
if (!extension_loaded('sapnwrfc')) {
    throw new \Exception('Extension "sapnwrfc" not loaded. Please see https://github.com/piersharding/php-sapnwrfc#installation');
}
// @see the available connection paraemters here
// http://help.sap.com/saphelp_nwpi711/helpdata/en/48/c7bb09da5e31ebe10000000a42189b/content.htm
$config = ['MSHOST' => '...', 'CLIENT' => '...', 'R3NAME' => '...', 'GROUP' => '...', 'CODEPAGE' => '...', 'LANG' => 'en', 'LCHECK' => true, 'TRACE' => true, 'user' => '...', 'passwd' => '...'];
$conn = new sapnwrfc($config);
$fds = $conn->function_lookup('STFC_DEEP_STRUCTURE');
$fdt = $conn->function_lookup('STFC_DEEP_TABLE');
$parms = ['IMPORTSTRUCT' => ['I' => 123, 'C' => 'AbCdEf', 'STR' => 'The quick brown fox ...']];
$results = $fds->invoke($parms);
var_dump($results);
$parms = ['IMPORT_TAB' => [['I' => 123, 'C' => 'AbCdEf', 'STR' => 'The quick brown fox ...']]];
$results = $fdt->invoke($parms);
var_dump($results);
$conn->close();