A little about me

pascal 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.

Click me

Re-writing SAP with PHP (part 1.5)

Posted on May 22, 2006 | Category: SAP

If things always went to plan, I guess I would now be writing part 2 and not 1.5! The truth is, I’ve had so many ideas lately that I just had to test them out and so this is how 1.5 came to be. In this post I’m going to show you how I used PHP/SAP/PEAR/AJAX together to come up with I’m sure you’ll agree, a pretty cool result.

To set the scene this is what will be shown:

  • We will first call a PHP script that uses BAPI BAPI_PRODORD_GET_LIST to retrieve a list of SAP production orders.
  • As time goes by the amount of production orders that live in a system can be quite staggering and I didn’t want to bombard the user with thousands of production orders in one go. To solve that problem I’m using PEAR, to be more specific I’m using the Structures_DataGrid package to setup the paged navigation and render the data in html format (I highly recommend this package as it takes care of everything for you and you can even style the output as you want it)
  • Once we have the data output (a list of production orders) we will then want to see a bit more detail for a chosen production order. This is where AJAX comes in. We will make an asynchronous call to another PHP script that calls the BAPI BAPI_PRODORD_GET_DETAIL.
  • The result of that AJAX call, is that the current page (or part of it) will be refreshed with new content. The content will be detailed production order information.

If you can’t wait to read this post to the end, I’ve recorded a small flash animation that demonstrates exactly what I have outlined above. The animation can be viewed here (Give the file time to load as it makes approx 4.8Mb).

So we start out with a list of orders:

listorders

Clicking on the detail icon will reveal detailed data about the production order:

detail

Finally we’ve added an image which shows an overlay of:

  • The list of orders
  • The order detail showing the operations and the components of the order
  • A screenshot of the operations (in SAP)
  • A screenshot of the components (in SAP)

collage

What? No code? do I hear you say. Well as there are very rarely comments made on the code, I’m not going to bother including any in this post – it’s up to you to change that….

As usual these tests have been made using an HP (Compaq nc6220) laptop running on MS Windows XP Pro, the Apache server version 1.3.33 and the PHP scripting engine in version 4.3.10 and of course the SAPRfc library (the Apache/PHP install was that installed via the EasyPhp package). SAP side I was using SAP ERP ECC (ERP Central Component) 5.0. I also used the script.aculo.us javascript libraries. You can download them here.

» Filed Under SAP

8 Responses to “Re-writing SAP with PHP (part 1.5)”

  1. Blag Says:

    Great as always Pascal! It’s cool to read your blogs and get some of your ideas -:P

    Greetings,

    Alvaro Tejada Galindo
    SDN Scripting Community Member.

  2. Lars Says:

    Hi, tried to rebuild your solution… but unfortunately following error appears:

    “SAPRFC extension not loaded”

    which saprfc version do you use ? my php and apache version are exact the same. you you might mail my the *.dll located in die php-extension dir and your php.ini where it is embedded?

    email: spamme@gmx.eu

    thanx a lot
    lars

  3. Pascal Says:

    Hello Lars,
    It could be that your problem is due to the fact that your PHP version is not compatible with your SAPRFC version.
    Go to the SAPRFC download page and make sure you download the correct version.

    For example the SAPRFC file titled saprfc-1.3.3-4.3.10.Win32.zip is the SAPRFC version 1.3.3 for PHP version 4.3.10.

    Once you have downloaded the package, put the file php_saprfc.dll inside the /php/extension folder.

    Then, all you have to is add extension=php_saprfc.dll in the Windows extension section of your php.ini file.

    Hope this helps.

  4. i-nie Says:

    nice jobs :)..but try to implement SAP-PHP but I get an error.

  5. Luciano Says:

    Can i get a copy of your code. I would like to look at learning php with SAP. thanks in advance

  6. renet@web Says:

    Thanks for your interest, but I do not make the code available anymore.
    Cheers.

  7. Building RIA’s using SAP, Flex and Php at renet@web Says:

    [...] a continuation to my experiments in marrying technologies such as Php, Pear & Ajax to query a SAP database and expose the data [...]

  8. Madhu Says:

    Hi,
    Nice application. May how to connect sap with php. Can i get the code how to connect with php. Thank you

Leave a Reply