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.
cancel
Showing results for 
Search instead for 
Did you mean: 
anant_acharya
Advisor
Advisor
In this blog the following topics are covered:

  • Creating an offline environment for an Extension Business Object

  • Creating content for an Extension Business Object

  • Testing the offline feature


Creating an offline environment for an Extension Business Object

The Repository Explorer has been enhanced for information about the offline capabilities of content within SAP. Here you can find the objects that are offline enabled (e.g. Extension Business Objects, fields, and nodes)


                           Repository explorer view from Cloud Application Studio


You have created an Extension Business Object in your solution. As per your requirement you wish to have access to this Extension Business Object when using the Offline Mode of the SAP Cloud for Customer system.

You start by creating an extension of the Extension Business Object and inserting the annotations:

[OfflineEnabled] for underlying SAP Business Object which is offline enabled.

 

[WithAdministrativeData(IncludeSubnodes)] annotation is not required for extension business object.

In the below example, I have created an Extension Business Object for SAP Business Object Opportunity and extended an extension field to a standard Thing Inspector (TI) via the Extensibility Explorer. A simple validation Onsave event is introduced to raise a custom error.

Steps in detail:

  1. Log into the Cloud Application Studio.

  2. Open the solution containing the Extension Business Object you wish to use offline.

  3. Open the file path "/[BusinessObjectName].xbo".

  4. Add the following annotation to your Extension Business Object:  [OfflineEnabled]

  5. Save and Activate the Extension Business Object                                                                                                                 For consistency purposes, it is recommended to reactivate the entire solution -> Right-click on the solution -> Activate All Items. The corresponding Extension Business Object should now be enabled for Offline mode.



BODL for Opportunity BO


Note:

  • [OfflineEnabled] annotation enhances the Offline Component Model (OCM) of the Extension Business Object which is used for synching the meta data and object data with the user device.

  • The annotation is allowed if the standard business object is offline enabled.

  • If the last shipped version of the Business Object or Extension Business Object was offline enabled and if you try to remove this annotation in development, a maintenance mode check error is thrown, and removal of the annotation is prohibited.


 

Enhancing User Interface Components with extension fields.

If you would like to see extension fields in an offline environment, you would need to add them to the corresponding User Interface Component. You can achieve this by doing the following:

  1. Open the solution containing the BO which earlier created to use offline.

  2. Open the file path "/[BusinessObjectName].xbo"

  3. Right click on enhance screen and choose the TI to extend the custom field.



Creation of UI screens for Offline


Creating offline scripts for the offline environment.

If you would like to execute a custom logic while being in the SAP Cloud for Customer offline environment, you would need to create an offline script for the same. These are separate from the online scripts and have “_Offline” as part of their name. You can currently create actions, event, and validations. You can achieve this by doing the following:

 

  1. Open the solution containing the BO which earlier created to use offline.

  2. Open the file path "/[BusinessObjectName].xbo"

  3. Right click on enhance script file and create a script as per your requirement.

  4. In my example below, the Validation on save has been created to display an error message for the Extension Business Object Opportunity.



Writing script in Validation on Save


 

If you are going offline for the first time, then we would recommend referring to the following blog

https://blogs.sap.com/2020/08/25/creation-of-an-offline-custom-business-object/

It covers:

  • How to login to the offline environment and perform the required offline settings for a business user.

  • To open the test offline environment, you will have to modify the URL adding as explained in the above blog.

  • How to access the generated scripts from the Developer Console in the browser and to find the script search for the solution Y name.


Note: The scripts will only be available when the Extension Business Object instance is opened or is being created.

Now let us test if the validation message is raised for the Item node correctly in our offline environment.


Raising an error in UI


Note: It is important to understand that during a sync the online scripts will be called. Hence if the coding is not reflected in both online & offline scripts the data can vary between the online and offline environments. This means that this error message can potentially only appear in the offline environment if the same error is not being raised in the online script.

 

You can find the parent blog here: https://blogs.sap.com/2020/05/19/offline-feature-in-cloud-application-studio/

Thanks for reading and stay tuned for the upcoming offline blogs.

Regards

Anant
1 Comment