Skip to Content

This blog post will explain how you can model your iFlow to insert and update data in your Custom Business Object. As a prerequisite you should read blog post https://blogs.sap.com/2017/05/12/usage-of-odata-service-of-custom-business-object/.

Overall iFlow

The iFlow consists of 8 steps for mass data coming in through a SOAP service and mapping to the OData service of a custom business object (CBO). Each step is explained in detail.


Step 1: Iterating Splitter to package mass data into chunks of 1000
Step 2: Process Call to Local Integration Process “Enrich SAP_UUID”
Step 3: Iterating Splitter to handle each entry in a seperate call
Step 4: Content Modifier to save the semantic key in properties
Step 5: Content Enricher to read the technical key SAP_UUID
Step 6: Mapping After Enrichment
Step 7: Gathering of SAP_UUID Enrichment Calls
Step 8: Map request chunk to OData Batch Processing

The HTTP session handling is set to “On Integration Flow” to ensure that the same session is used for all calls to SAP Hybris Marketing instead of creating multiple sessions. This increases performance:

In this example the payload of an incoming SOAP Service looks like this:

<inp:NewOperation xmlns:inp="http://www.example.org/InputSoap/" 
 xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
 <Run>
   <ContactID>6</ContactID>
   <IDOrigin>EXTERNAL</IDOrigin>
   <Field1>Max</Field1>
   <Field2>Mustermann</Field2>
 </Run> 
 <Run>
   <ContactID>7</ContactID>
   <IDOrigin>EXTERNAL</IDOrigin>
   <Field1>Ellen</Field1>
   <Field2>Musterfrau</Field2>
 </Run> 
 <Run>
   <ContactID>8</ContactID>
   <IDOrigin>EXTERNAL</IDOrigin>
   <Field1>John</Field1>
   <Field2>Doe</Field2>
 </Run> 
</inp:NewOperation>

The Custom Business Object from the prerequisite blog post https://blogs.sap.com/2017/05/12/usage-of-odata-service-of-custom-business-object/ is used in this example as well. The OData metadata document looks like this:

...
<EntityType Name="YY1_HCI_ID_ID_ORIGINType" sap:content-version="1">
 <Key>
  <PropertyRef Name="SAP_UUID"/>
 </Key>
 <Property Name="SAP_UUID" Type="Edm.Guid" Nullable="false"/>
 <Property Name="IDOrigin" Type="Edm.String" MaxLength="20"/>
 <Property Name="ContactID" Type="Edm.String" MaxLength="200"/>
 <Property Name="Field1" Type="Edm.String" MaxLength="20"/>
 <Property Name="Field2" Type="Edm.String" MaxLength="20"/>
</EntityType>
<EntityContainer Name="YY1_HCI_ID_ID_ORIGIN_CDS_Entities" m:IsDefaultEntityContainer="true">
 <EntitySet Name="YY1_HCI_ID_ID_ORIGIN" EntityType="YY1_HCI_ID_ID_ORIGIN_CDS.YY1_HCI_ID_ID_ORIGINType"/>
</EntityContainer>
...

 

Step 1: Iterating Splitter to package mass data into chunks of 1000

In order to not overload the CBO backend system the data is handled in chunks of 1000. An iterating splitter is used for that purpose. The incoming payload is split at the token <Run>:

After the split the payload looks like this (as there were only 3 entries in the incoming payload and the grouping would be done for chunks of 1000, the entries are grouped in one chunk):

<Run>
  <ContactID>6</ContactID>
  <IDOrigin>EXTERNAL</IDOrigin>
  <Field1>Max</Field1>
  <Field2>Mustermann</Field2>
</Run>
<Run>
  <ContactID>7</ContactID>
  <IDOrigin>EXTERNAL</IDOrigin>
  <Field1>Ellen</Field1>
  <Field2>Musterfrau</Field2>
</Run>
<Run>
  <ContactID>8</ContactID>
  <IDOrigin>EXTERNAL</IDOrigin>
  <Field1>John</Field1>
  <Field2>Doe</Field2>
  </Run>

Step 2: Process Call to Local Integration Process “Enrich SAP_UUID”

