There are use cases where one has to publish huge volume of data from SAP HANA to Salesforce, this blog describes options that are available with the Advantco Salesforce adapter for SDI. We describe how to use virtual tables to upsert (update/create) standard or custom objects in Salesforce. We will also handle platform events in case of more complex use cases where one has parent and child objects.
Configure the Remote Source for batch processing.
Configure the Process Prepare statement(s) Mode as Collect And Process Each Batch Later.
Option 1: Using virtual tables to create or update objects in Salesforce
Any operation (CREATE, UPDATE, DELETE) on a virtual table in HANA results to the same in Salesforce. For example, insert a new account into the Account virtual table, results in creation of a new Account object in Salesforce.
In this example, we create a trigger that will be activate whenever there is an insert or update into the table real table CUST_REV_SQL. The trigger will select any new or modified record and insert it into the virtual Account table.
Import Account virtual table.
Define the trigger.
CREATE trigger "SFDC_US_DEMO"."TRIGGER_CUST_REV_SQL" AFTER INSERT OR UPDATE ON "SFDC_US_DEMO"."CUST_REV_SQL" REFERENCING NEW ROW as newAccount FOR EACH ROW BEGIN INSERT INTO "SFDC_US_DEMO"."VT_Account"("Name","SAP_Source_ID_c","BillingCity","BillingPostalCode","BillingStreet","AccountNumber","SDI_test_c") VALUES(:newAccount."NAME",:newAccount."CUST_ID",:newAccount."CITY",:newAccount."POST_CODE",:newAccount."STREET",:newAccount."CUST_ID",'US_AGENT'); END;
We update the records in the table CUST_REV_SQL, which results into firing the trigger that was defined for this table.
In Salesforce, we see that a job was created for the account objects.
Option 2: Using Salesforce platform events.
When we have an use case where we have to create or update multiple objects in Salesforce, like Account and Contact, we can use platform event.
Create a platform event AccountContactEvent in Salesforce. This event is used to create an Account with a Contact.
Define the Custom Fields and Triggers
In SAP HANA, we import the virtual for the platform event AccountContactEvent.
We define new trigger, this time we insert any new or updated record of the table CUST_REV_SQL into the virtual table VT_AccountContactEvent__e.
CREATE TRIGGER "SFDC_US_DEMO"."TRIGGER_CUST_REV_SQL_PLATFORM_EVENT" AFTER INSERT OR UPDATE ON "SFDC_US_DEMO"."CUST_REV_SQL" REFERENCING NEW ROW NEWACCOUNT FOR EACH ROW BEGIN INSERT INTO "SFDC_US_DEMO"."SFDC_US_SANDBOX2_AccountContactEvent__e"("Account_Name__c","Contact_LastName__c","Account_ExtID__c","Account_BillingCity__c","Account_BillingStreet__c","Account_BillingZipcode__c","Contact_Title__c","Contact_Email__c","Account_BillingState__c") VALUES(:newAccount.NAME,:newAccount.NAME,:newAccount.CUST_ID,:newAccount.CITY,:newAccount.STREET,:newAccount.POST_CODE,'Mr','firstname.lastname@example.org','NC'); END
After running the update script, we see the following in Salesforce.
Summary: The Advantco Salesforce adapter for SDI provides bi-directional integration with Salesforce and HANA. In case of very large data volume, publishing data directly from HANA to Salesforce is option that valid option.