‎2012 Apr 20 9:07 AM
Hi,
Company wants to fetch data from Customer Details BAPI - BAPI_CUSTOMER_GETDETAIL2 using PHP Script,
How to go about it kindly help
Thanks and Regards,
Nishant Bhargava
‎2012 Apr 20 11:06 AM
Hi,
There is plenty of online documentations and examples on how to call BAPI's from PHP..
Check these out
http://www.sdn.sap.com/irj/sdn/index?rid=/webcontent/uuid/5d9fb155-0b01-0010-8e8a-d8703df8bb9e
http://saprfc.sourceforge.net/
Best regards,
Andrei Sosea
‎2012 Apr 20 11:06 AM
Hi,
There is plenty of online documentations and examples on how to call BAPI's from PHP..
Check these out
http://www.sdn.sap.com/irj/sdn/index?rid=/webcontent/uuid/5d9fb155-0b01-0010-8e8a-d8703df8bb9e
http://saprfc.sourceforge.net/
Best regards,
Andrei Sosea
‎2012 Apr 23 8:30 AM
Sir,
I am getting following error while connecting SAP and PHP, Kindly help
RFC Error Info : Key : RFC_NOT_INIT Status : Message : RFC subsystem not yet initialized. Internal:
‎2012 Apr 20 11:42 AM
Dear Nishant,
There is a typical way to do this, first of all you need to understand the RFC and Normal BAPI behaviour.
There is a significant difference in both, but time being you dont have to bother about it.
The way usually people do it is they create a MySql Table in a PHP environment, (Usually PHP goes smoothly with MySql thats why I have said MySql), and then by use of SAPRFC extension for PHP and using couple of predefined functions in PHP, fetch the data from SAP R/3. That data usually be stored in the created database undelaying in APACHE, MYSQL environment. (APACHE is HTTP server).
Its not that easy as we read it above, but you can refer to - Typical example below
http://www.sap-hefte.de/download/dateien/935/066_leseprobe.pdf
Complete set of ZEND API AND RFC API.
http://saprfc.sourceforge.net/
Lets try once .........
Cheers
‎2012 Apr 23 4:07 AM
Sir,
I am developed the below code, but not able to connect to SAP RFC to PHP Server, kindly check where I am going wrong in it.
I have installed SAPRFC on PHP server nut still its not connecting.
<html>
<h1>SAPRFC-Class: ---PHP</h1>
<?php
require_once("saprfc.php");
// Create saprfc-instance
$sap = new saprfc(array(
"logindata"=>array(
"ASHOST"=>" " // application server
,"SYSNR"=>"00" // system number
,"CLIENT"=>"600" // client
,"USER"=>" " // user name
,"PASSWD"=>"" // password
)
,"show_errors"=>false // let class printout errors
,"debug"=>true)) ; // detailed debugging information
// Call-Function
$result=$sap->callFunction("BAPI_SALESORDER_GETLIST",
array( array("IMPORT","CUSTOMER_NUMBER",5),
array("IMPORT","SALES_ORGANIZATION",1130),
array("EXPORT","RETURN",""),
array("TABLE","SALES_ORDERS",array())
));
// Call successfull?
if ($sap->getStatus() == SAPRFC_OK) {
// Yes, print out the Userlist
?><table>
<tr><td>SD_DOC</td><td>SHORT_TEXT</td></tr><?php
//$sap->printStatus();
//var_dump($result);
foreach ($result["SALES_ORDERS"] as $orders) {
echo "<tr><td>", $orders["SD_DOC"],"</td><td>",$orders["SHORT_TEXT"],"</td></tr>";
}
?></table><?php
} 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()
}
// Logoff/Close saprfc-connection LL/2001-08
$sap->logoff();
?>
‎2012 Apr 23 8:46 AM
Hi,
I guess your Php script is not connecting to
sap.If you are a SAP consultant put External break point in to the BAPI and Execute your script again (if not Ask ur sap consultant ).If your script is connecting to the SAP ,it would Execute the bapi in Debugging mode.But by looking in to your code i couldn't see any connection string( I am not a PHP developer,but having bit idea).Just check your script ,whether the script is sufficient or not.Best Regards
Naresh Bammidi
‎2012 Apr 23 11:50 AM
Dear Naresh,
Putting a break-point in a BAPI wont trigger a BP I guess, and as far as the PHP connection string goes he dont need it one.
As the RFC needs a BOR registration and provides several API's to connect to R/3 from outside world, the instance creation to the class here is the same as a connection to the SAP R/3. As u see closely its a parameterized constructor and having username/pass/client etc. information.
Considering I do not know PHP and Nishant knows it better than both of us, I would like to suggest Nishant to debug his code, whether he is properly calling each required API, and if he can get any help in debugging a BAPI/RFC whatever it is from a ABAPer, would lead to the problem then he can paste the problem and can seek for more information on the answer. ...
Thanks and Regards,
Ravindra Sonar.
‎2012 Apr 23 5:54 PM
Hi please confirm the following:
- have you copied saprfc.dll in php ext folder? (assuming you're on windows)
- have you modified php.ini to add saprfc.dll as an extension?
- do you see the SAP module in phpinfo()?
- is saprfc.php in your project's root folder?
- has the sap user you're using sufficient authorizations ?
- have you passed on the log on variables correctly (they are missing in the code you posted )
To what concerns your code look into the following aspects:
- change the CUSTOMER_NUMBER from 5 to 000000005.
- check the length of $result["SALES_ORDERS"] in case the BAPI returns 0 values due to incorrect/missing CUSTOMER_NUMBER
- check for any error messages in $result["RETURN"]
Andrei
‎2013 Aug 28 5:46 AM
Hi Andrei,
Please help me, how to insert into database like mysql from that result data.
Thanks
Deny
‎2013 Aug 28 8:24 AM
Hi,
You need to call RFC enabled FM. Either existing ones or you create them yourself . What exactly do you plan to insert into SAP ?
-
Andrei
‎2013 Aug 28 9:33 AM
Hi,
you can achieve this through web service function module.
Regards,
John.