0% found this document useful (0 votes)
288 views32 pages

Odata

Download as docx, pdf, or txt
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 32

1. What is OData ?

Ans. OData is abbreviation form of “Open Database Protocol”. OData is open source
interface that can be consumed by any program, platform, application, software and device
of the Non-SAP world that can connect with SAP using the HTTP(s) protocol.

2.  How SAP OData works ?


SAP OData is a standard Web protocol used for querying and updating data present in
SAP using ABAP. In SAP, we use SEGW transaction code to create an OData Service.
OData is used to define best practices that are required to build and consume RESTful
APIs.

3. What is the advantages of OData ?


Ans. Every Consumer (SAP & Non-SAP) can understand contents of OData Service without
having knowledge of SAP. OData is implemented using JSON & XML. No dependencies
(Backend & Front end developers can work independently).

4. What is ODBC ?
Ans. ODBC stands for Open Database Connectivity. ODBC is a standard API to access the
Data Base. OData acts like middleware between producers and consumers to communicate
data. It’s a uniform way to consume data.

5. What is SAP NetWeaver Gateway ?


Ans. SAP NetWeaver Gateway is a part of SAP Application Layer. It is open source to
exchange data over the internet and it transfer data to/from SAP.

6. What is the benefit of OData?


Ans: OData is lightweight and is built on the HTTP protocol which allows database-like
access to data via the web

Decouples the data provisioning from the UI designer by providing a bridge between SAP
developers and UI designer(non-SAP developers) • It supports multichannel access to SAP
data as it is supported by multiple platforms • The standard address representation or
resource is the URI (Uniform Resource Identifier) and all players can easily access it.

• XML-based Atom Pub format and the JSON format is popular industry-wide used formats
which OData supports. This makes it easy to learn, understand, connect and consume.

• OData messages are self-describing and hence all non-SAP developers are able to understand
the content of the OData message without the need to have any knowledge of how SAP ERP
system works.
• There is no expense associated with the use of OData. It is open and anyone can use it with
no cost or license agreement.

• OData is extensible.

7. Why OData is used in SAP?

Ans - OData is used to define best practices that are required to build and consume RESTful
APIs. It helps you to find out changes, defining functions for reusable procedures and sending
batch requests etc. OData provides facility for extension to fulfill any custom needs of your
RESTful APIs.

8. Creating your first very simple OData SAP Gateway Service


Ans -Step 1 – SAP Netweaver Gateway Service Builder. …
Step 2 – Create project. …
Step 3 – Enter project details. …
Step 4 – Import DDIC structure. …
Step 5 – Enter structure details. …
Step 6 – View Properties. …
Step 7 – Create Entity Set. …
Step 8 – Alternate way to create Entity Set.

9. What is the T code for OData project?


Ans : Go to transaction code /IWFND/MAINT_SERVICE . Click on push button Add services .
Next screen will appear, give the alias name and execute , Search you for your project .

10. What are the two components of the OData runtime?


Ans : OData Runtime Runs instances of MPC (Model Provider Class) and DPC (Data Provider
Class) that provide meta data information, acquire data and perform requested operations on
the data.

11. What is service implementation in SAP OData?


Ans : In SAP terms, Odata a platform/framework that can be used to create SAP objects or
services that can be consumed from outside of SAP box to read or write data. A service can be
called an API that SAP provides to their consumers.

12. What are the methods in OData?


Ans - The OData service interface has a fixed number of operations that have uniform meaning
across all the resources it can act on. These operations are retrieve, create, update and
delete and they map to the GET, POST, PUT/MERGE and DELETE HTTP methods. Each of them
acts on a resource that is indicated using a URI.

13. Which OData version do you use?

Ans : OData Version 4.01

The OASIS OData Technical Committee has published the latest OData 4.01 draft as a
Committee Specification.

14. What is Entity type and Entityset? What is the difference betweenthem?

Ans :  Entity type is the category of a particular entity in the table of an RDBMS; in contrast,
entity set refers to the collection of all entities of the same entity type in RDBMS.

The main difference between Entity Type and Entity Set is that Entity Type refers to the
category an entity belongs to while Entity Set refers to all the entities of an entity type.

15. Explain complex type in ODATA?

Ans : Complex types define the structure of the messages and elements in the message
model. By combining elements, attributes, groups and wildcards, almost any message structure
can be modeled.

16. Mention difference between Entity type and Complex type?

Entity types
Entity types are named structured types with a key. They define the named properties and
relationships of an entity. Entity types may derive by single inheritance from other entity types.
The key of an entity type is formed from a subset of the primitive properties (e.g. CustomerId,
OrderId, LineId, etc.) of the entity type.

Complex types

Complex types are keyless named structured types consisting of a set of properties. These are
value types whose instances cannot be referenced outside of their containing entity. Complex
types are commonly used as property values in an entity or as parameters to operations.
17. What is Function import? When should we opt for function import?
Ans :Function Imports are the actions like the release of a sales order/purchase order
executed in the back-end system. They can be used whenever the given requirement does
not fit into the CRUD-Q operations.They are defined at the service level and you can have N
number of function imports functions.
a. Go to Gateway Service Builder SEGW and choose the project in which you want to create
Function Import.

b. Expand the project, right click on Data Model and choose Create and the Function


Import.

c. Specify the name of the function import and click on green tick mark button.

d. In the next screen you will find different options for the Function Imports lets have a look
at each of them.

