CRM and CX Blogs by Members
Find insights on SAP customer relationship management and customer experience products in blog posts from community members. Post your own perspective today!
cancel
Showing results for 
Search instead for 
Did you mean: 
I have recently had a stint working on OData and how it can be used in C4C Analytics. And in this blog post I’m going to describe the basic functionality of ODATA API’s which we can use with other SAP or third-party system so that they can extract the data from the C4C and utilize that data for processing further.

To start with, let me give you a brief description of the work that I did as part of one of my assignments on SAP C4C Implementation. As per the requirements we needed to provide multiple details, in all the information from the Account and Contact objects along with their Marketing Attribute details to a third-party Non-SAP System. Though C4C provides standard ODATA collection with all the information for Account/Contacts objects, it doesn’t provide a single collection where we could get all the information about the Account object or Contact Object in one shot. So, to get through this challenge we utilized the concept of retrieving analytics data using ODATA by building ODATA queries so that we could provide a single ODATA URL to the third-party system and it could then consume that API and extract the data information according to the need.

Out of the box, C4C provides the ODATA APIs for SAP Business Analytics where the external system can query and extract the required information from the C4C System. SAP Cloud for customer provides two API’s which we can we used to extract the analytical data from C4C to Third Party System or SAP System which are mentioned below: -

1. ODATA using Reports: This OData API for reports is adapted for remote access to pre-process the analytical data. Using OData for Reports you can query and retrieve characteristics and key figures exposed in Business by design analytical reports which include:

  • Standard data sources and reports

  • Data sources and reports created using SDK

  • Custom Reports created using Standard data sources by key-user

  • Extension fields added via adaptation mode or via SDK


As a result, the ODATA provides highly flexible analytical data to the third-party system to do query, read and analyze the data as per need from C4C system. This ODATA suited our integration scenario better.


2. OData for Data Sources:This ODATA API is designed to extract analytical raw data.
Third party system can extract the data without having restrictions or free of redundancies from the business by design reports.The analytical raw data is then processed,combined and formatted in the other system.


Now, let me throw some light on the functionality set up


Functionality Set up


 

Once we complete the above steps in SAP C4C, we need to generate the ODATA query by clicking on button “Build ODATA Query” while selecting the custom report which we have already created in the system.


Creation of ODATA Query


 

When we click on Build ODATA Query, system takes us to the screen where we can see the characteristics and key-figures which we are using in the custom report as a selection as well as in the filter selection.


As you can see in the screenshots, once we select the Filters and Attributes (Selection), C4C generates the ODATA Query which we can expose to SAP or third-party system enabling it to extract the information from C4C System. C4C generates ODATA URL by using selection and filters from the report which consists of 4 Components as shown below.


ODATA URL


Business by design ODATA Supports various query options which can be used to provide the limited information from the third-party system by using these queries:

1)$filter: -This option can be used in variety of scenarios where user can put values on the particular field by using values. E.g.The below parameter provides all the data from the report where the changed date is greater than 01st Jan 2020.

Request Parameter: - 


https://my123456.crm.ondemand.com/sap/c4c/odata/ana_businessanalytics_analytics.svc/RPE123ABCDEFGHIJ...;$filter=(CCHANGE_DT gt '2020/01/01')

We also have various filter options which we can use to extract the data from ODATA.


General Filters


2)$Selection: -The select option can be used to choose properties(key figures and characteristics) that shall be returned.If no select options are specified in the URL,then the system returns all key figures and characteristics of the entity definition (report definition).E.g.Below Request parameter provides the Account id in the response parameter based on filter “Changed Date”.

Request Parameter:

https://my123456.crm.ondemand.com/sap/c4c/odata/ana_businessanalytics_analytics.svc/RPE123ABCDEFGHIJ...?$select=CBP_UUID&$filter=(CCHANGE_DT gt '2020/01/01')

3)$top: -The $top option specifies that only the first n records will be returned. E.g.The Below request parameter provides the top 2 account ids according to the filter.

Request Parameter: https://my123456.crm.ondemand.com/sap/c4c/odata/ana_businessanalytics_analytics.svc/RPE123ABCDEFGHIJ... gt '2020/01/01') &$top=2&$format=atom

4)$Skip: - The $skip option specifies that the result shall not include the first n entities. E.g., The below request will provide all the accounts and skip top 2 accounts from the filter list.

Request Parameter:

https://my345039.crm.ondemand.com/sap/c4c/odata/ana_businessanalytics_analytics.svc/RPZ492D08DA50F6A... gt '2020/01/01')&$skip=2&$format=atom

