Time for me to give back! After reading so many useful tips and blogs on all things Salesforce, I wanted to share with you a step-by-step approach to connecting your SAP ERP Central Component (ECC) system to Salesforce, without middleware!

Assuming your company has SAP on the back end, the tried and true way to get data into Salesforce has been using Data Loader. Well that’s about to change, big time! Salesforce continues to evolve and has recently implemented direct system-to-system integration.

You can now perform real-time queries against the back-end SAP ERP system without middleware! Imagine writing an Apex class that reads data from databases that do not exist inside your Salesforce org. And when you create a report on SAP data, the result looks like a custom object within Salesforce. That’s pretty cool stuff.

Prerequisite: Setting up SAP for public access

This article assumes that you have some relationship with SAP; for example, your company uses SAP products and you wish to connect your Salesforce instance; if that’s the case, you can skip ahead to Step 1: Configure the Lighting Connector for SAP Access. If you’re not using SAP (perhaps you’re evaluating the SAP-Salesforce scenario), this section covers how to get everything you need:

Sign up for your SAP Community Network Logon

We need to get your SAP Access!

  1. Click on this link here and select the “Join Us” link to get your free login.
  2. Now you will get a popup that will allow you the ability to get your login. Even a “Student” can access SCN.

Once you register you are now part of the SAP Community Network, and you can access a public SAP System.

Request access to the Public SAP System

Once you have requested your free SCN logon, you can now request access to the public SAP instance, this will allow you the ability to test out your Lighting Connect components.

  1. Log into the SCN system by clicking the link here. If you have done this correctly you should see the following screen:
  2. Click Register to get your Public SAP Logon sent to you.
  3. You will receive an email from SAP containing a SAP user id and password. Important: save this username and password, you’ll need it for the Salesforce setup.

Now we have everything we need to start the Salesforce setup.

Step 1: Configure the Lighting Connector for SAP Access

First, configure the connection from Salesforce to the public SAP system.

  1. Click Setup | Develop | External Data Sources.
  2. Now click New External Data Sources.
  3. Fill out the screen with the following information:
    Label: SAP Data
    Name: SAP_Data
    Type: Lightning Connect OData 2.0
    URL: https://sapes1.sapdevcenter.com/sap/opu/odata/sap/SALESORDERXX/
    Connection Timeout: 120
    High Data Volume: Unchecked
    Compress Requests: Unchecked
    Include in Salesforce Searches: Checked
    Custom Query Option: Blank
    Format: AtomPub
    Certificate: Blank
    Identity Type: Named Principal
    Authentication Protocol Password Authentication
    Username: <The SAP Supplied user-name from Step 2>
    Password: <The SAP supplied password from Step 2>

    When you are done the screen should look like this:

  4. Now click Save and you’ll see the following screen, which means Salesforce is happy with the data you have provided, but it is not yet proof that you can actually connect to the public SAP System.
  5. Click Validate and Sync button to make the connection. If you have done everything correctly you will then see the following screen:

    This shows that we were able to successfully logon to the SAP system and it returned the list of tables that we can access. We can now select the Sales Order Collection tables so that we can view this data inside Salesforce and also write Apex Code against this SAP data even though it does not actually get loaded into Salesforce. (Save your disk space for other Salesforce stuff!)

Step 2: Synchronize the Tables from SAP to Salesforce

In this step you tell Salesforce to log into the SAP System and proceeded to “read” the description of the SAP data. This data is used to create a custom object and the custom fields needed to query this data within Salesforce.

  1. Click Sync to have Salesforce read the SAP Tables and create the corresponding custom objects inside Salesforce.
  2. To see what happened behind the scenes, click SOHeaders and you can see the custom object and the custom fields that were created:

If you have ever coded an Apex Class or an Apex Trigger the API name should look pretty familiar to you. Objects that end in __c (underscore, underscore, c) are Custom Objects, meaning that you created them. Salesforce Lightning Connect uses the suffix __x (underscore, underscore, x) with the “X” for External.

At this point you can now directly read data from your back-end SAP system without any middleware, adapters, plug-ins or whatever the latest buzz-word is for an integration tool. But let’s not stop here, we want to read and display this data on a page layout. So the remaining steps will assist you in performing the needed steps to get this data to display real-time in your Salesforce org.

Step 3: Create an Apex Class to Retrieve SAP Data

All you Salesforce admins: you may not be a developer but you can cut and paste with the best of them, can’t you? Here is a small amount of Apex Code that we can use to read the SAP data when an account is being displayed. We want to see some SAP Sales Orders when we display the account in Salesforce. We want the data real-time, meaning that if another sales order is created just a minute later that data will be immediately available inside Salesforce! No Data Loader, no Batch Bulk API runs… just real-time access without any managed packages or SAP transports!

  1. OK, let’s create the Apex Class. Go to Setup | Develop | Apex Classes and then click New.
  2. Cut and paste the code provided in the code editor and then Save.