Return Type Kind:

If you want the function import to return data you can set this field. We have 3 possible options
available

 Complex Type – if the return data is of complex entity type, select this option

 Entity Type – if the return data is of entity type, select this option and

 No return – if you do not want to return anything, select this option.

Return Type:

This field depends on the option you have choose above. You need to specify the name of the
type in this field. Use the input help to choose from existing types or create a new type.

 If you choose Complex Type in the above step, specify the name of the complex
entity type in this field.

 If you choose Entity Type option in the above step, specify the name of entity type.
 If you choose No return, this field will be empty.

Why should we opt this :This is actually a reasonable reason if your module only requires the
user to have a certain module installed if they use specific functions of yours... If that's not he
reason you're doing this, it's almost certainly a yucky idea. It imports once when the function is
called for the first time.

18. What is Association, Association set, Navigation ?

Ans - An association is defined between entity types, Designer creates and displays the OData
navigation elements under the corresponding entity types.

An association set is a logical container for association instances of the same type. An
association set is not a data modeling construct; that is, it does not describe the structure of
data or relationships.

Navigation properties in OData are the reference attributes of an entity that points to another
entity. By default, navigation properties are not available on an entity representation when it is
accessed by an OData client.
19. How do I create an OData navigation in SAP?
Ans - Association and Navigation in OData Service

a. Go to Service Builder SEGW and expand the service to create an association.


b. Provide the following information and click on Next.
c. In the next screen, provide the common field among two entity sets and click on Next.
d. Check the entries and Click on Finish.

20. How do you implement $expand in OData?


Ans : Get Expanded Entity Set /Get Expanded Entity Sap OData
a. Header Table:
b. Item Table:
c. Create a project in SEGW and import these 2 structures into the project.
d. Create an association and navigation for Header and Item.
e. Entries in Header Table Entries in Item Table.

21. What is cardinality in OData?


Ans :Principal Entity – To which you want to build the association. Dependent Entity –
From which you want to get the data based on association. Cardinality – What the
occurrence of no records. Navigation Property – Name of the navigation property for
the Entity Type.
22. How to create OData Association and navigation in sapcodes?
Ans : Principal Entity- Scarr and the target/dependent entity- Spfli. And also provide the
Navigation Property Name.
The below screen appears, now we have to maintain the match up fields.
For dependent entity, from F4 provide dependent property as Carrid.
Create association set, than links the entity sets.
Choose Finish.

23. How is the navigation property under complex type-OData?


Ans : If the navigation source or part of binding path is in the path, we need it passed to the
constructor of OData Query Option Parser. So there are 2 overloaded constructor added to
accept OData Path as parameter. Note: Parameter IService Provider is related to Dependency
Injection.

24. Which is an example of Association and navigation in SAP?

Ans : Association and Navigation are two important properties available in SAP OData Service
to associate two entity types. Let us understand this with an example, in our earlier tutorials we
retrieved sales order header data and item data in two different entity types “ SalesOrderSet ”
and “ OrderItemsSet”.

25. How to get expanded entity in SAP OData?

Ans : URI : /sap/opu/odata/sap/ZDEEPSTRUCTURES_SRV/HeaderSet (‘100’)?


$expand=HeaderToItemNav Conclusion: The same can also be achieved from just redefining
Get entity of Header Set and Get entity set of Item Set.

Principal Entity- Scarr and the target/dependent entity- Spfli. And also provide the Navigation
Property Name. The below screen appears, now we have to maintain the match up fields. For
dependent entity, from F4 provide dependent property as Carrid. Create association set, than
links the entity sets. Choose Finish.

If the navigation source or part of binding path is in the path, we need it passed to the
constructor of ODataQueryOptionParser. So there are 2 overloaded constructor added to
accept ODataPath as parameter. Note: Parameter IServiceProvider is related to Dependency
Injection.

Association and Navigation are two important properties available in SAP OData Service to
associate two entity types. Let us understand this with an example, in our earlier tutorials we
retrieved sales order header data and item data in two different entity types “ SalesOrderSet ”
and “ OrderItemsSet”.

26. How to view OData service metadata in SAP?


Ans: To view the metadata for any OData service, append $metadata at the end of the URL in
your browser.
http://YourSystemURL:Portnumber/sap/opu/odata/IWBEP/GWDEMO/$metadata. To see the
data that is served by the OData service, just enter the collection you’d like to see:
http://YourSystemURL:Portnumber/sap/opu/odata/IWBEP/GWDEMO/SalesOrderCollection?

27. What is referential constraint?


Ans : Referential Constraint Actions are the actions that the database takes in the event
that an attempt is made to delete or update a primary key currently being referenced by a
foreign key in another table.
28.  Is it mandatory to create referential constraints?

Ans : Referential constraints are optional and can be defined in CREATE TABLE statements and
ALTER TABLE statements. Referential constraints are enforced by the database manager during
the execution of INSERT, UPDATE, and DELETE statements. The enforcement is effectively
performed at the completion of the statement except for delete and update rules of RESTRICT
which are enforced as rows are processed.

Referential constraints with a delete or update rule of RESTRICT are always enforced before
any other referential constraints. Other referential constraints are enforced in an order
independent manner. That is, the order does not affect the result of the operation. Within an
SQL statement:

 A row can be marked for deletion by any number of referential constraints with a delete
rule of CASCADE.

 A row can only be updated by one referential constraint with a delete rule of SET NULL
