0% found this document useful (0 votes)
239 views5 pages

Data From SAP BAPI Using PHP Script - SCN

The document discusses connecting to SAP systems from PHP scripts to retrieve data using BAPIs. It includes code examples for connecting via the saprfc PHP library and calling a BAPI to retrieve sales order data.

Uploaded by

Sandeep Hari
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
239 views5 pages

Data From SAP BAPI Using PHP Script - SCN

The document discusses connecting to SAP systems from PHP scripts to retrieve data using BAPIs. It includes code examples for connecting via the saprfc PHP library and calling a BAPI to retrieve sales order data.

Uploaded by

Sandeep Hari
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

6/24/2016

DatafromSAPBAPIusingPHPScript|SCN

GettingStarted Newsletters

Hi,Guest

LogOn

JoinUs

Store

SearchtheCommunity

Products

Services&Support

AboutSCN

Downloads

Industries

Training&Education

Partnership

DeveloperCenter

Activity

LinesofBusiness

UniversityAlliances

Events&Webinars

Innovation

Browse

Communications

Actions

10Replies Latestreply:Aug28,201310:33AMbyJohnK

Share

Tweet

Like

NishantBhargava

Apr20,201210:07AM

DatafromSAPBAPIusingPHPScript
ThisquestionisAssumedAnswered.
Hi,
CompanywantstofetchdatafromCustomerDetailsBAPIBAPI_CUSTOMER_GETDETAIL2using
PHPScript,
Howtogoaboutitkindlyhelp
ThanksandRegards,
NishantBhargava

HelpfulAnswerbyAndreiSosea

9008Views

Topics:abapTags:sap,scripting_languages,and,php,r/3,bapi

AverageUserRating
(0ratings)

AndreiSosea Apr20,201212:08PM (inresponsetoNishantBhargava)

HelpfulAnswer Re:DatafromSAPBAPIusingPHPScript
Hi,

ThereisplentyofonlinedocumentationsandexamplesonhowtocallBAPI'sfromPHP..

Checktheseout
http://www.sdn.sap.com/irj/sdn/index?rid=/webcontent/uuid/5d9fb1550b0100108e8a
d8703df8bb9e

http://saprfc.sourceforge.net/

Bestregards,
AndreiSosea

Like(0)

NishantBhargava Apr23,20129:30AM (inresponsetoAndreiSosea)

Re:DatafromSAPBAPIusingPHPScript
Sir,

IamgettingfollowingerrorwhileconnectingSAPandPHP,Kindlyhelp
RFCErrorInfo:Key:RFC_NOT_INITStatus:Message:RFCsubsystemnotyetinitialized.
Internal:

https://scn.sap.com/thread/3164246

1/5

6/24/2016

DatafromSAPBAPIusingPHPScript|SCN
Like(0)

RudraSonar Apr20,201212:42PM (inresponsetoNishantBhargava)

Re:DatafromSAPBAPIusingPHPScript
DearNishant,

Thereisatypicalwaytodothis,firstofallyouneedtounderstandtheRFCandNormalBAPI
behaviour.
Thereisasignificantdifferenceinboth,buttimebeingyoudonthavetobotheraboutit.

ThewayusuallypeopledoitistheycreateaMySqlTableinaPHPenvironment,(UsuallyPHPgoes
smoothlywithMySqlthatswhyIhavesaidMySql),andthenbyuseofSAPRFCextensionforPHP
andusingcoupleofpredefinedfunctionsinPHP,fetchthedatafromSAPR/3.Thatdatausuallybe
storedinthecreateddatabaseundelayinginAPACHE,MYSQLenvironment.(APACHEisHTTP
server).

Itsnotthateasyaswereaditabove,butyoucanrefertoTypicalexamplebelow
http://www.saphefte.de/download/dateien/935/066_leseprobe.pdf
CompletesetofZENDAPIANDRFCAPI.
http://saprfc.sourceforge.net/

Letstryonce.........

Cheers

Like(0)

NishantBhargava Apr23,20125:07AM (inresponsetoRudraSonar)

Re:DatafromSAPBAPIusingPHPScript
Sir,

Iamdevelopedthebelowcode,butnotabletoconnecttoSAPRFCtoPHPServer,kindlycheck
whereIamgoingwronginit.

IhaveinstalledSAPRFConPHPservernutstillitsnotconnecting.

<html>

<h1>SAPRFCClass:PHP</h1>

<?php

require_once("saprfc.php")
//Createsaprfcinstance

$sap=newsaprfc(array(

"logindata"=>array(

"ASHOST"=>""//applicationserver

,"SYSNR"=>"00"//systemnumber

,"CLIENT"=>"600"//client

,"USER"=>""//username

,"PASSWD"=>""//password

,"show_errors"=>false//letclassprintouterrors

,"debug"=>true))//detaileddebugginginformation

//CallFunction

https://scn.sap.com/thread/3164246

2/5

6/24/2016

DatafromSAPBAPIusingPHPScript|SCN

$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())

))

