Skip to Content

Tasting the mix of PHP and SAP

You must be Logged on to comment or reply to a post.
  • Hi Alvaro,
    Thanks for breathing life back into this subject.  Back when we set up the PHP forum last year we were interested to see what lively conversations would evolve. The likes of Jason Simnmons, Craig Cmehil, John Astill, Gregor Wolf,  Anton Wenzelhuemer and others kept conversation flowing for a while there, but without more interaction from the community the subject got real quiet.
    Thanks for bringing it back to life with your PHP forum posts and this weblog!


    • Thanks for your kind words Marilyn. And special thanks to Craig, who offer me trust and friedship. I’m sure that with the help of Craig, John and Jason we can make the PHP-SAP community user grow on every day.



  • Estoy bastante interesado en el tema de conectar php y sap, pero tengo un gran problema, desde la empresa en la que trabajo todas las conexiones requieren la cadena SAProuter y claro esto no lo cotempla aún el RFC.

    Mi pregunta es si hay algún sap de prueba que pueda instalar y hacer mis pequeños pinos o si sabes conectar php y sap habiendo una cadena Saprouter por el medio.

    Muchas gracias por todo y mut interesante este artículo.

    • Hola:

      Bueno, lo que puedes hacer es conseguir el minisap, instalar el apache, el php y el saprfc. Es lo que yo hice en mi casa, para poder escribir este weblog.

      What is MiniSap?



      Well, what you can do is get the MiniSap, install the apache web server, php and the saprfc.
      That’s what i do in my house in orden to write this weblog.

      What is MiniSap?



  • Just installed Apache and PHP a few weeks ago; now I can put it to use. I hate Java, too; all those tedious little bits and beans that have to be identified, arranged and assembled just in order to “get the job done”… bah.
    • Remember that this is just a test app. I made it in order to show some of the PHP/SAP functionallity. You must encrypt the send data and decrypt the recieved data, i don’t think that saprfc_open handle it. But as my blog says, this is not intended to be use on a productive system, so i just want to add some basic functionallity…If you want extra stuff, you can coded yourself -;) Or you can check the forums -:)



  • Hello,
    but that’s exactly the problem, why we only have examples and no productive usable solutions. Until now, i didn’t find any code to catch the login data and decrypt it.


    • Well…we only have test app and productive usability for a couple of reasons…First, most of the RFC are not release for customer use (Ask SAP why), and second because SAPRFC is still under development (At least i think it is).

      The main porpuse of my blogs is to show what you can do, and what you’re going to able to do in the future.

      Anyway…i think that Craig or Marilyn can give you better answers.



    • Well done. Been keeping one eye on the PHP/SAP front…I agree it is much easier to use. PHP definitely have it’s own niche area.

      For the issue of security you can implement SSL which, if I remember correctly in my old webmaster days, it decrypes every thing so you dont have to worry about clear text for the id and password being passed via the web.

    • I think the reason we have only examples is because many people haven’t taken PHP/SAP to the next level, or in my case weren’t allowed to blog about everything.

      SAPRFC, is as “Blag” states under development but only because PHP is under development so you can really use it in a productive environment if you want, or using PHP together with Web Services.

      Bottom line is that you can use it in a productive environment together with SSL for login encryption or even SSO and with real productive solutions. I’ll see if I might be able track down some higher end solutions to share here on SDN.


  • Hola Alvaro,

    Te Quiero hacer una consulta referente a una conexion de SAP con PHP, yo estoy haciendo mi aplicacion BSP, luego esta pagina sera colgada en internet, pero esta pagina esta hecha en php, quiero saber si existe una conexion PHP con SAP, ademas para poder enviarle los datos de user y pass(de sap dado que te los pide la aplicacion bsp cuando corre) para entrar al BSP.

    porfavor quisiera que me ayudes con este tema. si tuvieras un ejemplito seria chevere.

  • Hi there,

    Probably nobody will answer to this, but… I’d like to have a shot.

    I’m working in a very very very big company and bureaucracy is making anything impossible. The fact, is that I have SAP in my computer installed and it works pretty good, the problem is that I dont have the server address and the other parameters I need in order to connect to SAP through SAP-RFC via PHP.

    Is there any way to find out the characteristics of a connection that already happens in my computer?

    Thank you very much in advance.


    • Of course this is alive…a little bit old but I’m still here -;)
      If you have SAP on your computer…and you have SAPGui…then you have all the information you need…just go to your SAPGui, select the system you used to log-in and press “Change Item”…there you’re going to see the Application Server, System Number and System ID.
      If you have any further questions please let me know.


      • Hey Mr Tejada, thank you for the fast answer hehe.

        It seems we could speak in spanish but let’s not make a language mess here.

        Well, next problem, I’m just a poor spanish guy working in germany, and all the ******* software is -of course- in german. And SAP is not the exception.

        I can not find the “Change Item” I guess is the button under the “Log on” button (or however it’s written in English), but it looks more like an “add system” button.

        There is on the left of Systems another thing like “connections”, but then again, no info is available. I guess these people are hiding as much as they can.

        Once I’m logged onto the system ,is it possible to get the data I need?

        I’m just a php developer, and this stuff of SAP is being a pain in the *** hehe.

        By the way, I’m pretty sure you know it, but it is not a good practice to write plain HTML code through PHP =)

        Thank you very much! y un saludo!

        • Yes, I speak Spanish…but here we have to use only English…and please don’t use curse words…it’s completely forbidden here…
          I don’t know if there’s a way to get that info from SAP, but you should try looking for a file called SAPLogon.ini or something like that…it should contain the information.
          Or maybe you can download and install the NetWeaver Community Edition…it’s under Downloads…that’s why I use at home for all my personal projects…
          About passing plain HTML to PHP…I know that, but I’m just lazy -;)


          • Perfect!

            I found the file .ini and it seems there’s all I need. It’s a bit strange that the server is not and IP or something like this, but just IDS_LAN. Anyway, I’m going to try. Hey, and I’m sorry for the rude words =)

            Thank you very much!

            Spanish regards from Germany.

          • Hi there again,

            I tried to get as many data as possible from the .ini file you told me.

            There are several Items, so I looked for the one with the name of server I wanna connect, in my case: Item2… so going up and down I got these values:

            [Router],[Router2],[RouterChoice],[Server],[Database],[System],[Description],[Address],[MSSysName], [MSSrvName],[SessManKey],[SncName],[SncChoice], [CodepageIndex],[Origin],[MSSrvPort],[LowSpeedConnection],[Utf8Off]. Many of them are just empty or equal to 0.

            Ok, so we get back to the php file and try to fill the login array. This is my guess:

            $LOGIN =  array (    “ASHOST” => [Server],
                                  “SYSNR” => [System],
                                  “CLIENT” => “001”,
                                  “USER” => “blablabla”,
                                  “PASSWD” => “1234”,
                                  “GWHOST” =>[Address],
                                  “GWSERV” =>””,
                                  “MSHOST” =>””,
                                  “R3NAME” =>””,
                                  “GROUP” =>””,
                                  “LANG” =>”EN”,
                                  //”TRACE” =>””

            But it doesnt work. It gives me the following:


            Warning: RFC Error Info : Group : 101 Key : RFC_ERROR_PROGRAM Message : Open file ‘C:\WINNT\sapmsg.ini’ failed in C:\xammpOLD\htdocs\SAPphpO\index.php on line 25
            Failed to connect to the SAP serverRFC Error Info : Key : RFC_IO5 Status : CODE=CM_PRODUCT_SPECIFIC_ERROR STATUS=??? DATA=??? ID=??? Message : Open file ‘C:\WINNT\sapmsg.ini’ failed Internal: IO HANDLE=20 DRV=EXT LINE=589 CODE=5


            I checked for the file sapmsg.ini and it does not exist.

            Could you give me a hand? =)

            Thanks a lot in advance, at least now I see it tries to connect.


          • I would need to check my NSP when I get home to analyze the ini file…will reply you tonight or tomorrow…but better send me an email…you can find it on my business card.