Posts Tagged SAP

Calling SAP from PHP (on OS X)

You’d think it’d be easy eh?

  • My first google turned up SAPRFC, an extension module for php which allows direct ABAP calls from php.  ‘Perfect’, I thought, until I discovered that it is now essentially unmaintained, and it seems that no one ever tried it on OS X in the first place.
  • Very very happy was I then when I discovered its (very new) successor: sapnwrfc.  But no one has bothered to compile this yet on OS X either (and, like its predecessor, it requires the SAP RFC SDK, which I don’t have).  And besides, it really is very new, just a month or so old – not suitable for production then.
  • So I resigned myself to using another language to bridge the gap.  My first thought (my first hope really), was perl.  This turned up SAP::Rfc, written by the same guy who’s creating sapnwrfc.  But this also requires the SAP RFC SDK, and I couldn’t find anyone who’d ever compiled this on OS X.
  • So why not Java?  The SAP client my employer would have me use is pure Java, so surely I could use the same technologies?
    And this is where I stand at the moment: Use PHP/Java Bridge to call from php to Java, and SAP JCo to call from Java direct to SAP.

Yes, it’s cludgy, horrible, and sounds stupid.  And it probably is stupid.  But it’s how I plan to proceed for the present.  Tomcat will host the Java VM, and – if all the PHP/Java Bridge documentation is to be believed – there will be no need for Java ‘glue’ code, I should be able to use the JCo code directly in php.

If I live through the experience I’ll post more info about this soon.

Some pre-emptive defence: I know there are other technologies which would be preferable to my current solution – but I can make no changes whatsoever to SAP, this severely restricts my options.

, ,