To update or delete an entry, the SAP_UUID as technical key is needed. Therefore for each entry the SAP_UUID is enriched in a local integration process, if the entry already exists in the CBO.

Step 3: Iterating Splitter to handle each entry in a seperate call

Currently CPI does not support batch processing for OData GET calls. Therefore each entry must be handled seperatly. But they can be processed in parallel. The requests will be gathered back together in step 7. The splitting is again done at the Token <Run> but this time without grouping:

Step 4: Content Modifier to save the semantic key in properties

The semantic keys of the OData service of the CBO are ContactId and IdOrigin. In the Content Modifier the values are saved in properties for usage in step 5:

Step 5: Content Enricher to read the technical key SAP_UUID

A Get request is made to the SAP Hybris Marketing system to get the technical key SAP_UUID. The properties ContactId and IdOrigin are given over in the filter expression. As the content enricher needs a matching field from the existing payload and from the receiving payload, also the ContactID is requested:

In the Content Enricher properties the result is then mapped to the current payload:

If a SAP_UUID is returned by SAP Hybris Marketing, the payload looks as follows after the content enrichment:

<Run>
  <ContactID>7</ContactID>
  <YY1_HCI_ID_ID_ORIGINType>
      <SAP_UUID>00163e35-616b-1ed7-b5b9-662f3d264ba0</SAP_UUID>
      <ContactID>7</ContactID>
  </YY1_HCI_ID_ID_ORIGINType>
  <IDOrigin>EXTERNAL</IDOrigin>
  <Field1>Ellen</Field1>
  <Field2>Musterfrau</Field2>
</Run>

If no SAP_UUID is returned, the payload looks like this:

<Run>
  <ContactID>8</ContactID>
  <IDOrigin>EXTERNAL</IDOrigin>
  <Field1>John</Field1>
  <Field2>Doe</Field2>
</Run>

Step 6: Mapping After Enrichment

As the payload looks different after the content enrichment for new and changed objects, a mapping is introduced that maps both cases to the same structure. As result structure already the OData structure of the CBO is used. The fields ContactID, IDOrigin, Field1 and Field 2 can directly be assigned:

For the field SAP_UUID a complex expression is build. It is checked if the tag SAP_UUID exists in the incoming payload. In this case the SAP_UUID is taken over. In case the tag does not exist, an empty constant is written to the target SAP_UUID tag:

Step 7: Gathering of SAP_UUID Enrichment Calls

In the last step of the local integration process all calls are gathered and enhanced by an overall tag <All>. The overall tag is needed by CPI for further XML processing.

After the gathering the payload looks like this:

<All>
  <YY1_HCI_ID_ID_ORIGIN>
    <YY1_HCI_ID_ID_ORIGINType>
       <SAP_UUID>00163e0c-0f31-1ee7-8eae-19ed448a1944</SAP_UUID>
       <ContactID>6</ContactID>
       <IDOrigin>EXTERNAL</IDOrigin>
       <Field1>Max</Field1>
       <Field2>Mustermann</Field2>
    </YY1_HCI_ID_ID_ORIGINType>
  </YY1_HCI_ID_ID_ORIGIN>
  <YY1_HCI_ID_ID_ORIGIN>
    <YY1_HCI_ID_ID_ORIGINType>
       <SAP_UUID>00163e35-616b-1ed7-b5b9-662f3d264ba0</SAP_UUID>
       <ContactID>7</ContactID>
       <IDOrigin>EXTERNAL</IDOrigin>
       <Field1>Ellen</Field1>
       <Field2>Musterfrau</Field2>
    </YY1_HCI_ID_ID_ORIGINType>
  </YY1_HCI_ID_ID_ORIGIN>
  <YY1_HCI_ID_ID_ORIGIN>
    <YY1_HCI_ID_ID_ORIGINType>
       <SAP_UUID/>
       <ContactID>8</ContactID>
       <IDOrigin>EXTERNAL</IDOrigin>
       <Field1>John</Field1>
       <Field2>Doe</Field2>
    </YY1_HCI_ID_ID_ORIGINType>
  </YY1_HCI_ID_ID_ORIGIN>
</All>

Step 8: Map request chunk to OData Batch Processing

