Showing posts with label odata. Show all posts
SAP OData Development with SAP RAP

SAP OData Development with SAP RAP

Sanjo Thomas•03:22:00

SAP provides a comprehensive suite of tools and technologies to streamline business processes. One such powerful combination is SAP OData and SAP RAP (Rapid Application Development), which empowers developers to build scalable and efficient applications. In this blog, we will dive into the realm of SAP OData development using SAP RAP, exploring its key features, benefits, and best practices.



1. Understanding SAP OData:

SAP OData (Open Data Protocol) is a widely adopted industry standard for building and consuming RESTful APIs. It enables seamless data integration between different systems, making it easier to access and manipulate SAP data from external applications. OData follows a resource-oriented architecture, providing a uniform way to expose and consume data via HTTP protocols.


2. Introducing SAP RAP:

SAP RAP, also known as ABAP RESTful Application Programming Model, is a framework designed to simplify and accelerate application development on the SAP Business Technology Platform. It leverages the power of SAP OData to create robust and scalable applications with minimal coding effort. RAP provides a consistent and structured approach to building data-centric applications, enforcing best practices and reducing development time.


3. Key Features and Benefits of SAP RAP:

- Domain-Driven Design (DDD): RAP promotes the use of DDD principles to model and structure applications based on business domains. It encourages developers to focus on business logic rather than technical implementation details.

- Code Generation: RAP leverages code generation techniques to automate repetitive tasks and reduce manual effort. It generates standard CRUD (Create, Read, Update, Delete) operations, user interfaces, and service bindings, allowing developers to quickly bootstrap their applications.

- Data Modeling: RAP offers a rich set of tools for defining data models, including support for associations, validations, and annotations. It enables developers to create a comprehensive data model that aligns with business requirements.

- Authorization and Security: RAP incorporates built-in authorization and security mechanisms, ensuring that only authorized users have access to specific data and operations. It seamlessly integrates with SAP's Identity and Access Management solutions.

- Integration and Extensibility: RAP integrates well with other SAP technologies, such as the SAP Fiori UI framework and SAP Cloud Platform. It also allows for easy extensibility, enabling developers to enhance existing applications without modifying the core codebase.


4. Best Practices for SAP OData Development with RAP:

- Follow the DDD approach to structure your application based on business domains.

- Leverage annotations to provide metadata and enhance the OData service.

- Utilize SAP Web IDE or SAP Business Application Studio for development, as they offer robust tooling and templates for RAP-based projects.

- Implement proper error handling and exception management to ensure robustness.

- Regularly test and optimize performance to maintain a responsive application.

- Stay updated with SAP's documentation and community resources to leverage the latest features and best practices.


SAP OData development using SAP RAP brings immense potential for building efficient, scalable, and robust applications. By leveraging the power of OData and following the principles of RAP, developers can streamline their development process, reduce coding effort, and deliver high-quality applications aligned with business requirements. Embracing this powerful combination can unlock new possibilities in the SAP ecosystem and revolutionize the way enterprise applications are built.

Read more
SAP Gateway and OData Cache Clearing Ways in SAP Fiori Apps

SAP Gateway and OData Cache Clearing Ways in SAP Fiori Apps

Sanjo Thomas•03:32:00

SAP Gateway and OData Cache Clearing Ways in SAP Fiori Apps

SAP Gateway is a key component in the SAP Fiori landscape, responsible for providing a secure and efficient communication layer between SAP systems and external applications. One of the main features of SAP Gateway is its ability to expose SAP backend data to external applications using the OData protocol.



In SAP Fiori, caching is used to improve app performance by storing data and resources in temporary storage. However, sometimes these caches can become outdated or corrupted, leading to issues with the app. In such cases, clearing the cache becomes necessary to resolve the problem. 

When utilizing SAP Fiori apps, it is essential to understand how to clear the OData cache in order to ensure that the data presented is up-to-date and accurate. In this blog, we will explore the different cache clearing methods available for SAP Gateway and OData.


1. Cache Busting Technique

Cache busting is the technique of adding a unique identifier to the URL of the resource being requested. This forces the browser to make a new request for the resource, rather than relying on the cached copy. This method is typically used when there are changes made to the UI or data model, and you want to make sure that the user sees the latest version of the app.


To use cache busting in SAP Fiori, you can add a parameter to the end of the URL that contains a random value. For example:


```

/sap/opu/odata/sap/Z_MY_ODATA_SRV/MyEntitySet?$filter=Field eq 'Value'&cacheBuster=12345

```


This will force the browser to make a new request for the data, even if a cached copy is available.


2. Cache Invalidation

Cache invalidation is the process of removing a cached resource from the cache. This is typically done when the cached resource is no longer valid, such as when data has been updated or deleted. In SAP Fiori, cache invalidation can be done by sending a DELETE request to the cache.


To invalidate the cache in SAP Fiori, you can use the following URL:


```

/sap/opu/odata/sap/Z_MY_ODATA_SRV/$metadata?sap-cache-control=invalidate

```


This will invalidate the cache for the entire service, forcing the browser to request all resources again.


3. Cache Timeouts

Cache timeouts are used to specify how long a resource should be cached before it is considered stale and needs to be refreshed. In SAP Fiori, cache timeouts can be set using the SAP Gateway Service Builder.


To set a cache timeout in SAP Gateway, navigate to the Service Builder and select the service you want to configure. Then, go to the "Technical Settings" tab and set the cache timeout value in the "Caching" section.


4: /ui2/invalidate_global_caches

This method to clear cache in SAP Fiori apps is to use the transaction code /ui2/invalidate_global_caches. This method clears all the global caches, including the SAP Fiori cache, UI cache, OData cache, and others. 


To clear cache using this method, follow the below steps:


1. Open the SAP Fiori launchpad and log in with your credentials.

2. Open a new tab in the browser and enter the transaction code /ui2/invalidate_global_caches.

3. Click on the Execute button or press F8.

4. A pop-up window will appear, asking you to confirm the cache invalidation. Click on Yes to proceed.

5. Wait for the process to complete. The time taken to clear the cache will depend on the size of the cache.


5: /iwbep/cache_cleanup

This method to clear cache in SAP Fiori apps is to use the transaction code /iwbep/cache_cleanup. This method clears the OData cache, which stores metadata and data for OData services.


To clear cache using this method, follow the below steps:


1. Open the SAP Fiori launchpad and log in with your credentials.

2. Open a new tab in the browser and enter the transaction code /iwbep/cache_cleanup.

3. Click on the Execute button or press F8.

4. A pop-up window will appear, asking you to confirm the cache cleanup. Click on Yes to proceed.

5. Wait for the process to complete. The time taken to clear the cache will depend on the size of the cache.


Conclusion

Clearing the OData cache is an essential task when working with SAP Fiori apps. By utilizing the cache busting, cache invalidation, and cache timeout techniques, you can ensure that your apps are always presenting accurate and up-to-date data to the user.

Read more
Association and Navigation in OData

Association and Navigation in OData

Sanjo Thomas•23:47:00
In this blog we will be covering the concept of association and navigation in OData. 

In this tutorial, we will take example of navigating from one Sales Order to the related Sales Order line items, by using a link instead of manually putting a filter together. Moreover, it also allows us to use the $expand statement to fetch the Sales Order together will all the Sales Order line items in one call.

Lets say, we already have created an OData service in SEGW named ZGW100_XX_SO. Double click on Associations.
Press Create button.

Now, Enter the following values for association and press enter:
   

Name

SalesOrderSalesOrderItems

Principal Entity*

SalesOrder

Principal Entity Cardinality*

1

Dependent Entity*

SalesOrderItem

Dependent Entity Cardinality*

M


Now, create a referential constraint for the association
1) Expand the Associations node and the SalesOrderSalesOrderItems node and double-click Referential Constraints:















2) Choose the Create pushbutton:






3) Enter the following values and choose Enter:

Principal Key*

SoId

Dependent Property*

SoId

* This field has an Input Help




Now we create an association set for the association

1. Double-click Association Sets:


2. Choose the Create pushbutton:


3. Enter the values and choose Enter:

Name

SalesOrderSalesOrderItems

Association*

SalesOrderSalesOrderItems


And finally we create a navigation property based on the referential constraint

1. Expand Data Model > Entity Types > SalesOrder and double-click Navigation Properties:


2. Choose the Create pushbutton:

3. Enter the following values and choose Enter:

Name

SalesOrderItems

Relationship Name*

SalesOrderSalesOrderItems

Now we need to re-generate the runtime objects and we’re then ready to test the service

1. Choose the Generate pushbutton:

2. Verify that the runtime objects have been generated successfully:

3. Start the Gateway Client (Transaction /IWFND/GW_CLIENT) in a separate window to run the service. Provide the following URI to get the metadata for the service: 

/sap/opu/odata/sap/ZGW100_XX_SO_SRV/$metadata


The Sales Order collection now includes a navigation property.

4. When you now select a sales order entry using

/sap/opu/odata/sap/ZGW100_XX_SO_SRV/SalesOrderCollection(‘0500000001’), for example, you can simply add the navigation link /SalesOrderItems to navigate to the line items without having to set a filter yourself:


5. And finally you can use $expand to read all sales order items for a given sales order in a single http call.

Simply provide the following URI:

/sap/opu/odata/sap/ZGW100_XX_SO_SRV/SalesOrderCollection(‘0500000001’)/?$expand=SalesOrderItems


The $expand statement is handled by the framework (no additional implementation is required). Since the framework does not know that both entities can be obtained using a single RFC call, it executes two calls to the underlying BAPI. This can be improved by manually implementing (re-defining) the GET_EXPANDED_ENTITY method.

So we are done. The Service is up and running.


























Read more

Introduction to SAP NetWeaver Gateway

Sanjo Thomas•22:32:00

 In this blog, we will get a high level overview of the SAP NetWeaver Gateway. First let us look at SAP NetWeaver Application Server.

What is SAP NetWeaver Application Server?

The SAP NetWeaver Application Server is just like the nervous system of our body. It provides the runtime environment to the SAP applications. All of the SAP Business Suite e.g. ERP, CRM runs on SAP NetWeaver Application Server. Following layers will make it clearer:

Presentation layer 

UI5, Web Dynpro

Business layer (Application Layer)

ABAP/ Java

Integration layer 

SAP PI (Product Integration)

Connectivity layer 

HTTP/HTTPS/SOAP/REST

Persistence layer (Database Layer)

Open SQL

 

What is SAP NetWeaver Gateway?

SAP NetWeaver Gateway helps Application tier to communicate with Presentation Layer. In three-tier architecture, the Presentation layer is GUI (UI5 nowadays) and Database Layer is HANA Database (nowadays).

SAP Gateways is the middle or Application tier. This Application layer is essential for communication between the UI and the backend.

The main motto to use multi-tier architecture was to implement a data processing system that will add a valuable level of modularity and flexibility to the system by developing and maintaining each tier individually. OData is used to exchange data.

What is an OData?

OData which stands for Open Data Protocol is an open source to exchange data over the Internet. It was built by Microsoft.

OData protocol is HTTP based, due to which any programming language with HTTP stack can consume OData services. The output is in the form of JSON or ATOM (i.e. XML).

Why SAP NetWeaver?

Increases Efficiency of business processes by providing role based access

Provides dynamic and cost effective communication between different teams

Multichannel Enterprise access via different devices

Provides development environment using both ABAP and non ABAP languages and connects them all using REST & SOAP APIs.

In this and the previous blog, we had got the high level introduction to OData. From the next blog onwards, we will focus on OData in SAP fiori applications and the use cases.


Read more
Introduction to OData

Introduction to OData

Sanjo Thomas•22:13:00

In this blog series, I will try to cover use cases of OData in SAP Fiori. Lets start with introduction to OData in this blog.

If you plan to expose your SAP Data (Table or Query Data) to external environment like UI5/Fiori or HANA, then you need to push your data in a form of API. By API we mean, using OData we will generate a service link that can be accessed via internet and can be used to perform CRUD operations. SAP OData in SAP ABAP environment is just like another ABAP Class. We can access the methods of this class using SEGW transaction. We can write our required code here for the data manipulation and once we activate the class, the service link that we generate will act accordingly.

Definition

SAP OData is a standard Web protocol used for querying and updating data present in SAP using ABAP, applying and building on Web technologies such as HTTP to provide access to information from a variety of external applications, platforms and devices.

In SAP, we use SEGW transaction code to create an OData Service. SEGW stands for Service Gateway.

Architecture of SAP OData

Here, we will discuss about the High level architecture of SAP OData.



SAP OData High Level Architecture

Why we need ODATA

SAP OData comes with multiple advantages. It not only helps us to expose data but also helps a customer to access data from anywhere and any device. If there will be no OData services, then the data will remain on premise and in case a user needs to access their data, they might have to visit the data location, which is uncomfortable for the digital world.

Advantages of an ODATA

Using SAP OData provides us following advantages:

  • It helps to obtain human readable results i.e. you can use your browser to see the output data
  • It is very easy and relatively fast to access data
  • It uses all the standards of web protocols i.e. GET, PUT, POST, DELETE, and QUERY
  • It uses Stateless Applications: It means Server does not save any data of Client (e.g. UI5 Application) and treats every OData call as a new call
  • It receives data in form of related pieces of information, one leading to another: It is an interaction pattern known as “alert-analyse-act”, “view-inspect-act”, or “explore & act”. According to this pattern not all data are loaded together, and a user analyses a data and reaches its required information after navigation. In this way the data loads quickly and correctly.

SAP OData V2 (Version 2)

OData v2 is a set of new standards which are add-ons to SAP OData V1, and these are as follows:

  • Client-side sorting and filtering
  • All requests can be batched
  • All data is cached in the model
  • Automatic Message handling

You can read more about SAP OData v2 vs OData v1 here.

SAP OData V4 (Version 4)

OData v4 is the latest upgradation to the SAP OData services which comes with some addition and some reduction of features, such as:

  • The new version brings simplification in terms of data binding. The new OData V4 model simplifies the data binding parameter structure.
  • OData v4 requires only asynchronous data retrieval.
  • The Batch groups are solely defined via binding parameters in the new OData v4 calls with the corresponding parameters on the model as default.
  • It supports use of an operation binding. And now it is much easier to bind operation execution results to controls.
  • Create, Read, Update and Delete (Remove) operations are available implicitly via the bindings
  • In OData v4, the Metadata is only accessed via ODataMetaModel

In my next blog, I will try to cover SAP Netweaver Gateway.

 


Read more
Introduction to SAP Fiori

Introduction to SAP Fiori

Sanjo Thomas•02:16:00



Fiori the term actually means “flowers” in Italian, is actually used for personalizing and simplifying the user experience for the SAP Applications. Fiori Apps use SAPUI5 Framework in the Frontend and ABAP coding in the backend. SAP Fiori offers role-based, responsive, simple and Delightful applications. These Fiori applications basically, are apps based on sap itself, like finance apps, sales order apps, purchase order apps, approval apps and similarly.

Basic Design Principles of fiori are Role-Based, Responsiveness, Simple, Coherent, delightful.