or SET DEFAULT.

 A row that was updated by a referential constraint cannot also be marked for deletion
by another referential constraint with a delete rule of CASCADE.

29. What is Function Import?

Ans : Function Imports are the actions like the release of a sales order/purchase order executed
in the back-end system. They can be used whenever the given requirement does not fit into the
CRUD-Q operations.
They are defined at the service level and you can have N number of function imports functions.
a. Go to Gateway Service Builder SEGW and choose the project in which you want to create
Function Import.
b.Expand the project, right click on Data Model and choose Create and the Function Import.

c. Specify the name of the function import and click on green tick mark button.

d.In the next screen you will find different options for the Function Imports lets have a look at
each of them.

30. Why do I get CX_SADL_contract_violation when executing an OData request?


Ans : When executing an OData request with $expand or using a navigation property, you
receive the error CX_SADL_CONTRACT_VIOLATION. The behavior of the service differs
depending on which entities are used.If an entity is not mapped using SADL (RDS or
MDS), the navigation needs to be implemented by the application developer.
31. Which data source should I use when creating an OData service?
Ans : It is recommended that only referenced data source (RDS) is used when creating
an OData service with transaction SEGW. With RDS, the SADL framework automatically
implements the methods that are necessary for retrieving modifying data with OData in
the data provider class (DPC).
32. Why is there no default mapping in itemdata?
Ans : There is again no default mapping because the data model has been built based on a
different RFC module. Expand the ITEMDATA node from the tree on the right-hand side.
33. What are the runtime artifacts created when I export?
Ans : When you export the Runtime Artifacts you will find that ZIP archives are created. The
filename generally consists of the MAG name, but whitespace and special characters are
replaced by underscores (_). As can be seen in the screenshot above, for the Process
Integration artifacts, an ‘_PO’ suffix is added to the ZIP file name.
34. What are MPC, MPC Extension class & DPC, DPC Extension class?
Ans : Model Provider Class
Model Provider class registers the metadata used in a service, it is nothing but base class and
model provider extension class is nothing but derived class.
Model provider Extension class 
Model provider Extension class is derived class of Module Provider Class
Data Provider Class
Data provider class provides the methods to Data provider Extension class, so developer can
implement the functionalities for database interaction.
. Data provider Extension class 
A data provider extension is used to enrich attributes within the business model. An extension
is a data provider class that defines how the attribute is enriched. Before you create a data
provider extension, you must create an extension project to store and package the extension,
and define the data providers in the business model.

MPC is a Parent class and MPC_EXT->child class


MPC is used to define model you can use the method Define create entity and properties.

Model Provider class registers the metadata used in a service. Data provider class provides the
methods to Data provider Extension class, so developer can implement the functionalities for
database interaction.

35. What is the difference between model provider and data provider class?
Ans : Model Provider class registers the metadata used in a service, it is nothing but
base class and model provider extension class is nothing but derived class. Data provider
class provides the methods to Data provider Extension class, so developer can implement the
functionalities for database interaction.
36. What is Metadata? How to download Metadata?
Ans : The metadata document is a static resource that describes the data model and type
system understood by that particular OData service. You can use the metadata document to
learn how to query and navigate between the entities in the system.

Open MS Excel and create a blank workbook.


==> Click on the Data tab at the top and select From Other Sources->From OData Data Feed

==> Specify the link to the OData service in the next pop-up. In this case I am using the
publically availaible Northwind OData Service. You can also take up your own OData service by
providing necessary authentication details in the same popup. Then click Next

==> The wizard will fetch all the Entity Sets contained in the OData service. Select the one
which you want to download to Excel. I selected PersonDetails here.
==> Click Finish and you will be asked for how you want the data to be displayed in Excel.

==> Select table and click OK. Wait for some time while your data is downloaded.
The data from the OData service is now availaible in Excel 🙂

This functionality also works fine for HANA Exposed OData services (xsodata).

37. What is the format of HTTP response?


Ans : In case there is an error in carrying out the client's request, the server responds with an
error message. Moreover, the HTTP responses come as plain text formatted in either JSON or
XML format, just like the HTTP requests.
38. What is the structure of an HTTP Response?
Ans : Every HTTP Response received as a result of an HTTP request sent by the client to the
server has a status code. This status code value tells us if HTTP Response was successful or not. 
This article is a continuation of our previous article in which we performed a sample REST API
test call. In this article, we will discuss how to validate the HTTP response status using REST
Assured. The content of the post is reflected by the following index:

 Validate HTTP Response Status using Rest Assured


o How to validate HTTP response status code
o Validating the HTTP error status code?
o How to validate HTTP Response Status Line?

An HTTP response object typically represents the HTTP packet (response packet) sent back by
Web Service Server in response to a client request. An HTTP Response contains:

1. A status.
2. Collection of Headers.
3. A Body.

 the validation of an HTTP response status will be dealt with in three parts as follows:

 Validating HTTP Response Status Code.


 How to validate the Error Status Code

39. Can we query or retrieve metadata in JSON format?


Ans :The $metadata document is in the CSDL format, which currently only has an XML
representation. (As a side note, if you do want to request the json format for a different kind of
OData payload, make sure the format query token has a $ in front of it: $format=json .) So, no
it is not possible.

40. What kind of data is in JSON?