The last step of the whole integration flow maps a chunk of 1000 to batch processing of the CBO OData service. All entries are added to one changeset to allow a mass processing on SAP Hybris Marketing side. Putting each entry to an own changeset would be processed like single record processing.

The tag <All> is mapped to the tag <batchParts>. The target tag <batchChangeSet> gets an empty constant assigned to create the tag. The tag <YY1_HCI_ID_ID_ORIGIN> is mapped to the tag <batchChangeSetPart>. The target tags <method> and <uri> have a complex expression based if the entry needs to be created or updated. The target tag <headers> is not needed and therefore disabled. The target tags <YY1_HCI_ID_ID_ORIGIN> and <YY1_HCI_ID_ID_ORIGINType> get an empty constant. The target tag <SAP_UUID> has a complex expression. The fields ContactID, IDOrigin, Field1 and Field2 are mapped directly from source to target.

The target tag <method> can either be POST for a new entry or PUT for a changed entry. If the source tag <SAP_UUID> is empty (SAP_UUID equals string ”) then the constant POST is assigned to tag <method>. Else the constant PUT is assigned:

The target tag <uri> is only needed for changed entries. Therefore the complex expression is as follows: If the source tag <SAP_UUID> is empty (SAP_UUID equals string ”), revise the result (Not). Only if the revised result is true, create the tag <uri>. The creation of the tag <uri> is created by concatenation of constant value YY1_HCI_ID_ID_ORIGIN(guid’ with source SAP_UUID and next concatenation to constant value ‘):

The complex expression for the target tag <SAP_UUID> is similar to the target tag <uri>. Only if the source SAP_UUID is filled the target tag <SAP_UUID> is created:

The payload now looks as follows:

<?xml version="1.0" encoding="UTF-8"?>
<batchParts>
 <batchChangeSet>
  <batchChangeSetPart>
   <method>PUT</method>
   <uri>YY1_HCI_ID_ID_ORIGIN(guid'00163e0c-0f31-1ee7-8eae-19ed448a1944')</uri>
   <YY1_HCI_ID_ID_ORIGIN>
    <YY1_HCI_ID_ID_ORIGINType>
     <SAP_UUID>00163e0c-0f31-1ee7-8eae-19ed448a1944</SAP_UUID>
     <ContactID>6</ContactID>
     <IDOrigin>EXTERNAL</IDOrigin>
     <Field1>Max</Field1>
     <Field2>Mustermann</Field2>
    </YY1_HCI_ID_ID_ORIGINType>
   </YY1_HCI_ID_ID_ORIGIN>
  </batchChangeSetPart>
  <batchChangeSetPart>
   <method>PUT</method>
   <uri>YY1_HCI_ID_ID_ORIGIN(guid'00163e35-616b-1ed7-b5b9-662f3d264ba0')</uri>
   <YY1_HCI_ID_ID_ORIGIN>
    <YY1_HCI_ID_ID_ORIGINType>
     <SAP_UUID>00163e35-616b-1ed7-b5b9-662f3d264ba0</SAP_UUID>
     <ContactID>7</ContactID>
     <IDOrigin>EXTERNAL</IDOrigin>
     <Field1>Ellen</Field1>
     <Field2>Musterfrau</Field2>
    </YY1_HCI_ID_ID_ORIGINType>
   </YY1_HCI_ID_ID_ORIGIN>
  </batchChangeSetPart>
  <batchChangeSetPart>
   <method>POST</method>
   <YY1_HCI_ID_ID_ORIGIN>
    <YY1_HCI_ID_ID_ORIGINType>
     <ContactID>8</ContactID>
     <IDOrigin>EXTERNAL</IDOrigin>
     <Field1>John</Field1>
     <Field2>Doe</Field2>
    </YY1_HCI_ID_ID_ORIGINType>
   </YY1_HCI_ID_ID_ORIGIN>
  </batchChangeSetPart>
 </batchChangeSet>
</batchParts>

Batch requests to an OData service are always send as a POST request. Therefore the Receiver Channel needs to be setup like that:

The timeout is configured with 5 minutes as this is the normal runtime in SAP Hybris Marketing system.

 

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply