TDV Adapter for SAP Cloud for Customer

Build 22.0.8462

Tables

The adapter exposes tables for every entity set and singleton defined on the OData service document. Entities on these tables may be inserted, updated, or deleted using standard SQL insert, update, or delete statements.

Executing Deep Inserts with SQL

The adapter supports OData deep inserts, in which you simultaneously create a base entity and link it to related entities, by specifying navigation properties. To specify Navigation Properties for an entity, you create a temporary table for the navigation property and then reference the temporary table in the insert to the base table. Reference the temporary table in the appropriate navigation property column on the base table. Each navigation property column is prefixed with the word "Linked".

Note that you must define the temporary tables and insert to the base table within the same connection.

Example: Deep Inserts

For example, consider the AccountCollection and LeadBusinessDocumentReferenceCollection tables. When creating a new Account, you may also want to specify an Account Address. When creating a LeadBusinessDocumentReference, you need to specify an existing document. For each of these, you need to specify the following navigation properties.

Creating Temporary Tables

Insert the related entities into temporary tables that correspond to each navigation property. You can specify an existing entity's primary key or you can insert a new entity.

  • Account Address: The following statement creates two new Account Addresses:
    INSERT INTO AccountAddressCollection#TEMP (CountryCode, City, Street) VALUES ('USA', 'New York', '123 Fake Street')
    
    INSERT INTO AccountAddressCollection#TEMP (CountryCode, City, Street) VALUES ('USA', 'San Franscisco', '456 CA Street')
  • Opportunity: The following statement specifies an existing Opportunity:
    INSERT INTO OpportunityCollection#TEMP (ObjectID) VALUES ('123')

The adapter will assume that the Opportunity already exists and will only link to the existing references since only the primary key was specified. When more than just the primary key is defined, such as the example for Account Address, the SAP Hybris C4C Adapter will attempt to create new entries - triggering the deep insert.

Inserting the Entity

In the INSERT statement for the base entity, reference the temporary tables in the LinkedOpportunity or LinkedAccountAddress columns:

INSERT INTO AccountCollection (AccountID, AccountName, LinkedAccountAddress) VALUES ('123', 'My New Account', 'AccountAddressCollection#TEMP')

INSERT INTO LeadBusinessDocumentReferenceCollection (ParentObjectID, LinkedOpportunity) VALUES ('5555', 'OpportunityCollection#TEMP')

Code Example

Below is the complete code to create the new AccountCollection and LeadBusinessDocumentReferenceCollection entities:
Connection conn = DriverManager.getConnection("jdbc:saphybrisc4c:Tenant=mytenant.crm.ondemand.com;User=user;Password=password;");
Statement stat = conn.createStatement();
stat.executeUpdate("INSERT INTO AccountAddressCollection#TEMP (CountryCode, City, Street) VALUES ('USA', 'New York', '123 Fake Street')");

stat.executeUpdate("INSERT INTO AccountAddressCollection#TEMP (CountryCode, City, Street) VALUES ('USA', 'San Franscisco', '456 CA Street')");

stat.executeUpdate("INSERT INTO AccountCollection (AccountID, AccountName, LinkedAccountAddress) VALUES ('123', 'My New Account', 'AccountAddressCollection#TEMP')");

stat.executeUpdate("INSERT INTO OpportunityCollection#TEMP (ObjectID) VALUES ('123')");

stat.executeUpdate("INSERT INTO LeadBusinessDocumentReferenceCollection (ParentObjectID, LinkedOpportunity) VALUES ('5555', 'OpportunityCollection#TEMP')");

stat.close();

Copyright (c) 2023 CData Software, Inc. - All rights reserved.
Build 22.0.8462