0% found this document useful (0 votes)
319 views

OData V4 Code Based Implementation - Overview - SAP Community

This blog provides an overview of code-based OData V4 service development. It introduces a blog series that will explain how to create an OData V4 service using the SAP Gateway V4 framework. The blog describes what's new in OData V4, including the JSON format, cross-service references, support for Any/All, and filtering on expanded results. It also outlines the basic, intermediate, and advanced interfaces available in the Gateway V4 framework.

Uploaded by

geethashriit
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
319 views

OData V4 Code Based Implementation - Overview - SAP Community

This blog provides an overview of code-based OData V4 service development. It introduces a blog series that will explain how to create an OData V4 service using the SAP Gateway V4 framework. The blog describes what's new in OData V4, including the JSON format, cross-service references, support for Any/All, and filtering on expanded results. It also outlines the basic, intermediate, and advanced interfaces available in the Gateway V4 framework.

Uploaded by

geethashriit
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 49

2/7/24, 7:03 PM OData V4 code based implementation - Overview - SAP Community

Community

SAP Community  Products and Technology  Technology  Technology Blogs by SAP

 OData V4 code based implementation - Overview

Technology Blogs by SAP


Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP
BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.

All community  What are you looking for today?

OData V4 code based implementation - Overview

andrefischer
Product and Topic Expert

‎12-12-2017 2:10 PM

 50 Kudos

This blog is meant as an introduction of a series of blogs in which I will explain the use
of the new SAP Gateway V4 framework.

It is meant for those readers that must create OData V4 series now and that cannot
wait until an end-2-end support for OData V4 will be available through the new ABAP
programming model.

Before starting code based OData V4 development you should check my blog OData
service development options where I outline in more detail what the recommended
options for OData development are right now.

Updates

13.12.2017 - added link to the first how to guide and the blog that explains
the OData service devlopment options in more detail
https://community.sap.com/t5/technology-blogs-by-sap/odata-v4-code-based-implementation-overview/ba-p/13361814 1/49
2/7/24, 7:03 PM OData V4 code based implementation - Overview - SAP Community

19.05.2021 - published the source code on GitHub

Table of contents
This blog is part of blog series about OData V4 code based development

OData V4 code based implementation – Overview

OData V4 code based implementation I (basic interface, read access)

OData V4 code based implementation I (basic interface, create&update)

Demo system ES5


The service has been deployed in the ES5 demo system

https://sapes5.sapdevcenter.com/sap/opu/odata4/sap/ze2e001/default/sap/ze2e001_s
alesorder/0001/$meta...

In order to access the service you have to

Sign up for a demo account on ES5 here

More details about the ES5 demo system as such you will find in my following blog

New SAP Gateway Demo System available

Source code
The source code can be found on GitHub.

Data provider class - zcl_e2e001_odata_v4_so_data

Model provider class - zcl_e2e001_odata_v4_so_model

Exception class - zcx_e2e001_odata_v4_so

Interface - zif_e2e001_odata_v4_so_types

https://community.sap.com/t5/technology-blogs-by-sap/odata-v4-code-based-implementation-overview/ba-p/13361814 2/49
2/7/24, 7:03 PM OData V4 code based implementation - Overview - SAP Community

Consumption view - sales order - ze2e001_c_salesorder

Consumption view sales order items - ze2e001_c_salesorderitem

Interface view - ze2e001_i_salesorderitem_e

Consumption view - ze2e001_c_salesorder

What's new in the protocol?

The main paradigm: Reduction of data


The main paradigm of the OData V4 paradigm is the reduction of data. This reduction
is achieved through a more powerful query language and a new optimized JSON
protocol. At the same time it is possible to leverage richter metadata as compared to
OData V2.

New JSON format


The OData V4 protocol comes with a very lean JSON procol. The response payload
now basically only contains name value pairs. The metadata has been reduced to a a
single line

1 "@odata.context" : "$metadata#SalesOrder/$entity"

as opposed to the more richer metadata information in the V2 response payload, both
highlighted in blue in the following figure.

https://community.sap.com/t5/technology-blogs-by-sap/odata-v4-code-based-implementation-overview/ba-p/13361814 3/49
2/7/24, 7:03 PM OData V4 code based implementation - Overview - SAP Community

Cross service references

Cross service navigation enables inter communication of services. With this,


navigation properties of entities of one service can reach entities of another service in
a service group. With the support of cross service navigation several requirements of
SAP Fiori like applications can be addressed.

1.) The rich metadata can be leveraged but at the same time not the complete data
model has to be loaded at startup time of an application. There is rather the option to
have a lazy loading of parts of a service model on demand.

2.) Services can be reused more easily since services can be partioned without the
loss of navigation.

Examples of such services that can be reused in various SAP Fiori applications are
Users, Attachments, Conditions, Addresses, …

Please note:

Cross service references are only possible within one service group.

If a request like the following is issued:

1 …/SalesOrderItems(SalesOrder='500000000', SalesOrderItem='10')/_Product

https://community.sap.com/t5/technology-blogs-by-sap/odata-v4-code-based-implementation-overview/ba-p/13361814 4/49
2/7/24, 7:03 PM OData V4 code based implementation - Overview - SAP Community

one would receive a response like the following where it is indicated via the
@odata.context annotation that this response stems from another service.

1 {
2 "@odata.context" : "../../sap/Product/0001/$metadata#Product/$entity",
3 "value" : [
4 {
5 "Product" : "HT-1000",
6 "Currency" : "EUR",
7 ...
8 }
9 ]
10 }

Support for Any and All


New is the support of the query options any and all.

With these it is now possible to find all sales orders where at least one of the items
contains a particular product

1 …/SalesOrders?$filter = _Item/any(d:d/Product eq 'HT-1007')

or it is possible to find all sales orders where every item has a price greater than $100

1 …/SalesOrders?$filter = _Item/all(d:d/Price ge 100)

Filter on expanded result sets

New in OData V4 is the option for filtering on each level of an expanded enttiy set. In
the following figure you see a request that

1. reads all business partners that are located in 'Walldorf'

