cancel
Showing results for 
Search instead for 
Did you mean: 

call_and_receive fires 2 times?? why ??

florian_endres
Explorer
0 Kudos

Hello,

i have little problem with saprfc_call_and_receive().

In Firefox (2+) everything is ok. call_and_receive() fires only 1 time.

BUUUUUUT with IE (6+) the same call_and_receive() fire 2 times.

1. Firing => RCODE = 0 (OK)

2. Firing => RCODE = 4 (BAD) because datarow is already in DB.

PHP 5.1.1

SAPRFC_PHP 1.4.1

Any suggestions???


<?PHP

$login = array (	
                                        <passing logon data>
			);
			
$rfc = saprfc_open ($login );                                                                                
//We must know if the function really exists
$fce = saprfc_function_discover($rfc, "<function_name>");
if(!$fce){
	echo "The function module has failed.";
  echo $rfc;
  exit;
}

//Pass table parameters
saprfc_table_init ($fce,"<table_name");

//setting IMPORT-Param
$set_import = saprfc_import ($fce,"SPRAS",$SPRAS);

foreach ($new_data as $data){
  saprfc_table_append ($fce,"table_name", <building my array>);
															 
}

//Call and execute the function
$rc = saprfc_call_and_receive ($fce);

//wenn etwas auf Fehler läuft wird dieser ausgegeben.
switch ($rc) {
   case SAPRFC_OK        : break;
   case SAPRFC_EXCEPTION : echo "Exception raised:".saprfc_exception($fce)."<br>";
                           // handle exception
   default              : echo "RFC error ".saprfc_error()."<br>";
                           exit;  
}

?>

<html>
<head>
</head>

<body>
<?PHP
	$RCODE = saprfc_export ($fce,"RETURNCODE");
	$MESSAGE = saprfc_export ($fce,"MESSAGE");
      
//if $RCODE =4 Errormessage $MESSAGE
	if ($RCODE == "4") // Fehler
	{
                <PHP-Coding>
	}
	else
	{
		<PHP-Coding>
	} // if ($result == "" )

saprfc_function_free($fce);
saprfc_close($rfc);
?>
</body>
</html>

thanx

Florian Endres

Accepted Solutions (0)

Answers (3)

Answers (3)

florian_endres
Explorer
0 Kudos

The submit function was triggered two times.

Problem solved!!!

florian_endres
Explorer
0 Kudos

Hello,

It's not that easy.

My prior page calls the update page only 1 time.

I think some freaky dll form the IE fires the call_and_receive 2 times.

Some debugging on the update page give me this result.

Function module: /FIS/MON_SET_VERTRETER (remote SAP R/3: 700 Unicode)

IMPORT

CHECK_AUTGEN /o/ C 1 0 offset = 0

SPRAS C 1 0 offset = 0

EXPORT

MESSAGE C 72 0 offset = 0

RETURNCODE b 1 0 offset = 0

TABLE

VERTRETERLISTE MANDT C 3 0 offset = 0

EMPFAENGER_EMAIL C 128 0 offset = 3

ZEIT_VON D 8 0 offset = 131

ZEIT_BIS D 8 0 offset = 139

KZ_GRUNDSAETZLIC C 1 0 offset = 147

VERTRETER_EMAIL C 241 0 offset = 148

VERTRETER_SAPUSE C 12 0 offset = 389

DB_MODE C 1 0 offset = 401

Value of import (input) parameter CHECK_AUTGEN (optional) (memory = 1):

""

Value of import (input) parameter SPRAS (memory = 1):

"D"

Value of export (output) parameter MESSAGE (memory = 72):

""

Value of export (output) parameter RETURNCODE (memory = 1):

"0"

Internal table VERTRETERLISTE (memory = 408):

MANDT EMPFAENGER_EMAIL ZEIT_VON ZEIT_BIS KZ_GRUNDSAETZLIC VERTRETER_EMAIL VERTRETER_SAPUSE DB_MODE

"500" "balaba@FIS-GMBH.DE" "20080505" "20080505" "" "fdsahgfdaga@gfdg.de" "" "I"

1 rows

When the prior or update page fires the call_and_receive 2 times, should i see this debug info twice?

thanx

Edited by: Florian Endres on Sep 1, 2008 8:46 AM

Former Member
0 Kudos

hi florian,

you are aware of the fact, that your your PHP script and especially the RFC function in question is executed at the webserver and therefore independent of the browser used, right?

so, IMHO, the only way to get your problem is to call the script twice by some client side coding (HTML form and/or javascript in parallel). But you show only pseudo-coding for the client side.

anton

florian_endres
Explorer
0 Kudos

Hi,

Thats right i know.

Therefore it seems strange to me.

The coding you see is the php which calls the rfc-function. The data were entered one step before over a form and i call this file over post-method.

Debugging in SAP seems that the call_and_receive fired two times with IE. Second returncode = 4.

FF works fine IE doesn't work !!

thanx,

Florian

Former Member
0 Kudos

call_and_receive generally doesn't know from which browser (if any) the surrounding script was called.

so your error must be in the prior page, the html page containing the form calling your script.