Skip to Content
Author's profile photo Tobias Hofmann

Any given Tuesday – week 3: Introduction to Mobile Solution Development

Week 3 is over for me. Homework is submitted, content for week 4 already downloaded and ready to be watched.  This week was more intense for me and I am that I was capable of submitting the homework. This week was more focused on real practice after week 2 was teaching the theory. A nice touch of the course is that not everything is scripted and re-done several times until a perfect take is composed. Sometimes a demo fails and is solved right on (2x https) and Craig at least sounds surprised to some degree when something more complex works right away.

Week 3 covered registering to SMP, get and alter data. This meant: hands on. And while the SMP and backend system are real systems, real users and real connections have to be configured and established.

The schema is the same: first an example that can be run from the browser, than a hybrid app with Cordova. The Javascript file provided contains the logon information as shown in the course. To make it work, you have to modify the code. Easy! I’d suspect that everyone first checks the files before running the example, but for those who don’t do that, maybe a warning message in the index.html would be nice (“don’t simply click, alter the file first).

/wp-content/uploads/2013/09/week3_1_289154.jpg

Don’t ask me why it shows: successful connection and at the same time nothing shows up in SMP:

/wp-content/uploads/2013/09/week3_2_289155.jpg

I used the provided SAP Gateway Demo account as the application is using the ES1 system as authentication provider [1] [2]. The complete unit application worked, I got back, but the connection counter keeps insisting that there are 0 connections. I go with: it’s a cache issue.

The 2nd application of U3 shows in the Javascript source code that you have to add your own credentials:

var oModel = new sap.ui.model.json.JSONModel();
var myData = {};
myData.UserName = ""; // TODO: put your user name and password here
myData.Password = "";
oModel.setData(myData);

Not that this is needed, as this HTML5 app is more intelligent and asks for user/password.

/wp-content/uploads/2013/09/week3_3_289156.jpg

That does not mean that you don’t have to adjust the controller.js file!

data.baseURL = "https://[your server].hanatrial.ondemand.com";
data.appName = "[your app]";

The result is a working app:

/wp-content/uploads/2013/09/week3_4_289157.jpg

Sometimes later SMP also decided to agree upon connection facts:

/wp-content/uploads/2013/09/week3_5_289158.jpg

Unit 5 gave me a small problem when trying to update the business partner. First I got a csrf token undefined.

/wp-content/uploads/2013/09/week3_6_289159.jpg

I checked the header (Firebug) and the token was set. Looking into funciton getBP().

Original line:

header_xcsrf_token = response.headers['x-csrf-token'];

Modified line (all upper case)

header_xcsrf_token = response.headers['X-CSRF-TOKEN'];

After making the cookie upper case it worked:

/wp-content/uploads/2013/09/week3_7_289160.jpg

This didn’t mean that I can change the business partner entry. I got a 403 forbidden. I guess that is a simple permission problem, as I am using ES1 system, and that should be read only.

Ongoing issues

Ongoing problem is the slow download speed of content. Here is a screenshot showing the speed for downloading a simple PDF for week 4. I tested my connection speed and 4.1 KB/sec is not related to me.

/wp-content/uploads/2013/09/week3_8_289161.jpg

Another problem is that HANA Cloud / SMP gives me constantly a Javascript warning in Firefox: slow Javascript.

/wp-content/uploads/2013/09/week3_9_289162.jpg

Other blogs in this series from me about the open SAP course: Introduction to Mobile Solution Development



[1] http://scn.sap.com/docs/DOC-31221

[2] http://scn.sap.com/docs/DOC-40986

Assigned Tags

      3 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Raquel Pereira da Cunha
      Raquel Pereira da Cunha

      Tobias,

      do you have an Android device to test your apps?

      I don't, I use an emulator.. and one thing that I didn't like in this week is the fact that the ShakeSensor project to work properly needed a shake

      And I didn't have time to find an easy way to emulate a shake. I saw many posts on internet, some with codes that I could use and some explaining what I need to install in order to emulate a shake, but as I was out of time I gave up and did not test the ShakeSensor. Do you know an easy way for doind that? Remember, I am not a JavaScript developer...

      Author's profile photo Tobias Hofmann
      Tobias Hofmann
      Blog Post Author

      I own a small, tiny Android device 😆

      It's pretty easy to simulate a shake on the emulator. After the emulator is shown, carefully touch your monitor with both (!!) hands and then slowly move your hands to the left, than to the right, than to your hips, you bring your knees in tight and: shake. Another alternative is to open youtube in the Android emulator and watch a harlem shake video.

      Yes, agree, that session is hard to follow when you do not own an Android device. But as the shake calls a function, you may try a workaround and simply create a button that calls the shake function. Not as good as a real device, but it least it shows you the result.

      Author's profile photo Former Member
      Former Member

      Hi When i try to create connection with SMP cloud using wizTools REST Client, it gives me an error, "HTTP/1.1 401 Unauthorized"

      I entered my url like "https://smp-p1940844215trial.hanatrial.ondemand.com/odata/applications/latest/com.opensap.myfirst/Connections"

      entered my credentials in authentication tab
      entered the following code in body :

      <?xml version='1.0' encoding='utf-8'?>

      <entry xmlns='http://www.w3.org/2005/Atom'

      xmlns:d='http://schemas.microsoft.com/ado/2007/08/dataservices'

      xmlns:m='http://schemas.microsoft.com/ado/2007/08/dataservices/metadata'>

      <category term='applications.Connection'

      scheme='http://schemas.microsoft.com/ado/2007/08/dataservices/scheme' />

      <content type='application/xml'>

      <m:properties>

      <d:DeviceType>Android</d:DeviceType>

      </m:properties>

      </content>

      </entry>

      Can you please help me to solve it out ??