2. reads all sales orders of those business partners where the gross amount
exceeds 1100 Euro

3. reads only those items that contain the product HT-1041.

https://community.sap.com/t5/technology-blogs-by-sap/odata-v4-code-based-implementation-overview/ba-p/13361814 5/49
2/7/24, 7:03 PM OData V4 code based implementation - Overview - SAP Community

What's new in the framework?

Advanced, intermediate and basic interfaces


The API that is used to develop OData V4 services has significantly changed
compared to the API that is used to develop OData V2 services.

When you implement the methods of the basic interface you will get a working OData
V4 service that will satisfy most requests. Complex requests such as $expand are
then handled by the framework that will call the methods for the basic interface in the
correct order.

The mplementation of the intermediate or advanced interface should however also be


taken into account if your service implementation would be able to handle specific
requests such as specific $expand or navigation calls more efficient than by calling
the methods of the basic interface recursively.

https://community.sap.com/t5/technology-blogs-by-sap/odata-v4-code-based-implementation-overview/ba-p/13361814 6/49
2/7/24, 7:03 PM OData V4 code based implementation - Overview - SAP Community

Name Purpose

Methods provide basic functionality

(Create, Update, Delete, Navigation,


…)
/IWBEP/IF_V4_DP_BASIC

When being implemented à Working


OData service supporting most
requests

https://community.sap.com/t5/technology-blogs-by-sap/odata-v4-code-based-implementation-overview/ba-p/13361814 7/49
2/7/24, 7:03 PM OData V4 code based implementation - Overview - SAP Community

Medium complex functionality

/IWBEP/IF_V4_DP_INTERMEDIATE eTag handling, PATCH, $expand

Contains generic calls to other


(especially the basic) interfaces

Always called first by the framework

Contains generic calls to the other


(especially the basic) interfaces
/IWBEP/IF_V4_DP_ADVANCED

Will for example be overwritten by the


new RESTful ABAP Programming
model (planned)

$batch. Generic $batch and


/IWBEP/IF_V4_DP_BATCH
changeset

/IWBEP/IF_V4_DP_PROCESS_STEPS Transaction and lifecycle handling

https://community.sap.com/t5/technology-blogs-by-sap/odata-v4-code-based-implementation-overview/ba-p/13361814 8/49
2/7/24, 7:03 PM OData V4 code based implementation - Overview - SAP Community

io_request and io_response

All interface methods have an import parameter called io_request. It can be used to
retrieve all information you need to handle the request in your service implemenation.

A UPDATE_ENTITY method for example will have the following methods

GET_BUSI_DATA to retrieve entity data from the request, for example the
payload of the incoming request.

GET_ENTITY_SET to retrieve the entity set of the processed entity. So we can


switch to entity set specific methods

The corresponding parameter ip_response is used to return business data to the SAP
Gateway framework and to tell the framework which processing steps the service
implementation has handled iself (see todo and done flags below).

Generic framework support - example $expand


As already mentioned you will get a working OData V4 service by only implementing
the methods of the basic interface.If a client calls the following URL:

