Pushing Data into SAP Commerce Cloud

Data Hub Adapter provides a web-based service API called the ImportService. It is used to upload data into SAP Commerce Cloud from Data HubImpEx file format.

At Least Once Delivery

When the Data Hub returns a 200 response, the data is guaranteed to be persisted. It is also guaranteed to be sent to the target system when appropriate actions are triggered. Triggering these actions is a configurable, automatic part of the SAP integration. If the data is reported as invalid or failed in the target system, the . Provide the data in the Data Hub continues to publish it until:
  • the publication succeeds
  • the number of attempted publications reaches the value of the datahub.max.publication.retry.count property
There are some other corner cases where a piece of data can be delivered multiple times. For example:
  • The data is received by the target system, but the target sends a non-200 response to the Data Hub.
  • The target system reports that there were problems with the data when it actually continued to be processed in that system.
  • Faulty network setup prevents the HTTPS response from making it back to the Data Hub.
  • The Data Hub crashes after sending the data and before capturing the response, and so on.

Duplicate Checking

Duplicate checking depends on the approach taken to data modeling. If the primary key fields of the canonical model uniquely identify the item accurately, then the Data Hub merges those items together if duplicates are sent. These items would be merged together when the different versions are sent to the Data Hub. Provide the data in the. There is nothing out of the box preventing these versions from being published independently. Custom logic could be added to provide different behaviors here. For example, a custom grouping handler could prevent a new item from being created if one with the same integration key exists. In the standard SAP order case, orderId is the primary key field.

Sequencing

The Data Hub deals with sets of data and does not focus on individual messages. Therefore, the entire set of unpublished items publishes at the same time. Some ordering can be achieved by the target modeling. Target type dependencies can easily be introduced in the modeling metadata. Target type dependencies can be used to guarantee that the Data Hub publishes all items of one type before publishing the items of the dependent type.

The ImportService is the primary service used to provide data transfer from Data Hub to SAP Commerce Cloud. Whenever Data Hub Adapter is used to push data from Data Hub to SAP Commerce Cloud, the ImportService is used.

ImportService only works with the ImpEx file format.

A typical ImpEx file looks like the following:
$baseProduct=baseProduct(code, catalogVersion(catalog(id[default='apparelProductCatalog']),version[default='Staged']))
$catalogVersion=catalogversion(catalog(id[default=apparelProductCatalog]),version[default='Staged'])[unique=true,default=apparelProductCatalog:Staged]
 
INSERT_UPDATE Category;supercategories(code,$catalogVersion);code[unique=true];$catalogVersion
;;3912;
;;1;
;;2625;
;;tshirts;
 
INSERT_UPDATE Product;code[unique=true]; name[lang=en]; Unit(code); $catalogVersion[unique=true,allowNull=true];description[lang=en];approvalStatus(code);ean;manufacturerName
;123A;A12334567890BC; pieces; ;Very good product;approved;testEAN;A Manufactor"
However, there may be large volumes of data that must be included in the file, which can make the transmission very time-consuming. To bypass these problems and to load the data more efficiently, Data Hub Adapter uses a special format for the ImpEx file. Only headers are present and there is information about how to retract the data from Data Hub. The following is an example:
$baseProduct=baseProduct(code, catalogVersion(catalog(id[default='apparelProductCatalog']),version[default='Staged']))
$catalogVersion=catalogversion(catalog(id[default=apparelProductCatalog]),version[default='Staged'])[unique=true,default=apparelProductCatalog:Staged]
 
INSERT_UPDATE Category;;supercategories(code,$catalogVersion);code[unique=true];$catalogVersion
#$URL: https://data.integration.host/datahub-webapp/target-system-publications/123/ApparelProductCatalog.txt?targetName=TestHybrisCore&fields=parent,catalog,version
#$HEADER: x-TenantId=master
 
INSERT_UPDATE Product;;code[unique=true]; name[lang=en]; Unit(code); $catalogVersion[unique=true,allowNull=true];description[lang=en];approvalStatus(code);ean;manufacturerName
#$URL: https://data.integration.host/datahub-webapp/target-system-publications/123/ApparelProduct.txt?targetName=TestHybrisCore&locale=en&fields=code,name,unit,catalogVersion,description,approvalStatus
#$HEADER: x-TenantId=master
To further understand Data Hub Adapter ImpEx script, consider these 4 important aspects.
  1. Processing of the ImpEx files in Data Hub Adapter supports multithreading (utilizing all cores of the server).
  2. Data Hub validates each ImpEx header and, in case of an error, all of the items related to that error are reported as FAILURE. The rest of the data contained in the same publication (for valid headers) attempts to load and the relevant status is reported. The overall publication is marked as COMPLETE_W_ERROR.
  3. Data Hub Adapter uses special comments to retrieve information about the call back to Data Hub. Then it replaces those comments with the data received from the call back into the file. The following values can be specified in the special comments:
    • <URL>: a URL for the call back. Use the URL "as is" to request data from Data Hub.
    • <HEADER>: an HTTPS header name=value to add to the call back HTTPS Request. The headers can be used to pass required information, for example, tenant ID or security context, to Data Hub.
  4. The first field in the ImpEx command declaration is empty. An empty first field means that the values are ignored by the ImportService. However, they can still be used by Data Hub Adapter. Data Hub Adapter requires that the canonical item ID appears in the empty header column for each data record being imported. This ID is reported back to Data Hub in case of an error and lets Data Hub tie that error to a specific item.