Top Banner
– SAP Gateway Builder – Building OData Services Best Practices Daniel Ridder (V2016-03-09)
15

Daniel Ridder Best Practices SAP Gateway Builder

Apr 11, 2017

Download

Technology

Daniel Ridder
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Daniel Ridder Best Practices SAP Gateway Builder

– SAP Gateway Builder – Building OData Services

Best Practices Daniel Ridder (V2016-03-09)

Page 2: Daniel Ridder Best Practices SAP Gateway Builder

Topics

• Modeling and Creating Entities – Basics

– Namespaces

– Search-Helps

– Re-Use OData Services

• Service Implementation – Mapping

– Extend/Overwrite Mappings

– OData is type based

– SAP Annotations

Hints&Hacks using SAP NetWeaver Gateway Builder for creating „good“ OData-Services

V2016-03-09 Best Practices for SAP Gateway Builder 2

Page 3: Daniel Ridder Best Practices SAP Gateway Builder

MODELING AND CREATING ENTITIES

Best Practices

V2016-03-09 Best Practices for SAP Gateway Builder 3

Page 4: Daniel Ridder Best Practices SAP Gateway Builder

Modeling und Creating Entities • Create an entity via importing a

DDIC-Structure • Do not address the underlying BO

directly for model import Transp. Table DDIC View CDS View BOPF

• Create a DDIC structure instead This structure may look like the

underlying CDS View for instance You are able to append additional

specific runtime fields later

V2016-03-09 Best Practices for SAP Gateway Builder 4

Page 5: Daniel Ridder Best Practices SAP Gateway Builder

Mapping ABAP data types to OData

ABAP

• GUID (RAW16)

OData

• Set manually from Edm.Binary (max. 16) to Edm.Guid (without additional definition)

V2016-03-09 Best Practices for SAP Gateway Builder 5

http://help.sap.com/saphelp_nw74/helpdata/en/54/a326519eff236ee10000000a445394/content.htm

• Use Timestamps as Date information (i.e. last change) with DDIC domains – TZNTSTMPS – TZNTSTMPL

• Edm.DateTime

Common questions:

Page 6: Daniel Ridder Best Practices SAP Gateway Builder

• The namespace of your service equals to the technical service name by default – It is influenced by your ABAP DEVC linked with

the TMS If you have a reserved namespace (i.e.

/acme/) remove all slashes (they are not allowed in the XML schema and SAPUI5 will face problems while addressing search helps)

Use something like a common internet address notation FQDN (i.e. „your.company.project“).

To impress the relation between your service and your Fiori-Application use the same namespace as defined in the WebIDE

V2016-03-09 Best Practices for SAP Gateway Builder 6

Namespaces

Page 7: Daniel Ridder Best Practices SAP Gateway Builder

• Let the Gateway Builder create your search helps directly during model import

• Be sure not creating them twice during another model import

Search Helps

V2016-03-09 Best Practices for SAP Gateway Builder 7

Page 8: Daniel Ridder Best Practices SAP Gateway Builder

Re-Use of Search Helps

• If you have a bunch of common search helps

– Provide a dedicated project (service) for them

– Depending on the count of your search helps it may be worth grouping them into several services

V2016-03-09 Best Practices for SAP Gateway Builder 8

Page 9: Daniel Ridder Best Practices SAP Gateway Builder

• OData 2.0 does not support cross service usage of entities To access a re-use OData-

Service include the specific service

Do not redefine it • Redefinition of a service

doesn't let you create own entities

• It focuses extending and overwriting existing services

V2016-03-09 Best Practices for SAP Gateway Builder 9

Re-Use OData-Services

Page 10: Daniel Ridder Best Practices SAP Gateway Builder

SERVICE IMPLEMENTATION Best Practices

V2016-03-09 Best Practices for SAP Gateway Builder 10

Page 11: Daniel Ridder Best Practices SAP Gateway Builder

• Map your EntitySet when ever possible

Let the Service Adaptation Definition Language (SADL) do the work for you

It will generate the specific design time artifacts (ABAP classes) for you

You do not need to implement OData specifics like „$top“, „$filter“ etc.

When using BOPF your service will be fully CRUD compliant

V2016-03-09 Best Practices for SAP Gateway Builder 11

Mapping during Service Implementation

Page 12: Daniel Ridder Best Practices SAP Gateway Builder

• Mapping can be extended / overwritten – Jump into ABAP Workbench and open your

service implementation *DPC_EXT class – Redefine the appropriate CRUD-Method – Extend: Call the generated super method first

(SADL) – Extend/Overwrite: Add your specific code

• Use it to provide your additional transient fields (go back to slide „Modeling und Creating Entities“)

V2016-03-09 Best Practices for SAP Gateway Builder 12

Extend or overwrite your Mapping

Call the super-method to extend your mapping

Add your own code for extending/ overwriting

Page 13: Daniel Ridder Best Practices SAP Gateway Builder

Do not force generic programming – An OData service points to a

specific well formed resource – You deal with typed data – Implementing the CRUD interface-

methods directly will force you to code OData-specifics move the identification of types to

another place where you have to do it on your own

Redefine the typed CRUD-methods of your generated *DPC class

V2016-03-09 Best Practices for SAP Gateway Builder 13

OData is type based

Page 14: Daniel Ridder Best Practices SAP Gateway Builder

• Are essential for SAPUI5 SmartControls like SmartTable

• Needed for UI Adaptation at Runtime

V2016-03-09 Best Practices for SAP Gateway Builder 14

SAP Annotations

Page 15: Daniel Ridder Best Practices SAP Gateway Builder

Daniel Ridder @nielseabap

Thank you.

V2016-03-09 Best Practices for SAP Gateway Builder 15