Skip to Content
Technical Articles
Author's profile photo Mio Yasutake

Enable App-to-App Navigation in BAS

Introduction

During development of Fiori apps, you may want to test app-to-app navigation in SAP Business Application Studio (BAS). In Web IDE Full-Stack this can be easily achieved by the method described in the following blog post.
Fiori App To App Navigation in Web IDE Full-Stack

Recently I found Fiori tools documentation and learned how to enable app-to-app navigation in BAS. If you are developing a Fiori elements app, you can activate app-to-app navigation with just a few clicks. If you are developing a freestyle app, this method is not available, but you can still enable navigation by following a few manual steps. In this blog, I’m going to demonstrate the both scenarios.

 

Enable App-to-App Navigation between Fiori elements app

If the source and target apps are both Fiori elements apps, it’s easy. The only prerequisite is that the both apps are located in the same workspace.

1. Create source and target apps with Fiori elements

In the example below, the source app shows the a of orders and the target app shows a list of customers. The data source is Northwind OData V2 service.

1.1. Create the source and the target apps using SAP Fiori application template.SAP%20Fiori%20application%20template

 

1.2. Select “List Report Object Page” floorplan.Select%20floorplan

 

1.3. Select Data Source and Service URL.Datasource

 

1.4. Select main entity. I have selected “Orders” for the source app and “Customers” for the target app.Select%20Entity

 

1.5. Specify Project Attributes.Project%20Attributes

 

Select “Yes” for “Add FLP configuration”.Add%20FLP%20configuration

 

1.6. Maintain Fiori Launchpad Configuration. Semantic Object and Action are necessary for app-to-app navigation.FLP%20Configuration

 

1.7. To enable intent-based navigation, add the following annotation to the source (Orders) app.

            <Annotations Target="NorthwindModel.Order">
                <Annotation Term="UI.LineItem">
                    <Collection>
                        <Record Type="UI.DataField">
                            <PropertyValue Property="Value" Path="OrderID"/>
                            <Annotation Term="UI.Importance" EnumMember="UI.ImportanceType/High"/>
                        </Record>
                        <Record Type="UI.DataField">
                            <PropertyValue Property="Value" Path="OrderDate"/>
                            <Annotation Term="UI.Importance" EnumMember="UI.ImportanceType/High"/>
                        </Record>      
                        <Record Type="UI.DataFieldWithIntentBasedNavigation">
                            <PropertyValue Property="Value" Path="CustomerID"/>
                            <PropertyValue Property="SemanticObject" String="Customers"/>
                            <PropertyValue Property="Action" String="display"/>
                            <Annotation Term="UI.Importance" EnumMember="UI.ImportanceType/High"/>
                        </Record>                                           
                    </Collection>
                </Annotation>
            </Annotations>

 

Also, I have added the following annotation to the target (Customers) app so that Customer ID and Company Name are displayed in the Object Page header.

            <Annotations Target="NorthwindModel.Customer">
                <Annotation Term="UI.HeaderInfo">
                    <Record Type="UI.HeaderInfoType">
                        <PropertyValue Property="TypeName" String="Customer"/>
                        <PropertyValue Property="TypeNamePlural" String="Customers"/>
                        <PropertyValue Property="Title">
                            <Record Type="UI.DataField">
                                <PropertyValue Property="Value" Path="CustomerID"/>
                            </Record>
                        </PropertyValue>
                        <PropertyValue Property="Description">
                            <Record Type="UI.DataField">
                                <PropertyValue Property="Value" Path="CompanyName"/>
                            </Record>
                        </PropertyValue>                        
                    </Record>
                </Annotation>
            </Annotations>

 

1.8. Test the source app. It looks like below picture and the Customer ID is displayed as a link.Order%20List

 

However, navigation is not possible yet.Navigation%20error

 

2. Enable App-to-App Navigation

Next, let’s enable app-to-app navigation.

2.1. Open Command Palette and enter Fiori: Enable App-to-App Navigation Preview.

 

2.2. Select the source application.

 

2.3. Select the target application.

 

As a result, the following message is displayed: App-to-App Navigation enabled.

2.4. Execute the source app and this time the navigation should work.
If you select customer “VINET” for example,

 

Customers app opens in the Object Page.

 

3. Behind the scenes

When you enable app-to-app navigation with the command described above, a file named appconfig/fioriSandboxConfig.json is generated.

Also, the following section is added to ui5.yaml.

These settings need to be manually added if you want to enable navigation for freestyle apps.

 