1 GET .../ze2e001_salesorder/0001/SalesOrder('500000000')?$select=Salesord
2 $expand=_Item($select=Salesorderitem,Product,Grossamountintransaccurrenc

the SAP Gateway framework will call the following basic methods in your service
implementation:

https://community.sap.com/t5/technology-blogs-by-sap/odata-v4-code-based-implementation-overview/ba-p/13361814 9/49
2/7/24, 7:03 PM OData V4 code based implementation - Overview - SAP Community

# Method call Purpose


This method will read the data
1 …_BASIC~READ_ENTITY
of the sales order header
This method will read the key
fields of the items that can be
2 ..._BASIC~READ_REF_TARGET_KEY_DATA used by the
READ_ENTITY_LIST method as
a $filter statement

This method reads the items.


3 ..._BASIC~READ_ENTITY_LIST

and would finally return the following data

https://community.sap.com/t5/technology-blogs-by-sap/odata-v4-code-based-implementation-overview/ba-p/13361814 10/49
2/7/24, 7:03 PM OData V4 code based implementation - Overview - SAP Community

1 {
2 "@odata.context" : "$metadata#SalesOrder(Salesorder,Customer,_Item(Sal
3 "Salesorder" : "500000000",
4 "Customer" : "100000000",
5 "_Item" : [
6 {
7 "Salesorder" : "500000000",
8 "Salesorderitem" : "10",
9 "Product" : "HT-1000",
10 "Transactioncurrency" : "EUR",
11 "Grossamountintransaccurrency" : 1137.64
12 },
13 {
14 "Salesorder" : "500000000",
15 "Salesorderitem" : "20",
16 "Product" : "HT-1001",
17 "Transactioncurrency" : "EUR",
18 "Grossamountintransaccurrency" : 2972.62
19 },
20 ...
21 ]
22 }

Please note:
With OData V4 now query options are supported on all levels of an $expand
statement.

ToDo and Done-Flags


The SAP Gateway V4 framework has introduced so called ToDo-Flags which provide a
hint for the application developer what his implemenations has to do. Depending ont
the query options that have been used in the request you will get simple list with
boolean values for the following flags:

deltatoken, select, filter, skip, orderby, skiptoken, search, top, ...

Done-Flags confirm that the response fits to the request. They allow the application
developer to inform the framework to handle feature generically e.g., $top, $skip, and
$select. Using such flags also allows an implementation tobe compatible in the future.
Instead of a wrong result an exception will be raised if a done flag is not set.

The list of todo and done flags will vary depending on the method which is called.
(READ; READ_LIST, CREATE, ...)

https://community.sap.com/t5/technology-blogs-by-sap/odata-v4-code-based-implementation-overview/ba-p/13361814 11/49
2/7/24, 7:03 PM OData V4 code based implementation - Overview - SAP Community

For a simple GET request with a $filter query option:

1 …/SalesOrder?$filter=Customer eq ‚SAP‘

a service implementation would have to look like as follows.

At the beginning of our service implementation we have to check whether we have to


handle the filter option. For this we call the method io_request->get_todos. Then we
have to check whether the flag ls_todo_list-process-filter is set. If yes, the filter string
is requested via the method io_request->get_filter_osql_where_clause and the flag
that we have handled the filter query option is set in the structure ls_done_list. This
information is at the end sent back to the framework via the method io_response-
>set_is_done that takes the done-list as a parameter.

1 io_request->get_todos( importing es_todo_list = ls_todo_list ).


2 ...
3 if ls_todo_list-process-filter = abap_true.
4 io_request->get_filter_osql_where_clause( importing ev_osql_where_clau
5 ls_done_list-filter = abap_true.
6 endif.
7 ...
8 " Report list of request options handled by application
9 io_response->set_is_done( ls_done_list ).

SAP Managed Tags:

OData, SAP Gateway

Labels:

Technology Updates

48 Comments

https://community.sap.com/t5/technology-blogs-by-sap/odata-v4-code-based-implementation-overview/ba-p/13361814 12/49
2/7/24, 7:03 PM OData V4 code based implementation - Overview - SAP Community

Lokes
Participant

‎12-12-2017 4:41 PM

 0 Kudos

Hello andre.fischer,

Most wanted blog, thank you so much

It is really awseome..!!!..

Regards,

Lokeswar.

NagaPrakashT
Contributor

‎12-21-2017 3:38 PM

 0 Kudos

Hi,

Very informative blog. Thanks

From which ABAP Netweaver version, developers can start using V4?

https://community.sap.com/t5/technology-blogs-by-sap/odata-v4-code-based-implementation-overview/ba-p/13361814 13/49
2/7/24, 7:03 PM OData V4 code based implementation - Overview - SAP Community

Thanks,

Naga

andrefischer
Product and Topic Expert

‎12-24-2017 10:27 PM

 0 Kudos

Odata v4 was first supported as of SAP Netweaver 750 SP4.

This implementation still lacks some features. There is however planned a downport
of SAP Gateway features from 752 to older releases down to 750 SPx, if the
corresponding 750 SPx allows such a downport .

Best regards

Andre


‎12-25-2017 5:53 AM

 0 Kudos

Hi Andre,

https://community.sap.com/t5/technology-blogs-by-sap/odata-v4-code-based-implementation-overview/ba-p/13361814 14/49
2/7/24, 7:03 PM OData V4 code based implementation - Overview - SAP Community

The blog is very nice and helpful.

But i am unable to open the source code that you have given. As because i am new to
Odata i just want to see the coding style.

Thanks

Ranjan

DouglasCezar
Contributor

‎01-22-2018 6:09 PM

 0 Kudos

Hi andre.fischer, how are you?

I've seen that SEGW transaction is in maintenance mode.

What is the correct tool to use if I'm on an ABAP ECC environment and we still use
standard tools as SE38, SE80 etc?

Is Eclipse a mandatory way to go? If so is there any documentation showing how to


do this from absolutely scratch?

Thank you!

Douglas

https://community.sap.com/t5/technology-blogs-by-sap/odata-v4-code-based-implementation-overview/ba-p/13361814 15/49
2/7/24, 7:03 PM OData V4 code based implementation - Overview - SAP Community

andrefischer
Product and Topic Expert

‎01-22-2018 6:55 PM

 1 Kudo

Hi Douglas,

thanks for bringing up this question.

SEGW is still the tool of choice when developing OData V2 services as they are
currently used in ECC systems as well as in SAP S/4 HANA systems.

Only when it comes to the development of OData V4 services the recommendation is


to use pure ABAP code based development. Here my recommendation would be
ABAP in Eclipse but it is not mandatory. SE24 would work.

Links that show how develop OData V2 services from scratch you can find in my blog
about OData development options.

Best Regards,

Andre

DouglasCezar
Contributor

‎01-23-2018 12:51 PM

 0 Kudos

Hi Andre, thank you very much for the reply and clarifications around this!

https://community.sap.com/t5/technology-blogs-by-sap/odata-v4-code-based-implementation-overview/ba-p/13361814 16/49
2/7/24, 7:03 PM OData V4 code based implementation - Overview - SAP Community

Do you know of any guide to building OData V4 services from scratch using SE24 ?

Thank you and best regards,

Douglas

andrefischer
Product and Topic Expert

‎01-23-2018 12:59 PM

 1 Kudo

Hi Douglas,

sure. You can use my three blogs that I have mentioned above that explain code
based development of OData V4 services.

When using SE24 be sure to use the source code based view.

Best Regards,

Andre

KKilhavn
Active Contributor

‎03-27-2018 12:30 PM

 0 Kudos

https://community.sap.com/t5/technology-blogs-by-sap/odata-v4-code-based-implementation-overview/ba-p/13361814 17/49
2/7/24, 7:03 PM OData V4 code based implementation - Overview - SAP Community

Your blogs have been very useful. There is one thing to be aware of though, with
respect to setting the 'done' flags. I would recommend setting those flags when the
filter (for example) criteria have been applied successfully, not immediately after you
have retrieved the criteria - just in case...

andrefischer
Product and Topic Expert

‎03-27-2018 5:10 PM

 0 Kudos

You are right.

I'll change the sample code.

Thanks and best regards

Andre

former_member194418
Participant

‎07-20-2018 3:26 PM

 0 Kudos

Hi Andre,

that is clear. However, with SEGW you can generate quite a few services; eg via a
simple redefinition for ODP. Are you going to add some features, ie one interface for
an ODATA-Service via ODP, in order to implement that in an efficient and stable way?
The ODP framework consists of several interfaces which are not released. So redoing
that yourself is not that straightforward and involves quite some maintenance.

https://community.sap.com/t5/technology-blogs-by-sap/odata-v4-code-based-implementation-overview/ba-p/13361814 18/49
2/7/24, 7:03 PM OData V4 code based implementation - Overview - SAP Community

A lot of 3rd party applications which might consume OData do not really like v2. And,
especially important for data export like ODP, v2 has same nasty deficiencies
regarding date/time. You will lose some information. That got solved with v4.

thanks, C

maheshpalavalli
Active Contributor

‎08-01-2018 7:59 AM

 0 Kudos

Very Informative blog!!!!

JacquesDuparc
Employee

‎11-21-2018 2:26 PM

 0 Kudos

Hi Andre,

Very nice blog!

for those also searching, the path of the service is:

https://sapes5.sapdevcenter.com/sap/opu/odata4/sap/ze2e001/default/sap/ze2e001_s
alesorder/0001/$meta...

Otherwise: any news of the availability of the downport for 7.50?


https://community.sap.com/t5/technology-blogs-by-sap/odata-v4-code-based-implementation-overview/ba-p/13361814 19/49
2/7/24, 7:03 PM OData V4 code based implementation - Overview - SAP Community

Kind regards,
Jacques

andrefischer
Product and Topic Expert

‎11-21-2018 3:00 PM

 0 Kudos

Hi Jacques,

please check SAP Note 2512479 "SAP Gateway Foundation Support Package Stack
Definition"

https://launchpad.support.sap.com/#/notes/2512479

The latest downport of the current V4 capabilities is part of SAP_GWFND 750 SP12.

I am working on feature list but this is not yet available.

Regards,

Andre

former_member276628
Explorer

‎12-19-2018 6:55 PM

 0 Kudos

How do I create a deep insert

https://community.sap.com/t5/technology-blogs-by-sap/odata-v4-code-based-implementation-overview/ba-p/13361814 20/49
2/7/24, 7:03 PM OData V4 code based implementation - Overview - SAP Community

I am getting an error:

"code" : "/IWBEP/CM_V4S_RUN/066",
"message" : "Application did not set DONE list for an expand node '_OBJECT'"

How do I set a done list for an expand node ?

AbhijeetK
Active Participant

‎08-16-2019 1:20 PM

 1 Kudo

Can we leverage cds view as Reference data source for generating version 4 Odata.

former_member239941
Explorer

‎10-18-2019 12:06 PM

 0 Kudos

Hi,

In note 2485370 it is stated that it is still recommended to use Odata V2 if it is not

https://community.sap.com/t5/technology-blogs-by-sap/odata-v4-code-based-implementation-overview/ba-p/13361814 21/49
2/7/24, 7:03 PM OData V4 code based implementation - Overview - SAP Community

mandatory for the business scneario to use Odata V4. The note version is from
2017/09/11.

is this still the current recommendation, are there any restriction in Odata V4 we
should be aware of if we develop our REST Services with Odata V4?

Regards,

Silvia

andrefischer
Product and Topic Expert

‎10-19-2019 11:32 AM

 2 Kudos

Hi Silvia,

I have just updated the note though the changes are not visible due to a 4 eyes
principle that is in place when SAP Notes are changed.

Unfortunately the main statement still holds true that if you must use OData V4 now
you have to perform a code based implementation. And here it is recommended to
use the approach I described above because this way your data model will already be
based on CDS views and it will be more easy to reuse this in the ABAP RESTful
programming model which is available in SAP S/4HANA as of SAP S/4HANA 1909.

Restrictions with regards to the support of OData V4 are not on the service
implementation side if you go for a code based implementation. The only problem
you will have is that such a code based implementation is implementing the OData V4
API's of the SAP Gateway Framework, rather than using the OData protocol agnostic
implementation of the ABAP RESTful Programming Model.

So you would have to adapt your coding manually when moving to the ABAP RESTful
programming model at a later point in time.

The restrictions are more on the UI side since there is currently no support for OData
V4 for SAP Fiori elements applications. Though this is planned.
https://community.sap.com/t5/technology-blogs-by-sap/odata-v4-code-based-implementation-overview/ba-p/13361814 22/49
2/7/24, 7:03 PM OData V4 code based implementation - Overview - SAP Community

So if you are planning to build SAP Fiori applications the recommendation is still to
use OData V2.

Best Regards,

Andre Fischer

samson_moses
Explorer

‎10-31-2019 7:44 PM

 0 Kudos

Hi Andre,

Thanks for your helpful blog.

For one of our project requirements, we had to use V4 O-Data implementation. So I


referred the blog to set-up and implement my service successfully in my development
environment. Our service is defined in Back-end system(SAP_ABA-Version 7.50 SP-
Level 11) with the service Group registration done at Gateway system(SAP_GWFND-
Version 7.52 SP-Level 0 ).

After transporting my Back-end / GW transports to IT system, my service in IT is not


working (Table /IWFND/C_V4_RSAG is not having respective entries ).

Just wanted to confirm that the service registration has to be manually configured in
each of IT/Production environment.

Also we need to have client-open for the configurations set-up?

Thanks & Regards,

Samson

https://community.sap.com/t5/technology-blogs-by-sap/odata-v4-code-based-implementation-overview/ba-p/13361814 23/49
2/7/24, 7:03 PM OData V4 code based implementation - Overview - SAP Community

gregorw
Active Contributor

‎04-01-2020 5:23 PM

 2 Kudos

In the context of SAP Fiori Launchpad Notifications I was able to solve a similar issue
by applying the Note 2860780 - Expand functionality of entity in Notification channel.

hschaefer123
Participant

‎07-08-2020 3:23 PM

 0 Kudos

Hi Andre,

currently the ABAP RESTful programming model which is available in SAP S/4HANA as of SAP S/4HANA 1909 has been
release and is there an update for this blog?

Is the abap end-2-end scenario for odata v4 available with 1909?

Regards Holger

andrefischer
Product and Topic Expert

‎07-08-2020 3:25 PM

https://community.sap.com/t5/technology-blogs-by-sap/odata-v4-code-based-implementation-overview/ba-p/13361814 24/49
2/7/24, 7:03 PM OData V4 code based implementation - Overview - SAP Community

 0 Kudos

No, unfortunately not.

hschaefer123
Participant

‎07-08-2020 4:08 PM

 0 Kudos

Sorry, but one additional question:

I just saw the asug abap roadmap webinar of Karl Kessler and v4 release is planned
for onprem 2020 release and september is not far away

Is this something to rely on? Because also SAP CAP is heavily focused on v4 and the
used SAP Fiori Elements for v4.

Also Peter Spielvogel is anouncing Fiori Elements Floorplans for OData v4 comming
soon (Q3/2020)
https://blogs.sap.com/2020/03/17/fiori-elements-floorplans-for-odata-v4-coming-soon/

But if this is not part of onPrem yearly release, this will be to late for most of our
onprem customers.

Regards Holger

s4-analytics_com
Explorer

‎10-21-2020 6:14 PM

 0 Kudos

https://community.sap.com/t5/technology-blogs-by-sap/odata-v4-code-based-implementation-overview/ba-p/13361814 25/49
2/7/24, 7:03 PM OData V4 code based implementation - Overview - SAP Community

Hi Andre,

we do need the oData-Service functionality for stateful on SAP Netweaver 7.5.

Currently it is available on 1809 upwards:


https://help.sap.com/viewer/68bf513362174d54b58cddec28794093/201809.002/en-
US/5fb6396b8b304bce9b9dba...

So can you tell me if this feature is on the downport-list and if so, with which
7.5 Support Package it will be availabe then?

Thank you!

// Klaus

andrefischer
Product and Topic Expert

‎10-21-2020 10:24 PM

 0 Kudos

Hi Klaus,

no down ports have been performed from SAP S/4HANA foundation 1809 to SAP
NetWeaver 750.

See also SAP Note 512479 – SAP Gateway Foundation Support Package Stack
Definition

https://launchpad.support.sap.com/#/notes/2512479

1809 features are (currently) only down ported to SAP NetWeaver 752 and later.

Do you need "real" stateful session handling or would something like the softstate be
sufficient?

https://community.sap.com/t5/technology-blogs-by-sap/odata-v4-code-based-implementation-overview/ba-p/13361814 26/49
2/7/24, 7:03 PM OData V4 code based implementation - Overview - SAP Community

https://blogs.sap.com/2014/10/14/how-to-use-soft-state-support-for-odata-services/

Best regards,

Andre

former_member572035
Member

‎11-11-2020 2:57 PM

 0 Kudos

Hi Andre Fishcher,

I have implemented code based ODATA V4. Everything is working as expected. We


are facing some issue with Quantity and currency formatting.

Case 1 Quantity is zero and reference UOM is empty

{
"error" : {
"code" : "/IWBEP/CM_V4_COS/041",
"message" : "Conversion error for property MATERIALNETWEIGHT in entity type BASI
CDATA",
"@SAP__common.ExceptionCategory" : "Gateway_Framework_Error",
"@SAP__common.Application" : {
"ServiceRepository" : "DEFAULT",
"ServiceId" : "ZGW0026V1_MATERIAL_MASTER",
"ServiceVersion" : "0001"
},
"@SAP__common.TransactionId" : "AC73D61EBF1801E0E005F97393825AAE",
"@SAP__common.Timestamp" : "20201111144648.802259",
"@SAP__common.ErrorResolution" : {

https://community.sap.com/t5/technology-blogs-by-sap/odata-v4-code-based-implementation-overview/ba-p/13361814 27/49
2/7/24, 7:03 PM OData V4 code based implementation - Overview - SAP Community

"Analysis" : "Run transaction /IWFND/ERROR_LOG on SAP Gateway hub system and s


earch for entries with the timestamp above for more details",
"Note" : "See SAP Note 1797736 for error analysis (https://service.sap.com/sap/suppo
rt/notes/1797736)"
},
"innererror" : {
"ErrorDetails" : [
{
"code" : "/IWBEP/CM_V4_COS/035",
"message" : "Measure formatting with unit failed",
"exception" : "/IWBEP/CX_V4_CONVERSION",
"@SAP__common.Severity" : "error"
},
{
"code" : "/IWBEP/CM_V4_COS/036",
"message" : "No configuration for unit of measure",
"exception" : "/IWBEP/CX_V4_CONVERSION",
"@SAP__common.Severity" : "error"
}
]
}
}
}

Case 1 Amount is zero and reference currency code is empty

{
"error" : {
"code" : "/IWBEP/CM_V4_COS/041",
"message" : "Conversion error for property PRICE in entity type OPERATIONS",
"@SAP__common.ExceptionCategory" : "Gateway_Framework_Error",
"@SAP__common.Application" : {
"ServiceRepository" : "DEFAULT",
"ServiceId" : "ZGW0026V1_PRODUCTION_ORD",
"ServiceVersion" : "0001"
},
"@SAP__common.TransactionId" : "AC73D61EBF1801E0E005F97393825AAE",
"@SAP__common.Timestamp" : "20201111145642.537439",
"@SAP__common.ErrorResolution" : {
"Analysis" : "Run transaction /IWFND/ERROR_LOG on SAP Gateway hub system and s
earch for entries with the timestamp above for more details",
"Note" : "See SAP Note 1797736 for error analysis (https://service.sap.com/sap/suppo
rt/notes/1797736)"

https://community.sap.com/t5/technology-blogs-by-sap/odata-v4-code-based-implementation-overview/ba-p/13361814 28/49
2/7/24, 7:03 PM OData V4 code based implementation - Overview - SAP Community

},
"innererror" : {
"ErrorDetails" : [
{
"code" : "/IWBEP/CM_V4_COS/034",
"message" : "Amount formatting with currency failed",
"exception" : "/IWBEP/CX_V4_CONVERSION",
"@SAP__common.Severity" : "error"
},
{
"code" : "/IWBEP/CM_V4_COS/043",
"message" : "Currency does not exist",
"exception" : "/IWBEP/CX_V4_CONVERSION",
"@SAP__common.Severity" : "error"
}
]
}
}

I can disable formatting. But we have multiple currency and need formatting based on
currency.

Regards

Karthikeyan Kamalesan

d_enkel
Explorer

‎01-29-2021 2:52 PM

 0 Kudos

https://community.sap.com/t5/technology-blogs-by-sap/odata-v4-code-based-implementation-overview/ba-p/13361814 29/49
2/7/24, 7:03 PM OData V4 code based implementation - Overview - SAP Community

Hi Andre,

can you tell me where i can enable Oauth for SAP ODataV4 Services?

Best regards,

Domenik

thomasassmann
Discoverer

‎02-04-2021 1:30 PM

 0 Kudos

Hi,

I am dealing with the same issue as Domenik and I have not been able to work out a
solution so far.

Did someone ever figure this out?

Cheers,

Thomas

former_member635327
Discoverer

‎06-15-2021 1:17 PM

https://community.sap.com/t5/technology-blogs-by-sap/odata-v4-code-based-implementation-overview/ba-p/13361814 30/49
2/7/24, 7:03 PM OData V4 code based implementation - Overview - SAP Community

 0 Kudos

Thanks for the blog.


Could u plz tell me what is meant by "end-2-end support of OData V4 by the new
programming model".
If we are implementation code based odata service 4 ,anything wrong will happen in
the next upgrade?

Regards
Suresh

bsal2703
Discoverer

‎06-15-2021 2:12 PM

 0 Kudos

Hi Pradeep, what makes you think there is going to be anything wrong with "the next
upgrade"?

As andre.fischer has already stated in the OData service development options blog:

"By choosing a service implementation based on the new ABAP RESTful Application
Programming Model in SAP S/4HANA 1909, you are well prepared for the end-2-end
support of the OData V4 protocol in SAP S/4HANA 2020 FPS1"

The essensial here is that there is no relation between the RAP and OData V4 code
based approach.

Kind Regards,
Boyan

https://community.sap.com/t5/technology-blogs-by-sap/odata-v4-code-based-implementation-overview/ba-p/13361814 31/49
2/7/24, 7:03 PM OData V4 code based implementation - Overview - SAP Community

andrefischer
Product and Topic Expert

‎06-15-2021 2:49 PM

 1 Kudo

End to end support means that in addition to the possibility to develop an OData V4
service there should be the option to consume the same using the SAP Fiori Elements
list reporting template which now is also V4 based.

An existing OData V4 code based implementation will also run after the upgrade (at
least it is supposed to do that, because otherwise it would be a bug in the framework).

As said the downside of the codebased implementation approach is that the


implementation is specific to the protocol being used whereas using the ABAP
RESTful programming model has the advantage that different binding types are
available.

former_member635327
Discoverer

‎06-18-2021 2:17 PM

 0 Kudos

Ok. Thank You.

Will aggregate functionality support? I am in NW 7.50 with SP 17.

I just passed 'aggregate' function in the url but I am getting the error
/IWBEP/IF_V4_DP_ADVANCED~READ_ENTITY_LIST has to implement.

Can you provide some additional information with sample code as you given above.

https://community.sap.com/t5/technology-blogs-by-sap/odata-v4-code-based-implementation-overview/ba-p/13361814 32/49
2/7/24, 7:03 PM OData V4 code based implementation - Overview - SAP Community

Regards
Suresh

0020229930
Explorer

‎07-28-2021 4:54 PM

 0 Kudos

Hi Andre, thanks for your helpful blog.

For one of our project requirements, I need to Create a deep entity with multilevel, for
example Sales Order -> Items -> Serials, I have followed your logic, created the
entities and navigation as well, then I implemented the method
/iwbep/if_v4_dp_advanced~create_entity but I am facing some issues when I provide
Serial entity on payload file, if I remove the Serial entity is works.

I think that it is missing some associations between Item -> Serials, using your
example as reference, can I use the same logic that you created to SalesOrder to
SalesOrderItem? Or I need to do anything else?

If I execute the POST with the _Serial I get error message: "message" : "In the context
of Data Services an unknown internal server error occurred".

In /IWFND/ERROR_LOG : HTTP 500 Dereferencing of the NULL reference

{
"@odata.context" : "$metadata#HeaderSet(_Item())/$entity",
"@odata.metadataEtag" : "W/\"20210727230600\"",
"SalesOrg" : "1001",
"ShipTo" : "55552581",
"SoldTo" : "55552581",
"OrderType" : "ZKE",
"OrderReason" : "Z09",
"DlvBlock" : "60",
"PoMethod" : "ZMMR",
"Ref1" : "11111",

https://community.sap.com/t5/technology-blogs-by-sap/odata-v4-code-based-implementation-overview/ba-p/13361814 33/49
2/7/24, 7:03 PM OData V4 code based implementation - Overview - SAP Community

"Name" : "TEST KRAUTE (1615)",


"MeansOfTransport" : "0001",
"PurchOrdNumber" : "04262021",
"PurchNoS" : "TEST NUMBER",
"PoDatS" : "2000-12-12",
"InvcHeaderText" : "Text Header",
"EmailAddress" : "[email protected]",
"_Item" : [
{
"ItemNo" : "1",
"Material" : "087790430",
"Batch" : "",
"Plant" : "",
"Lgort" : "",
"OrderQty" : 1.000,
"ItemCateg" : "",
"TargetQu" : "KG",
"_Serial" : [
{
"ItemNo" : "1",
"Serial" : "123"
}
]
}
]
}

In debug mode I saw that the entity_info-targer is INITIAL

https://community.sap.com/t5/technology-blogs-by-sap/odata-v4-code-based-implementation-overview/ba-p/13361814 34/49
2/7/24, 7:03 PM OData V4 code based implementation - Overview - SAP Community

https://community.sap.com/t5/technology-blogs-by-sap/odata-v4-code-based-implementation-overview/ba-p/13361814 35/49
2/7/24, 7:03 PM OData V4 code based implementation - Overview - SAP Community

andrefischer
Product and Topic Expert

‎07-28-2021 5:26 PM

 0 Kudos

In my data model the child entity contains two key fields and a grand child entity
would have to use at least three key fields.

1 {
2 //ZE2E001_I_SalesOrderItem_E
3 key SalesOrder,
4 key SalesOrderItem,

So some grandchild entity would have the following keys

https://community.sap.com/t5/technology-blogs-by-sap/odata-v4-code-based-implementation-overview/ba-p/13361814 36/49
2/7/24, 7:03 PM OData V4 code based implementation - Overview - SAP Community

1 {
2 //ZE2E001_I_SalesOrderSchedLine_E
3 key SalesOrder,
4 key SalesOrderItem,
5 key line,
6

0020229930
Explorer

‎07-28-2021 6:22 PM

 0 Kudos

My scenario is a Sales Order creation, so, the key fields in Header are the
mandatories fields to create a sales order, there is no "effective association" with Item
entity, but I created the navigation between them directly in the code, it works fine,
when I read the deep entity the values comes. In Item entity has created ITEM_NO as
a key field, also I created the navigation with Serial entity, but in this case there is a
association because SERIAL entity has ITEM_NO and SERIALNUMBER as key field.

How I should model this scenario?

URI for POST: /sap/opu/odata4/sap/ztest/default/sap/zdeep/0001/HeaderSet

The URI post is correct?

current mapping:

Header -> Sales_org AND Ship_to (KEY) (1º LEVEL)

Item -> Item_no (KEY) (child)

https://community.sap.com/t5/technology-blogs-by-sap/odata-v4-code-based-implementation-overview/ba-p/13361814 37/49
2/7/24, 7:03 PM OData V4 code based implementation - Overview - SAP Community

Serial -> Item_no AND Serial_number (KEY) (grand child)

mcarunnie
Employee

‎09-29-2021 4:12 AM

 0 Kudos

Hi,

I need to provide options for customer enhancement for ex: Add a new field / Add a
new entity by Customer. Do you have suggestion/ examples how that could be done?

former_member608522
Member

‎02-24-2022 11:58 AM

 0 Kudos

Hello,

We have to add Annotations like Common.Label and Aggregation.ApplySupported to


the Entities for our OData V4 Service

I was wondering if this should be done directly in CDS Views, or if we should define
then using code based implementation. Do you maybe have a blog/ example of a
CDS View containing Annotations?

https://community.sap.com/t5/technology-blogs-by-sap/odata-v4-code-based-implementation-overview/ba-p/13361814 38/49
2/7/24, 7:03 PM OData V4 code based implementation - Overview - SAP Community

andrefischer
Product and Topic Expert

‎02-24-2022 2:39 PM

 0 Kudos

Hi Ingo,

when you are using a code based implementation you have to add the code in the
model provider class via code based implementation as well.

Please note that as of SAP S/4HANA 2020 FSP1 you are able to build OData V4
Services using the ABAP Restful Application Programming Model.

Kind regards,

Andre

former_member17083
Explorer

‎03-07-2022 9:56 AM

 0 Kudos

Hi Andre!

Which standard classes can be used to add from source code Annotations to
$metadata result?

Do you have maybe an example?

https://community.sap.com/t5/technology-blogs-by-sap/odata-v4-code-based-implementation-overview/ba-p/13361814 39/49
2/7/24, 7:03 PM OData V4 code based implementation - Overview - SAP Community

Thanks!

former_member758362
Member

‎07-13-2022 12:20 PM

 0 Kudos

Hi Andre.

Thank you so much for you answer, we managed to create the annotations via code
based implementation.

We are trying to use the Location Header feature from OData to provide the URL for
the next function that has to be called. After some debugging we managed to find the
/IWCOR/IF_OD_RESPONSE_PROVIDER -->SET_HEADER method but couldn't find a
way to access it in the Data Provider method of the Action. Is there a way to add
custom Response Headers using code based (for example to also change the status
code of the call)?

With V2 I believe it was possible using the method


/iwbep/if_mgw_conv_srv_runtime~set_header.

Thank you and best regards,

Ingo

christian_bartlog2
Explorer

‎03-15-2023 4:43 PM

https://community.sap.com/t5/technology-blogs-by-sap/odata-v4-code-based-implementation-overview/ba-p/13361814 40/49
2/7/24, 7:03 PM OData V4 code based implementation - Overview - SAP Community

 0 Kudos

Hello andre.fischer,

thanks for this great Blog!

Actually I'm working on a Fiori Elements Worklist App based on OData V4 using RAP. I
want to use Cross-Service Reference but can't find this function in ADT RAP tooling. Is
this function supported by S/4HANA 2021 and RAP?

Best regards

Christian

andrefischer
Product and Topic Expert

‎04-30-2023 4:11 PM

 0 Kudos

Hi Christian,

Cross Service Referencing is not supported by RAP.

But you can call other RAP based services via EML or OData services using OData
Client Proxy Calls.

What's the scenario you want to implement?

Kind regards,

Andre

https://community.sap.com/t5/technology-blogs-by-sap/odata-v4-code-based-implementation-overview/ba-p/13361814 41/49
2/7/24, 7:03 PM OData V4 code based implementation - Overview - SAP Community

michaelhatfield
Discoverer

‎10-10-2023 11:25 AM

 0 Kudos

Hi andre.fischer

We have recently moved to Odata V4 code based implemenation on our hub


landscape with dev objects on S4HANA backend and service group/service published
on GW hub.

Every month or so an incident is being raised because our service is throwing this
error /IWBEP/CM_V4S_RUN/001.

We can solve the incident easily by manually loading metadata from GW_CLIENT, but
would like to solve the issue permanently without having any possible downtime from
when issue reappears and we realize and solve.

We are unable to find which program/background job is being run that causes the
issue or removes the cache and are even unable to reproduce the exact error using
/IWBEP/CACHE_CLEANUP or similar.

Any thoughts/hints? Thanks so much for this blog and all your stuff, we are big fans!

Kind regards,

Michael

Molle
Advisor

‎10-11-2023 5:57 PM

https://community.sap.com/t5/technology-blogs-by-sap/odata-v4-code-based-implementation-overview/ba-p/13361814 42/49
2/7/24, 7:03 PM OData V4 code based implementation - Overview - SAP Community

 2 Kudos

Andre asked me to share my thoughts about this one.

The corresponding error is a very generic one, so this could mean a lot of things. From
the manual solution, however, I would assume this might be a 503 response due to an
outdated cache (e.g., the metadata or service alias cache). This issue is easily solved
by simply sending the request again.

However, this is only an assumption and first step would be indeed to identify the
OData call that triggers this exception, which might give hints which job causes the
issue here.

If such an issue occurs, there should be a corresponding error log entry. Have you
already checked if there is a corresponding entry in TA /IWFND/ERROR_LOG? It
should show you which user and which request caused the issue. This could be an
important first hint.

Best regards,

Andreas

michaelhatfield
Discoverer

‎10-16-2023 8:58 AM

 0 Kudos

Thanks for your response molberg86

https://community.sap.com/t5/technology-blogs-by-sap/odata-v4-code-based-implementation-overview/ba-p/13361814 43/49
2/7/24, 7:03 PM OData V4 code based implementation - Overview - SAP Community

Initially we had the same idea as you and implemented that workaround when the
error is thrown, however, its difficult to test because we still havent identified the
culprit and cant replicate the exact error thrown.

The error is due to service alias cache as you mentioned. Any other
ideas/recommendations how to prevent the issue?

Thanks so much for your support!!

Kind regards,
Michael

Molle
Advisor

‎10-16-2023 9:52 AM

 0 Kudos

Hi Michael,

we're getting closer, your screenshot offers some very valuable hints concerning what
is going wrong (and why you have trouble replicating it):

https://community.sap.com/t5/technology-blogs-by-sap/odata-v4-code-based-implementation-overview/ba-p/13361814 44/49
2/7/24, 7:03 PM OData V4 code based implementation - Overview - SAP Community

The actual issue here happens when it is tried to load the Service Alias Cache via RFC
connection from the backend - see /iwbep/cl_v4_service_alias->load( ). It is indeed an
RFC issue, which makes it so difficult to reproduce via e.g. /IWBEP/CACHE_CLEANUP.

RFC

So, there must be something wrong when executing the RFC call itself. Maybe the
backend system is not always available? Does the underlying user not have sufficient
rights to execute the RFC/log onto the backend system? Is the RFC destination not
maintained correctly? (...)

I would suggest to check these points as next step.

Best regards,

Andreas

michaelhatfield
Discoverer

https://community.sap.com/t5/technology-blogs-by-sap/odata-v4-code-based-implementation-overview/ba-p/13361814 45/49
2/7/24, 7:03 PM OData V4 code based implementation - Overview - SAP Community
‎10-16-2023 11:00 AM

 0 Kudos

Hi molberg86

Thanks again for your quick response

If the issue happens again hopefully we can get more information, because no reason
backend should not be available, user has all privileges needed because request is
usually always OK, and we will have to check the RFC destination to see if something
is not maintained correctly. Still not clear what is causing the issue, we only know that
it has happened twice always Monday after weekend that new developments are
imported. Could other V4 service transports affect this, somehow clearing service
alias cache or something similar?

Thanks!
Best,
Michael

Molle
Advisor

‎10-16-2023 1:13 PM

 0 Kudos

Hi Michael,

short answer: That could not really be caused by another V4 transport.

Long answer: While it is possible that the Service Alias Cache was outdated by one of
these transports, that is not the reason for the exception.

https://community.sap.com/t5/technology-blogs-by-sap/odata-v4-code-based-implementation-overview/ba-p/13361814 46/49
2/7/24, 7:03 PM OData V4 code based implementation - Overview - SAP Community

The reason is that the RFC call itself, i.e. the execution of CALL FUNCTION...
DESTINATION was not working; so, even more technical then e.g. an outdated Cache.

Being not an expert concerning RFC, I can only come up with the assumptions in my
last reply as to why the RFC Call is (occasionally) failing. Finding the underlying
reason is likely very tricky!

Maybe it would be an idea to create a little dummy Function Module and call it
around 100.000 times with the same RFC destination that is assigned to the
underlying OData Service to see if/how many times the RFC call fails? If you can
reproduce it this way, this would surely help in analysing the root cause.

Best regards,

Andreas

 You must be a registered user to add a comment. If you've already registered,


sign in. Otherwise, register and sign in.

Comment

Labels In This Area


Analyze Workload Data 1 Business Trends 1,662 Business Trends 17

Data Analysis Tool 1 Event Information 1,400 Event Information​11

Expert Insights 177 Expert Insights​64 Life at SAP 785 Life at SAP 2

Network Performance Analysis 1 Product Updates 4,583 Product Updates​104

Technology Updates 6,887 Technology Updates 114 Workload Fluctuations 1

Related Content
How SAP’s Generative AI Hub facilitates embedded, trustworthy, and reliable AI 
https://community.sap.com/t5/technology-blogs-by-sap/odata-v4-code-based-implementation-overview/ba-p/13361814 47/49
2/7/24, 7:03 PM OData V4 code based implementation - Overview - SAP Community
in Technology Blogs by SAP 4 hours ago

Stay Compliant in Israel with SAP Document and Reporting Compliance,


Electronic Invoicing solution 
in Technology Blogs by SAP 4 hours ago

What’s New in SAP Analytics Cloud Q1 2024 


in Technology Blogs by SAP 13 hours ago

Optimizing HANA Cloud : A Practical Exploration of Replication, Latency, and


Availability Zones 
in Technology Blogs by SAP yesterday

Unlocking the Power of Encryption 


in Technology Blogs by SAP yesterday

Popular Blog Posts

Get Your SAP HANA Idea Incubator Badge Today!

Former Member

 28386  252  1280

https://community.sap.com/t5/technology-blogs-by-sap/odata-v4-code-based-implementation-overview/ba-p/13361814 48/49
2/7/24, 7:03 PM OData V4 code based implementation - Overview - SAP Community

Follow

Privacy Terms of Use

Copyright Legal Disclosure

Trademark Newsletter
SCN Mission - SAP HANA Quiz Challenge is now retired
Support Cookie Preferences
ThomasJenewein
Product and Topic Expert

https://community.sap.com/t5/technology-blogs-by-sap/odata-v4-code-based-implementation-overview/ba-p/13361814 49/49

You might also like