Extending SAP Fiori My Inbox 2.0 in SAP Web IDE
Prerequisites:
You must have a working implementation of My Inbox on your Fiori Frontend Server (FES). This document assumes My Inbox is deployed on your ABAP system.
The entire flow is performed in SAP Web IDE, therefore most of it also applies if the application is deployed on HCP.
For detailed information on My Inbox in general visit the Fiori Apps Library.
Creating an Extension Project
The first thing you need to do is to create an extension project. This project references My Inbox and therefore must be deployed to the same system your original application resides on.
- Open SAP Web IDE and select File > New > Extension Project.
- In the wizard, click Select Application and choose SAPUI5 ABAP Repository from the dropdown list.
- Select the ABAP system containing My Inbox from the System Wait for the applications to load and then search for My Inbox.
- Select the application from the list and click OK.
The fields in the wizard should be populated with the original application name and a suggestion for the new extension project name. You may rename it if needed.
- Click Next. The confirmation step is displayed. It contains a confirmation message and a checkbox. Leaving the checkbox selected will cause the extensibility pane to open once the project is generated. For the purpose of this guide, leave it on.
- Click Finish. Your extension project is generated and you may start customizing your application.
Using the Extensibility Pane
Most of the extensions available can be easily performed in the extensibility pane tool.
To open it, choose an extension project and from the menu bar, choose Tools > Extensibility Pane.
Using the Extensibility pane allows you to see which UI extensions are available and how they will impact your application. The outline on the right shows the structure of the parent application and visual ques to indicate extensions, while the preview on the left allows you to extend the UI in an intuitive way and provides a real-time preview of the extensions made. The extensibility pane also allows you to remove most extensions. Finally, it is possible to use this tool in conjunction with mock data if you have no OData service to work with or if it isn’t available.
In this example, we will extend the list of items and change the its format.
- Click the arrow next to the Preview Mode text and select Extensibility Mode.
Now the application UI is locked. If you hover over a control it is highlighted in blue, and if you click on one, it is selected both in the application and in the Outline.
- In the Outline, from the dropdown list, choose Show extension points.
This will filter the Outline to show extension points while maintaining the structure, so you can see where each extension point is located.
Note: There are more filtering options to make searching for specific elements easier. - Expand the elements under S2 until you reach the node named CustomerExtensionForObjectListItem with a wrench icon next to it.
- Right-click on the node and choose Extend.
- In the popup that appears choose Open Extension Code. The Extensibility pane closes and the code editor opens with the fragment that will replace the extension point. The fragment contains the XML written inside the extension point in the original application or, if no content is available, a commented code snippet as an example of a valid XML that you can add to the application.
To view your changes, simply run the application by clicking or right click the project folder and select Run > Run as > Web Application.
You can repeat the process and perform other UI extensions such as hiding controls and extending a controller.
Using the Layout Editor
To speed things up we will modify the fragment created in the last step using the Layout Editor. This is a visual tool for building UI based on SAPUI5, allowing fast UI composition and also assistance with data binding and event handling. It is divided into three major areas:
- The Outline and the Controls tabs: The left-most part of the editor. The control pallet enables you to drag and drop controls into the UI and the Outline view shows the UI structure.
- The Canvas: At the center of the editor, this is where the UI is rendered. It allows you to see the changes you are making as they happen, to focus on different elements, to move them around, and more.
- The Properties pane: The right side of the editor, listing all the properties of the currently selected control and also the event bindings when dealing with views.
For more information on the layout editor, see here.
Right now we will focus on the Canvas and the Properties pane:
- Right-click on the new fragment created in the extension project folder and go to Open With > Layout Editor. Make sure the Properties pane title is Xml View. If not, click on the gray background of the list item template.
- From the Data Set dropdown list, choose TaskCollection. This will enable the editors’ data binding feature. When prompted, click OK to confirm your action.
- In the canvas, select the “{CustomAttributeData, taskDefinitionsModel>/}” attribute. The Properties pane is populated with the relevant data.
- Click the Binding icon next to the input field of the Text
This will bring up the data binding dialog. In it, you can see the data structure on the left and the binding expression on the right. You can search for data fields, labels or strings for binding.
- Enter the following binding expression:
{ parts: [{path: 'SAP__Origin'}, {path: 'Status'}], formatter: 'cross.fnd.fiori.inbox.Conversions.formatterStatus'}
This expression will replace the previous data to show the status of the item (for example, “Ready”, “In Progress”).
- Click OK and you will notice the canvas has been updated with the bound properties.
- Choose the “{CompletionDeadLine}” attribute from the left column of the control and open the Binding dialog box of the Text
- Delete the current expression, and search for “processor”. Double click on the “ProcessorName” data field and it will be added to the binding expression. Click OK.
- Save the changes to the file and run the application to see that the list items on the left of the applications have changed.
Next we will modify the application logic. To do this we will use the Extension Wizard to extend the controller of a view and implement an extension hook. These hooks are placed in key flows of applications and are documented in the SAP Help Portal.
Using the Extension Wizard
The extension wizard supports all the extensions available from the extensibility pane, but is mainly used for non-UI extensions such as service replacements.
- Right-click on the extension project folder and choose New > Extension.
- In the first wizard step, verify you are extending the correct project, if not change the path to the relevant extension project folder. Click Next.
- Choose the Implement UI Controller Hook tile and click Next.
- From the Controller dropdown list, choose S2.
- From the UI Controller Hooks dropdown list, choose extHookChangeFilterItems.
- Click Next and then Finish.
SAP Web IDE will display the extended controller in the code editor with the extension hook ready for you to enter your code. This particular extension hook allows you to add custom categories and items to the filter selection dialog.
Now repeat the same process with the extHookGetCustomFilter hook also found in S2. This extension hook allows you to implement custom hooks based on the filters the user has chosen in the filter dialog and to modify existing filters. To demonstrate, replace the empty hooks with the following snippet:
extHookGetCustomFilter: function(oFilterOptions) {
for (var key in oFilterOptions.selectedFilterOptions) {
if (oFilterOptions.selectedFilterOptions.hasOwnProperty(key) && key) {
var aKeyParts = key.split(":");
if (aKeyParts[0] === this._SORT_HASATTACHMENTS) {
var oAttachmentsFilter = new sap.ui.model.Filter(aKeyParts[0], sap.ui.model.FilterOperator.EQ, aKeyParts[1] === "true");
oFilterOptions.additionalFilters.push(oAttachmentsFilter);
}
}
}
},
extHookChangeFilterItems: function(aFilters) {
var oi18n = this.getView().getModel("i18n").getResourceBundle();
var oCustomCategory = this._createFilterCategory("Additional");
var sHasAttachments = this._SORT_HASATTACHMENTS + ":true";
var oCustomFilter = this._createFilterItem(sHasAttachments, oi18n.getText("sort.hasAttachments"));
oCustomCategory.addItem(oCustomFilter);
aFilters.push(oCustomCategory);
}
This will create a new filter category and list item in the filter dialog box and a model filter showing only items with attachments.
To see it in action, save the change and run the application preview, then click on the funnel icon at the bottom of the list. A new category called Additional appears in the dialog box. In it you will find the Attachments filter.
Deploying the Extension Project
Once the extension project is customized according to your needs, deploy it to the same system where the original application is stored.
If you aren’t sure whether it was already deployed in the past or you wish to get an update on its status, open the extension project’s context menu and select Deploy > Application Status.
For detailed information on how to deploy applications from within SAP Web IDE to an ABAP system see here.
This guide assumes this is the first time the project is deployed:
- Select the extension project and the extension project’s context menu select Deploy > Deploy to SAPUI5 ABAP Repository.
- In the wizard, choose the system which contains the original My Inbox
If an application with the same namespace already exists on the system you will get a warning. We recommend you change the namespace of the application before proceeding. - Make sure the Deploy a new application radio button is selected and click Next.
- Provide a name for the deployed application along with a description.
- Click Browse to search for a package to assign it to and then click Next.
NOTE: If your ABAP system does not support transports for any reason, or you chose a local package, the wizard will forward you to the confirmation page. - Select the transport for your package. The wizard lets you either create a new one, input an existing request number, or choose from a list of transports related to you.
- Click Next and then confirm by clicking Finish.
You can follow the deployment process in the SAP Web IDE console.
Deploying an application also performs a build process on it and saves the result into a “dist” folder inside the project. The content of this folder is the actual deployed artifact and is overwritten with each deployment. You can delete this folder once deployment has finished.
Registering to SAP Fiori Launchpad
To enable access to your extended My Inbox application, add a tile for it in the relevant SAP Fiori Launchpad. For more information on how to do this on ABAP see:
Great post. Thanks!
Hello Yevgeni Strongin,
Nice blog… Thanks…!!!
I’m working on 1610, My Inbox 2.0. And need to extend the same. We would like to add/remove some of fields from the header (only for Purchase Order Approval workitem). I’m following the same step by creating an extension project. But when opening the page in extensibility pane, nothing is appearing and when I see the error log as below.
Failed to load resource: the server responded with a status of 404 (Not Found)
send @ sap-ui-core.js:49
sap-ui-core.js:160 2017-04-04 09:17:53.222875 [visual_ext_index.html] No component handle available for ‘cross.fnd.fiori.inbox.CA_FIORI_INBOXExtension1’; fallback to component.load() – sap.ushell.components.container.ApplicationContainer
K @ sap-ui-core.js:160
sap-ui-core.js Failed to load resource: the server responded with a status of 404 (Not Found)
send @ sap-ui-core.js:49
sap-ui-core.js:160 2017-04-04 09:17:53.423969 [visual_ext_index.html] registerResourcePath (‘cross/fnd/fiori/inbox’, ‘/sap/bc/ui5_ui5/sap/CA_FIORI_INBOX/’) – sap.ui.ModuleSystem
2sap-ui-core.js Failed to load resource: the server responded with a status of 404 (Not Found)
send @ sap-ui-core.js:49
sap-ui-core.js:469 Uncaught TypeError: Cannot read property ‘RendererExtensions’ of undefined
at constructor.onInit (webidetesting6578789-db152b58a.dispatcher.us2.hana.ondemand.com/sap/bc/ui5_ui5/sap/CA_FIORI_INBOX/Component-preload.js?eval:5)
at f.a.fireEvent (sap-ui-core.js:451)
at f.a.fireEvent (sap-ui-core.js:1002)
at f.fireAfterInit (sap-ui-core.js:580)
at f.c._initCompositeSupport (eval at evalModuleStr (sap-ui-core.js:174), <anonymous>:908:1158)
at sap-ui-core.js:463
at f.constructor (sap-ui-core.js:463)
at f.constructor (sap-ui-core.js:982)
at f.constructor (sap-ui-core.js:817)
at f [as constructor] (sap-ui-core.js:645)
sap-ui-core.js:160 2017-04-04 09:18:02.498875 [visual_ext_index.html] Cannot get UI2ShellService – Error: Service UI2ShellService not declared! cross.fnd.fiori.inbox.Component
Hi Sameer,
The symptom you describe can be a result of several causes. Based on the error it doesn't seem like it's related to the extensibility framework itself.
Is the original application running correctly for you (e.g. open it using Fiori Launchpad)? Does it run if you import My Inbox into Web IDE and try to preview it?
If you have a license I suggest you open a ticket and provide the information above in addition to your detailed flow and screenshots. Otherwise, contact me by email with the details and we'll continue from there.
Best Regards,
Yevgeni Strongin
Sameer, hope things are good on your side. I have same error that you have posted here, did you find a solution for the error?
your reply is highly appreciated
Hi Sudheer,
Did you find the solution? I am facing the same issue..
No, extension pane still doesn't work on our IDE. So we have implemented the code with out extending pane by just right clicking on the project and adding extension. it opens a code in text editor and start adding our custom code.
Hi Sameer,
Even i am getting error:
No component handle available for ‘cross.fnd.fiori.inbox.CA_FIORI_INBOXExtension1’; fallback to component.load() – sap.ushell.components.container.ApplicationContainer
If you get fix for it please do share?
Hi Guys, I am getting the same issue on the standard application UI2ShellService not declared! cross.fnd.fiori.inbox.Component .
Have you found a solution for it?
Hello everyone!!
I'm facing the same problem. The extending pane is empty. Has anyone found the cause?
Hi All,
i was having the same issue as @sameer Bhavar. However instead "run as webapp" try running component with FLP Sandbox.
run->Configurations.
I got it working this way. I am not a big fan of submitting the project to repository (ABAP in my case) until i can see some output 😛
Cheers,
Kashif
Hi Kashif,
I have similar issue:
No component handle available for 'cross.fnd.fiori.inbox.CA_FIORI_INBOXExtension1'
I tried executing it with FLP sandbox but while using this option it says "Could not open App"
If you get any further details on it please do share.
Thanks & Regards,
Ashwini
Thanks a lot Kashif, works!!
But with a Defaut user, not my user. It's right? Open a lot of data but fictitious, so I mark the checkbox "Run with mock data" and then the data it was empty.
It's possíble open with my user?
If not, even with the dummy data, the approve and reject button did not appear.
How to show the buttons in this case?
Best regards!
Sorry Kashif everything works!! my problem was the cache.
Thanks a lot
Hi Yevgeni Strongin,
Nice blog!
Even I have implemented a controller hook to 'My Inbox' applicationand deployed it as new BSP application, now I have used same tile(which was there for standard Inbox) and same intent navigation and updated the URL and app ID in the target mapping, but the intent is loading only the old Inbox 'CA_FIORI_INBOX' but not my new extended bsp app.
Now, If I create a new tile with different intent(same semantic object and different action) then my extension hook implemented app is getting loaded along with zca_fiori_inbox but the tile title and sub title are not translating when logged in with different language, as we have implemented an
extension hook to standard app I believe the standard inbox intent navigation should work for
the extended one so we can use the same tile and the translations wont be broken.
Please suggest a way for using the same intent for my extension hook app so that the app tile will auto translate the title and sub title in all languages supported by My Inbox.
Regards,
Bhargavi