Enable App-to-App Navigation from Free style app

Freestyle apps don’t appear in the source and target app list when you execute “Enable App-to-App Navigation Preview” command. So you need to add some manual configurations to enable navigation.

1. Create a Freestyle app

In the example below, I will create a freestyle app as a source app which shows a list of orders. The target app is the same as the previous example.

1.1.  Create a freestyle app using SAP Fiori application template. Here I have chosen “SAPUI5 Application”.

 

1.2. Select Data Source and Service URL.

 

1.3. Specify Project Attributes and Launchpad Configuration.

 

1.4. Maintain the view code as follows.

<mvc:View
    controllerName="northwind.ordersfreestyle.controller.App"
    xmlns:mvc="sap.ui.core.mvc"
    displayBlock="true"
    xmlns="sap.m"
>
	<Shell id="shell">
		<App id="app">
			<pages>
				<Page id="page" title="{i18n>title}">
					<content>
                        <Table id="table" 
                            items="{path: '/Orders'}" mode="SingleSelectLeft">
                            <headerToolbar>
                            <OverflowToolbar>
                                <content>
                                <Title text="Orders" />
                                <ToolbarSpacer/>
                                <Button text="Nav to Customer" press="onNavToCustomer" />   
                                </content>
                            </OverflowToolbar>
                            </headerToolbar>
                            <columns>
                            <Column>
                                <Text text="Order ID"/>
                            </Column>
                            <Column>
                                <Text text="Order Date"/>
                            </Column>   
                            <Column>
                                <Text text="Customer ID"/>
                            </Column>                        
                            </columns>
                            <items>
                                <ColumnListItem>
                                    <Text text="{OrderID}"/>
                                    <Text text="{path: 'OrderDate', type: 'sap.ui.model.odata.type.DateTime'}"/>
                                    <Text text="{CustomerID}"/>
                                </ColumnListItem>    
                            </items>  
                        </Table>                        
                    </content>
				</Page>
			</pages>
		</App>
	</Shell>
</mvc:View>

The view will show a list of orders and “Nav to Customer” button as below.

 

1.5. Maintain the controller code that triggers navigation.

sap.ui.define([
	"sap/ui/core/mvc/Controller"
],
	/**
	 * @param {typeof sap.ui.core.mvc.Controller} Controller
	 */
	function (Controller) {
		"use strict";

		return Controller.extend("northwind.ordersfreestyle.controller.App", {
			onInit: function () {

            },
            
            onNavToCustomer: function (oEvent) {
                var customerId = this.byId("table").getSelectedContexts()[0].getObject().CustomerID;
                if (sap.ushell && sap.ushell.Container && sap.ushell.Container.getService) {
                    var oCrossAppNav = sap.ushell.Container.getService("CrossApplicationNavigation"); 
                    oCrossAppNav.toExternal({
                        target : { semanticObject : "Customers", action : "display" },
                        params : { CustomerID : [ customerId ] }
                    })
                }

            }
		});
	});

 

2. Enable App-to-App Navigation

Here you will add some configurations manually which would be generated if you use “Enable App-to-App Navigation Preview” command.

2.1. Create test/flpSandbox.html file.

<!DOCTYPE html>
<html>

<head>
	<meta http-equiv="X-UA-Compatible" content="IE=edge" />
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
	<meta name="viewport" content="width=device-width, initial-scale=1.0" />
	<title>Fiori Launchpad Sandbox</title>

	<script>
		window["sap-ushell-config"] = {
            defaultRenderer: "fiori2",
            bootstrapPlugins: {
                "KeyUserPlugin": {
                    "component": "sap.ushell.plugins.rta"
                },
                "PersonalizePlugin": {
                    "component": "sap.ushell.plugins.rta-personalize"
                }
            },
            applications: {
                "masterDetail-display": {
					title: "Order List",
					description: "",
					additionalInformation: "SAPUI5.Component=northwind.ordersfreestyle",
					applicationType: "URL",
					url: "../"
                },
            }
        };
	</script>

	<script id="sap-ui-bootstrap" src="/test-resources/sap/ushell/bootstrap/sandbox.js">
	</script>

    <script id="sap-ui-bootstrap" 
        src="/resources/sap-ui-core.js"
		data-sap-ui-resourceroots='{"northwind.ordersfreestyle": "../"}' 
        data-sap-ui-theme="sap_fiori_3" 
        data-sap-ui-compatVersion="edge" 
        data-sap-ui-async="true"
		data-sap-ui-frameOptions="allow">
	</script>

	<script>
		sap.ui.getCore().attachInit(() => sap.ushell.Container.createRenderer().placeAt("content"));
	</script>
