I would like to share some of my experiences in developing OData services using SAP Gateway in this article, and I would be glad if a discussion evolved out of it. Let´s start with an overview of common problems and some hints on how to avoid them. I see those hints as an addition to the Best Practices published by SAP.
That problem is not specific to OData service development, it is an issue for almost every software developer. In contrast to a traditional ABAP developer, a backend service developer may have to work separately from the front-end developers building the client that the service interacts with. That may lead to unnecessary errors and iterations to adapt your code to requirements revealed to you step-by-step and too late.
Hints:
The Gateway Service Builder is an effective tool for modelling OData services with SAP Gateway – but only if you already have a picture of the entity set types and there relations ships in mind. If not, you will likely get lost as soon as you have to define associations, referential constraints and navigation properties, and even more when you start implementing navigation in service operations.
Gateway Service Builder (Transaction Code SEGW)
The SAP-internal data model can be very complex, comprising dozens of business object types with hundreds of attributes and allowing for special cases which may not be needed in your application. If you do not take the chance to simplify the data model exposed by your service, then your service will be harder to understand and to work with for client developers. Moreover, it will show suboptimal performance, as more data will have to be transmitted.
Hints:
SAP OData Modeler for Eclipse
There is some serious criticism against it in SCN, and it is still so true: On of the biggest misunderstandings in Gateway service development is: "There are standard BAPIs for the operations, and you just have to wrap them". Such statements are mostly made by consultants who never looked at the details, or by developers who never worked on complex services yet.
Typical reasons which prevent simple wrapping of existing RFC modules are from my experience:
An unnecessarily long runtime is another drawback of RFC module calls, as far more data is read from the DB than required, but for the first version of the service that may be acceptable. And there are also specific weaknesses of the RFC/BOR generator when used without custom coding, some of which are:
However, the approach of using existing RFC modules and possibly the generator as starting point also has some strengths: It gives you a very quick start with data access using water-proof business logic, some error handling, readiness for Hub deployment and paging (skip/top). Apart from the implementation, I do consent to modelling entity types using the RFC/BOR generator. I believe that´s fine if you plan to use RFC modules as a basis for implementing one or more service operations and if you thoroughly select and rename some properties to have consistent and clear names throughout your model.
Generation of service operation by mapping of RFC Modules with RFC/BOR Generator
Hints:
The Gateway Client is included in SAP Gateway as service testing tool and you should use it – but will you only test HTTP response codes. Particularly with reading operations, it may easily happen that you return a response with missing attribute values due to some mistake in your service implementation. As long as there is no runtime exception the HTTP status code will be 200, and the Gateway Client Test will be green.
Gateway Client /IWFND/GW_CLIENT - will test HTTP response codes, but not body content
Hints:
Let´s face the truth: Performance is often a weakness of SAP systems – and there are some good reasons for it, such as extensive checks of user authorization and input data consistency. However, as service developer you have to do your best to keep response times in an acceptable magnitude. Especially the Query operation of a service (Get entity set) can cause problems. If the implementation is bad in terms of performance, already a few hundred or thousand of datasets in the result set may lead to response times of several minutes.
Hints:
You will find more hints in Gateway Performance Best Practices - How to consume Gateway from performance point of view by David Freidlin.
A number of tasks in service implementation will occur over and over again, e.g. reading filter criteria, get object key values, writing log entries, throwing business exceptions with messages, implementing paging with $skip and $top. Coding that stuff again and again would be a waste of time and mental capacity. Copy & Paste from existing projects is a possible solution, but it´s not particularly convenient and it´s one of the top root causes for errors in code.
Hints:
Editing a simple code template for timestamp creation
Service documentation should at least comprise information on the contained entities and relationships, on the meaning of entity properties and on the relation of entity properties to fields visible to SAP dialog users. If you do provide that information, either you or somebody else will likely spend more time later on understanding the service before being able to work with it than you would have spent documenting it. The OData standard provides some degree of service self-description, however compiling a complete documentation still requires quite some manual effort, which you should take into account when planning service development projects.
Hints:
Portion of a screenshot from Gateway Service Builder as part of documentation of entity type properties
Screenshot from SAP transaction with references to entity type properties as part of the service documentation
Which problems and solutions did you encounter in modelling, implementation, test and documentation of OData services with SAP Gateway? Let´s discuss them.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
5 | |
5 | |
5 | |
5 | |
4 | |
4 | |
4 | |
4 | |
3 | |
3 |