Hi, my name is Pascal and I am a SAP & Supply Chain specialist. I work for PLAUT and I do things others can't.
This blog only contains my personal views, thoughts and opinions. It is not endorsed by my employer nor does it constitute any official communication of PLAUT. You can contact me via email at pascal[at]renet-web.net or use the contact form that you will find by following the 'Contact' link and you can follow me on twitter here.
Posted on July 30, 2005 | Category: SAP
A couple of years ago I started experimenting with the SAPRfc library but a busy schedule prevented me from doing anything more then execute the demo script.
So, a couple of years down the road, I last week again installed the SAPRfc library on my new work PC (running XP Pro). Although I have been pretty busy this week, I took the time to try out the demo script (reading the SAP username list within a SAP client) and I also tried to adapt that script to see if I could get it to do something else.
As I am currently doing a bit of MM (Materials Management) work I thought that it would be appropriate to do something around that module…nothing extravagant tough. I set my sights on the BAPI
QkFQSV9NQVRFUklBTEdST1VQX0dFVF9MSVNU
(which is very simple – it reads the material groups within a SAP client).
I then proceeded to use transaction SE37 to read the import parameters and tables used by this BAPI.
Import parameters:
Tables:
I also tested the BAPI (within SAP) to see what table was being filled with the information I wanted.
Still in SE37, test the module with the following parameters:

The data returned is in the tables as shown below:

I found that the data I wanted to extract was in table
U0hPUlRERVNDUklQVElPTlM=
.

All I had to do now was to modify the code (the code below is not the complete code).
Call the BAPI and specify the parameters:
DQokcmVzdWx0PSRzYXAtPmNhbGxGdW5jdGlvbigiQkFQSV9NQVRFUklBTEdST1VQX0dFVF9MSVNUIiwNCiAgICAgICAgIGFycmF5KAlhcnJheSgiSU1QT1JUIiwiU0hPUlRERVNDUklQVElPTkZMQUciLCJYIiksDQoJYXJyYXkoIklNUE9SVCIsIkxBTkdVQUdFIiwiRSIpLCANCglhcnJheSgiVEFCTEUiLCJTSE9SVERFU0NSSVBUSU9OUyIsYXJyYXkoKSkpKTsJDQo=
And output the data by using the SAP field name:
DQpmb3JlYWNoICgkcmVzdWx0WyJTSE9SVERFU0NSSVBUSU9OUyJdIGFzICRtYXRncm91cCkgew0KCQkJZWNobyAiPF90X3I+PF90X2Q+IiAsICRtYXRncm91cFsiTUFUTF9HUk9VUCJdICwiPF8vdF9kPjxfdF9kPiIgLCAkbWF0Z3JvdXBbIk1HX0RFU0NSX1NIT1JUIl0gLCAiPF8vdF9kPjxfL3Rfcj4iOw0KCQl9DQo=
NB: get rid of the (_) underscore in the tr and td tags.
Here is a screen dump of the result:

This was done using a SAP client in version 4.6c on a notebook running XP Pro with Apache 1.3.33 and PHP 4.3.10 as provided by the EasyPHP version 1.8 installer.
» Filed Under SAP
May 13th, 2006 at 6:44 pm
[...] List material groups (You can find more information in this post) [...]
May 26th, 2006 at 12:36 am
Have you tried something with sales order module ?
Do you have some full example of your tries to download ?
Thanks
August 9th, 2006 at 12:23 pm
Hi,
I would like to receive more informations about how to connect to SAP from PHP, it’s possible?
Regards,
Claudiomiro Silva
August 10th, 2006 at 12:23 pm
Hello Claudiomiro,
If you want more information on SAP and php, I recommend you check out the following sites.
SAPRFC Homepage and the SAP and PHP forum on the SAP Developper Network.
They will have all the information you need to get started.
August 28th, 2006 at 11:27 pm
we are starting with SAP, at a big industry company, and i want informations and exemples if possible of installing and using SAPRFC
Best regards
August 28th, 2006 at 11:44 pm
Hello Abdou,
I recommend you follow the links I have indicated in my previous answer. These two sites offer plenty of information to get you started.
All the best.
March 5th, 2007 at 3:13 pm
Hi Pascal,
I read ur post about using a BAPI in MM to get the data in PHP where u hv used the BAPI as it has been defined by SAP…What if I need to build a logic based on the data returned by various BAPIs in a program flow, and store it in a table to be retrieved later by using saprfc…Can we write a customized function like a BAPI and extract the data out in PHP…Ur help is highly appreciated…Thanks…
Regds,
Jairam
March 5th, 2007 at 8:53 pm
Hey Jairam,
Yes you can write your own functions and then use them using SAPrfc. Remember that BAPI’s are just Function Modules. So you can write your own functions and then use SAPrfc to extract the data.
Good luck.
July 13th, 2009 at 3:42 pm
I want to connect a PHP program with a SAP R/3 system where it will retrieve data and then update data (Physical Inventory) with BAPIs and SAPRFC. I have no experience using BAPIs and RFCs and ABAP, and limited knowledge of SAP.
Can SAPRFC connect to a remote server over the net or lan?
Is there a way to test BAPIs and RFCs in a test environment?
If I am not a SAP admin or don’t have my own SAP R/3 system to use, is there a developer verson?
September 7th, 2011 at 6:11 pm
Hello Pascal,
Very good work indeed – do you see extensive uses of this in the Enterprise World.