</head>

<body class="sapUiBody" id="content"></body>

</html>

 

2.2. Create appconfig/fioriSandboxConfig.json file.

{
  "applications": {
    "Orders2-display": {
      "additionalInformation": "SAPUI5.Component=northwind.ordersfreestyle",
      "applicationType": "URL",
      "url": "../"
    },
    "Customers-display": {
      "additionalInformation": "SAPUI5.Component=northwind.customers",
      "applicationType": "URL",
      "url": "../resources/northwind.customers"
    }
  }
}

 

2.3. Add the following section to ui5.yaml.

  - name: fiori-tools-servestatic
    afterMiddleware: compression
    configuration:
      paths:
        - path: /resources/northwind.customers
          src: /home/user/projects/customers/webapp
        - path: /appconfig
          src: /home/user/projects/orders-freestyle/appconfig  

 

Finally, start the app and open test/flpSandbox.html.
When you select a row and press “Nav to Customer” button, the Customers app will open and navigate to the Object Page.

 

 

Conclusion

  • You can enable app-to-app navigation for Fiori elements app with Fiori: Enable App-to-App Navigation Preview command.
  • You can enable app-to-app navigation for freestyle apps with manual configuration.

References

Assigned Tags

      20 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Ekansh Saxena
      Ekansh Saxena

      Hi Mio,

      Thanks a lot for this blog. I was actually thinking of it while navigating away from WebIDE.

      I am using VSCode with SAP Fiori Tools extension package and was testing the fiori element navigation. However, when we click on customer id in orders app, it shows error popup stating 'Navigation to this application is not supported.' 

      I cross verified my Semantic Object and Action for target app but availed no benefit. Both my apps are using different ports (8080 for orders and 8081 for customers), is this the root cause for this error?

      BR, Ekansh

      Author's profile photo Mio Yasutake
      Mio Yasutake
      Blog Post Author

      Hi Ekansh Saxena,

       

      Thank you for your comment.

      I think you need to adjust ui5.yaml file of orders project according to your local directory structure.

      I have cloned the project to VS code and made the following change to ui5.yaml, and navigation worked.

          - name: fiori-tools-appreload
            afterMiddleware: compression
            configuration:
              port: 35729
              path: webapp
          - name: fiori-tools-servestatic
            afterMiddleware: compression
            configuration:
              paths: #adjust paths according to your local deirectory structure
                - path: /resources/northwind.customers
                  src: ../customers/webapp
                - path: /appconfig
                  src: ./appconfig

       

      Best regards,

      Mio

       

      Author's profile photo Ekansh Saxena
      Ekansh Saxena

      Thanks Mio Yasutake

      Infact 'fiori-tools-servestatic' were already present in my ui5.yaml file but with absolute path. Changing these to relative paths did the magic. Thanks for your support.

      BR, Ekansh

      Author's profile photo Mahesh Palavalli
      Mahesh Palavalli

      Awesome one Mio Yasutake , this helped me a lot 🙂

      BTW, i am doing for freestyle in BAS and I used the below config, which worked for me and not the one with 'home/user..' , not sure about the reason though..

          - name: fiori-tools-servestatic
            afterMiddleware: compression
            configuration:
              paths:
                - path: /resources/reusedapp
                  src: ../reusedapp/webapp
                - path: /appconfig
                  src: appconfig
      
      Author's profile photo Mio Yasutake
      Mio Yasutake
      Blog Post Author

      Hi Mahesh Kumar Palavalli,

      Thank you for your comment. Good to know that this post was helpful to you and you were able to solve your problem!

       

      Author's profile photo Dhiraj More
      Dhiraj More

      Hi Mio,

      Nice blog. I have a requirement where I have two fiori applications developed on cloud foundry using BAS. I need to call(more of a embed type) one application into one of the tab of other application.

      If you have done something like this then please advise.

       

      Thanks,

      Dhiraj M

      Author's profile photo Mio Yasutake
      Mio Yasutake
      Blog Post Author

      Hi Dhiraj More,

      Thanks for your comment.

      Based on your requirement, embedding the second app as a component might be a good option.

      https://sapui5.hana.ondemand.com/sdk/#/topic/346599f0890d4dfaaa11c6b4ffa96312.html

      Author's profile photo UDAY SHANKAR M S
      UDAY SHANKAR M S

      Hi Mio

      Great blog!!

      I have requirement where from a custom Fiori module of mta application in Cloud Foundry, I want to call a standard fiori application which is deployed on premise on S/4 HANA. For example from one of the table row cell data like a invoice number, clicking on which should take me to a standard fiori application on on premise. Is it possble?

       

      Thanks

      Uday

      Author's profile photo Mio Yasutake
      Mio Yasutake
      Blog Post Author

      Hi Uday,

      Thank you for your comment.

      If your custom app and the standard app are both on BTP Launchpad, you can navigate from the custom app to the standard app.

      I think it is not possible to test it in BAS, though.

      Author's profile photo UDAY SHANKAR M S
      UDAY SHANKAR M S

      Hi Mio

      We are having custom app on btp cloud launchpad and standard app on on premise s/4 hana

      Thanks

      uday

      Author's profile photo Poonam Kshirsagar
      Poonam Kshirsagar

      Hi Uday.

      are you able to resolve this issue

      Author's profile photo Poonam Kshirsagar
      Poonam Kshirsagar

      Hi Mio,

      can you please share some details on above mentioned navigation

      Author's profile photo Mio Yasutake
      Mio Yasutake
      Blog Post Author

      Hi Poonam Kshirsagar,

      The prerequisite is you have both apps (custom app and S/4HANA app) available on the BTP launchpad (SAP Build work zone). To navigate from the custom app to the S/4HANA app, you use the intent (semantic object + action ) of the S/4HANA app.

      How to make S/4HANA apps available on the BTP launchpad is described in the below tutorial.

      https://developers.sap.com/tutorials/cp-launchpad-federation-prepares4hana.html

       

      Author's profile photo Hao Zhang
      Hao Zhang

      Thanks to your blog, I was able to navigate with the above method, but I would like to add a check process for the selected data.

      what should I do (for example, select multiple rows and display only the data of the same date in the navigation destination app)?I couldn't find a place where I could add check logic.

      Author's profile photo Mio Yasutake
      Mio Yasutake
      Blog Post Author

      Hi Hao Zhang,

      Thanks for reading. Below extension can be used to modify properties handed over to the target app.

      Please note this is not for checking, but for modifying navigation context.

      https://sapui5.hana.ondemand.com/#/topic/199a496c5fa544dfbe134b53eaba092e

      Author's profile photo Hao Zhang
      Hao Zhang

      Hi Mio

      Thank you for your reply!

      I checked the link you gave me.

      I'll try this extension method.

      Author's profile photo Hao Zhang
      Hao Zhang

      Hi Mio
      I'm sorry for repeatedly asking questions.

      In navigation settings above,  "Display" of "Semantic Object Action" is being used.

      Are actions other than "Display" also available? For example, Create, Edit, Manage, etc.

      If they are not available by default, could you please explain how to create custom actions?

      From my research, it seems that in S/4, it can be configured through "SPRO," but I couldn't find a way to do it on BTP.

      I appreciate your assistance.

      Author's profile photo Mio Yasutake
      Mio Yasutake
      Blog Post Author

      Hi Hao Zhang,

      If you would like to have the target application open in edit mode, you need to create a custom action. With Fiori tools (guided development), you can easily configure custom actions. Here is the documentation on how to do it manually.

      https://sapui5.hana.ondemand.com/#/topic/7619517a92414e27b71f02094bd08d06.html

      Inside the custom action you can control in which mode (display/edit) the target application should open using the following extension API. There is a parameter "displayMode" which determines the target application's mode.

      https://sapui5.hana.ondemand.com/sdk/#/api/sap.suite.ui.generic.template.extensionAPI.NavigationController/methods/navigateInternal

      Author's profile photo Hao Zhang
      Hao Zhang

      Hi Mio,

      Thank you for your response.

      I checked the provided API but the parameter "displayMode" seems to be used for navigation within an app. Is it also possible to use it for navigation between apps?

      Currently, I'm using the "CrossApplicationNavigation" API as introduced in this blog post. Regarding the "action: "display"", is it customizable?

      I apologize for the repeated inquiries, but I would appreciate your response.

      Author's profile photo Mio Yasutake
      Mio Yasutake
      Blog Post Author

      Hi,

      Sorry for giving a wrong link. Indeed, it was for internal navigation.

      If your target app has different intents (semantic object + action) depending on display or edit mode, you can simply give different action to the "oCrossAppNav.toExternal" method.