Please also have a look in our OnlineHelp for further information.

This article will describe how to extract data from SAP to Salesforce using Xtract Universal and then Process it using scheduled Apex jobs. We will here extract annual revenue values from SAP to a staging object in Salesforce and then transfer them to the annual revenue field of the standard Salesforce Accounts object.

Define extraction

We define an extraction based on the SAP table KNA1 for general customer information.

settings_create_object_2

The two columns needed for this example are KUNNR and UMSA1. The Where Clause will be used to get only those entries which match our criteria.

Set destination

To use the Salesforce destination we have to set our Salesforce login data.

definition

Define destination settings

These settings are set by default and required for this example.

settings_create_object__0

The Preparation option Create if not exists will only create a new Salesforce object if no object with the same name already exists. With Row processing set to Insert all new entries will be inserted into the specified object and merging won’t be possible.

Run extraction

Click the Run button in the extraction definition window. In the dialog click either Run in xu.exe or Run in Browser.

run_extraction_popup

Refresh the Designer by clicking the Refresh button. Check the execution status and the number of rows that have been extracted.

designer_view

To check the processing status in Salesforce we have to navigate to Setup > Jobs > Bulk Data Load Jobs. Here we can check the status of our extraction job. Make sure the number of records processed matches the number of rows extracted in Xtract Universal.

salesforce_view

The entries in our Sales__c object look as following:

salesforce_entries_view

Create Apex class

To create the Apex class for our scheduled APEX job we navigate to the Developer Console. Under File > New > Apex Class create a new Apex class and name it ScheduledSalesJob.

defcon_new_class

This example class will take all entries from our custom Sales__c object that have been modified since the last run of the scheduled job and write its Annual Revenue (UMSA1) value to our corresponding Account by matching the Account Number (KUNNR).

defcon_class_source

(Source code can be downloaded from the attachments)

Create scheduled Apex job

To create the job we will have to open the Execute Anonymous Window. It can be opened under Debug > Open Execute Anonymous Window or by pressing CTRL + E. The following code will create a scheduled job that is named Sales and runs daily at 17:00.

defcon_execute_anon

Once we executed this code by clicking the Execute button we can check Setup > Jobs > Scheduled Jobs to see if our job got created successfully.

salesforce_scheduled_jobs_view

By checking the Log in the Developer Console we can check if the scheduled execution of the Apex code was successful.

defcon_log

What our Accounts looked like before the execution:

scheduled_apex_job_pre_output

What our Accounts look like after successful execution:

scheduled_apex_job_output

Attachments —————————————-

scheduledsalesjob.zip (0.79 KB)