Ans : It consists of lightweight data for data exchange. If you are familiar with Amazon Web
Service, DynamoDB, MongoDB, Couchbase databases, you should be familiar with
the JSON documents. These NoSQL databases primarily uses JSON structured data.
41. What is with Mapping for BAPI & RFC in OData?
https://blogs.sap.com/2012/10/26/step-by-step-guide-to-build-an-odata-service-based-on-
rfcs-part-1/
https://blogs.sap.com/2012/10/26/step-by-step-guide-to-build-an-odata-service-based-on-
rfcs-part-2/
https://saplearners.com/build-odata-service-using-rfc-bapi-in-sap-netweaver-gateway/
42. What are CRUD methods?

Ans : The Open Data Protocol (OData) includes standard CRUD (Create, Retrieve, Update, and
Delete) operations that map to the HTTP methods POST, GET, PUT/MERGE, and DELETE.

43. What are the methods in OData?

Ans : The OData service interface has a fixed number of operations that have uniform meaning
across all the resources it can act on. These operations are retrieve, create, update and
delete and they map to the GET, POST, PUT/MERGE and DELETE HTTP methods. Each of them
acts on a resource that is indicated using a URI.

44. Which method used to trigger a request to the function import OData service?

Ans :Choose the HTTP method type to invoke the Function Import

45. What is $expand in OData?

Ans : OData query option $expand is used to read multiple entities or entity sets in a single
service call instead of two different calls. Prerequisite, entity sets which are used should be
associated. To know about Association in OData service click here.

46. Is OData synchronous or asynchronous?

Ans : OData requires asynchronous data retrieval: Synchronous data access requires that data
has already been loaded from the server. This means there is no way of knowing whether this
already happened, meaning the result of a synchronous access method is quite often
unpredictable.
47. What is REST API in OData?

Ans : REST stands for REpresentational State Transfer which is a resource based architectural
style. Resource based means that data and functionalities are considered as resources. OData is
a web based protocol that defines a set of best practices for building and consuming RESTful
web services.

48. What is a data model in OData?

Ans : An OData Metadata Document is a representation of a service's data model exposed for
client consumption. The central concepts in the EDM are entities, relationships, entity sets,
actions, and functions.

49. Which method of OData is used for read single record?

Ans : There are 5 methods associated with each entity set. As a whole, there are 5
operations(CRUD-Q) in OData that are as shown below and mapped to HTTP methods. But for
now, we will check the GET Operation which is also known as single read operation. Read
operation is used for Reading a single record.

50. How do I open SAP gateway client?

Ans : Go to Tcode '/IWFND/ERROR_LOG' to see all the errors that occurred in your Gateway
system. Click on a particular error. In the below pane you see a button called Replay, and select
'Gateway Client' there.

51. Why function import is used in OData?

Whenever the given requirement does not fit into the crud operations, that time we will go for
Function import in OData. function imports are used to do the GET and POST operations for the
requirements , which are not possible by the standard operations available in OData

52. Mention different status codes you have came across in OData?
53. What are the status codes for Create, Update, Delete and Getoperations?
Ans : For a PUT request: HTTP 200 or HTTP 204 should imply "resource updated successfully". 
For a DELETE request: HTTP 200 or HTTP 204 should imply "resource deleted successfully".