When you’re done the code should look like this with no errors. Now if something is mistyped you may receive a compile error. If you do please send a screen shot to me or post it in the comments section so that everyone can benefit by solving the issue. But hopefully you will have a screen just like this one and we can continue to create the Visualforce page.

Step 4: Create a Visualforce page to display your data

Now that we have an Apex class that will read the SAP data, we would like to display this on a Visualforce Page.

  1. Let’s create the Visualforce Page. Go to Setup | Develop | Pages and then click New. You should see the following screen:
  2. Now let’s update this Visualforce page to include the following information.
    Label SAP_oData_Example
    Name SAP_oData_Example
    Description A simple example of getting SAP Data without any middle-ware!
  3. In the code editor, remove all of the <apex: page> …. </apex:page> tags from the Visualforce markup section of the screen. We don’t need any of this. Instead, paste in this code:
  4. Click Save. Hopefully you have no typos and Salesforce will allow you to save your Visualforce Page. If you have any errors you will not be able to save the page. If this happens check your typing or cut-and-pasting to make sure you are not missing anything. Please post a screen shot in the comments if you have any errors!

If you have no errors the screen should look like the following:

Step 5: Assign the Visualforce page to the Accounts Page Layout

At this point we have built everything we need to access SAP data real-time. All that is left to do is to put the Visualforce page on the Accounts Page Layout to display the data.

  1. Navigate Setup | Customize | Accounts | Page Layouts. If you have a brand new Developer Edition org, the Page Layouts are pretty straight forward. However, if you are performing this in a well-used Developer Edition or sandbox, you may have more Page Layouts. Use your good judgment on which page layout to modify.
  2. I will modify the basic “Account” Page Layout since this is one of the more commonly used Page Layouts. Click Edit to modify this page layout.

    The following should be your screen once you are in edit mode for the Page Layout.
  3. The first thing we want to do is create a new “Section” on the screen where the SAP data will reside. This is done by clicking on the word Section in the palette at the top of the screen and dragging the Section to the spot on the screen where we want the new Section to be:
    In the screenshot below I am dragging the “Section” down the page until I find a spot where I want to create a new “Section”. Continue to drag downward until you find a spot where the Icon changes to green.

    Here is a screenshot of a spot on the Accounts Page Layout where we can create a new section. Release the mouse button here and you will be creating a new section for the SAP Data.
  4. Once we release the mouse button a popup box will appear which will give us the opportunity to name the new section. Here is a screen shot before I rename the new section.
    Now here is a screen shot after I have renamed the Section, selected the 1-Column Layout and clicked the OK button.
  5. Now let’s drop the Visualforce Page into the newly created “SAP Data” Section. This is done by grabbing the scroll bar and locating the Visualforce Page list. Once you locate it click on it and all available Visualforce Pages will be available for you to drag onto your Accounts Page Layout.
  6. Here we want to scroll to the section to add the newly created Visualforce Page to the screen.
  7. Now we drop the Visualforce page on the screen.
  8. Once this step is completed the only thing remaining is to Save the updated Accounts Page Layout.

Step 6: Test your work!

  1. Click the Accounts tab and bring up any account. Since this org has no data, I will create a new Account. Just click the New button:
  2. Now I will create a record that I know exists in my SAP system:

    Use the following data:

    Account Name Belmont cafe Inc
    Account Number 100001

    Why did we use this data? Because I quickly checked the public SAP System for a customer master record:

    If you noticed the SAP system is ES1 (in the lower right hand corner). You don’t need to know how to log onto the SAP System but if there is any interest I can create a step by step blog to get you SAP access if you like (Remember this is a public SAP system so you can gain access). Please just post a comment and I will consider doing this.

  3. Now just click the Save button on the Salesforce Account page:
  4. Let’s click on the newly created account: We can see the details of this account and all the real-time SAP data that was returned!

Some of these fields may look not too familiar to the Salesforce admin but I can assure you to the SAP Sales Order Management team, they know exactly what is being displayed here!

Lots of screen shots and words, but hopefully you too can connect an ERP system to your Salesforce Developer Edition instance!

About the Author

Steve is an experienced Architect at SGC Software responsible for the design, development and deployment of enterprise class solutions for major corporate clients. Certified SAP ASAP methodology consultant. Certified in Agile/SCRUM implementation methodologies. Passionate about helping non-profits/NGO’s and giving back, and enjoys blogging and contributing whenever he can! ! Please reach out if you require any help with your Salesforce system and need Pro Bono work for your non-profit / NGO.

Get the latest Salesforce Developer blog posts and podcast episodes via Slack or RSS.

Add to Slack Subscribe to RSS