Calling php functions from sap
hi all,
I have to call the php functions from the r/3. my requirement is that I have to read the mail from the internet adress([email protected]) through php and then send its content in r/3.For that I have to write function in php which are rfc enabled and then call those function in r/3. Can anyone help me in calling the php function from r/3 and how to get the content of mail in r/3.I have to create php as a server and r/3 as client.
regards
ashish
hi Anton,
I have get have to read the read the internert mail in php hrough this class . I am sending you that code test_pop3.php. For this you even need pop3 class. I am even sending you that code.It will be better if you give me your mail id. But I donot know how to create a rfc enabled function in php that can be read in r/3 .
<?php
test_pop3.php
@(#) $Header: /home/mlemos/cvsroot/pop3/test_pop3.php,v 1.6 2005/10/18 17:44:46 mlemos Exp $
?><HTML>
<HEAD>
<TITLE>Read email attachments from pop3 server</TITLE>
</HEAD>
<BODY>
<?php
require("pop3.php");
/* Uncomment when using SASL authentication mechanisms */
require("sasl.php");
$pop3=new pop3_class;
$pop3->hostname=""; /* POP 3 server host name */
$pop3->port=110; /* POP 3 server host port */
$user=""; /* Authentication user name */
$password=""; /* Authentication password */
$pop3->realm=""; /* Authentication realm or domain */
$pop3->workstation=""; /* Workstation for NTLM authentication */
$apop=0; /* Use APOP authentication */
$pop3->authentication_mechanism="USER"; /* SASL authentication mechanism */
$pop3->debug=0; /* Output debug information */
$pop3->html_debug=0; /* Debug information is in HTML */
$pop3->join_continuation_header_lines=1; /* Concatenate headers split in multiple lines */
if(($error=$pop3->Open())=="")
echo "<PRE>Connected to the POP3 server "".$pop3->hostname."".</PRE>\n";
if(($error=$pop3->Login($user,$password,$apop))=="")
echo "<PRE>User "$user" logged in.</PRE>\n";
if(($error=$pop3->Statistics($messages,$size))=="")
echo "<PRE>There are $messages messages in the mail box with a total of $size bytes.</PRE>\n";
$result=$pop3->ListMessages("",0);
if(GetType($result)=="array")
for(Reset($result),$message=0;$message<count($result);Next($result),$message++)
echo "<PRE>Message ",Key($result)," - ",$result[Key($result)]," bytes.</PRE>\n";
$result=$pop3->ListMessages("",1);
if(GetType($result)=="array")
for(Reset($result),$message=0;$message<count($result);Next($result),$message++)
echo "<PRE>Message ",Key($result),", Unique ID - \"",$result[Key($result)],"\"</PRE>\n";
if($messages>0)
$var = 1;
if(($error=$pop3->RetrieveMessage($var,$headers,$body,-1))=="")
for($line=0;$line<count($headers);$line++)
if(($error=$pop3->RetrieveMessage(34,$headers,$body,-1))=="")
echo "<PRE>Message 1:\n-Message headers starts below-</PRE>\n";
for($line=0;$line<count($headers);$line++)
echo "<PRE>",HtmlSpecialChars($headers[$line]),"</PRE>\n";
echo "<PRE>-Message headers ends above-\n-Message body starts below-</PRE>\n";
for($line=0;$line<count($body);$line++)
echo "<PRE>",HtmlSpecialChars($body[$line]),"</PRE>\n";
echo "<PRE>-Message body ends above-</PRE>\n";
if(($error=$pop3->DeleteMessage(1))=="")
echo "<PRE>Marked message 1 for deletion.</PRE>\n";
if(($error=$pop3->ResetDeletedMessages())=="")
echo "<PRE>Resetted the list of messages to be deleted.</PRE>\n";
if($error==""
&& ($error=$pop3->Close())=="")
echo "<PRE>Disconnected from the POP3 server "".$pop3->hostname."".</PRE>\n";
else
$error=$result;
else
$error=$result;
if($error!="")
echo "<H2>Error: ",HtmlSpecialChars($error),"</H2>";
?>
</BODY>
</HTML>
*******start of new php file********
<?php
pop3.php
@(#) $Header: /home/mlemos/cvsroot/pop3/pop3.php,v 1.15 2005/10/18 17:43:25 mlemos Exp $
class pop3_class
var $hostname="";
var $port=110;
var $quit_handshake=0;
var $error="";
var $authentication_mechanism="USER";
var $realm="";
var $workstation="";
var $join_continuation_header_lines=1;
/* Private variables - DO NOT ACCESS */
var $connection=0;
var $state="DISCONNECTED";
var $greeting="";
var $must_update=0;
var $debug=0;
var $html_debug=0;
var $next_token="";
/* Private methods - DO NOT CALL */
Function Tokenize($string,$separator="")
if(!strcmp($separator,""))
$separator=$string;
$string=$this->next_token;
for($character=0;$character<strlen($separator);$character++)
if(GetType($position=strpos($string,$separator[$character]))=="integer")
$found=(IsSet($found) ? min($found,$position) : $position);
if(IsSet($found))
$this->next_token=substr($string,$found+1);
return(substr($string,0,$found));
else
$this->next_token="";
return($string);
Function SetError($error)
return($this->error=$error);
Function OutputDebug($message)
$message.="\n";
if($this->html_debug)
$message=str_replace("\n","<br />\n",HtmlEntities($message));
echo $message;
flush();
Function GetLine()
for($line="";;)
if(feof($this->connection))
return(0);
$line.=fgets($this->connection,100);
$length=strlen($line);
if($length>=2
&& substr($line,$length-2,2)=="\r\n")
$line=substr($line,0,$length-2);
if($this->debug)
$this->OutputDebug("S $line");
return($line);
Function PutLine($line)
if($this->debug)
$this->OutputDebug("C $line");
return(fputs($this->connection,"$line\r\n"));
Function OpenConnection()
if($this->hostname=="")
return($this->SetError("2 it was not specified a valid hostname"));
if($this->debug)
$this->OutputDebug("Connecting to ".$this->hostname." ...");
if(($this->connection=@fsockopen($this->hostname,$this->port,$error))==0)
switch($error)
case -3:
return($this->SetError("-3 socket could not be created"));
case -4:
return($this->SetError("-4 dns lookup on hostname \"$hostname\" failed"));
case -5:
return($this->SetError("-5 connection refused or timed out"));
case -6:
return($this->SetError("-6 fdopen() call failed"));
case -7:
return($this->SetError("-7 setvbuf() call failed"));
default:
return($this->SetError($error." could not connect to the host \"".$this->hostname."\""));
return("");
Function CloseConnection()
if($this->debug)
$this->OutputDebug("Closing connection.");
if($this->connection!=0)
fclose($this->connection);
$this->connection=0;
/* Public methods */
/* Open method - set the object variable $hostname to the POP3 server address. */
Function Open()
if($this->state!="DISCONNECTED")
return($this->SetError("1 a connection is already opened"));
if(($error=$this->OpenConnection())!="")
return($error);
$this->greeting=$this->GetLine();
if(GetType($this->greeting)!="string"
|| $this->Tokenize($this->greeting," ")!="+OK")
$this->CloseConnection();
return($this->SetError("3 POP3 server greeting was not found"));
$this->Tokenize("<");
$this->must_update=0;
$this->state="AUTHORIZATION";
return("");
/* Close method - this method must be called at least if there are any
messages to be deleted */
Function Close()
if($this->state=="DISCONNECTED")
return($this->SetError("no connection was opened"));
if($this->must_update
|| $this->quit_handshake)
if($this->PutLine("QUIT")==0)
return($this->SetError("Could not send the QUIT command"));
$response=$this->GetLine();
if(GetType($response)!="string")
return($this->SetError("Could not get quit command response"));
if($this->Tokenize($response," ")!="+OK")
return($this->SetError("Could not quit the connection: ".$this->Tokenize("\r\n")));
$this->CloseConnection();
$this->state="DISCONNECTED";
return("");
/* Login method - pass the user name and password of POP account. Set
$apop to 1 or 0 wether you want to login using APOP method or not. */
Function Login($user,$password,$apop=0)
if($this->state!="AUTHORIZATION")
return($this->SetError("connection is not in AUTHORIZATION state"));
if($apop)
if(!strcmp($this->greeting,""))
return($this->SetError("Server does not seem to support APOP authentication"));
if($this->PutLine("APOP $user ".md5("<".$this->greeting.">".$password))==0)
return($this->SetError("Could not send the APOP command"));
$response=$this->GetLine();
if(GetType($response)!="string")
return($this->SetError("Could not get APOP login command response"));
if($this->Tokenize($response," ")!="+OK")
return($this->SetError("APOP login failed: ".$this->Tokenize("\r\n")));
else
$authenticated=0;
if(strcmp($this->authentication_mechanism,"USER")
&& function_exists("class_exists")
&& class_exists("sasl_client_class"))
if(strlen($this->authentication_mechanism))
$mechanisms=array($this->authentication_mechanism);
else
$mechanisms=array();
if($this->PutLine("CAPA")==0)
return($this->SetError("Could not send the CAPA command"));
$response=$this->GetLine();
if(GetType($response)!="string")
return($this->SetError("Could not get CAPA command response"));
if(!strcmp($this->Tokenize($response," "),"+OK"))
for(;;)
$response=$this->GetLine();
if(GetType($response)!="string")
return($this->SetError("Could not retrieve the supported authentication methods"));
switch($this->Tokenize($response," "))
case ".":
break 2;
case "SASL":
for($method=1;strlen($mechanism=$this->Tokenize(" "));$method++)
$mechanisms[]=$mechanism;
break;
$sasl=new sasl_client_class;
$sasl->SetCredential("user",$user);
$sasl->SetCredential("password",$password);
if(strlen($this->realm))
$sasl->SetCredential("realm",$this->realm);
if(strlen($this->workstation))
$sasl->SetCredential("workstation",$this->workstation);
do
$status=$sasl->Start($mechanisms,$message,$interactions);
while($status==SASL_INTERACT);
switch($status)
case SASL_CONTINUE:
break;
case SASL_NOMECH:
if(strlen($this->authentication_mechanism))
return($this->SetError("authenticated mechanism ".$this->authentication_mechanism." may not be used: ".$sasl->error));
break;
default:
return($this->SetError("Could not start the SASL authentication client: ".$sasl->error));
if(strlen($sasl->mechanism))
if($this->PutLine("AUTH ".$sasl->mechanism.(IsSet($message) ? " ".base64_encode($message) : ""))==0)
return("Could not send the AUTH command");
$response=$this->GetLine();
if(GetType($response)!="string")
return("Could not get AUTH command response");
switch($this->Tokenize($response," "))
case "+OK":
$response="";
break;
case "+":
$response=base64_decode($this->Tokenize("\r\n"));
break;
default:
return($this->SetError("Authentication error: ".$this->Tokenize("\r\n")));
for(;!$authenticated;)
do
$status=$sasl->Step($response,$message,$interactions);
while($status==SASL_INTERACT);
switch($status)
case SASL_CONTINUE:
if($this->PutLine(base64_encode($message))==0)
return("Could not send message authentication step message");
$response=$this->GetLine();
if(GetType($response)!="string")
return("Could not get authentication step message response");
switch($this->Tokenize($response," "))
case "+OK":
$authenticated=1;
break;
case "+":
$response=base64_decode($this->Tokenize("\r\n"));
break;
default:
return($this->SetError("Authentication error: ".$this->Tokenize("\r\n")));
break;
default:
return($this->SetError("Could not process the SASL authentication step: ".$sasl->error));
if(!$authenticated)
if($this->PutLine("USER $user")==0)
return($this->SetError("Could not send the USER command"));
$response=$this->GetLine();
if(GetType($response)!="string")
return($this->SetError("Could not get user login entry response"));
if($this->Tokenize($response," ")!="+OK")
return($this->SetError("User error: ".$this->Tokenize("\r\n")));
if($this->PutLine("PASS $password")==0)
return($this->SetError("Could not send the PASS command"));
$response=$this->GetLine();
if(GetType($response)!="string")
return($this->SetError("Could not get login password entry response"));
if($this->Tokenize($response," ")!="+OK")
return($this->SetError("Password error: ".$this->Tokenize("\r\n")));
$this->state="TRANSACTION";
return("");
/* Statistics method - pass references to variables to hold the number of
messages in the mail box and the size that they take in bytes. */
Function Statistics(&$messages,&$size)
if($this->state!="TRANSACTION")
return($this->SetError("connection is not in TRANSACTION state"));
if($this->PutLine("STAT")==0)
return($this->SetError("Could not send the STAT command"));
$response=$this->GetLine();
if(GetType($response)!="string")
return($this->SetError("Could not get the statistics command response"));
if($this->Tokenize($response," ")!="+OK")
return($this->SetError("Could not get the statistics: ".$this->Tokenize("\r\n")));
$messages=$this->Tokenize(" ");
$size=$this->Tokenize(" ");
return("");
/* ListMessages method - the $message argument indicates the number of a
message to be listed. If you specify an empty string it will list all
messages in the mail box. The $unique_id flag indicates if you want
to list the each message unique identifier, otherwise it will
return the size of each message listed. If you list all messages the
result will be returned in an array. */
Function ListMessages($message,$unique_id)
if($this->state!="TRANSACTION")
return($this->SetError("connection is not in TRANSACTION state"));
if($unique_id)
$list_command="UIDL";
else
$list_command="LIST";
if($this->PutLine("$list_command".($message ? " ".$message : ""))==0)
return($this->SetError("Could not send the $list_command command"));
$response=$this->GetLine();
if(GetType($response)!="string")
return($this->SetError("Could not get message list command response"));
if($this->Tokenize($response," ")!="+OK")
return($this->SetError("Could not get the message listing: ".$this->Tokenize("\r\n")));
if($message=="")
for($messages=array();;)
$response=$this->GetLine();
if(GetType($response)!="string")
return($this->SetError("Could not get message list response"));
if($response==".")
break;
$message=intval($this->Tokenize($response," "));
if($unique_id)
$messages[$message]=$this->Tokenize(" ");
else
$messages[$message]=intval($this->Tokenize(" "));
return($messages);
else
$message=intval($this->Tokenize(" "));
$value=$this->Tokenize(" ");
return($unique_id ? $value : intval($value));
/* RetrieveMessage method - the $message argument indicates the number of
a message to be listed. Pass a reference variables that will hold the
arrays of the $header and $body lines. The $lines argument tells how
many lines of the message are to be retrieved. Pass a negative number
if you want to retrieve the whole message. */
Function RetrieveMessage($message,&$headers,&$body,$lines)
if($this->state!="TRANSACTION")
return($this->SetError("connection is not in TRANSACTION state"));
if($lines<0)
$command="RETR";
$arguments="$message";
else
$command="TOP";
$arguments="$message $lines";
if($this->PutLine("$command $arguments")==0)
return($this->SetError("Could not send the $command command"));
$response=$this->GetLine();
if(GetType($response)!="string")
return($this->SetError("Could not get message retrieval command response"));
if($this->Tokenize($response," ")!="+OK")
return($this->SetError("Could not retrieve the message: ".$this->Tokenize("\r\n")));
for($headers=$body=array(),$line=0;;)
$response=$this->GetLine();
if(GetType($response)!="string")
return($this->SetError("Could not retrieve the message"));
switch($response)
case ".":
return("");
case "":
break 2;
default:
if(substr($response,0,1)==".")
$response=substr($response,1,strlen($response)-1);
break;
if($this->join_continuation_header_lines
&& $line>0
&& ($response[0]=="\t"
|| $response[0]==" "))
$headers[$line-1].=$response;
else
$headers[$line]=$response;
$line++;
for($line=0;;$line++)
$response=$this->GetLine();
if(GetType($response)!="string")
return($this->SetError("Could not retrieve the message"));
switch($response)
case ".":
return("");
default:
if(substr($response,0,1)==".")
$response=substr($response,1,strlen($response)-1);
break;
$body[$line]=$response;
return("");
/* DeleteMessage method - the $message argument indicates the number of
a message to be marked as deleted. Messages will only be effectively
deleted upon a successful call to the Close method. */
Function DeleteMessage($message)
if($this->state!="TRANSACTION")
return($this->SetError("connection is not in TRANSACTION state"));
if($this->PutLine("DELE $message")==0)
return($this->SetError("Could not send the DELE command"));
$response=$this->GetLine();
if(GetType($response)!="string")
return($this->SetError("Could not get message delete command response"));
if($this->Tokenize($response," ")!="+OK")
return($this->SetError("Could not delete the message: ".$this->Tokenize("\r\n")));
$this->must_update=1;
return("");
/* ResetDeletedMessages method - Reset the list of marked to be deleted
messages. No messages will be marked to be deleted upon a successful
call to this method. */
Function ResetDeletedMessages()
if($this->state!="TRANSACTION")
return($this->SetError("connection is not in TRANSACTION state"));
if($this->PutLine("RSET")==0)
return($this->SetError("Could not send the RSET command"));
$response=$this->GetLine();
if(GetType($response)!="string")
return($this->SetError("Could not get reset deleted messages command response"));
if($this->Tokenize($response," ")!="+OK")
return($this->SetError("Could not reset deleted messages: ".$this->Tokenize("\r\n")));
$this->must_update=0;
return("");
/* IssueNOOP method - Just pings the server to prevent it auto-close the
connection after an idle timeout (tipically 10 minutes). Not very
useful for most likely uses of this class. It's just here for
protocol support completeness. */
Function IssueNOOP()
if($this->state!="TRANSACTION")
return($this->SetError("connection is not in TRANSACTION state"));
if($this->PutLine("NOOP")==0)
return($this->SetError("Could not send the NOOP command"));
$response=$this->GetLine();
if(GetType($response)!="string")
return($this->SetError("Could not NOOP command response"));
if($this->Tokenize($response," ")!="+OK")
return($this->SetError("Could not issue the NOOP command: ".$this->Tokenize("\r\n")));
return("");
?>
Similar Messages
-
How to call a php function from java...
helllo fellow java developers!
Im trying to figure out how I can call a php function from my java code.
I know it sounds a bit unintiutive, seeing how java is a rich programming language, BUT java simply cannot do the task that the php script can do. It simply acts differently.
So I am trying to call a php function, that returns a string object, and capture that string object....
is this possible?
something like....
String strMyString = phpFunction( strVariable )
???????/ any ideaS?idea #1 - come up with a better plan that doesn't involve invoking php from java.
Give one example of something php can do that java can't.
idea #2 - forget java, and just write it in php.
Involving multiple frameworks/languages/runtime environments is a recipe for an overcomplicated solution that will be impossible to maintain.
I'd say keep it simple and stupid, and stick with one language.
If you're still hooked on the idea, maybe try [this link|http://www.infoq.com/news/2007/10/php-java-stack] -
Send data to ECC table through RFC Call function from SAP B1 via b1if
Hi,
I have created scenario in B1if which triggers from SAP B1, now I have to send this data in to ECC table, so I have created scenario for that with inbound SAP B1, outbound void and in process RFC Call atom is there but I am not getting data in receiver and also how to write xml to send data in RFC function. Function for RFC has configured from ECC end and have access of that function.
So please help me to send data to ECC table through RFC Call function from SAP B1 (9.0) via b1if
ThanksSolved by my own.
-
How does execute PHP Script from SAP?
I've already installed SAPRFC and run SAP Function from PHP successfully. But failed when tried execute PHP script from SAP (SM59). Anyone can help me for a clear instruction for this problem?
ThanksHi Max,
here is the Source:
[code]
#!/usr/bin/php -q
<?php
// SAPRFC - Server example
// PHP server function RFC_READ_REPORT
// Require: CGI version PHP, RFC destination defined in SAP R/3 (SM59)
// http://saprfc.sourceforge.net
// Interface definiton for RFC_READ_REPORT
// (generated by saprfc.php - option Generate PHP)
$DEF_RFC_READ_REPORT = array (
array (
"name"=>"SYSTEM",
"type"=>"EXPORT",
"optional"=>"0",
"def"=> array (
array ("name"=>"","abap"=>"C","len"=>8,"dec"=>0)
array (
"name"=>"TRDIR",
"type"=>"EXPORT",
"optional"=>"0",
"def"=> array (
array ("name"=>"NAME","abap"=>"C","len"=>40,"dec"=>0),
array ("name"=>"SQLX","abap"=>"C","len"=>1,"dec"=>0),
array ("name"=>"EDTX","abap"=>"C","len"=>1,"dec"=>0),
array ("name"=>"VARCL","abap"=>"C","len"=>1,"dec"=>0),
array ("name"=>"DBAPL","abap"=>"C","len"=>1,"dec"=>0),
array ("name"=>"DBNA","abap"=>"C","len"=>2,"dec"=>0),
array ("name"=>"CLAS","abap"=>"C","len"=>4,"dec"=>0),
array ("name"=>"TYPE","abap"=>"C","len"=>3,"dec"=>0),
array ("name"=>"OCCURS","abap"=>"C","len"=>1,"dec"=>0),
array ("name"=>"SUBC","abap"=>"C","len"=>1,"dec"=>0),
array ("name"=>"APPL","abap"=>"C","len"=>1,"dec"=>0),
array ("name"=>"SECU","abap"=>"C","len"=>8,"dec"=>0),
array ("name"=>"CNAM","abap"=>"C","len"=>12,"dec"=>0),
array ("name"=>"CDAT","abap"=>"D","len"=>8,"dec"=>0),
array ("name"=>"UNAM","abap"=>"C","len"=>12,"dec"=>0),
array ("name"=>"UDAT","abap"=>"D","len"=>8,"dec"=>0),
array ("name"=>"VERN","abap"=>"C","len"=>6,"dec"=>0),
array ("name"=>"LEVL","abap"=>"C","len"=>4,"dec"=>0),
array ("name"=>"RSTAT","abap"=>"C","len"=>1,"dec"=>0),
array ("name"=>"RMAND","abap"=>"C","len"=>3,"dec"=>0),
array ("name"=>"RLOAD","abap"=>"C","len"=>1,"dec"=>0),
array ("name"=>"FIXPT","abap"=>"C","len"=>1,"dec"=>0),
array ("name"=>"SSET","abap"=>"C","len"=>1,"dec"=>0),
array ("name"=>"SDATE","abap"=>"D","len"=>8,"dec"=>0),
array ("name"=>"STIME","abap"=>"C","len"=>6,"dec"=>0),
array ("name"=>"IDATE","abap"=>"D","len"=>8,"dec"=>0),
array ("name"=>"ITIME","abap"=>"C","len"=>6,"dec"=>0),
array ("name"=>"LDBNAME","abap"=>"C","len"=>20,"dec"=>0)
array (
"name"=>"PROGRAM",
"type"=>"IMPORT",
"optional"=>"0",
"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);
saprfc_server_export ($fce,"SYSTEM","PHP");
return (true);
// Call script with: ./server.php -a phpgw -g hostname -x sapgw00
$rfc = saprfc_server_accept ($argv);
// Dispatch one function call
$rc = saprfc_server_dispatch ($rfc,$GLOBAL_FCE_LIST);
saprfc_close ($rfc);
?>
[/code]
Regards
Gregor
Message was edited by: Gregor Wolf -
Calling a function from a DLL, exectution in background mode.
Dear Experts,
We have created an ABAP report the calls a function from a DLL file. If the report is executed in on-line mode the program calls and executes the function from the DLL, but if the ABAP programa is executed in background mode it doesnt calls the DLL function.
Do you know a way to solve the problem when executing in background mode?
Best regards.
AntonioHi Gabriel,
Let me explain in details about my DLL function.
We are importing the business partners from legacy system into the SAP CRM system, so at the moment we created the BP master data via BAPI, I get the name of the BP and this moment I call the function in the DLL file. I export the parameter name and I receive back a simplified string with the name reduced to a code. This code I get back from the dll it is insert in a Z table, so there is no interaction in the screen, all must be executed in background mode, because there are a lot of business partners to be converted in SAP system.
I am sending my code for your considerations.
Instancia a DLL
CREATE OBJECT dll 'MTCODE.CPFONET'.
IF sy-subrc NE 0.
RAISE without_dll.
ENDIF.
Move para a tabela interna IT_NAME os valores recebidos na TI_NAME
it_name[] = ti_name[].
Para cada registro importado
LOOP AT it_name.
CLEAR v_string_ret.
wa_matchcode-zregid = it_name-zregid.
wa_matchcode-name1_text = it_name-name1_text.
v_string = it_name-name1_text.
CONDENSE v_string.
TRANSLATE v_string TO UPPER CASE.
CALL METHOD OF dll 'SetNome' EXPORTING #1 = v_string.
CALL METHOD OF dll 'ExecMatch'.
CALL METHOD OF DLL 'GetMCData' = v_string_ret.
FREE OBJECT dll.
Preenche os campos do match-code de acordo com o retorno da DLL
SPLIT v_string_ret
AT '|'
INTO wa_matchcode-zparmcln
wa_matchcode-zparmcfn
v_empty
wa_matchcode-name_first
wa_matchcode-name_last
wa_matchcode-namemiddle.
Adiciona o registro com o match-code correspondente na TE_MATCHCODE
APPEND wa_matchcode TO te_matchcode.
ENDLOOP. -
How can I call a function from a procedure
I have a function named: f_calc_value which return the variable v_result. This function is part of a package.
How can I call this function from a new procedure I am creating?
Thanksor refer this theread....calling function from procedure
-
Dear All,
How can we call web service from SAP?
Thanks in Advance,
RamanaHI kcr,
pls see this link
http://****************/Tutorials/Others/ValidateEmailID/Webservice.htm
write this program
REPORT zvalidate_email.PARAMETERS: p_mail(100) LOWER CASE. " E-Mail id to be verifiedDATA: http_client TYPE REF TO if_http_client .DATA: w_string TYPE string ,
w_result TYPE string ,
r_str TYPE string .DATA: result_tab TYPE TABLE OF string.START-OF-SELECTION .
CLEAR w_string .
CONCATENATE
'http://www.webservicex.net/ValidateEmail.asmx/IsValidEmail?Email=' p_mail
INTO
w_string . CALL METHOD cl_http_client=>create_by_url
EXPORTING
url = w_string
IMPORTING
client = http_client
EXCEPTIONS
argument_not_found = 1
plugin_not_active = 2
internal_error = 3
OTHERS = 4. CALL METHOD http_client->send
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2. CALL METHOD http_client->receive
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3.
CLEAR w_result .
w_result = http_client->response->get_cdata( ). REFRESH result_tab .
SPLIT w_result AT cl_abap_char_utilities=>cr_lf INTO TABLE result_tab . READ TABLE result_tab INTO r_str INDEX 2.
IF r_str+44(1) = 't'.
WRITE:/ 'Valid email address'.
ELSE.
WRITE:/ 'Invalid email address'.
ENDIF.Output:
thanks
karthik -
I have a function from a dll that return a double* string and an integer. How can I call this function from LabVIEW? There is a possibility to work in LabVIEW with a double* string?
pcbv wrote:
> Hello all,<br><br>The header of the function is:
>
> "HRESULT WRAPIEnumerateDevices(WRAPI_NDIS_DEVICE **ppDeviceList, long *plItems);"
>
> where WRAPI_NDIS_DEVICE have this form:
>
> typedef struct WRAPI_NDIS_DEVICE<br>{<br>
> WCHAR *pDeviceName;<br>
> WCHAR *pDeviceDescription;<br><br>}
> WRAPI_NDIS_DEVICE;<br><br>
>
> The function is from WRAPI.dll, used for communication with wireless card.
> For my application I need to call in LabVIEW this function.
Two difficulties I can see with this.
First the application seems to allocate the array of references
internally and return a pointer to that array. In that case there must
be another function which then deallocates that array again.
Then you would need to setup the function call to have a pointer to an
int32 number for the deviceList parameter and another pointer to int32
one for the plItems parameter.
Then create another function in your DLL similar to this:
HRESULT WRAPIEnumExtractDevice(WRAPI_NDIS_DEVICE *lpDeviceList, long i,
CHAR lpszDeviceName, LONG lenDeviceName,
CHAR lpszDeviceDesc, LONG lenDeviceDesc)
if (!lpDeviceList)
return ERROR_INV_PARAMETER;
if (lpDeviceList[i].pDeviceName)
WideCharToMultiByte(CP_ACP, 0,
pDeviceList[i].pDeviceName, -1,
lpszDeviceName, lenDeviceName,
NULL, NULL);
if (lpDeviceList[i].pDeviceName)
WideCharToMultiByte(CP_ACP, 0,
pDeviceList[i].pDeviceDescription, -1,
lpszDeviceDesc, lenDeviceDesc,
NULL, NULL);
return NO_ERROR;
Pass the int32 you got from the first parameter of the previous call as
a simple int32 passed by value to this function (and make sure you don't
call this function with a higher index than (plItems - 1) returned from
the first function.
Rolf Kalbermatter
Rolf Kalbermatter
CIT Engineering Netherlands
a division of Test & Measurement Solutions -
CALL WEBI Report from SAP Portal
Hi Experts,
I need to call WEBI report from SAP Portal, is it possible?
The submitted report will be opened in the same window?
Kind Regads.Hi
You can call SAP portal from WebI Report...
insert blank cell in the report / or select the cell whaere do you want to in the report
and then Right click and select hyper link.
Enter the portal address
It will be opened in the same or new window based on your settings.
Target Window : New Window ..then it will open new window. -
How to call javascript function from PL/SQL procedure
Can anybody advice me how to call javascript function from PL/SQL procedure in APEX?
Hi,
I have a requirement to call Javascript function inside a After Submit Process.
clear requirement below:
1. User selects set of check boxes [ say user want to save 10 files and ticks 10 checkboxes]
2. user clicks on "save files" button
3. Inside a After submit process, in a loop, i want to call a javascript function for each of the file user want to save with the filename as a parameter.
Hope this clarify U.
Krishna. -
Calling user function from Interface mapping
I am getting error "Bad query:ORA-00904: invalid identifier" while calling function in the mapping of an interface.
Can some one provide the syntax of calling user function from interface mapping.
Thanks,
RPuser452108 wrote:
Can some one provide the syntax of calling user function from interface mapping.Oracle's Call Iinterface, the OCI, does not work differently when coding using a Dvorak keyboard, or writing code using a pretty pink font in the editor.. or coding the call from an interface mapping (whatever the hell that that is).
You have 2 types of calls. SQL and PL/SQL.
To call a function via SQL, it can be done using a the standard cursor interface. E.g.
select MyFunkyFunction from dualIt will return the function value via a single row with a single column. The standard cursor fetch and close cursor calls are used.
To call it via PL/SQL, an anonymous PL/SQL block is needed, and the caller needs to use a bind variable to receive the value from the function. The anon block will look as follows:
begin
:bindVar := MyFunkyFunction;
end;Refer to your client's abstract layer for interfacing with the Oracle Call Interface, on how to deal with bind variables. -
How to call oracle function from ejb3
i'm trying to call an oracle query-function from ejb3.
The oracle function:
create or replace FUNCTION getSecThreadCount(secId in NUMBER,avai in NUMBER)
RETURN SYS_REFCURSOR is cur SYS_REFCURSOR;
m_sql VARCHAR2(250);
BEGIN
m_sql:='select count(thrId) from thread where secId='|| secid||'
and thrAvai='|| avai;
open cur for m_sql;
return cur;
END;
I'v tried several ways to call it,but all failed:
1. the calling code:
public Object getSectionThreadCount(int secId,int avai){
Query query=manager.createNativeQuery("{call getSecThreadCount(?,?) }");
query.setParameter(1, secId);
query.setParameter(2, avai);
return query.getSingleResult();
but i got the exception:
Exception in thread "main" javax.ejb.EJBException: javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute query; nested exception is: javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute query
javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute query
Caused by: java.sql.SQLException: ORA-06550: row 1, col 7:
PLS-00221: 'GETSECTHREADCOUNT' not procedure or not defined
ORA-06550: row 1, col 7:
PL/SQL: Statement ignored
2. the calling code:
@SqlResultSetMapping(name = "getSecThreadCount_Mapping")
@NamedNativeQuery(name = "getSecThreadCount",
query = "{?=call getSecThreadCount(:secId,:avai)}",
resultSetMapping = "getSecThreadCount_Mapping",
hints = {@QueryHint(name = "org.hibernate.callable", value = "true"),
@QueryHint(name = "org.hibernate.readOnly", value = "true")})
public Object getSectionThreadCount(int secId,int avai){
Query query=manager.createNamedQuery("getSecThreadCount");
query.setParameter("secId", secId);
query.setParameter("avai", avai);
return query.getSingleResult();
but i run into the exception:
Exception in thread "main" javax.ejb.EJBException: javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute query; nested exception is: javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute query
javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute query
Caused by: java.sql.SQLException: lost in index IN or OUT parameter:: 3
By the way, i have successfully called the function from hibernate. And i use oracle 11g, JBoss5 RC1.
Could anyone tell me how to call the function from EJB3?
Thanks.Here's a working model:
package.procedure: (created in example schema scott)
CREATE OR REPLACE package body data_pkg as
type c_refcursor is ref cursor;
-- function that return all emps of a certain dept
function getEmployees ( p_deptId in number
return c_refcursor
is
l_refcursor c_refcursor;
begin
open l_refcursor
for
select e.empno as emp_id
, e.ename as emp_name
, e.job as emp_job
, e.hiredate as emp_hiredate
from emp e
where e.DEPTNO = p_deptId;
return l_refcursor;
end getEmployees;
end data_pkg;
/entity class:
package net.app.entity;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedNativeQuery;
import javax.persistence.QueryHint;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
@SuppressWarnings("serial")
@Entity
@Table (name="emp")
@SequenceGenerator(name = "EmployeeSequence", sequenceName = "emp_seq")
@NamedNativeQuery( name = "getEmpsByDeptId"
, query = "{ ? = call data_pkg.getEmployees(?)}"
, resultClass = Employee.class
, hints = { @QueryHint(name = "org.hibernate.callable", value = "true")
, @QueryHint(name = "org.hibernate.readOnly", value = "true")
public class Employee implements Serializable
@Id
@Column(name="emp_id")
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "EmployeeSequence")
private int id;
@Column(name="emp_name")
private String name;
@Column(name="emp_job")
private String job;
@Column(name="emp_hiredate")
private Date hiredate;
// constructor
public Employee (){}
// getters and setters
public int getId()
return id;
etc...session bean:
package net.app.entity;
import java.util.ArrayList;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import net.app.entity.Employee;
import net.app.iface.ScottAdmin;
@Stateless
public class ScottAdminImpl implements ScottAdmin
@PersistenceContext
private EntityManager entityManager;
@SuppressWarnings("unchecked")
public List<Employee> getEmployeesByDeptId(int deptId)
ArrayList<Employee> empList;
try
Query query = entityManager.createNamedQuery("getEmpsByDeptId");
query.setParameter(1, deptId);
empList = (ArrayList<Employee>) query.getResultList();
return empList;
catch (Exception e)
e.printStackTrace(System.out);
return null;
}client:
package net.app.client;
import java.util.List;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import net.app.entity.Employee;
import net.app.iface.ScottAdmin;
public class ScottClient
public static void main(String[] args)
try
// create local interface
InitialContext ctx = new InitialContext();
ScottAdmin adminInterface = (ScottAdmin) ctx.lookup("ScottAdminImpl/remote");
// select employees by deptno
int deptno = 20;
List<Employee> empList = adminInterface.getEmployeesByDeptId(deptno);
// output
System.out.println("Listing employees:");
for (Employee emp : empList)
System.out.println(emp.getId() + ": " + emp.getName() + ", " + emp.getJob() + ", " + emp.getHiredate());
catch (NamingException e)
e.printStackTrace(System.out);
}Basically you just ignore the refcursor outbound parameter.
This is a stored function, have yet to try outbound refcursor parameters in stored procedures...
Edited by: _Locutus on Apr 2, 2009 2:37 PM -
Calling a function from SQL prompt that returns a record
Hi,
I've been trying to execute a function that is present on a different database. for eg. I am loged on to a database say 'A' and trying to execute a function present in database 'B'. this function is present in a package 'X' which has 2 functions and two procedures. From the packages i am able to execute the two procedures and one of the function.
So i guess it is not a problem with the access permissions. The function that i am trying to call say function I has got 3 OUT
parameters and 1 IN parameter. the Function returns a record. When i try to execute this function i get an error. Can you please let me know as to how exactly i need to call this function from the SQL prompt...
thanx in advance
nullHi Anand,
As your function has 3 OUT parameters and it returns a record you can not just call it from SQL Plus. You need to write small PL/SQL program and use variables to hold the OUT values and the returned record.
Good Luck,
RajKiran
null -
Calling a function from within a movieclip
How do I do this, and Is it wrong to do it this way?
I have a movieclip on the timeline and within that movieclip
it has buttons which I've placed listeners. I'm doing it this way
rather than putting the code in the document class because the
buttons don't appear right away in the movieclip (not until around
frame 10). The function is defined in the document class because it
is used with other movieclips.
Anyone have an idea on how to properly do this?Well, I'm at least not getting an error - however, nothing is
happening when I click the button to call the function (which is
indeed public). Inside the function is a simple trace. I've even
added a param to the function just for fun, and there's no error
when calling the function from the button. -
Calling a function from a dll written by using visual studio c++
Hi, how can i call a function from a dll which is written by visual studio c++ in test stand? Although the functions in dll are exported and i've chosen c/c++ adapter, i saw no function in test stand. Is there a different step while i'm calling a function from a dll written by c++ than calling a function from a dll written by cvi?
Hey Sadik,
Selecting the C/C++ DLL Adapter Module should be sufficient for this. When you drag an action step for this onto the Main Step and navigate to the location of the DLL, the function list should populate and you should be able to select the function you want to use. If this is not the case, would you be able to post this DLL so that we can test this on our end?
Regards,
Jackie
DAQ Product Marketing Engineer
National Instruments
Maybe you are looking for
-
Photoshop trial cs6 on windows xp will not startup
I downloaded the photoshop cs6 trial on my computer running windows XP and I am getting an error message and the program continuously force closes after loading. What do I do?
-
Sharepoint (email drag and drop)
I would be grateful if someone could recommend a good drag and drop email program - we have just tested OnePlaceMail but this does not allow us to copy duplicate emails. Any suggestions/recommendations gratefully received.
-
I have created one web job - on demand schedule under azure web site. This web jobs contains .execmd(i.e.) Console Application. I am retrieving the data from SQL Azure database and uploaded the data in sharepoint online lists. (i.e.)I have uploaded
-
Oracle Reports Developer 10g schema missing
Hi All: I took the course for "Oracle Reports Developer 10g" but I didn't copy the schema when I took the course. Now,I have the book "Oracle Reports Developer 10g: Build Reports Student Guide" but I look over the internet and I can't find the schema
-
I want to export a generated business graphic to Excel. Is this possible? Regards Sebastian