Additional Blogs by Members
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member
0 Kudos

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.

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.

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.

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 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=...

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.

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 force.com process just make a call like:

The frontend of the process in force.com 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):

5 Comments