CREATE
The create action is usually implemented via HTTPs POST method. In RESTful APIs, these
endpoints are used to create new resources or access tokens.
Status Codes
200 OK - It’s the basic status code to tell the client everything went good. Since we don’t create
endpoint accessible resource when creating an access token, we can use 200 as a status for
that action.
201 Created - The most fitting for Create operations. This code should signal backend-side
resource creation and come along with a Location header that defines the most specific URL for
that newly created resource. It’s also a good idea to include appropriate representation of the
resource or at least one or more URLs to that resource in the response body.
202 Accepted - Often used for asynchronous processing. This code tells the client that the
request was valid, but its processing will finish sometime in the future. The response body
should include an URL to the finished resource with some information about when it will be
available, or an URL to some monitoring endpoint that tells the client when the resource is
available.
303 See Other - Like the 202 code but using a Location header field in response to informing
the client about the location of the created resource or an endpoint that lets the client check
for the status of the creation process. Some clients follow the status codes of the Redirect-class
automatically. This code is usually only used for POST requests.
READ
The read action gets implemented via HTTPs GET method and used to fetch resource
representations. Asynchronous responses aren’t much of a thing here, because the reason for
asynchronous processing is often that the resource doesn’t exist yet and has to be created, so
it’s a create action anyway.
Status Codes
200 OK - Most of the read actions will be answered with a 200 OK status.
206 Partial Content - This code is useful for lists of content that are too big to be delivered in
one response. It has to be used with a Range header field in the request. Usually, this header
field defines the byte-range the backend should send to the client, but the unit can be freely
assigned as long as both sides understand it.
300 Multiple Choices - This redirect is used if there are multiple representations for one
resource and the client (or its user) has to choose one of them.
308 Permanent Redirect - This tells the client to use another URL to access the resource and
not use the current URL anymore. It’s helpful when we have multiple endpoints for one
resource, but don’t want to implement reading from all of them.
304 Not Modified - Is used like 200 but without a body, so the client will be redirected to its
locally cached representation from a previous read.
307 Temporary Redirect - When the URL to a resource could change in the future, and the
client should always ask the current URL before accessing the real one.
UPDATE
An update can be implemented with an HTTP PUT or PATCH method. The difference lies in the
amount of data the client has to send to the backend.
PUT requires the client to send an entire representation of a resource to update it. (Replace the
old one with the new one)
PATCH requires the client only send parts of the representation of the resource to update it.
(Add, update or delete these parts in the old version)
Status Codes
200 OK - This is the most appropriate code for most use-cases.
204 No Content - A proper code for updates that don’t return data to the client, for example
when just saving a currently edited document.
202 Accepted - If the update is done asynchronous, this code can be used. It should include an
URL to access the updated resource or an URL to check if the update has been succeeded. It
can also include an estimation of how long the update will take.
DELETE
The delete action can be implemented with the HTTP DELETE method.
Status Codes
200 OK - Some people think a delete function of any kind should return the deleted element, so
a representation of the deleted element can be included in the response body.
204 No Content - The most fitting status code for this case. It’s better to reduce traffic and
simply tell the client the deletion is complete and return no response body (as the resource has
been deleted).
202 Accepted - If the deletion is asynchronous and takes some time, which is the case in
distributed systems, it can be appropriate to return this code with some information or URL to
tell the client when it will be deleted.
API Changes
If our API lives long enough, sooner or later it will change its structure. It’s best practice to
avoid breaking changes and the redirection class of status codes can help with this because
some clients follow their Location header automatically.
Status Codes
307 Temporary Redirect - This is the right code if the resource could be available on a different
URL in the future, but we want the current endpoint to control where the client is redirected
to. This status code will let the client come back to the current URL for every request.
308 Permanent Redirect - This is the right code if the resource will now be available at a new
URL and the client should directly access it via the new URL in the future. The current endpoint
can’t control the clients’ behavior after the request and a subsequent redirect if the resource
URL changes again have to be issued from the new URL.
Multiple Endpoints for One Resource
If we opt-in to use nested or sub-resources in our API it can help to only deliver representations
from root (non-nested) resources to keep the implementation DRY. Redirect status codes help
with this.
Status Codes
308 Permanent Redirect - If we have nested
resources /user/kay/comments/456 and /posts/123/comments/456; and a root
resource /comments/456 it can make things easier to simply issue 308 redirects at the nested
resources with the Location header field pointed to the root resource so not every endpoint
needs a delivery implementation. This should only be done for GET requests.
Errors
The next important part of an API is its errors. Many API frameworks use 500 and 404 status
codes by default when something went wrong, but depending on the situation, often there are
more descriptive ones.
500 means Internal Server Error, which can be anything from a missing header field the
backend accessed without checking its existence to an unreachable third party service the
backend wanted to call.
So it can be that the client did something wrong and we would expect a 400-499 status code,
but the backend never tried to validate the request and tried to process it even if it was invalid
and we end up with a server error.
404 means Not Found. This can be because of a wrong URL used by the client to some endpoint
not being set up right on the backend.
As we see the 404 is a client error status code, but it could very well be that we did something
wrong on the backend.
Wrong URL
When a client sends a URL, we don’t know. This can have multiple different reasons, so we have
to check which of them applies here.

Status Codes

 404 Not Found - This is the most natural of responses and should be used in the case
that the client URL was wrong.
 405 Method Not Allowed - In many frameworks we define the URL alongside the HTTP
method, so removing one of these definitions could leave all but one methods to one
URL intact. The response has to include an Allow header field that lists what is allowed
to do.
 501 Not Implemented - Like 405, but the method is missing for all resources on the
backend.
 406 Not Acceptable - The URL exists, but the backend can’t send a representation the
client will accept. So for that specific client, the URL behaves like a 404, but they now
know that they need to update the client.
 410 Gone - This is like 404 but we know that the resource existed in the past, but it got
deleted or somehow moved, and we don’t know where.
 414 Request-URI Too Long - This is sometimes the case when the endpoint is right, and
the resource exists, but the query makes the URL too long to be interpreted.
 308 Permanent Redirect - This would be the right code if we know that a resource has
moved to a different URL and we can tell the client about it.
 307 Temporary Redirect - Same as 308, but we don’t know if the resource will be back
on the original URL or another different URL in the future.
No Permissions
Often clients can’t access every resource on the backend, so we need a way to tell them about
it.

Status Codes
 401 Unauthorized - The client hasn’t authorized itself to the backend yet and the server
may give it access after that has happened.
 403 Forbidden - The client has authorized or doesn’t need to authorize itself, but still has
no permissions to access the resource.
 404 Not Found - If 401 or 403 is the case, but the backend doesn’t want to tell the client
that the resource exists for security reasons.

54. Does OData work with SCP API management?


Ans :When calling the OData service directly, everything worked as expected. I then set
the OData service up as an API in SCP API Management. When calling the API with the HTTP
verb GET, everything worked as expected.
55. How to get Po data from OData service?
Ans :Now, Write a code to call your odata service to get data for PO . Code is ready in Function
Module to get the details for Purchase order based on object id received on event trigger. We
will map this Function Module in Event configurations now. Save the data .
Step :3 to trigger odata service call.

56. Does OData support HTTP verbs GET and put?


