Skip to Content

Connecting SAP to

Connecting SAP to


There are multiple ways to extend your enterprise application. The platform offers you a PAAS (Platform As A Service) solution to build powerful and scalable enterprise applications. In many cases integration with other enterprise application (like SAP) is needed to support end-to-end business processes. I would like to provide you some insight in how we manage to integrate a solution build on the platform with SAP ERP 6.0 using SAP NetWeaver PI.

Although the scope of the interface is broader, I will guide you though the process with the interface to create a new Employee in SAP HR from 


To realize this interface we installed a SAP NetWeaver PI interface layer to communicate with both the webservices in and the SAP backend system. The path will be: “Create employee in” –> “Interpret and process the data in SAP NetWeaver PI” –> “Results in SAP backend system”.

Process steps

Find processing object from SAP (iDoc, BAPI, Function Module)

For the creation of new employees, a new HR document has to be created, iDoc HRMD_A07 is suitable for that.


Mapping in SAP NetWeaver PI

HRMD_A07 is an extremely extensive iDoc so choose the fields used for mapping wisely. It will take a while to load the iDoc and therefore it is nice to set the mapping of the fields right the first time.


In the interface of the webservice should be known and available. To achieve this, first we have to export the WSDL from SAP NetWeaver PI.


Next we have to append the URL to the WSDL for user and password confirmation. Make sure you use the correct business system, software component and namespace.



Now we can import the WSDL into We will do this by use of the standard functionality to create an apex class (this is somewhat similar to a normal ABAP class in SAP). We will not create a new one but we will generate it automatically from the WSDL. Restrictions and additional information of this generation can be found at|WSDLs|wsdl


We have to determine an apex class name, we will use ‘SAPPersonCreate’. Now we have created the apex class to call the webservice in SAP NetWeaver PI, we want to build a shell around this object in the form of a class method. This method can be implemented within the system process or workflow by simply calling the class method.

The screenshot below shows that the apex class in Eclipse indicates that this is generated automatically. image

In this apex class we will find the method corresponding to the service interface. As you can see, even the name is the same(MIOS_SAPPersonCreate). Always check if the endpoint in this method is the correct one.


When we want to use this classmethod in a system process, it is recommended to not change this method but create a calling method. In this method we also define the username and password for our SAP connection. In this case we create a class called jTNF and we will create methods SAPPersonCreate, InputHeaderPerson and OutputHeaderPerson.


In the process just make a call like:


The frontend of the process in will look something like:



In this example we will hire mr. Armstrong. When he is hired the proposal will result in a new employee in SAP HR. Press Hire:


The calling of the webservice was successful and the result is shown in SAP backend (the nickname field in infotype personal data will be abused as external key field):




You must be Logged on to comment or reply to a post.
  • Interesting!!!
    One quick query... Generally SAP PI is in company network and its WS is visible only within intranet whereas is on Internet? So did you enable SAP PI WS to internet for apex to consume?? Or was this handled in the APEX coding?


    • Yes we had to enable SAP PI to internet and we had to add the IP to the firewall. We also added the SAP PI IP address to the firewall of the server.
  • Hi,

    this a nice description on connecting to SAP and its a fairly easy step, but if we want to use a bapi and get the response back I understand that its not this easy...
    Do you prepare a blog about this?

    • Hi Pontus,

      the project is on pause at the moment but I was investigating the same. The way I see it you will have 2 options for a synchronous call.
      1) BAPI
      2) Related documents (correlation)

      1) this is a nice options but you'll have to create a RFC connection which a customer does not always accepts. I have not tested this but I believe this is fairly easy.
      2) this will make use of the existing iDoc structure. The disadvantage is that you'll have to create a waiting period (with a max of 1 minute or so) and this will check if the document has a return value. This has to be a quick respons because you'll get a timeout and not all backend systems are fast enough.

      We are thinking about the first option but I think we'll have to create both situations.

      Kind regards,
      Wim van Erp

      • Hi,

        we did a POC and one of the scenarios where was asking for a customers open orderlines.

        This seemed as a walk in the park until the technical parts of were revealed.

        We were using a standard BAPI in SAP an this was not a problem at all.
        A request comming in from and this was fairly straight forward... but this is where the fun ended.
        If I remember correctly a notification was only sent from and PI needed to logon to and fetch the request and ID.
        When returning the list to there was not any open connection to respond to. sends an async request and expects a async reponse.
        In the return the response were to be posted against the innitial ID and type so that could recognise it.
        To complicate things required a login ticket to be requested separately in all requests
        and responses to
        The most efficient way should have been to use a ccBPM but performance wise that was quickly abandoned. The complete flow was built using UDFs in the mappings to do lookups agains for all tasks performed in this sequense.
        This gave us a quite good responsetime after all.

        Although... connecting anything to seems to be a sad story...

        In the end the preffered recommendation from was chosen by the company, to use Informatica.
        This should be "out of the box" and the best approach...
        Nothing out-of-the-box...
        Performance so sad that a ccBPM word be a race car...