Three Essential Services of OData Read Service in JSON 

Odata-service
Table of Contents

What is SAP Open Data Protocol (OData)?

Open Data Protocol (OData) serves as the default web gateway to access information from different sources. Generally, data is available in different formats, such as HTTP, AtomPub (Atom Publishing Protocol), XML, and JSON (Java Script Object Notation). OData helps developers to access data between frontend and backend or in any other integration scenario. With SAP OData adapter, OData client can have access to OData Service Provider, its data, and metadata. 

OData performs a wide range of operations, including read, create, update, delete, and function import.  

This blog attempts to provide a glance into SAP OData Read Service retrieving data, that’s available in JSON format, through: 

Prerequisite

Input should be below format in the URL. 

$filter=Input eq ‘<Database Table Name>, <Field1>,<Field2>,<Field2>,<Etc..>’ 

$filter=Input eq ‘<Database Table Name>,<Field1=Field value>,<Field2>,<Field2>,<Etc..>’ 

Example – $filter=Input eq ‘LFA1,LIFNR,NAME1,ORT01,REGIO’ 

     $filter=Input eq ‘LFA1,LIFNR,NAME1,ORT01,REGIO=22’ 

Process

Step1 :

Create an entity type with two fields one for input and another one for output. 

 

SAP Gateway data model key fields
Step 2:

Generate run time artifacts and redefine the GET_ENTITYSET method in the DPC_EXT class. 

generate-run-time
Step 3 :

Write the Below code in the Redefined GET_ENTITYSET method. 

SAP ABAP Input Mapping
ABAP dynamic filter and structure creation
SAP OData JSON Output
Step 4 :

After registering the OData service and loading the information, use the SAP Gateway client to run the OData service. 

run-Odata-Service
Different test cases :

After registering the OData service and loading the information, use the SAP Gateway client to run the OData service. 

Testing Database Tables using Different Filters
Results:

Input – 1:  KUNNR filter 

/sap/opu/odata/SAP/ZB5_KV_DATABASE_TABLE_SRV/Database_fieldsSet?$filter=Input eq ‘KNA1,KUNNR=0000000221,NAME1’ 

Testing Database Table KNA1 using KUNNR Filter

Input – 2: NAME1 filter 

/sap/opu/odata/SAP/ZB5_KV_DATABASE_TABLE_SRV/Database_fieldsSet?$filter=Input eq ‘KNA1,KUNNR,NAME1=NK Suppliers’ 

Testing Database Table KNA1 using NAME1 Filter

Input – 3: LIFNR filter/sap/opu/odata/SAP/ZB5_KV_DATABASE_TABLE_SRV/Database_fieldsSet?$filter=Input eq ‘LFA1,LIFNR=0000001000,NAME1,ORT01,REGIO‘ 

Testing Database Table LFA1 using LIFNR Filter

Input – 4 : Multiple filter 

/sap/opu/odata/SAP/ZB5_KV_DATABASE_TABLE_SRV/Database_fieldsSet?$filter=Input eq ‘LFA1,LIFNR=0000001000,NAME1,ORT01,REGIO=22′ 

Testing Database Table LFAI case using Multiple Filters

Input – 5 : REGIO  filter 

/sap/opu/odata/SAP/ZB5_KV_DATABASE_TABLE_SRV/Database_fieldsSet?$filter=Input eq ‘LFA1,LIFNR,NAME1,ORT01,REGIO=22’ 

 

Testing Database Table LFAI using REGIO Filter

Input – 6 :  No filter values. 

/sap/opu/odata/SAP/ZB5_KV_DATABASE_TABLE_SRV/Database_fieldsSet?$filter=Input eq ‘LFA1,LIFNR,NAME1,ORT01,REGIO’ 

Testing Database Tables without Filters

Input –7 : Wrong field 

/sap/opu/odata/SAP/ZB5_KV_DATABASE_TABLE_SRV/Database_fieldsSet?$filter=Input eq ‘KNA1,KUNN,NAME1′ 

Testing Database Table using Wrong Field

Convert JSON to XML format:

Copy the output from the OData service. With the help of a converter, we can convert JSON to any format. 

Covert JSON to XML format

Conclusion

Efficient SAP HANA performance optimization is integral for enhancing data processing. Beyond the opportunities for gaining effective performance benefits, multiple factors impact SAP performance. Addressing those factors and prioritizing performance optimization is essential for sustaining productivity. In addition, systematic performance optimization becomes important in preserving and enhancing the overall value of the business application. Proactively prioritizing optimization efforts helps organizations in securing both the current and future efficiency of their SAP systems.

Migrate to SAP S/4HANA

Our team of experienced SAP S/4HANA consultants are available round the clock to solve your existing business complexities.

Receive the latest news in your email

Leave a Reply

Your email address will not be published. Required fields are marked *

Get Your S/4HANA Audit For Free

SAP S/4HANA Migration Blog Popup