Role-Based – Role based would mean, that only some users would have been assigned roles, and only those users would be able to use particular apps. SAP Fiori provides the right information at the right time and reflects the way you actually work.
Responsiveness – The fiori applications are responsive and would adapt any screen and display data accordingly. It enables you to work how and where you want, regardless of the device you use.
Simple – Fiori apps are simple apps, and are not complex, the essential functions are easy to use and one can personalize the experience to focus on their relevant tasks and activities.
 Coherent – SAP Fiori adheres to a consistent interaction and visual design language. Across the enterprise, you enjoy the same intuitive and consistent experience.
Delightful – SAP Fiori was designed to work with ECC 6.0 to make it easy for the users and to deploy on the existing SAP system.

Architecture of SAP FIori

 
 


1) SAP Fiori uses SAPUI5 Framework in the frontend and SAP ABAP in the backend for integration with the SAP.
2) OData is a protocol for transferring data from the backend to the frontend. Using SAPUI5, this model is consumed and the data is populated.
3) SAP ABAP front-end server contains all the UI components of Fiori system and NetWeaver gateway.
4) SAP NetWeaver Gateway is used to setup a connection between SAP business suite and target clients, platforms and framework. It offers development and generation tools to create OData services to different client development tools.
5) SAP ABAP Back-End Server is used to contain the business logic and the back-end data.

SAP NetWeaver Gateway
As stated above, SAP NW is used to setup connection between SAP Business suite and target clients, platforms and frameworks. SAP NetWeaver Gateway is a technology that provides a simple way to connect devices, environments and platforms to SAP software based on market standards. In just simple words, it is a set of ABAP add-ons to the existing SAP ERP system that provides easy access to the business information in a simple way.

SAP NetWeaver Gateway offers connectivity to SAP applications using any programming language or model without the need for SAP knowledge by leveraging REST services and OData/ATOM protocols.

REST: Representational State Transfer is a style of software architecture for distributed systems such as the World Wide Web. REST has increasingly displaced other design models such as SOAP and WSDL due to its simpler style. REST uses the standard GET, PUT, POST & DELETE methods and other existing features of the HTTP protocol. Key goals of REST include Scalability of component interactions, Generality of interfaces, and Independent deployment of components, Intermediary components to reduce latency, enforce security and encapsulate legacy systems.

OData: The Open Data Protocol is an open web protocol for querying and updating data. The protocol allows for a consumer to query a data source over the HTTP protocol and get the result back in formats like Atom, JSON or plain XML, including pagination, ordering or filtering of the data.

Key Benefits of SAP NetWeaver Gateway
1) REST-enables your SAP system, thereby lowering the data consumption barrier to the point that no specialist knowledge of an SAP system is required before SAP business data and functionality can be consumed.
2) Hides the technical complexities of your SAP system landscape behind a single interface that is easy-to-use and non-proprietary.
3) Makes your SAP business data and functionality accessible to any external device or system that can communicate using the HTTP(S) protocol
4) Understand OData messages.
5) Provides Service Provisioning tools that allow the quick REST-enablement of existing ABAP functionality.
6) Provides plug-ins for well-known IDEs such as Eclipse, Visual Studio 2010 and XCode.

This fig. would give you better understanding of Fiori Architecture

 
 
The SAP Web dispatcher is the entry point for HTTP(s) requests into the system. It can reject or accept connections. When it accepts a connection, it selects and appropriate application server and balances the load to ensure an even distribution across the servers.

The ABAP front-end server contains the UI layer with the necessary product-specific UI add-ons for the respective products (Enterprise Resource Planning (ERP) and Supplier Relationship Management (SRM)) as well as the infrastructure components. The infrastructure comprises the central UI add-on with the SAP UI5 control library and the SAP Fiori launch pad as well as SAP NetWeaver Gateway with the OData enablement.

These front-end components have access through a trusted RFC connection to the ABAP back-end server containing the business logic and the necessary integration add-ons with the OData services and the PFCG roles for ERP and SRM.

The underlying database can be any database, and can be accessed from the back-end server. If your back end runs on SAP NetWeaver 7.40, you can also use SAP HANA as a database.


So, this was some introduction to SAP Fiori, more to come, stay tuned!
Read more