Skip to Content

Connecting SAP to Force.com

Introduction

There are multiple ways to extend your enterprise application. The force.com 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 Force.com 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 force.com 

Scenario

To realize this interface we installed a SAP NetWeaver PI interface layer to communicate with both the webservices in force.com and the SAP backend system. The path will be: “Create employee in force.com” –> “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.

image

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.

image

Force.com

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

image

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.

image

 

Now we can import the WSDL into force.com. We will do this by use of the standard force.com 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 http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_callouts_wsdl2apex.htm?SearchType=Stem&Highlight=WSDL|WSDLs|wsdl

image

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.

image

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.

image

In the force.com process just make a call like:

image

The frontend of the process in force.com will look something like:

image

 

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:

image

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):

image

image

image

To report this post you need to login first.

5 Comments

You must be Logged on to comment or reply to a post.

  1. Santhosh Kumar Vellingiri
    Interesting!!!
    One quick query… Generally SAP PI is in company network and its WS is visible only within intranet whereas force.com is on Internet? So did you enable SAP PI WS to internet for force.com apex to consume?? Or was this handled in the APEX coding?

    ~SaNv…

    (0) 
    1. Wim van Erp Post author
      Yes we had to enable SAP PI to internet and we had to add the force.com IP to the firewall. We also added the SAP PI IP address to the firewall of the force.com server.
      (0) 
  2. Pontus Borgström
    Hi,

    this a nice description on connecting Force.com 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?

    (0) 
    1. Wim van Erp Post author
      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

      (0) 
      1. Pontus Borgström
        Hi,

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

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

        We were using a standard BAPI in SAP an this was not a problem at all.
        A request comming in from SalesForce.com and this was fairly straight forward… but this is where the fun ended.
        If I remember correctly a notification was only sent from Force.com and PI needed to logon to Force.com and fetch the request and ID.
        When returning the list to Force.com there was not any open connection to respond to.
        Force.com 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 Force.com could recognise it.
        To complicate things Force.com required a login ticket to be requested separately in all requests
        and responses to Force.com.
        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 Force.com for all tasks performed in this sequense.
        This gave us a quite good responsetime after all.

        Although… connecting anything to Force.com seems to be a sad story…

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

        (0) 

Leave a Reply