cancel
Showing results for 
Search instead for 
Did you mean: 

No Mock data when running App from FLP

agnihotro_sinha2
Active Contributor
0 Kudos

Hi,

I have been able to register my App(created on Hana webide trial) on the trial FLP.

But the thing is that although I am able to run the App using Mock data from WebIDe, I am not able to run with mock data OR no mock data comes up if I run the App from Fiori LaunchPad. Any idea what step am I missing?

I have already configured project settings and Mock data settings.

Thanks,

Ags

Accepted Solutions (1)

Accepted Solutions (1)

This is what I've done to make it working:

1 - I created a new SAP Fiori Master-Detail application using the ES4 Public Gateway system. I used the GWSAMPLE_BASIC service: then I used the Products collection for the Master  view and the SalesLineItemCollection for the Detail view

2 - I had to remove the sorter from the Master.view.xml file from line 37 to 40 because this collection cannot be sorted on Name, but this should not influence this process

3 - I removed all the Run Configurations just to be sure that it's using the new one

4 - I tested the app  in Web Preview by selecting the Component.js file and clicking on Run and it worked fine

5 - Then I edited the Component.js file adding the code

  sap.ui.require([

  "com/test/mock/localService/mockserver"

  ], function (mockserver) {

  // set up test service for local testing

  mockserver.init();

  });

just in between the string "this.getRouter().initialize();" and the "}" closing the init function. Pay attention that in the rquire function the path to the mock server must match the name of the namespace specified in the Component.js file.

I saved the Component.js file

6 - I executed again the Component.js file and now the application starts automatically with mock data

7 - I deployed the app to the HANA Cloud Platform

8 - When finished, I registered the app to SAP Fiori Launchpad by clicking on the "Register to SAP Fiori launchpad" button

9 - When finished, I clicked on the link "Open the registered application"

10 - The application works with mock data on the FLP

The only issue I found is that, when I start again the application by using the direct link to it, the first time it asks me for the credentials to the real server. I just press "Cancel" and then "Retry" on the next error message and the mock data appear.

Regards,

Simmaco

danreg
Advisor
Advisor
0 Kudos

Hi Simmaco,

very interesting! Thanks a lot for sharing.

Similarly to yours, when I carry out the steps described, I get the following error pop-up when launching the deployed app from the launchpad:

Sorry, a technical error occurred! Please try again later.

{

  "requestUri": "/here/goes/your/serviceurl/$metadata?sap-documentation=heading",

  "statusCode": 404,

  "statusText": "Not Found",

  "headers": [],

  "body": "<html><head><title>Error report</title></head><body><h1>HTTP Status 404 - Not Found</h1></body></html>"

}

Clicking Retry shows the mockdata. Any idea how to avoid this?

Thanks and regards Daniel

renne_bueno
Explorer
0 Kudos

Hello Daniel,

Did you solve this issue? If so what is the solution?

Thank you.

pavlo_denysyuk
Participant
0 Kudos

What I have done is declared model in controller file.

