<?php class PartnerRepository extends SapFunction { #My system specific function, don't bother const RFC_FUNCTION_NAME = 'Z_RFC_PARTNER_SELECT'; public function getName() { return self::RFC_FUNCTION_NAME; } public function getPartners($vatnum) { $result = $this->__invoke(array('I_PARS' => array('STCD2' => $vatnum))); return $result['ET_PARTNER_LIST']; } } $sapConfig = (include __DIR__ . DIRECTORY_SEPARATOR . 'sap_config.php'); $sap = new Sap($sapConfig); $partnerRepository = new PartnerRepository(); $sap->fetchFunction($partnerRepository); $partners = $partnerRepository->getPartners('123456789'); print_r($partners);
} $arr[] = $obj; } return $arr; } public function select($fields, $table, $where = array(), $rowcount = 0, $offset = 0) { return $this->mapToObjects(parent::select($fields, $table, $where, $rowcount, $offset)); } } $sapConfig = (include __DIR__ . DIRECTORY_SEPARATOR . 'sap_config.php'); try { $sap = new Sap($sapConfig); /* * Option 1: Fetch RFC_READ_TABLE function into a previously * instatiated instance of 'MyRfcReadTable' class */ #$myRfcReadTable = new MyRfcReadTable('Argument #1'); #$sap->fetchFunction($myRfcReadTable); /* * Option 2: Fetch RFC_READ_TABLE function, returning a new instance * of 'MyRfcReadTable' class with constructor arguments */ $myRfcReadTable = $sap->fetchFunction('RFC_READ_TABLE', 'MyRfcReadTable', array('Argument #1')); /* Reads the selected fields for the first 5 rows of table 'T100' with constraint SPRSL = 'D' */ $data = $myRfcReadTable->select(array('SPRSL' => 'LANG', 'ARBGB' => 'MSGID', 'MSGNR', 'TEXT'), 'T100', array('SPRSL' => 'D'), 5); } catch (SapException $se) { echo 'SapException ::', $se->getMessageKey(), ':: ', $se->getMessage(), PHP_EOL; exit(1); } print_r($data);
return $this->reason; } } $sapConfig = (include __DIR__ . DIRECTORY_SEPARATOR . 'sap_config.php'); if (isset($argc, $argv) && $argc > 2) { /* get username/password from command line arguments */ $username = $argv[1]; $password = $argv[2]; } else { /* use Sap logon parameters to test this example */ $username = $sapConfig['user']; $password = $sapConfig['passwd']; } try { $sap = new Sap($sapConfig); $loginCheckFunction = $sap->fetchFunction('SUSR_LOGIN_CHECK_RFC', 'SapRfcUserLogin'); } catch (SapException $se) { echo 'System not available (', $se->getMessageKey(), ')', PHP_EOL, $se->getMessage(), PHP_EOL; exit(1); } echo "Authenticating {$username}... "; switch ($loginCheckFunction->authenticate($username, $password)) { case $loginCheckFunction::SUCCESS: echo 'SUCCESS!', PHP_EOL; break; default: switch ($loginCheckFunction->getReason()) { case 'PASSWORD_EXPIRED': /* You could use the SUSR_USER_CHANGE_PASSWORD_RFC function for password change here */ /* You could use the SUSR_USER_CHANGE_PASSWORD_RFC function for password change here */ default: