cancel
Showing results for 
Search instead for 
Did you mean: 

problem calling function

milascon_daniel
Participant
0 Kudos

Hi,

i have creted a function module which read stock quantity using BAPI_MATERIAL_AVAILABILITY.

Import - MFRPN

Export - QNTY

If i execute function module from SAP the result it's OK but when i call function from PHP it does not output nothing.

$sap = new saprfc(array(
							"logindata"=>array(
								"ASHOST"=>"192.168.3.1"		// application server
								,"SYSNR"=>"00"				// system number
								,"CLIENT"=>"200"			// client
								,"USER"=>"rfc"			// user
								,"PASSWD"=>"123456789"		// password
								)
							,"show_errors"=>true			// let class printout errors
							,"debug"=>false)) ; 				// detailed debugging information
		// Call-Function


		// Call-Function
		$result=$sap->callFunction("Z_READ_QNTY",
											  array(
													array("IMPORT","MFRPN",$_POST['cod']),
													array("EXPORT","QNTY",$quantity),
													)
									  );

		// Call successfull?
		if ($sap->getStatus() == SAPRFC_OK)
		{
			echo $quantity;
		}
		else
		{
			// No, print long Version of last Error
			$sap->printStatus();
			// or print your own error-message with the strings received from
			// 		$sap->getStatusText() or $sap->getStatusTextLong()
		}

Please someone help me.

Thank you.

Accepted Solutions (0)

Answers (1)

Answers (1)

milascon_daniel
Participant
0 Kudos

any clue?

Former Member
0 Kudos

hi Dan,

i will send you an working code sample. The Fuba ZGET_MAKTX is easy MATNR as import parameter and MAKTX as export parameter.

you will receive the material short description.

hope this will help you a little bit.

in your code i thing you forgot to fill the $quantity like this $quantity = saprfc_export($fce,"QNTY"); before echo $quantity;

regards

Tony

<?php

//Login to SAP R/3

$login = array ("ASHOST"=>"vsap3", "SYSNR"=>"2", "CLIENT"=>"200","USER"=>"vsrfc", "PASSWD"=>"********", "CODEPAGE"=>"1100");

$rfc = saprfc_open($login);

if (!$rfc) {

echo "RFC connection failed";

exit;

}

$fce = saprfc_function_discover($rfc,"ZGET_MAKTX");

if (!$fce) {

echo "Discovering interface of function module failed";

exit;

}

saprfc_import($fce,"MATNR","200200");

$rc = saprfc_call_and_receive ($fce);

if ($rfc_rc != SAPRFC_OK) { if ($rfc == SAPRFC_EXCEPTION ) echo ("Exception raised: ".saprfc_exception($fce)); else echo (saprfc_error($fce)); exit; }

$maktx = saprfc_export($fce,"MAKTX");

echo $maktx;

saprfc_function_free($fce);

saprfc_close($rfc);

?>

Edited by: Tony Wienhold on Oct 7, 2008 11:19 AM

Edited by: Tony Wienhold on Oct 7, 2008 11:22 AM