/** * Define interface of function module * * @param [rfc] RFC handle * @param [name] Name of function module * @param [def] Definition of function interface * * @return SAPRFC_OK on success, SAPRFC_ERROR on failure */ function Define($rfc, $name, $def) { if ($this->fce) { return $this->SetStatus(SAPRFC_ERROR, "SAPFunction::Define: Function is " . "already defined."); } $this->fce = @saprfc_function_define($rfc, strtoupper($name), $def); if ($this->fce == false) { return $this->SetStatus(SAPRFC_ERROR, "SAPFunction::Define: " . "Failed for function module " . $name . "\n" . "with error " . @saprfc_error()); } $this->rfc = $rfc; $this->name = @saprfc_function_name($this->fce); $this->exception = ""; $this->server = $rfc == false ? true : false; $this->bapi = substr($this->name, 0, 4) == "BAPI"; $this->def = $this->GetDefinition(); $this->InitVars(); return $this->SetStatus(SAPRFC_OK, ""); }
function install() { global $GLOBAL_FCE_LIST, $rfc_handle; $tbuf = "\n<== RfcInstallTransactionControl"; TRFC_trace($tbuf); saprfc_trfc_install ("TID_check", "TID_commit", "TID_rollback", "TID_confirm","USER_GLOBAL_SERVER"); $tbuf = sprintf("\n<== RfcInstallFunction '%s' rfc_rc = ", "STFC_WRITE_TO_TCPIC"); TRFC_trace($tbuf); $def = array ( array ( "name"=>"RESTART_QNAME", "type"=>"IMPORT", "optional"=>"0", "def"=> array ( array ("name"=>"","abap"=>"C","len"=>24,"dec"=>0) ) ), array ( "name"=>"TCPICDAT", "type"=>"TABLE", "optional"=>"0", "def"=> array ( array ("name"=>"LINE","abap"=>"C","len"=>72,"dec"=>0) ) ) ); $GLOBAL_FCE_LIST["STFC_WRITE_TO_TCPIC"] = saprfc_function_define($rfc_handle,"STFC_WRITE_TO_TCPIC",$def); return SAPRFC_OK; }
"def"=> array ( array ("name"=>"","abap"=>"C","len"=>40,"dec"=>0) ) ), array ( "name"=>"QTAB", "type"=>"TABLE", "optional"=>"0", "def"=> array ( array ("name"=>"LINE","abap"=>"C","len"=>72,"dec"=>0) ) ) ); // Create list of PHP server functions $GLOBAL_FCE_LIST[RFC_READ_REPORT] = saprfc_function_define(0,"RFC_READ_REPORT",$DEF_RFC_READ_REPORT); // PHP server function function RFC_READ_REPORT ($fce) { $REPORT = saprfc_server_import ($fce,"PROGRAM"); saprfc_table_init ($fce,"QTAB"); $fd = fopen ($REPORT,"r"); if (!$fd) return ("NOTFOUND"); // raise exception "NOTFOUND" while (!feof($fd)) { $LINE = fgets ($fd,73); saprfc_table_append ($fce,"QTAB",array("LINE"=>$LINE)); } fclose ($fd);