Ans : I had created an OData service that supported the HTTP verbs GET and PUT.
When calling the OData service directly, everything worked as expected. I then set the OData
service up as an API in SCP API Management. When calling the API with the HTTP verb GET,
everything worked as expected.
57. What do the HTTP status codes mean?
Ans : This class of status codes indicates the action requested by the client was received,
understood, accepted and processed successfully. Standard response for successful HTTP
requests. The actual response will depend on the request method used. In a GET request, the
response will contain an entity corresponding to the requested resource.
58. What are the parent classes of OData services?
Ans : For example, the parent classes for DP (Data Provider) classes and MP (Model Provider)
classes of OData services. With transaction code SE43 it is possible to create folders for the
Easy Access Menu in the SAP GUI that pops up after logging in.
59. What does this class of status codes indicate?
Ans : This class of status codes indicates the action requested by the client was received,
understood, accepted and processed successfully. Standard response for successful HTTP
requests. The actual response will depend on the request method used.
60. List some query options in OData?
Ans : A query option is a set of query string parameters applied to a resource that can help
control the amount of data being returned for the resource in the URL. A query option is
basically requesting that a service perform a set of transformations such as filtering, sorting,
etc. to its data before returning the results. A query option can be applied to every verb
except DELETE operations.

The query options part of an OData URL specifies three types of information: System query
options, Custom query options, and Parameter aliases.

System query options


System query options are query string parameters that control the amount and order of the
data returned for the resource identified by the URL. The names of all system query options are
optionally prefixed with a dollar ($) character. OData Protocol V4.01 based services support
case-insensitive system query option names specified with or without the $ prefix. Clients that
want to work with 4.0 services must use lower case names and specify the $ prefix.
System query options are $filter, $select, $orderby, $count, $top, $skip and $expand.

Expand
The $expand system query option specifies the related resources or media streams to be
included in line with retrieved resources. Each expandItem is evaluated relative to the entity
containing the navigation or stream property being expanded.
Select
The $select system query option allows clients to request a specific set of properties for each
entity or complex type.
The $select query option is often used in conjunction with the $expand system query option, to
define the extent of the resource graph to return ($expand) and then specify a subset of
properties for each resource in the graph ($select).
OrderBy
The $orderby system query option allows clients to request resources in a particular order.

Top and Skip

The $top system query option requests the number of items in the queried collection to be
included in the result. The $skip query option requests the number of items in the queried
collection that are to be skipped and not included in the result. A client can request a particular
page of items by combining $top and $skip.

Count
The $count system query option allows clients to request a count of the matching resources
included with the resources in the response. The $count query option has a Boolean value of
true or false.

Search
The $search system query option allows clients to request items within a collection matching a
free-text search expression.
The $search query option can be applied to a URL representing a collection of entity, complex,
or primitive typed instances, to return all matching items within the collection. Applying the
$search query option to the $all resource requests all matching entities in the service.
If both $search and $filter are applied to the same request, the results include only those items
that match both criteria.
Custom query options
Custom query options provide an extensible mechanism for service-specific information to be
placed in a URL query string. Custom query options MUST NOT begin with a $ or @ character.

Parameter aliases

Parameter aliases can be used in place of literal values in entity keys, function parameters, or
within a $filter or $orderby expression. Parameter aliases MUST start with an @ character.

Conventions
A request to a resource using Http verbs GET, PATCH or PUT follow these conventions:
 Resource paths identifying a single entity, a complex type instance, a collection of
entities, or a collection of complex type instances allow $compute, $expand and
$select.
 Resource paths identifying a collection allow $filter, $search, $count, $orderby,
$skip, and $top.
 Resource paths ending in /$count allow $filter and $search.
 Resource paths not ending in /$count or /$batch allow $format.
 Query options for a POST operations may differ due to the type of object being
returned in the response. If a POST returns a single entity vs collection of entities,
it will impact the query options that are applicable to the request.

61. What are actions in OData?


Ans : Actions will provide a way to inject behaviors into an otherwise data centric model
without confusing the data aspects of the model, while still staying true to the resource
oriented underpinnings of OData." When a client GETs a resource over HTTP it learns about the
content type (perhaps HTML) via a header in the response.

62. How do I use OData actions in EDM?


Ans : To use your new OData action, you must first register it in your EDM model builder, just
like you did with the OData functions. If you are using endpoint routing and the GetEdmModel
() method from the previous tutorial, bind your action to the Project entity type and
register the Title parameter.
63. How to catch dbupdateconcurrencyexception with OData action?
Ans : Of course, you would want to enclose the SaveChangesAsync () command in a try-catch
block in order to catch any DbUpdateConcurrencyException exceptions. To use your new OData
action, you must first register it in your EDM model builder, just like you did with the
OData functions.
64. How do I implement additional service operations in OData?
Ans : In addition, OData supports further service operations (function imports) that can be
invoked by the HTTP methods GET or POST for anything that cannot be mapped
to the standard CRUD operations. You can implement such additional service operations in
the Service Builder by creating function imports within your data model.

65. How do I DEBUG OData service?


If you want to debug OData Lib, WebAPI, Restier source, open DEBUG -> Options and Settings
in VS, configure below things in General tab: Uncheck Enable Just My Code (Managed
only) . Uncheck Enable . NET Framework source stepping

66. How can I tell if Odata is activated?


Log on to your front-end server (your SAP Gateway system). and execute the Customizing
activity. As a quick shortcut to the same screen, use transaction /n/IWFND/MAINT_SERVICE.
The Service Catalog shows you all the services that are currently active in your SAP Gateway.
67. How do I find OData URL?
If you have an on-premise system, then call /N/IWFND/MAINT_SERVICE, choose your service,
click on Gateway Client, set the protocol to HTTPS and you'll see the full URL.
68. How is OData different from rest?
REST stands for REpresentational State Transfer which is a resource based architectural style.
Resource based means that data and functionalities are considered as resources. OData is a
web based protocol that defines a set of best practices for building and consuming RESTful web
services.

