Message Image  

Update and delete actions are available in the SAP OData application

 View Only
Thu July 23, 2020 10:20 AM

The latest release of IBM® App Connect supports update and delete actions for SAP (via OData).

Unlike the “update or create” action, the update action updates a record without the option to create one. This is helpful in cases where you need to update records without creating them. This action results in a “record not found” exception when it tries to update a record with an ID that doesn’t exist.

Connecting to your SAP OData service

Before you use App Connect with SAP (via OData), make sure that you can connect to the SAP OData service from App Connect. You can connect App Connect to your SAP OData account by providing a set of connection details on the Catalog page:


To connect to SAP(via OData), you need to create a private network because the OData server is behind a firewall. When you click Create a new network, you’ll see a set of instructions to create a private network. When you’ve followed the instructions, and you’ve connected to your SAP OData service, you can discover the supported objects and actions by clicking Show more.


Scenario

There are multiple use cases for integrating the SAP OData service with other applications and utilities in the App Connect catalog. In this article, we’re going to show how when a Salesforce contact is created, we retrieve travel agencies from SAP (via OData), then check whether a matching travel agency record exists. If it exists, we’ll update the record by using the new update action. If the record doesn’t exist, we’ll use a separate action to create a travel agency.

Note: We’re using a “TravelAgencies” object in this use case but objects might vary based on the SAP service that we connect to. The objects and operations supported are as defined in the OData service that we provide while creating the SAP OData account.

    • To begin, create an event-driven flow, connect to your Salesforce account, and add “New contact” as the event that triggers the flow.
    • Click the + icon, open the Toolbox, and select the Set variable node. Click Add property, add a property called “id”, and set the type to “Number”. Now click Edit mappings and map an ID value from Salesforce. In Salesforce, you can add custom user-defined fields to capture unique business data, which you can then use in your flow. In Salesforce, the “SAP_CustomerId” field has been added to Salesforce so that the customer can provide the value the ID to be updated in SAP. To learn more about creating custom fields in Salesforce, see Create Custom Fields in the Salesforce documentation.

    • This action sets the ID to the value of the “SAP_CustomerId” custom field in Salesforce so that it can be used later in the flow.

    • Click the + icon, scroll down to SAP (via OData), expand TravelAgencies, then add the Retrieve travel agencies action. This action uses the ID that the “Set variable” node extracted from the Salesforce record to retrieve the travel agency that has the same number as the ID.
    • Click the + icon, open the Toolbox, and select the If (conditional) node. The If node allows conditional processing, so that if the Retrieve TravelAgencies action finds a matching ID and responds with a 200 success message, the record exists, and the action on the “if” branch is triggered. Otherwise, the action on the else branch is triggered. Set the “If” node to “Status code” equals “200”.
    • On the “if” branch of the If node, click the + icon, scroll down to SAP (via OData), expand TravelAgencies, then select Update TravelAgencies. Configure the “where” filter so that the SAP OData Agency No. equals the ID that was extracted by the Set variable node.
    • Map the appropriate Salesforce fields that you want to use to update the travel agency record.
    • On the “else” branch of the If node, click the + icon, scroll down to SAP (via OData), expand TravelAgencies, then select Create TravelAgencies. Map the Agency No. field to the ID that was extracted by the Set variable node.
    • Finally, start the flow. You can test the flow by creating a contact in Salesforce and adding an SAP_CustomerId field for the record to be updated.


We’d love to hear from you. Why not share some of your use cases with us or send us any other comments?


#AppConnect
#update
#delete
#SAP-OData