//Callsuccessfull?

if($sap>getStatus()==SAPRFC_OK){

//Yes,printouttheUserlist

?><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,printlongVersionoflastError

$sap>printStatus()

//orprintyourownerrormessagewiththestringsreceivedfrom

//$sap>getStatusText()or$sap>getStatusTextLong()

//Logoff/ClosesaprfcconnectionLL/200108

$sap>logoff()

?>

Like(0)

NareshBammidi Apr23,20129:46AM (inresponsetoNishantBhargava)

Re:DatafromSAPBAPIusingPHPScript
Hi,
IguessyourPhpscriptisnotconnectingto
sap.IfyouareaSAPconsultantputExternalbreakpointintotheBAPIandExecuteyour
scriptagain(ifnotAskursapconsultant).IfyourscriptisconnectingtotheSAP,itwould

https://scn.sap.com/thread/3164246

3/5

6/24/2016

DatafromSAPBAPIusingPHPScript|SCN
ExecutethebapiinDebuggingmode.Butbylookingintoyourcodeicouldn'tseeany
connectionstring(IamnotaPHPdeveloper,buthavingbitidea).Justcheckyourscript
,whetherthescriptissufficientornot.

BestRegards
NareshBammidi

Like(0)

RudraSonar Apr23,201212:50PM (inresponsetoNareshBammidi)

Re:DatafromSAPBAPIusingPHPScript
DearNaresh,

PuttingabreakpointinaBAPIwonttriggeraBPIguess,andasfarasthePHP
connectionstringgoeshedontneeditone.

AstheRFCneedsaBORregistrationandprovidesseveralAPI'stoconnecttoR/3from
outsideworld,theinstancecreationtotheclasshereisthesameasaconnectiontothe
SAPR/3.Asuseecloselyitsaparameterizedconstructorandhaving
username/pass/clientetc.information.

ConsideringIdonotknowPHPandNishantknowsitbetterthanbothofus,Iwouldlike
tosuggestNishanttodebughiscode,whetherheisproperlycallingeachrequiredAPI,
andifhecangetanyhelpindebuggingaBAPI/RFCwhateveritisfromaABAPer,
wouldleadtotheproblemthenhecanpastetheproblemandcanseekformore
informationontheanswer....

ThanksandRegards,
RavindraSonar.

Like(0)

AndreiSosea Apr23,20126:54PM (inresponsetoNishantBhargava)

Re:DatafromSAPBAPIusingPHPScript
Hipleaseconfirmthefollowing:

haveyoucopiedsaprfc.dllinphpextfolder?(assumingyou'reonwindows)
haveyoumodifiedphp.initoaddsaprfc.dllasanextension?
doyouseetheSAPmoduleinphpinfo()?
issaprfc.phpinyourproject'srootfolder?
hasthesapuseryou'reusingsufficientauthorizations?
haveyoupassedonthelogonvariablescorrectly(theyaremissinginthecodeyouposted)

Towhatconcernsyourcodelookintothefollowingaspects:
changetheCUSTOMER_NUMBERfrom5to000000005.
checkthelengthof$result["SALES_ORDERS"]incasetheBAPIreturns0valuesdueto
incorrect/missingCUSTOMER_NUMBER
checkforanyerrormessagesin$result["RETURN"]

Andrei

Like(0)

DenySaputra Aug28,20137:37AM (inresponsetoAndreiSosea)

Re:DatafromSAPBAPIusingPHPScript
HiAndrei,

Pleasehelpme,howtoinsertintodatabaselikemysqlfromthatresultdata.

Thanks
Deny

Like(0)

https://scn.sap.com/thread/3164246

4/5

6/24/2016

DatafromSAPBAPIusingPHPScript|SCN

AndreiSosea Aug28,20139:24AM (inresponsetoDenySaputra)

Re:DatafromSAPBAPIusingPHPScript
Hi,

YouneedtocallRFCenabledFM.Eitherexistingonesoryoucreatethemyourself.What
exactlydoyouplantoinsertintoSAP?

Andrei

Like(0)

JohnK Aug28,201310:33AM (inresponsetoNishantBhargava)

DatafromSAPBAPIusingPHPScript
Hi,

youcanachievethisthroughwebservicefunctionmodule.

Regards,
John.

Like(0)

Share

SiteIndex
Privacy

Tweet

ContactUs
TermsofUse

https://scn.sap.com/thread/3164246

Like

SAPHelpPortal
LegalDisclosure

Copyright

FollowSCN

5/5

You might also like