69. What can you do to activate multiple OData services?


In the Select System Alias for Activation task, enter the system alias. In the Select OData
Services for Activation task, make sure that all services are selected that you want to activate.
You can exclude some services that you do not want to activate. Choose Generate Task List Run
.
70. How do I transport OData service in SAP?
Another option is to add this manually to the transport. The System Aliases are stored in
table /IWFND/C_MGDEAM and can be added manually to the transport. After transport the
System Aliases is set in target system
71. What is OData filter?
The $filter system query option allows clients to filter the set of resources that are addressed
by a request URL. $filter specifies conditions that MUST be met by a resource for it to be
returned in the set of matching resources. The semantics of $filter are covered in the
OData:Core document.
72. What is Uri in OData?
The Open Data Protocol (OData) enables the creation of HTTP-based data services, which allow
resources identified using Uniform Resource Identifiers (URIs) and defined in an abstract data
model, to be published and edited by Web clients using simple HTTP messages.
73. How will you implement a deep entity in OData?
Go to Runtime Artifacts node, open the ZCL_ZGW_PRACTICE006_MPC_EXT class in ABAP
Workbench(Right-Click: Go to ABAP Workbench) & click on the Types tab. Click on the
Change(Ctrl+F1) button for editing. Click on the Direct Type Entry button. Then, create the deep
structure & activate.
74. Is OData a webservice?
The Open Data Protocol (OData) is a web protocol that is designed for querying tabular data
and provides you with an alternative to SOAP-based web services.

75. What is the architecture of SAP OData?

An OData server consists of OData Producers and an HTTP server. In SQL Anywhere, an OData
Producer is a Java Servlet that uses the JDBC API to connect to a database server. An OData
Producer processes OData requests and interfaces with the database.

76. How do I add OData services?


Go to transaction code /IWFND/MAINT_SERVICE . Click on push button Add services . Next
screen will appear, give the alias name and execute , Search you for your project . Now click
back and go to main screen of transaction /IWFND/MAINT_SERVICE and find your service.

How do I take OData service in Fiori?


var oModel = new sap. ui. model. odata.
...
Create an SAPUI5 project.
Start the New Application Project wizard. In the SAP HANA studio's Project Explorer view,
choose New Other...
Select the application project. ...
Define details of the new project. ...
Define details of the new SAPUI5 application view and choose Finish.
Where can I find TR for OData service in SAP?
Go to SE80 open your program and go to Utilities. Select Versions and then go to version
management. Double click this number. This is your Transport request.

77. Where is OData service for Fiori app?


In the Fiori Apps Library, find the Fiori app you are interested in. Just select the apps > select
List View > use the Settings icon button to change the selection to include OData Services.
78. How do I activate my Fiori service?
Procedure
Run transaction Maintain Services (SICF) on the front-end server.
In the menu under Service/host Activate , activate the services under the Yes with the
hierarchy icon to activate all child nodes under a service.

79. Is OData synchronous or asynchronous?


OData requires asynchronous data retrieval: Synchronous data access requires that data has
already been loaded from the server. This means there is no way of knowing whether this
already happened, meaning the result of a synchronous access method is quite often
unpredictable.

80. What is OData type?


The odata. type annotation specifies the type of a JSON object or name/value pair. Its value is a
URI that identifies the type of the property or object. For built-in primitive types the value is
the unqualified name of the primitive type, specified as a URI fragment.

81. What is REST API in SAP OData?


An application programming interface (API) allows you to access data, for example, monitoring
data. The OData API is implemented as a REST API and the technical protocol is Open Data
Protocol (OData). This means that you can use standard HTTP methods (for example, the GET
method) to call the API.
82. How do I pass multiple filters in SAP OData?
On the filter button trigger, grab all the input via the "getControlsByFieldGroupId" method and
construct the filters using the custom data form each input via the "data" function call
83. What is $expand in OData?
OData query option $expand is used to read multiple entities or entity sets in a single service
call instead of two different calls. Prerequisite, entity sets which are used should be associated.
To know about Association in OData service click here
84. What is OData namespace?
OData Data Namespace: The namespace used by OData services when representing data in
XML-based formats. The URI identifying the namespace is
http://schemas.microsoft.com/ado/2007/08/dataservices .
85. What is OData Service document?
The service documents provide information about the types of data available via the REST
service and about the URLs under which the data can be accessed. The service documents are
available under the following URLs: ~/rest - exposes the service document.

86. How do I update OData entity?


Use the Update Entity action to update an entity in the specified entity set in your SAP system.
Complete the following steps to use the Update Entity action in your workflow: 1. Drag the
Update Entity action under SAP OData to the canvas, place the pointer on the action, and then
click or double-click the action.

87. What is EDM in OData?


OData has a built in type system to fully describe all the entities in the metadata. This is called
the Entity Data Model (or EDM) and from this it is possible for the caller to infer information
about the type from the metadata to ensure that some client side validation such as range
checking can be done.
Which of the below method triggers put request to the OData service?
The update function triggers a PUT request to an OData service which was specified during
creation of the OData model.
88. Which method is OData used to read multiple record?
OData($expand query):

The $expand query option is very powerful and allows us to provide multiple entities and/or
entity sets in one single service call, instead of performing several calls subsequently.