Both query options together can be used to process a paging through the server side hit list.If no paging options are specified, ODATA returns the first 50 entries due as default page size = 50.

Once we have done our internal testing i.e. in C4C or in Postman, we can provide the ODATA URL to third party system so that they can extract the required information from C4C without having any issues.But the third-party system cannot execute the ODATA without having Access for it. To overcome this problem, we must follow the below steps:

  • Create an employee or service agent (for service agents additionally request a user).

  • Assign the work center and work center view which contains the analytical report to the access rights of the employee or User and provide the user credential so that they can access our ODATA URL from their system


SAP C4C Standard ODATA also offers standard HTTP Operations which are mentioned below:

1)GET: It is used to get the details by using single entity or multiple entity instances.Requests using GET should only retrieve data and should have no other effect on the data.

Example: -If you need to extract the information for the particular account id,put the filter and then execute the query.

Request Parament Example: -https://my123456.crm.ondemand.com/sap/c4c/odata/v1/c4codataapi/CorporateAccountAddressCollection?$filter=AccountID eq '123456'

2)POST: It is used to create the new entities. In this method, we have to use post method and pass the mandatory values so that c4c standard data sources will create new entities.

Example: - If we need to create the new entry then choose the fields and put the values in the attribute by using POST Method. Once you execute the query, the system will generate the new account ID.

Request Parameter: -

https://my123456.crm.ondemand.com/sap/c4c/odata/v1/c4codataapi/CorporateAccountAddressCollection

Put the Values in the Attributes: -

Account ID: - 1234567

Role Code: - CRM000

Lifecycle status Code: - 02

3)PATCH: It is used to override or replacing the existing instances.

Example: - First, we have to get the object id for the Account by using GET Method which was shown above. Once you get the object id, then pass the object id in the URL using PATCH Method. Pass the Value in the attribute which you need to update and once you execute, the system will update the data successfully.

Request Parameter: -https://my123456.crm.ondemand.com/sap/c4c/odata/v1/c4codataapi/CorporateAccountAddressCollection('Object ID')

4)DEEP INSERT: It is similar like POST Method. The only difference is that we can create Parent (CorporateAccountCollection) and (CorporateAccountSalesDataCollection) in one call instead of multiple POST calls for Parent and Child entities.

Example: -If we need to update full account information in one go, then we can use deep insert method for the particular object.

Request Parameter: -Pass the parameter and OData collection by using “DEEPINSERT” method.

Once we pass the below information then the account with their sales data has been created.

{

"Name" : "Test",

"CorporateAccountCollection":

[{

"RoleCode" : "CRMOOO"

"LifeCycelStatusCode" : "02"

]},

"CorporateAccountSalesDataCollection":

[{

"SalesOrganizationID" : "ABC",

"Division" : "09"

]}

}

5)DELETE: Used to delete an entity record

Example: -

You have to first get the Object ID of the specific entry which you want to delete and then you can pass the URL in the below format using DELETE function.

Request Parameter: -

https://my123456.crm.ondemand.com/sap/c4c/odata/v1/c4codataapi/CorporateAccountAddressCollection('Object ID')

Important Points to remember: -

  • We recommend that you select data explicitly for the needed fields. As per the Standard C4C limitation only up to 50 Characteristics and key figures can be selected, if the limit exceeds than 50 during execution of ODATA, system throws an error “TOO_MANY_DRILL_DOWN_OBJECTS”.

  • We cannot pass those parameters which are not present in the report selection or view, system will throw an error that this field is not present in the ODATA Collection

  • We have an option to pass OData parameter values (for example: $filter=AccountID eq ‘120102’). These overrule the existing parameter values in the initial selection. The remaining parameter values, if any, in initial selection, would still apply.

  • Personalized fields that have been added through the Add Fields option are supported as selection drill down, as well as filters. This includes master data attributes.

  • We cannot consume the ODATA API Without having credential in the system, C4C will throw an error “Logon user does not have authorization to access the report”.

  • Always create the mapping sheet which can be used by third party so that they can pass the values in the correct parameters otherwise system will not provide the correct data or will provide an error.

  • ODATA will provide 50 entries which is the default if the parameter $top is not specified in the URL. Use $top, $skip and $inlinecount=allpages to specify the number of entries to be returned and for paging


I will be glad if you find this helpful.In case if you have any questions,please feel free to post the questions!!!Hope you enjoyed reading this blog post!!!

Thanks for reading!!
17 Comments