Skip to Content
Author's profile photo Alan Indomenico

First conection with SAP and PHP

Hellos alls , this blog is about Web Services (WS) and trying to use them in PHP , it’s kind of cool , but it gave me a lot of headakes for 2 weeks to understand , i used HTML5 Builder (That’s right is in HTML5 just to proof that i can ,jejej)

So Lets….

what we are going to do is a simple conection to a WS and then show data in a grid , this is the UI for the page

/wp-content/uploads/2013/10/ui_289935.png

As you can see is a button , a label and a grid just to show some data

Now to see the code

The declaration

<?php
require_once("rpcl/rpcl.inc.php");
require("rpcl/nusoap/nusoap.php");
//Includes
use_unit("forms.inc.php");
use_unit("extctrls.inc.php");
use_unit("stdctrls.inc.php");
use_unit("platinumgrid/jtplatinumgridlite.inc.php");
use_unit("jqgrid/jqgrid.inc.php");
use_unit("comctrls.inc.php");
use_unit("styles.inc.php");

This is how i star the code , but to be honest , it’s auto generated by my php suite ,jejeje , the only thing that i write in this part was line number 3 , (trust me we are going to need it)

Now i’ll show you the real code , when i click in the  button is gonna call the WS to sap and ask me about my credentials

 function Button1Click($sender, $params)
    {
  // mi codigo THOR 15/05/2013
    // crea el cliente
    $wsdl = true;
    $cliente = new nusoap_client('wsdltabla.wsdl', $wsdl );
    $cliente->soap_defencoding = 'UTF-8';
    $cliente->setCredentials('adm1','Mjo2','basic')  ;

Firs we have to start a cliente , this is what is going to connect to sap , line 11 are declaration where we say to the WS that we are using wsdl file or direccion , in this case a file , becase by a url didn’t work

line 12  the decoding uds for this , more declaration for the client

line 13 is where we put the credentials to be sent to sap , in this order is user , password , and mode of autentication

NEXT time i’ll explain the other steps for this button , thanks

Assigned Tags

      11 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Andy Silvey
      Andy Silvey

      Hi Alan,

      excellent blog and thank you for sharing.

      This will be very useful to anybody interested in getting SAP and PHP to work

      together.

      Best regards,

      Andy.

      Author's profile photo alan indomenico
      alan indomenico
      Blog Post Author

      Thanks , still have another part to write , it's very simple but it gets to the point

      Author's profile photo Andy Silvey
      Andy Silvey

      thanks

      I am working on a little personal project at the moment, using the apache, php, mysql standard and this is useful for me for the SAP/PHP part.

      Thanks,

      Andy.

      Author's profile photo alan indomenico
      alan indomenico
      Blog Post Author

      What OS are you going to use ?

      Author's profile photo Andy Silvey
      Andy Silvey

      a flavour of linux, I don't know which I will have to ask the hoster.

      currently the project is in the functional design stage

      I know what the product will do, and am doing the functional

      and database design

      i have the domain, but not the hosting yet, and no code written yet

      Andy.

      Author's profile photo alan indomenico
      alan indomenico
      Blog Post Author

      We had 2 servers , the first one was windows XP , apache , and oracle (really messy) but it was to start understandig how to work with php and apache , now we have cent os (like red hat) , are you planing doing it web oriented or destokp ? , i recomend to work in web design , so any device can see it no matter how

      Author's profile photo Andy Silvey
      Andy Silvey

      yes it is going to be a cloud based product

      Andy.

      Author's profile photo Andy Silvey
      Andy Silvey

      infact, I think probably I should be using the Hana Cloud Portal

      I will look at that too.

      Andy.

      Author's profile photo alan indomenico
      alan indomenico
      Blog Post Author

      i make a paper of this with all the code , when it get aproved i'll send the link , and if yopu need some help just tell me

      Author's profile photo Andy Silvey
      Andy Silvey

      Hi Alan,

      thank you.

      Best regards,

      Andy.

      Author's profile photo alan indomenico
      alan indomenico
      Blog Post Author

      I also have conections with vb.net and vb.net for mobile devices , if you are interested i can make a paper