var data = {

  request: [

  {

  "requestId": "SAP-6895",

  "ID": 6895

}

}

var oModel = new sap.ui.model.json.JSONModel();

oModel.setData(data);

Former Member
0 Kudos


SIMMACO FERRIERO


Thank you. Suggested approach is working . when there is no index.html maintaining proper namespace got it working.

sap.ui.require([

  "com/test/mock/localService/mockserver"

  ], function (mockserver) {

  // set up test service for local testing

  mockserver.init();

  });


And using edit mockdata on right click of metadata.xml could create data and could succesfuly run and test in FLP. its working!


former_member187069
Participant
0 Kudos

Hi,

You can configure a dummy service(say northwind service) and use that request url in place of "here/goes/your/serviceurl" in manifest.json.

"ach": "ach",

  "resources": "resources.json",

  "dataSources": {

  "main": {

  "uri": "/northwind/V2/Northwind/Northwind.svc/",

  "type": "OData",

  "settings": {

  "odataVersion": "2.0",

  "localUri": "localService/metadata.xml"

  }

  },

  "Northwind.svc": {

  "uri": "/northwind/V2/Northwind/Northwind.svc/",

  "type": "OData",

  "settings": {

  "odataVersion": "2.0",

  "localUri": "localService/metadata.xml"

  }

  }

  },

Regards,

Vishnupriya

Answers (6)

Answers (6)

0 Kudos

Hi, i also have the same Problem which I try to solve for hours now. I can deploy the App from WebIDE but when openin FLP no mockup data are shown,page is empty.

Does any one have make this working? And how?

meni_tito
Explorer
0 Kudos

Hi Pavlo, Rene,

Mock server is supported by FLP, if it works in Web IDE scenario it should work for FLP.

Please describe your scenarios.

Thanks,

Meni

Former Member
0 Kudos

Hi Meni,

In my case it doesn't work same way. When it runs on LPD following error occurs:

Why does this happen?

Thanks,

Jaime

meni_tito
Explorer
0 Kudos

Hi Jaime,

You are referring to Cloud FLP, right?

Thanks,

Meni

Former Member
0 Kudos

Hi Meni,

Right, it happens in the Cloud FLP.

I force the use of Mock Server

Then if it runs standalone in Web IDE it works

But if I run it via Cloud LPD this error happens:

Any clue why this happens?

Thanks for your help!

Regards,

Jaime

pavlo_denysyuk
Participant
0 Kudos

Hey , Meni.

I am struggling with the same problem. Could not present Fiori app in launch pad for customers as backend is not even accessible and mock data is not loaded in FLP case.

Did you solve that somehow ?

former_member299909
Discoverer
0 Kudos

I have the exact same original issue... and the answer is not given yet

Background:


1. Created Hana Cloud Platform Trial

2. Enabled all services including SAP HANA Cloud Portal (needed for FLP)

3. Use "WebIDE" to create an application

     a. chose "Sample application" > "Shop"  (this creates a project "nw.epm.refapps.ext.shop")

I can run it with MockData from the WebIDE when I choose to run it as WebApplication and choose: /webapp/test/testFLPService.html

That works fine.

Now for a demo I want to deploy this application to the HANA Cloud Platform and Register it in my HANA Cloud Portal > FLP page. WITH MockData as I don't have the resources to setup a real oData services now.

I cannot understand why this isn't possible. If it works form the WebIDE when run as "WebApplication" why can it not work with MockData when it is deployed and registered in FLP?

FYI everyone can recreate the issue just by using a trial and a copy of the demo app "Shop".

Thanks in advance.

B.

michal_keidar
Active Contributor
0 Kudos

Hi,

It seems that this feature is not yet supported in FLP, it should be soon.

Regards,
Michal.

meni_tito
Explorer
0 Kudos

Indeed, the upcoming version of Cloud FLP will support working with Mock server

- Meni

agnihotro_sinha2
Active Contributor
0 Kudos

Wow, if thats an official answer, then it brings an interim solution to my issue. I thought I was messing up with the code/process because of which I was not getting the data.

Thanks and let me keep the thread open until we have a final solution.

Regards,

Ags

benjamin_houttuin
Active Contributor
0 Kudos

Michal and Meni, thanks for the replies. Much apreciated

Any ETA on this release?

Former Member
0 Kudos

Hello Meni, Michal,

Is this feature already official? In fact having mock server running on Launchpad would be great for demos.

BR,
Jaime

meni_tito
Explorer
0 Kudos

Mock server is supported by Cloud Fiori Launchpad.

What is the relevant scenario?

Former Member
0 Kudos

Hello Meni,

I've just set it to always force Mock Server in my app component this way in my onInit method:

this._startMockServer(sServiceUrl);

The method itself looks like this:

  _startMockServer: function(sServiceUrl) {

  jQuery.sap.require("sap.ui.core.util.MockServer");

  var oMockServer = new sap.ui.core.util.MockServer({

  rootUri: sServiceUrl

  });

       console.log(oMockServer);

    

  oMockServer.simulate("model/metadata.xml", "model/");

  oMockServer.start();

  sap.m.MessageToast.show("Mock data runs", {

  duration: 4000

  });

  },

This works well when running it standalone from Web IDE. However, when running on the Fiori Launchpad this error occurs:

Do you have an idea why this happens?

Is there otherwise a way to make apps run with mock data on launchpad? Perhaps using parameters?

Thanks a lot!

Jaime

daniel_ruiz2
Active Contributor
0 Kudos

Hi Jaime,

Seems to me you have a dependency to a version that does not work well.. why don't you just re-package the MockServer dependencies into your own application and re-deploy?

You can resolve the files, either the same ones WebIDE is using, or OpenUI5.. you can actually choose.. this should very likely fix your issue.

Cheers,

Dan.

Former Member
0 Kudos

Hi Daniel,

First of all, thanks a lot for your help! Now sorry for my dummy beginner question, but how could I re-package the MockServer dependences into my application? Sorry I'm not quite sure what you mean...

Cheers,

Jaime

daniel_ruiz2
Active Contributor
0 Kudos

hi Jaime,

you do what SAP does, but in your own application.. so you're not loading something from the UI5 "deployed version" but rather from your own namespace.

https://github.com/SAP/openui5/blob/master/src/sap.ui.core/src/sap/ui/core/util/MockServer.js

This is the MockServer.. download, copy to your project and load from there.. there is a dependency to sinon and some other mockserver classes, like annotation handler.. (which is probably what's giving you trouble in the parse method)

Cheers,

Dan.

Former Member
0 Kudos

Hi Daniel,

Many thanks!! So as I understand, I should load the MockServer locally, something like this, right?

So far I was referencing the MockServer in my component.js as shown below

How should I invoke my local server now? I guess it should be something like

It however contains a syntax error. Any ideas?

BR,

Jaime

daniel_ruiz2
Active Contributor
0 Kudos

hi Jaime,

yeah, pretty much.. you "add" all dependencies of MockServer (like sinon, etc) into your own project and instead of loading from the UI5 resources you load the one in your own namespace.

reason for such is, it would appear there is some sort of issue going on, not on your own code but rather maybe a bug with the UI5 version you're using.. this would remove doubts as you're loading code you control.

probably best to upgrade your UI5 library afterwards so you don't replicate files and versions everywhere - but as a workaround (and to test a solution) it should work.

Cheers,

Dan.

agnihotro_sinha2
Active Contributor
0 Kudos

Hi,

I created a fresh new Kaspel App and did all the config/deployment so as to register it in my FLP.

But now I am not able to run the APP itself in FLP. Below are the screen shots. Can anyone tell me where am I wrong?

This is the response when I click my APP in FLP

The strange thing is that if I am registering a NORMAL fiori App I can open it, but when its Kaspel App, I get this error.

- Ags

agnihotro_sinha2
Active Contributor
0 Kudos

Thinking from a different angle, is it an account specific limitation since I am having trial accounts for both my CLOUD as well as LOCAL Webide ??

michal_keidar
Active Contributor
0 Kudos

No it is not related to the fact you're using trial account

michal_keidar
Active Contributor
0 Kudos

Please attach the Component.js of your application, it might need a small addition

agnihotro_sinha2
Active Contributor
0 Kudos

jQuery.sap.declare("Flight_app.Component");

jQuery.sap.require("Flight_app.MyRouter");

sap.ui.core.UIComponent.extend("Flight_app.Component", {

  metadata : {

  name : "Flight_app",

  version : "1.0",

  includes : [],

  dependencies : {

  libs : ["sap.m", "sap.ui.layout"],

  components : []

  },

  rootView : "Flight_app.view.App",

  config : {

  resourceBundle : "i18n/messageBundle.properties",

  serviceConfig : {

  name: "",

  serviceUrl: ""

  }

  },

  routing : {

  config : {

  routerClass : Flight_app.MyRouter,

  viewType : "XML",

  viewPath : "Flight_app.view",

  targetAggregation : "detailPages",

  clearTarget : false

  },

  routes : [

  {

  pattern : "",

  name : "main",

  view : "Master",

  targetAggregation : "masterPages",

  targetControl : "idAppControl",

  subroutes : [

  {

  pattern : "{entity}/:tab:",

  name : "detail",

  view : "Detail"

  }

  ]

  },

  {

  name : "catchallMaster",

  view : "Master",

  targetAggregation : "masterPages",

  targetControl : "idAppControl",

  subroutes : [

  {

  pattern : ":all*:",

  name : "catchallDetail",

  view : "NotFound",

  transition : "show"

  }

  ]

  }

  ]

  }

  },

  init : function() {

  sap.ui.core.UIComponent.prototype.init.apply(this, arguments);

  var mConfig = this.getMetadata().getConfig();

  // Always use absolute paths relative to our own component

  // (relative paths will fail if running in the Fiori Launchpad)

  var oRootPath = jQuery.sap.getModulePath("Flight_app");

  // Set i18n model

  var i18nModel = new sap.ui.model.resource.ResourceModel({

  bundleUrl : [oRootPath, mConfig.resourceBundle].join("/")

  });

  this.setModel(i18nModel, "i18n");

  var sServiceUrl = mConfig.serviceConfig.serviceUrl;

  //This code is only needed for testing the application when there is no local proxy available

  var bIsMocked = jQuery.sap.getUriParameters().get("responderOn") === "true";

  // Start the mock server for the domain model

  if (bIsMocked) {

  this._startMockServer(sServiceUrl);

  }

  // Create and set domain model to the component

  var oModel = new sap.ui.model.odata.ODataModel(sServiceUrl, {json: true,loadMetadataAsync: true});

  oModel.attachMetadataFailed(function(){

            this.getEventBus().publish("Component", "MetadataFailed");

  },this);

  this.setModel(oModel);

  // Set device model

  var oDeviceModel = new sap.ui.model.json.JSONModel({

  isTouch : sap.ui.Device.support.touch,

  isNoTouch : !sap.ui.Device.support.touch,

  isPhone : sap.ui.Device.system.phone,

  isNoPhone : !sap.ui.Device.system.phone,

  listMode : sap.ui.Device.system.phone ? "None" : "SingleSelectMaster",

  listItemType : sap.ui.Device.system.phone ? "Active" : "Inactive"

  });

  oDeviceModel.setDefaultBindingMode("OneWay");

  this.setModel(oDeviceModel, "device");

  this.getRouter().initialize();

  },

  _startMockServer : function (sServiceUrl) {

  jQuery.sap.require("sap.ui.core.util.MockServer");

  var oMockServer = new sap.ui.core.util.MockServer({

  rootUri: sServiceUrl

  });

  var iDelay = +(jQuery.sap.getUriParameters().get("responderDelay") || 0);

  sap.ui.core.util.MockServer.config({

  autoRespondAfter : iDelay

  });

  oMockServer.simulate("model/metadata.xml", "model/");

  oMockServer.start();

  sap.m.MessageToast.show("Running in demo mode with mock data.", {

  duration: 4000

  });

  },

  getEventBus : function () {

  return sap.ui.getCore().getEventBus();

  }

});

0 Kudos

Hi,

you can follow this blog if you want to completely embed mock data in your Fiori app: in this way it will always use mock data.

Regards,

Simmaco

michal_keidar
Active Contributor
0 Kudos

Hi,

After this line:

var sServiceUrl = mConfig.serviceConfig.serviceUrl;


Add this line:

sServiceUrl = oRootPath + "/" + sServiceUrl;


Then redeploy your app and try again.


Regards,

Michal.

agnihotro_sinha2
Active Contributor
0 Kudos

if i insert this line :

var sServiceUrl = mConfig.serviceConfig.serviceUrl;

  sServiceUrl = oRootPath + "/" + sServiceUrl;

I am not able to run the App using Mock data anymore from Webide. And from FLP too as usual, no data is coming up.

michal_keidar
Active Contributor
0 Kudos

Just to make sure, you only entered this line:

sServiceUrl = oRootPath + "/" + sServiceUrl;


right?

agnihotro_sinha2
Active Contributor
0 Kudos

Yes.

Maybe the Chrome debugger response might help:

var sServiceUrl = mConfig.serviceConfig.serviceUrl;

sServiceUrl = "", mConfig = Object {resourceBundle: "i18n/messageBundle.properties", serviceConfig: Object}

sServiceUrl = oRootPath + "/" + sServiceUrl;

oRootPath = "/sap/fiori/flightapp"

sServiceUrl = "/sap/fiori/flightapp/"

  //This code is only needed for testing the application when there is no local proxy available

  var bIsMocked = jQuery.sap.getUriParameters().get("responderOn") === "true";

bIsMocked = false


// Start the mock server for the domain model

  if (bIsMocked) {

this._startMockServer(sServiceUrl);

  }


- Ags

michal_keidar
Active Contributor
0 Kudos

Actually this workaround is not for running with mock data, but rather for running a real service. Since your sServiceUrl is "" I understand there's no service. I'm not familiar with the possibility to run app from FLP with mock data. Have you checked if Simmaco's link is helpful?

agnihotro_sinha2
Active Contributor
0 Kudos

Hi,

I was presuming that I can straight away deploy my hana webide app to the FLP provided to my account. Well it seems not to work that way.

Well my trial Webide has HAT installed as an optional plugin. But I do not get the options you have mentioned in the document to configure my device or run HAT ?

Where is my option "Configure your Project Settings --> Device configuration"

I have even installed an HAT locally in my local Webide. So am i supposed to run my cloud WebIde development in local HAT ?? I am a bit confused here... not able to connect the dots..

- Ags

0 Kudos

You have the Device Configuration item only if you started your project from a Kapsel template. If you started from a FIORI template at moment it's not possible to create a mobile app from that.

Regards,

Simmaco

agnihotro_sinha2
Active Contributor
0 Kudos

Thanks for the info.

But can I change the project type without creating a new project?

I see an option in Project setting ->Project types. Once I select HAT in that, my Device Config option is coming up.

Can I change the type here OR creating a fresh new project is suggested?

- Ags

0 Kudos

Unfortunately you cannot do it. You have to restart from a Kapsel template.

Regards,

Simmaco

agnihotro_sinha2
Active Contributor
0 Kudos

Ok let me try.

So basically you are saying any app on the fiori launchpad which uses MOCK data should be off type kaspel?

0 Kudos

There is actually a separation between the two things at moment. You have to decide: if you want to create a Fiori application which runs on the Fiori Launchpad you better start from a Fiori template. If you want instead to create a mobile application which at the ends runs on your mobile device as a stand alone application (you'll need to use HAT in this case to mobilise it) you need to start from a Kapsel template.

Regards,

Simmaco

agnihotro_sinha2
Active Contributor
0 Kudos

As of now,  i want to display my fiori app as a tile in my FLP and trigger mock data. I don't want an app in my phone now. 

I guess from what you suggest that this app should be from fiori template and not kaspel. I have created this app from fiori template,  so why is it not displaying the mock data?

Or did you mean, to display mock data we always need a kaspel app?  I can understand that a kaspel app can be loaded in phone as a "standalone" app,  but that's not what i intend to do now.

Hope i m clear in explaining the issue.

-Ags

0 Kudos

So if you want to run your app on the FLP it's good that you started from the FIORI template. Now, I guess you want to completely detach your application from the back end database and use mock data. In this case you can first generate the json files related to the collections you want to use for your service. These files need to be located in the model folder together with the metadata.xml file as I explained in the blog I suggested you before. Once the json files are in place you need to force your application to always use mock data. This can be done by editing your Component.js file in the following way:


//var bIsMocked = jQuery.sap.getUriParameters().get("responderOn") === "true";

var bIsMocked = "true";

As you can see I've commented out the line where the bIsMocked is assigned with a value coming from a parameter on the URL string and I assigned to it always the value of "true". In this way the app will always use mock data for running.

Please also check that in the Project Settings --> Mock Data the Mock Data Source is set to JSON Files.

If you need I can send you my working app.

Regards,

Simmaco

agnihotro_sinha2
Active Contributor
0 Kudos

Hi,

Actually I have done all these steps and have created multiple Fiori apps earlier. I am always been able to execute the Apps with MOCK data and also with Backend data directly from the WebIde from INDEX->RUN WITH MOCK DATA.

But whenever I deploy these Apps to my Fiori Launch Pad, I do not get any data ( mock data or backend data).

Steps I do:

* create mock data and replace with json data i get using my SEGW service from tcode-"gw_client" in SAP.

* i hv both metadata.xml as well as a .JSON file.

* in Webide, change project settings of the folder to use Mock data.

* initiated the "bIsMocked" with "true".

* tested Index.html file with "run mock data" option and make sure it shows data - working,

* then I deploy the INDEX.html as well as the project FOLDER to HANA cloud platform and also to Fiori Launchpad.

* I can find the App in my FLP catalog.

* I add it to my home screen of FLP.

* Click to RUN it. - NO DATA displayed - This is the ISSUE here.

I have no idea where am I going wrong... Am I deploying the solution in the wrong way to my FLP? Why is the solution not working from FLP but is working with mock data from Webide using Index file?

Thanks for your help.

- Ags

0 Kudos

You don't have to test with the option "Run with Mock Data" because you don't have this option on FLP. You need to ensure that your app is working fine with mock data in SAP Web IDE even when running it with the standard Run command. For this reason I recommended to change the app in such way.

Regards,

Simmaco

agnihotro_sinha2
Active Contributor
0 Kudos

Everything is in place, I can Run normally the INDEX file from Webide and its showing data. Did changes in the code as suggested as well as project changes.

But whenever I deploy my app in FLP. it comes up with empty screen.

I checked my FLP subscription config in HANA account and I see there are errors. "Destinations not correctly mapped".. Maybe this is responsible. If I edit , i have multiple options of selecting the account - GM6, Northwind, HMAdminJaxrs, HMAdminHandlers etc. Not sure which one to select.

So I selected Northwind and it became green - OK.

But still I dont get data in my App in FLP.

I debugged FLP/Webide APP using CHROME and found out there were differences.

In FLP, I see _SERVER0 is selected whereas in Webide _SERVER1 is selected.

oMockServer = sap.ui.d…e.M.e…d.constructor {mEventRegistry: Object, sId: "__server1"

oMockServer = sap.ui.d…e.M.e…d.constructor {mEventRegistry: Object, sId: "__server0"


In FLP, oMockServer object is loading with 0 records, whereas in WebIde oMockServer has all the Mock records fetched from JSON file.

Maybe this is why it is not displayed. Any hint why is this happening? Deployment issue? FLP subscription issue?

- Ags

Former Member
0 Kudos

The above solution worked for me. Thank you