89. How do you create PDF or media files using OData?


Goto SEGW, Create OData project, import your table (ZFILE) from DDIC structure to create
ENTITY_TYPE. Select the entity type “ZFILE” you just created and Choose the check box media
as selected. Now generate Runtime Artifacts and Redefine the DEFINE method of the model
provider extension call
90. What is referential constraint in SAP OData?
A referential constraint in OData consists of one principal property (the ID property of the
entity being referenced) and one dependent property (the ID property to reference another
entity). This section shows how to define referential constraints on a partner navigation
property.
91. Is OData SOAP or REST?

ODATA is derivative of REST or built on top of it. - It is approved from International


Organization for Standardization (ISO) & International Electrotechnical Commission (IEC) for
release
92. What are annotations in OData?
Annotations are a powerful way of extending OData services. By annotating a service you add
information that tells clients how to interpret the service and its data.

93. What is the advantages of OData ?


Ans. Every Consumer (SAP & Non-SAP) can understand contents of OData Service without
having knowledge of SAP. OData is implemented using JSON & XML. No dependencies
(Backend & Front end developers can work independently).
94. What is ODBC ?
Ans. ODBC stands for Open Database Connectivity. ODBC is a standard API to access the Data
Base. OData acts like middleware between producers and consumers to communicate data. It’s
a uniform way to consume data.
95. What is SAP NetWeaver Gateway ?
Ans. SAP NetWeaver Gateway is a part of SAP Application Layer. It is open source to exchange
data over the internet and it transfer data to/from SAP.
96. What is Consumers & Producers in OData ?
Ans. Clients that consume the service called as “Consumers” of OData Service. Servers that
expose the OData services known as “Producers” of OData services. Consumer
send HTTP(s) request and SAP would provide them with OData response.

97. What is Stateless ?


Ans. The server does not store any state about the client session on the server-side. This
restriction is called Statelessness. It mean servers do not remember or recall the previous
requests.
98. What is the name of the protocol that is supported by SAP Gateway ?
Ans. OData
99. What is the name of the tool that is used to implement OData services for SAP Gateway
Ans. SAP Gateway Service Builder
100. What is the transaction code for creating OData project ?
Ans. Segw
101.What are the steps to develop OData services ?
Ans. A. Create Project
B. Create the Entity Types/Set.(Data Model Definition)
C. Service Implementation
102. What is the transaction code to check the error logs in SAP Gateway hub system ?
Ans. /IWFND/ERROR_LOG
103.  What contain service urllink ?
Ans. http(s)://(Hostname):(Service i.e Port Number)/(rest is from the relevant ICF path).
104. What is the transaction code to Add/remove services from SAP Gateway hub system ?
Ans. /IWFND/MAINT_SERVICE
 105. What is ICF path in OData ?
Ans. sap->opu->odata->sap->ProjName.
106. What query used to limit the size of the result set by limiting the number of columns ?
Ans. $select
107. Which all query can be used to limit the size of the result set?
Ans. $select
$filter
108.  What query used to used to return the media data ?
Ans. $value
109. What query used to retrieve multiple entities that connected through navigation ?
Ans. $expand
110. What all folders created when OData project create ?
Ans. Data Model
Service Implementation
Runtime Artifacts
Service Maintenance

111. What all folders contains Data Model in SAP Gateway hub system ?
Ans. A. Entity Types
B. Associations
C. Entity Sets
112. What is Embedded deployment ?
Ans. Embedded deployment means that the services are registered and published in the SAP
Business Suite backend system.
113. What is HUB Deployment ?
Ans. HUB Deployment (Development on Backend System) means Services are deployed on the
backend systems and only registered on the server.

114. What does OData Batching ?


Ans. OData Batching can group multiple operations into a single HTTP request.
115. How to check if your system has SAP Netweaver Gateway ?
Ans. SAP_GWFND
116. What all guiding contraints should satisfy to called an interface Restful ?
Ans. Client-Server
Stateless
Cacheable
Uniform Interface
Layered System
Code on demand (Optional)
117. What $orderby query option does ?
Ans. Query option $orderby adds sorting capabilities to the SAP gateway OData service. So that
you can able to order the OData service feed/collection based on the fields available in the
Entity Type set.
118. What $skip query option does ?
Ans. Query option $top and $skip are used to restrict the amount of data retrieved from back-
end system.
119. What $filter query option does ?
Ans. Query option $filter adds filtering capabilities to the SAP gateway OData service. So that
you can able to filter the OData service feed/collection based on the fields available in the Entity
Type set.
120. What $inlinecount query option does ?
Ans. Query option $inlinecount is used to get the overall count of feed/collection together with
the entity set collection data.
121. What syntax use to debugging in OData ?
Ans. &sap-ds-debug=true
122. What is the transaction code to trace OData service ?
Ans. /IWFND/TRACES

123. What is the transaction code to clean cache in OData service ?


Ans. /IWFND/CACHE_CLEANUP
124. What is the BADI ?
Ans. BAPI (Business Application Programming Interface ) is API provided by SAP which can be
used for interfacing third-party systems with SAP.

125. What is the OData Query Options ?


Ans. Query Options means the additional parameters /syntaxes like Filter, Orderby, Expand add
to the OData Service URI to perform extra work.

126. What is transaction code to check if your system has SAP Netweaver Gateway ?
Ans. SAP_GWFND

You might also like