Beispiel #1
0
 /**
  * @param string $name
  * @param array $request
  * @param array $responseKeys
  * @throws Exception
  * @return object
  */
 public function execute($name, $request, $responseKeys)
 {
     $start = microtime(1);
     $fce = saprfc_function_discover($this->connection, $name);
     if (!$fce) {
         throw new Exception("Error discovering " . $name, 1);
     }
     foreach ($request as $k => $v) {
         if (is_array($v)) {
             foreach ($v as $index => $row) {
                 if (is_object($row)) {
                     $row = get_object_vars($row);
                 }
                 foreach ($row as $row_key => $row_value) {
                     $row[$row_key] = $this->encodeString($row_value);
                 }
                 saprfc_table_insert($fce, $k, $row, $index + 1);
             }
         } else {
             saprfc_request($fce, $k, $this->encodeString($v));
         }
     }
     $result = saprfc_call_and_receive($fce);
     if ($result != SAPRFC_OK) {
         $message = isset($this->errors[$result]) ? $this->errors[$result] : 'Unknown error';
         if ($this->profiler) {
             $this->profiler->register((object) array('name' => $name, 'request' => $request, 'success' => false, 'message' => $message, 'time' => microtime(1) - $start));
         }
         throw new Exception($message);
     }
     $response = array();
     foreach ($responseKeys as $table) {
         $count = saprfc_table_rows($fce, $table);
         if ($count == -1) {
             // responseKeys param
             $data = $this->decodeString(saprfc_export($fce, $table));
         } else {
             // responseKeys table
             $data = array();
             for ($i = 1; $i <= $count; $i++) {
                 $row = saprfc_table_read($fce, $table, $i);
                 foreach ($row as $k => $v) {
                     $row[$k] = $this->decodeString($v);
                 }
                 $data[] = (object) $row;
             }
         }
         $response[$table] = $data;
     }
     if ($this->profiler) {
         $this->profiler->register((object) array('name' => $name, 'request' => (object) $request, 'response' => (object) $response, 'success' => true, 'time' => microtime(1) - $start));
     }
     return (object) $response;
 }
Beispiel #2
0
 /**
  * @author Manuel Will
  * @since 2013
  *
  * @param string $moduleName
  * @param SAP_Table_Abstract $table
  */
 public function setTable($moduleName, SAP_Table_Abstract $table)
 {
     $tableName = $table->getName();
     $dataSap = $this->getDataFromClass($table);
     if (!isset($this->tableLoop[$tableName])) {
         $this->tableLoop[$tableName] = 1;
     }
     $loop =& $this->tableLoop[$tableName];
     $this->debug['table'][$tableName]['parameters'][$loop] = $dataSap;
     $this->debugCompressed['table'][$tableName]['parameters'][$loop] = $this->compressData($dataSap);
     $state = saprfc_table_insert($this->getModuleResource($moduleName), $tableName, $dataSap, $this->tableLoop);
     $this->debug['table'][$tableName]['states'][$loop]['successfully'] = (bool) $state;
     $loop++;
 }
Beispiel #3
0
 /**
  * Insert raw into internal table
  */
 function Insert($row, $index = 1)
 {
     if ($this->__CheckParams($index, true, true) == false) {
         return false;
     }
     unset($this->row);
     $this->row = array();
     foreach ($this->rowStruct as $member) {
         if (is_array($row) && isset($row[$member])) {
             $this->row[$member] = $row[$member];
         } else {
             $this->row[$member] = "";
         }
     }
     return @saprfc_table_insert($this->fce, $this->name, $this->row, $index);
 }