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 BAPI_MATERIALGROUP_GET_LIST (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:
import parameters
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:
execution parameters
The data returned is in the tables as shown below:
Short descriptions
I found that the data I wanted to extract was in table SHORTDESCRIPTIONS.
Material groups

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:


And output the data by using the SAP field name:

foreach ($result["SHORTDESCRIPTIONS"] as $matgroup) {
echo "" , $matgroup["MATL_GROUP"] ,"<_/t_d>" , $matgroup["MG_DESCR_SHORT"] , "<_/t_d><_/t_r>";

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.

Tags technorati :

Privacy Preference Center