Quantcast
Channel: SAPUI5 Developer Center
Viewing all 789 articles
Browse latest View live

Develop Hybrid Mobile Apps With SAP Web IDE Part 3

$
0
0

part 1

  • Create a new Kapsel App
part 2
  • Add new Functionality
  • Test In Browser with Cordova Facade

part 3

this part

  • Run The App On Your Mobile Device


 

 

Run The App On Your Mobile Device

 

To run the App on a mobile device we must first install Companion-App. For Android you will get it here.

The companion App is also a part of HAT. Here you can download HAT. (And here are guides how you can install HAT)

 

This app allows us to scan the QR-Code from the SAP Web IDE-WebPreview and start the same App on a mobile device.

All the Kapsel plugins our mobile app might need are already included in the Companion App.

 

Test On Your Device

 

Now that the Companion App has been installed, we can scan the QR Code shown the SAP Web IDE Preview window and this will start the app on the mobile device.

 

On the preview tab click on the small QR Code icon at right-top of view.

52.png

 

Start the companionApp

53.png

 

Double tap on the screen or click the button at the bottom left to open the menu.

Click the SCAN button at the top.

54.png

 

Scan the QR Code from your SAP Web IDE Application preview in the chrome browser.

55.png

 

Enter your HANA Cloud credentials (or SCN credentials) and click Login

pic.png

 

The products will show up.

Click the Scan button

57.png

 

Scan the QRCode/Barcode

58.png

 

In the Message box you will see the result of your scan.

In the background it searches for the scanned product.

59.png60.png

 

Open one product to see the details.

At the bottom click Add to Contact button.

61.png

 

Click OK on the success message.

62.png

 

Open the Contacts App on your smart phone

63.png

 

search for this contact.

If you cannot find it make sure that you used the Android for work contacts app

64.png

 

 

More Web IDE stuff published by Technology RIG

 

 

See you

Claudi


Understanding RTL Language Support in SAPUI5

$
0
0

As part of my preparation for teaching a SAPUI5 workshop in Israel, I was asked to provide some explanation on how SAPUI5 handles the topic of right-to-left languages.  Since I've never had to look at that subject before, I've done some digging and asking around, and here's what I've found.

 

First we must understand how a browser handles the direction in which characters should be printed.  This could be right-to-left, left-to-right or some mixture of both (known as bi-directional).


Once we understand how browsers handle this topic, then the way SAPUI5 handles the subject will make a lot more sense (and take far less time to explain).


Since I am not a Hebrew speaker, I trust that Google Translate is telling me the truth when it says that "Hello World!" is "Shalom Olam!" or !שלום עולם


Text Direction in Browsers

There are two things to understand here:

  1. The order in which words are displayed to form a sentence
  2. The order in which the characters within a contiguous text string are displayed to form one or more words

 

Any browser that supports the use of Unicode characters must support the use of the W3C's bi-directional algorithm.  As end-users, we don't have to care too much about how this algorithm works internally, but we do need to understand how it behaves.  See section 8.2 of the W3C’s Language Direction specification for browsers http://www.w3.org/TR/html4/struct/dirlang.html

 

The behaviour of this algorithm can be loosely summarised in the following way:

  1. All HTML pages contain text that belongs to a base or default language.
  2. If there is any ambiguity about text directionality within an HTML page, then the dir="rtl|ltr” parameter should be used on a block element (usually the <html> tag) to specify the predominant directionality.
  3. The default value for the dir= parameter is LTR for left-to-right.
  4. The dir= parameter is inherited by any nested elements within the current block; therefore if it is applied to the <html> element, you have defined the default directionality for the entire web page.
  5. The dir= parameter value may be overridden by specifying a new value for the current block.
  6. Here's the important bit - Once the browser has determined the predominant text directionality, it then assumes that all character stringsin the HTML page are represented using this directionality - irrespective of the language to which that text belongs!
  7. If a contiguous string of two or more Unicode escape characters are found that have the opposite directionality, then that string of characters is automatically reversed.


For example, the following HTML page contains two paragraphs that both say "Hello World", first in English then in Hebrew.  The Hebrew characters have been represented as Unicode escape characters rather than the actual Hebrew glyphs.


<!DOCTYPE html><html><head>  <meta http-equiv="X-UA-Compatible" content="IE=edge" />  <meta charset="UTF-8">  <title>Bidirectional Text</title>  </head><body>  <p>Hello World!</p>  <p>&#x05E9;&#x05DC;&#x05D5;&#x05DD; &#x05E2;&#x05D5;&#x05DC;&#x05DD;!</p></body></html>


When the browser renders this page, the following logic is used:

  1. None of the block elements in the HTML page specify a directionality, so the default value or LTR is assumed.
  2. The browser assumes that all text within this file will be presented in LTR format - irrespective of the actual language represented by the text!
  3. A sequence of Unicode escape characters is used to represent the Hebrew text.  This sequence has been specified according to the web page's overall text directionality of LTR - which means the order of characters in the Hebrew text has been written backwards!

 

If we display this HTML file as is, we get the following:

bidi_1.png

Notice that the following things have happened here:

  • Irrespective of their content, all paragraphs have been left aligned
  • The character order of the Hebrew text has been reversed automatically.  This is because:
    • The browser supports Unicode text
    • The dominant text direction of the current web page is LTR
    • A contiguous string of Unicode escape characters was found that all have the opposite text directionality
    • Therefore, the browser automatically reverses the order of characters in this contiguous string (and only this contiguous string) otherwise, it could not be rendered correctly
  • In "Unicode speak", all white space and punctuation characters are said to be "weak": that is, they have no inherent directionality; therefore, the exclamation mark is positioned according to the dominant word order for the web page.  This puts it at the right-hand end of the Hebrew sentence - which is not correct.

 

Overall, this is not an acceptable way to render both English and Hebrew text together on the same web page.  So let’s correct the situation.


<!DOCTYPE html><html><head>  <meta http-equiv="X-UA-Compatible" content="IE=edge" />  <meta charset="UTF-8">  <title>Bidirectional Text</title></head><body>  <p>Hello World!</p>  <p dir="rtl">&#x05E9;&#x05DC;&#x05D5;&#x05DD;&#x05E2;&#x05D5;&#x05DC;&#x05DD;!</p></body></html>


Simply by adding the dir="rtl" parameter to a block element (the paragraph element in this case), we are telling the browser that we want to change the directionality of the text within this block.


Displaying this web page now gives the following:

bidi_2.png

That's better!  Now the Hebrew text has been rendered correctly.  The entire paragraph is right justified and the exclamation mark is at the left-hand end of the sentence.


But there's one more twist to the story...


Let's change the HTML page to add a third paragraph in which the actual Hebrew glyphs have been entered - not their Unicode escaped representation:


<!DOCTYPE html><html><head>  <meta http-equiv="X-UA-Compatible" content="IE=edge" />  <meta charset="UTF-8">  <title>Bidirectional Text</title></head><body>  <p>Hello World!</p>  <p dir="rtl">&#x05E9;&#x05DC;&#x05D5;&#x05DD; &#x05E2;&#x05D5;&#x05DC;&#x05DD;!</p>  <p>!שלום עולם</p></body></html>


Now let's see what that looks like...

Screen Shot 2015-11-27 at 15.27.10.png

Hmmm, that's not right.  Ok, let's add the direction parameter back in....


<!DOCTYPE html><html><head>  <meta http-equiv="X-UA-Compatible" content="IE=edge" />  <meta charset="UTF-8">  <title>Bidirectional Text</title></head><body>  <p>Hello World!</p>  <p dir="rtl">&#x05E9;&#x05DC;&#x05D5;&#x05DD; &#x05E2;&#x05D5;&#x05DC;&#x05DD;!</p>  <p dir="rtl">!שלום עולם</p></body></html>

Screen Shot 2015-11-27 at 15.36.56.png

What the...!!  The exclamation mark is now in the wrong place!


First of all, by entering text into the web page directly in Hebrew glyphs, the browser does not reverse the character order of "Shalom Olam".  This is because the character order is only reversed when Unicode escape characters are used, not actual glyphs.


Secondly though, we have mixed the Hebrew characters with a Latin character (the exclamation mark).  Consequently, the browser looks at the overall contents of this paragraph and sees only two things:

  1. An exclamation mark belonging to the Latin-1 character set
  2. An existing RTL character sequence.


The Unicode bidirectional algorithm now kicks in and reasons that since the overall text direction of the web page is LTR, therefore all text, irrespective of language, will be specified in this order.  However, we have just told the browser that the text direction is RTL; therefore, it must reverse the order of the exclamation mark and the Hebrew character string.


Oops!

 

This can be "fixed" by moving the exclamation mark to the right-hand end of the character string; but this is really a workaround.

 

<!DOCTYPE html><html><head>  <meta http-equiv="X-UA-Compatible" content="IE=edge" />  <meta charset="UTF-8">  <title>Bidirectional Text</title></head><body>  <p>Hello World!</p>  <p dir="rtl">&#x05E9;&#x05DC;&#x05D5;&#x05DD; &#x05E2;&#x05D5;&#x05DC;&#x05DD;!</p>  <p dir="rtl">שלום עולם!</p></body></html>


Screen Shot 2015-11-27 at 16.25.38.png

For more information on this topic, see the W3C's web page on creating HTML pages using RTL scripts.


Now we should turn our attention to .properties files


.properties files

For .properties files, there are several factors involved here:

  1. All .properties files must be encoded using the LATIN-1 code page (ISO-8859-1)
  2. As a consequence of point 1), all non-Latin characters must be represented as Unicode escape characters in the form of \uHHHH, where HHHH is a two byte, hexadecimal number
  3. As a second consequence of point 1), the character order in a .properties file is required to be left-to-right - irrespective of the language in which any particular text string is represented
  4. As a consequence of point 3), text strings belonging to RTL languages such as Hebrew must have their character order reversed

 

So in a .properties file in which you wish to place the Hebrew text “Shalom Olam”, it is incorrect to add the text like this:

 

shalomOlam=!שלום עולם

 

This is wrong for two reasons:

  1. The character order of the Hebrew text has not been reversed
  2. The Hebrew characters have been entered as the actual glyphs, rather than as Unicode escape characters

 

If you enter the text string in the way shown above, it will create a similar problem to the one described immediately above when a mixture of Hebrew glyphs and Latin characters were entered directly into the HTML page.  When rendered in the browser, the Hebrew glyphs will be in the correct order, but if any Latin characters are additionally present, then the order will be reversed.

 

The correct entry in the .properties file is this:

 

shalomOlam=\u05E9\u05DC\u05D5\u05DD \u05E2\u05D5\u05DC\u05DD!

 

Notice that the Latin exclamation mark character is now also at the right hand end of the text string because the entire string has been reversed.


Creating a basic SAPUI5 app that uses RTL text

Using step 8 of the SAPUI5 Walkthrough tutorial as the starting point, here's a simple modification that includes "Hello World" in Hebrew.


Modify i18n/i18n.properties to add a property called shalomOlam


shalomOlam=\u05E9\u05DC\u05D5\u05DD \u05E2\u05D5\u05DC\u05DD!


Modify view/App.view.xml to include the following extra <Text> element shown in red:

 

<mvc:View controllerName="sap.ui.demo.wt.controller.App"    xmlns="sap.m"    xmlns:mvc="sap.ui.core.mvc" >  <Button text="Say Hello" press="onShowHello"/>  <Input value="{/recipient/name}"      description="{i18n>showHelloButtonText}"      valueLiveUpdate="true"      width="60%"/>  <Text text="{i18n>shalomOlam}" class="sapUiMarginSmall" textDirection="RTL" />
</mvc:View>

Screen Shot 2015-11-27 at 17.23.20.png

So there you have it - how to get RTL text to appear in the correct order in a SAPUI5 app.  As you can see, the majority of this blog discusses how a browser handles this situation.  Therefore, if you understand that, you're about 90% of the way to getting this working in SAPUI5.




Chris W




PS.

The only thing that does not work as expected is the textAlign property of the <Text> element.  Setting this parameter to "Right" does not alter the alignment of the text.  The text is always left justified - at least in the apps I've created.  Maybe I've missed a trick here or maybe its a bug...


YMMV



Create custom control - Bubble

$
0
0

Hello Everyone, I would like to explain how to create a bubble in SAP UI5 using third party library such as D3.

 

In our daily day work life of meeting the business requirements and expectations of clients. Many a times we do come across a situation where customer needs some different kind of graphical visualization to show the values to get more delightful user experience. So In such cases during implementation we face find difficulties in finding a right control from the SAPUI5 library.

 

In such cases SAPUI5 provides a feature of called "custom control" where we can create any kind of control we desire to create and can be reused for multiple times.

 

So lets start to create a custom control.

 

First create a javascript file by name convenient to you for ex: Bubble.js

 

Import the third party library( I am using D3 library to create circle and other shapes. we can use simple html svg even to create without using D3.

But I prefer using D3 since it is already available in SAPUI5 standard third party library)

 

jQuery.sap.require("sap/ui/thirdparty/d3");

 

Declare the package name as you wish.

jQuery.sap.declare("myAppName.ui.control.viz.Bubble");

Capture.PNG

 

Implement the body of drawBubble method to draw the bubble.

Capture.PNG

 

Then you are done with custom control. Now lets see how to use it in a view.

 

Import the custom control name space in the view and use it as shown below.

Capture.PNG

 

Now run the app on a web app preview or on your server. You could see the bubble with the color and text you have set in the xml.

 

Capture.PNG

 

You can also download the attached files to run on your eclipse having folder structure as shown below. Rename attached .txt files to .js files

Capture.PNG

 

Thanks,

Vinay

sapui5 input validation using conditional combobox binding.

$
0
0

What we are going to do is simple.We have two comboboxes.Based on first combobox value second combobox values should change.ie when value changes second combobox binding should change(dynamic binding).

Steps

1.Our odata should look like this.Here iam using custom data.Set data to the core so we can access it.

dynamic1.PNG

2.Create first combobox and bind data to it.Here is the tricky part.In the selectionchange event of combobox call a function for binding the secondcombo passing the selected key as parameter.

dynamic2.PNG

3.Function for binding second combobox.

dynamic3.PNG

4.You Should set initial binding of second combo by calling function passing 0 as parameter

dynamic4.PNG

 

for more information please see blog sapui5 input validation using conditional combobox binding | sap abap | sapui5 made easy

Wanted: UI5 developers. UI5 is mandatory, JavaScript is optional

$
0
0

Hello All,

 

Our org. is in need of UI5 developers. The requirement is clear. The candidate should be able to develop using UI5. Then, on query about the need to know JavaScript, the team's reply, ' JavaScript? Not required'. I went silent and then remained silent.

 

The topic came across yesterday during my conversation with one of the team member, who shared the experience. I was just wondering, why do we always make the mistake of falling for the same trap or the same marketing gimmick. To clarify, I am not saying UI5 is a gimmick. Its just that we always tend to fall for the keywords.

 

UI5 is nothing more than a set of JavaScript libraries which are made available as open source by SAP. Its not a new language neither a new specification by SAP. Its just a set of features on top of existing web technology.

 

JavaScript is at the core of the development. The client side scripting language which has literally come to the fore front, is the actual engine behind the new user interface. In collaboration with HTML5 and CSS they form the trio of modern web technologies. UI5 is nothing more than set of SAP toolset on top of the trio. Its like an external API/JAR which is used within the existing framework.

 

To perceive UI5 as a new language the team leads make the mistake of giving importance to the terminologies. The fundamentals of JS are more important to the developer rather than the jargon. The technical terms can be adapted to by the developers in a few days. But, to have one without the necessary fundamentals, we risk giving another half-baked solution. Later, we blame the developer for not being good enough. Well, where was the wisdom of the team when the skill was identified based on the outer branding rather than the actual fundamentals.

 

We should give more impetus in using the technology trio and use the UI5 libraries to facilitate the SAP specific solution. The former is the key, the latter is an assist. Let us not mix it up, Once Again.

 

Best Regards,

Sharath

SAPUI5 walkthrough step 7 - JSON model, dive in - how does JSON model work?

$
0
0

Welcome to my SAPUI5 Walkthrough, And Dive In blog series, where I’ll not only walkthrough the tutorial, but dive in, to explore the magic behind SAPUI5. Buckle up and sit tight, it's gonna be a bumpy ride as I’m no expert in any way shape or form, just a humble learner who loves coding and likes to get to the bottom of things =。=

 

01.png

 

We’ll be looking into the JSON Model in this post, the JSON model alone seems a bit boring...

02.png


Let’s expand our digging, try to find the answers to these three questions:


(1) How does the input control pick up these attributes (we’ll focus on the value attribute)?

03.png


(2) How does the “World” end up in the input field without we setting it explicitly?

04.png


(3) How come the description value get live updated when input field value changes.

05.png


Sounds interesting? let’s dive in


(1) How does the input control pick up these attributes (we’ll focus on the value attribute)?

06.png


With the knowledge we had on “how does a xml view get created?” We go straight to the XMLTemplateProcessor class’s createRegularControls method, where the input control is created. The framework calls createRegularControls with node, node holds all the attributes in its attributes property.

07.png


Within it, it calls parseScalarType function, to have all the attributes set to the mSettings map.

08.png


Then it calls the control constructor with mSettings map.

09.png


Which leads to the parent class ManagedObject’s constructor method, it calls applySettings where settings will be processed.

10.png


In the applySettings method, it extracts settings into bindingInfo object (we’ll rely heavily on this object in the next section to do the binding stuff), then it calls bindProerty method.

11.png


bindProperty creates a new key on the mBindingInfos map of the input control object. With that, the first question is answered.

12.png



(2) How does the “World” end up in the input field without we setting it explicitly?

13.png


We create a JSONModel object called oModel, then call the setModel method, to set the oModel object to the view, we’ll start from here.

14.png


Let’s take a break from the one after another screenshot, I’ll try to explain this section with this simple diagram which contains the key methods that invoked and the arguments passed in.

15.png


The oBinding object looks like a important middle man, let’s take a look at what it holds before ending this section. It holds the JSONModel object, the oValue which will be set to the input field, the sPath which points to the oValue in the model, the fModelChangeHandler (in the mEventRegistry) as well as some other stuff. Good enough, next question awaits, let’s continue.

16.png



(3) How come the description value get live updated when input field value changes.

17.png

 

Well, both value and description attributes were set with the same sPath, clearly one change would effect the other. Let’s find out how exactly that happens.


The input field change triggers the oninput event, which first checks valueLiveUpdate value (which set this attribute to true in the xml document as you may recall), then calls setProperty method.

18.png


setProperty calls updateModelProperty to have our JSON model object oModel’s property updated since it two way binding.

19.png


updateModelProperty calls setExternalValue with the changed value ‘x’.

20.png


setExternalValue calls setValue.

21.png

 

Which leads to have oModel to call setProperty, to set the oValue from ‘World’ to ‘x’.

22.png


Since oModel had been changed, the fModelChangeHandler function which listens to the model change will be involved, it calls the updateProperty method on the ‘description’ attribute, which leads its value to be changed to ‘x’ as well.

23.png

 

To summarize the last finding, looks like here’s what happened: change Input field value -> input control ‘value’ property changed -> model property updated as for two way binding -> model change handler invoked -> ‘description’ property updated -> value set.

24.png


The end, happy coding

SAPUI5 walkthrough step 8 - translatable texts, dive in - how does i18n model work?

$
0
0

Welcome to my SAPUI5 Walkthrough, And Dive In blog series, where I’ll not only walkthrough the tutorial, but dive in, to explore the magic behind SAPUI5. Buckle up and sit tight, it's gonna be a bumpy ride as I’m no expert in any way shape or form, just a humble learner who loves coding and likes to get to the bottom of things =。=


This is a fairly straight forward step, but let’s go a little bit further than what the tutorial shows us.


Let’s first create an i18n_de.properties file.

01.png


And also, make German as the default language in the Chrome browser language settings.

02.png


With those preparations done, let’s run our application, and see what will happen and more importantly, ask the question how.


We see german on the screen, yeah.

03.png


Here comes the questions:


(1) How does SAPUI5 pick up the browser language setting.

(2) How does SAPUI5 know which i18n file to load.

(3) How does {0} turn into ‘World’.


(1) How does SAPUI5 pick up the browser language setting.


During the Core class instantiation process, a new Configuration object will be created.

04.png


The configuration object will pick up our Browser language settings, and make the first entry (de) as the default language value.

05.png


(2) How does SAPUI5 know which i18n file to load.


We go back to the App.controller.js to instantiate an i18nModel object.

06.png


During the instantiation process, we’ll get the language code from the configuration object.

07.png


It continues to construct the correct url (base url + the sLocale code) for requesting the resource.

08.png


Having the resource loaded.

09.png


(3) How does {0} turn into ‘World’.


Start with getText method call.

10.png

 

getText invokes jQuery.sap.formatMessage method.

11.png


Which does its regular expression magic to replace the pattern '{0}' with value ‘World’.

12.png


13.png

 

Mission completed  

14.png

Want to use Bitbucket as your Project Repository with SAP Web IDE?

$
0
0

Introduction

From time to time, I get asked the question “Can I use an external Git with SAP Web IDE?”

When working with SAP Web IDE I recommend using the integrated SAP HCP Git (Look in the Summary section for some of the reasons).

However, SAP Web IDE enables the use of an external Git as well.

 

As Lidor Tal mentions in his excellent blog post How to Use the SAP Web IDE Git Client, the first thing you have to do to work with Git, is to have a Git repository in your SAP Web IDE workspace”. However, the examples in Lidor’s blog post, use the SAP HCP Git server that is well integrated with SAP Web IDE.

 

This blog post describes how to use Bitbucket as an external Git as the project repository with SAP Web IDE. It is part of a series of blogs that discuss Git and SAP Web IDE.

  • It is NOT intended to teach Git. For this there are plenty of resources on the web, specifically with most Git services, you’ll find an education section.
  • It is NOT intended to educate on SAP Web IDE Git client functionality.

This is the second blog post in a series of related blogs that will describe how to use additional Git services as Git repositories for a SAP Web IDE project as well as relevant tips & tricks. In the previous blog post Want to use GitHub as your Project Repository with SAP Web IDE? I presented how to use GitHub as a project repository with SAP Web IDE.

Overview

In this blog I will discuss:

  • Creating the repository
  • Cloning the repository

 

Creating the Git Repository

When working with external Git repositories, and with Bitbucket specifically, the first step is to create the repository. This step is probably the only thing that is substantially different from working with the SAP HCP Git. The reason for this is that when working with external Git, the Git repository creation is done through the Git service, while with the SAP HCP Git when creating an HTML5 application in the HCP cockpit or when deploying to HCP from the SAP Web IDE, it is automatically created for you.Steps to create the Git repository on Bitbucket:

  • Login to your Bitbucket account.
  • Create a new repository.

 

Following are several ways to create a new repository:

13-12-2015 15-47-05_.png

13-12-2015 15-48-20_.png

13-12-2015 15-42-44_.png

  • Fill in the repository fields, mainly Repository name, description, public/private, etc.
  • Click the "Create repository" button.

Note:  Unlike GitHub, Bitbucket does not provide the option to initialize the repository upon creation. As a result, once the repository is created, you'll need to go through an additional step of repository initialization prior to cloning it in SAP Web IDE.

13-12-2015 15-57-32_.png

  • Initialize the newly created Bitbucket repository. This is the only additional step you need to make compared to GitHub. Everything you need to do is documented in the webpage that opens after you click on the "Create repository" button in the previous step.
  • Click the "I'm starting from scratch" for teh steps you need to make.

13-12-2015 16-06-32_.png

  • Make sure you have a Git client installed on your machine.
  • Then go through the first set of console commands. I use Windows for this blog.

13-12-2015 16-33-26_.png

  • Going through the first set of commands:

13-12-2015 16-38-22.png

  • Going through the second set of commands:

13-12-2015 16-40-43.png

 

Now, that the Git repository is initialized I can proceed to cloning it in SAP Web IDE.

 

Cloning the Git Repository

Steps to clone the Git repository from Bitbucket:

  • In your Bitbucket account, select the repository to clone.

13-12-2015 16-44-01_.png

  • Copy the repository link.

13-12-2015 16-51-28_.png

 

  • In SAP Web IDE, choose the “Clone Repository” option.

13-12-2015 16-53-58_.png

  • In the URL field of the popup, paste the GitHub repository link and push <Tab> button.

Note: The “Host”, “Repository Path”, "Protocol" and "User" fields are filled-in automatically.

13-12-2015 16-58-36_.png

  • Fill-in the authentication fields. You’re welcome to check the “Remember Me” checkbox for next times.
  • Click "OK".
  • After clicking “OK” you’ll get notifications both in the console pane as well as in the “Highlighted Announcement Area” of the SAP Web IDE. You will see them at the beginning of the clone operation as well as at the completion.

13-12-2015 17-18-00_.png

  • A new option is available with the latest release of the SAP Web IDE enabling you to "Git Ignore System Files". You're welcome to choose either of the options per your work standards.

13-12-2015 17-02-14_.png

 

Congrats !!!

 

A new project was generated in SAP Web IDE that was cloned from Bitbucket. You can see that, as expected, the project only contains the contributors.txt file.

 

Open the Git History pane. Since I chose the "Ignore System Files" options, you’ll see that it contains two commits, the initial commit and the igonre commit. If you click on the initial commit, you’ll see that it only contains one file, contributors.txt that was added to the repository (Status – A).

13-12-2015 17-18-00_.png


Summary & Next Steps

Cloning from an external Git repository is simple.

Bitbucket is somewhat more complicated than GitHub as it requires the additional steps for initializing the repository.


The major difference from the SAP HCP Git is:

  • You need to create the Git repository in Bitbucket prior to the start of development.
  • You need to check initialize the repository using a Git client.


OK, now that the project is cloned in SAP Web IDE, what can I do next?Following are a few options:

  • Import a project.
  • Create a project from template.
  • ...


A few things to note when working with external Git

  • You cannot deploy from SAP Web IDE to HCP.
  • Creation of branches, and possibly additional repostiroy management operations, should be done via the Git service UI / client.

 

-- Raz


My SAPUI5 Christmas Wish List

$
0
0

Dear Santa,

 

I think I have been pretty good this year. I have tried not to fight with my brothers too much. I have tried to think of others before myself. I have tried to be more tolerant of those other idiots - who are everywhere by the way.

 

So, if it's okay, here is my short list of some things I would like from SAP for Christmas

 

Downloadable SAPUI5 Runtime & SDK.

Thankyou for giving me one of last years wishes - namely the hosting the SAPUI5 and OpenUI5 libraries on a CDN so that those of us who live and work outside the SAP corporate network can get fast and reliable access to them.

 

But whilst I can download the OpenUI5 SDK to my development environment I can't easily do this for the SAPUI5 library. This makes it hard to do offline development of SAPUI5 applications. It also makes development a pain when I have browser caching turned off and the library has to reload all the time.

 

Not being able to easily download the SAPUI5 runtime makes it more difficult for me to provision non-SAP servers, such as NGINX, for SAPUI5 apps.

 

Combine SAPUI5 and OpenUI5 libraries into a single package.

Why do we have two different libraries for the same thing? Is it a symptom of bureaucracy gone mad or is it something else? A single library with a single code line has got to be easier for all - and of course keep it Open Source. If SAP have proprietary IP in the SAPUI5 library then just agree to Open Source it please. If the SAPUI5 library uses non-SAP IP that is restricted just get it sorted out please.

 

FLP to use standard SAPUI5 library

The Fiori Launchpad (FLP) is designed to use the SAPUI5 library that is delivered with the underlying application server. This appears to be a 'special' third SAPUI5 library! *Note - please change previous request to combine every SAPUI5 library into one.

 

SAPUI5 applications that are built to run as first-class citizens of the FLP have to use the same SAPUI5 library that FLP loads. This means these apps have to be written for the SAPUI5 library that is installed on the application server and in most cases an older version than is generally available.

 

If FLP used the standard (unified) SAPUI5 library it would be a simple matter to point it to the latest available and allow developers to build FLP apps using the latest available technology.

 

SAP to actively enable rapid innovation on ABAP platform.

The change management culture of enterprise software inhibits innovation. While carefully managing change in enterprise systems we also slow down the potential rate of innovation. Changes tend to be bundled into large groups that are implemented once or twice a year scheduled months in advance.

 

Rapid innovation requires a different approach. One that supports lots of incremental changes. An environment where ideally the develop, test, deploy cycle can happen in minutes not months. The people building SAPUI5 applications need this now.

 

SAP gets this - but they are doing nothing to help enable rapid innovation on their good ole' ABAP platform. I want tooling and strategies to support rapid innovation on all SAP platforms. How about SAP support for ABAP/Git integration for a start?

 

Letter-to-Santa-Claus-400x318.gif

 

Thanks for your patience Santa. I will try to be better next year.

 

Your friend,

Graham Robbo

Using Custom Charts with SAPUI5 Mobile

$
0
0

In this post I will describe how you can easily insert any custom chart control in a SAPUI5 Mobile app.

2015-12-17 13_47_48-htmlpreview.github.io__https___raw.githubusercontent.com_Qrist0ph_CodeSamples_ma.png

In this particular example I am going to use a SplitApp and  D3 as charting library however the steps apply also to other libraries and controls. Please find the comple source code on GitHub.


Let´s start by creating a simple SplitApp with two detail pages:


var oSplitApp = new sap.m.SplitApp("mySplitApp")          .addMasterPage(new sap.m.Page("master2", {              title: "Master2",              navButtonPress: function () {                  oSplitApp.backMaster();              },              content: [new sap.m.List({                  mode: "SingleSelectMaster",                  select: function (oEv) {                      if (oEv.getParameter("listItem").getId() == "listDetail2") {                          oSplitApp.toDetail("detail2");                      } else {                          oSplitApp.toDetail("detail1");                      }                  },                  items: [new sap.m.StandardListItem("listDetail2", {                      title: "To Detail 2"                  }), new sap.m.StandardListItem("listDetail", {                      title: "To Detail 1"                  })]              })]          }))         .addDetailPage(new sap.m.Page("detail1", {             title: "Detail 1"         }))         .addDetailPage(new sap.m.Page("detail2", {             title: "Detail 2",         })).placeAt("content");

Now we want to place a chart control on both detail pages. The chart will be drawn by the  function shown in the snippet below that is taken from this D3 example. That function is passed the DOM element that will contain the chart.

My first idea was to just use jQuerys document.ready function and just add the chart in here. However there is one big issue with that approach as only the first detail page is available in the DOM once the document.ready function gets called. So DetailPage1 will contain the chart, DetailPage2 won´t. See it in action here.

 

$(document).ready(function () {            drawChart(jQuery.sap.byId("detail1")[0]);            drawChart(jQuery.sap.byId("detail2")[0]);        });

So the problem here is basically that SAPUI5 is clever enough to lazy load components and only insert them into the DOM once they are actually needed.

 

In order to draw the chart in a SAPUI5 conforming way we will just create a simple custom control and make use of its onAfterRendering function. So the final SplitApp looks like below (see it in action here) .

 

    sap.ui.core.Control.extend("chris.Chart", {            renderer: function (oRm, oControl) {                oRm.write("<div");                oRm.writeControlData(oControl);                oRm.write("</div>");            },            onAfterRendering: function (eeee) {                drawChart(eeee.srcControl.$()[0]);            }        });        var oSplitApp = new sap.m.SplitApp("mySplitApp")         .addMasterPage(new sap.m.Page("master", {             title: "Master",             navButtonPress: function () {                 oSplitApp.backMaster();             },             content: [new sap.m.List({                 mode: "SingleSelectMaster",                 select: function (oEv) {                     if (oEv.getParameter("listItem").getId() == "listDetail2") {                         oSplitApp.toDetail("detail2");                     } else {                         oSplitApp.toDetail("detail1");                     }                 },                 items: [new sap.m.StandardListItem("listDetail2", {                     title: "To Detail 2"                 }), new sap.m.StandardListItem("listDetail", {                     title: "To Detail 1"                 })]             })]         }))        .addDetailPage(new sap.m.Page("detail1", {            title: "Detail 1",            content: [new chris.Chart()]        }))        .addDetailPage(new sap.m.Page("detail2", {            title: "Detail 2",            content: [new chris.Chart()]        })).placeAt("content");

 

 

DrawChart Function:

 

function drawChart(element) {            var margin = { top: 20, right: 20, bottom: 70, left: 40 },    width = 600 - margin.left - margin.right,    height = 300 - margin.top - margin.bottom;            // Parse the date / time            var parseDate = d3.time.format("%Y-%m").parse;            var x = d3.scale.ordinal().rangeRoundBands([0, width], .05);            var y = d3.scale.linear().range([height, 0]);            var xAxis = d3.svg.axis()                .scale(x)                .orient("bottom")                .tickFormat(d3.time.format("%Y-%m"));            var yAxis = d3.svg.axis()                .scale(y)                .orient("left")                .ticks(10);            var svg =                d3                .select(element)                //.select("#detail1")                .append("svg")                .attr("width", width + margin.left + margin.right)                .attr("height", height + margin.top + margin.bottom)              .append("g")                .attr("transform",                      "translate(" + margin.left + "," + margin.top + ")");            var data = [                {                    date: "2013-01",                    value: "53"                },                 {                     date: "2013-02",                     value: "153"                 },            ];            data.forEach(function (d) {                d.date = parseDate(d.date);                d.value = +d.value;            });            x.domain(data.map(function (d) { return d.date; }));            y.domain([0, d3.max(data, function (d) { return d.value; })]);            svg.append("g")                .attr("class", "x axis")                .attr("transform", "translate(0," + height + ")")                .call(xAxis)              .selectAll("text")                .style("text-anchor", "end")                .attr("dx", "-.8em")                .attr("dy", "-.55em")                .attr("transform", "rotate(-90)");            svg.append("g")                .attr("class", "y axis")                .call(yAxis)              .append("text")                .attr("transform", "rotate(-90)")                .attr("y", 6)                .attr("dy", ".71em")                .style("text-anchor", "end")                .text("Value ($)");            svg.selectAll("bar")                .data(data)              .enter().append("rect")                .style("fill", "steelblue")                .attr("x", function (d) { return x(d.date); })                .attr("width", x.rangeBand())                .attr("y", function (d) { return y(d.value); })                .attr("height", function (d) { return height - y(d.value); });        }

SAPUI5 / Fiori is not a mobile solution

$
0
0

phone.jpgBecause it is an everything solution...

 

Over the past few years I have heard some variation of a concern about using SAPUI5 applications to solve a problem because "we wouldn't want to do that on a phone". While it may be a valid point that "doing it on a phone" may not be a scenario related to the problem we are trying to solve, it doesn't matter. This is a false dilemma, which occurs because we want to organize things we view in the world in distinct boxes, such as mobile vs. desktop. I think some marketing or sales people may also be to blame for this confusion, since I assume they are showcasing how Fiori apps work on a mobile device to give a wow affect, but we know that the biggest benefit of using a responsive framework such as SAPUI5 is that it can work on any device and that should also be emphasized. I think this causes some groups to not consider SAPUI5 in non-mobile scenarios where it may be a great solution.


It's comforting to have clear indications of what something is and what type of application should be used. This is often attempted when trying to choose between native, hybrid, and web mobile applications. Though the lines between these options are constantly getting blurred. I think the solution is instead to focus on the problem you are trying to solve and find the best context-aware solution for that problem instead of trying to come up with a set of rules to determine when one thing should be used over the other. I had a project where we used the winJS framework to build a native app in HTML5/JS. Before the project began we were told this would be impossible because it did not cleanly fit in a bucket (Microsoft would disagree and say it is native).

 

The world is not black and white. Instead it is filled with gray. It is so easy to get overwhelmed with decisions that stall innovation, instead we should talk about a problem and how we can solve it. Decisions should be made based on what is the best way to solve a particular problem.

 

What are your thoughts? Have you heard similar comments from colleagues or clients?

 

Image by Moyan Brenn @ flickr

An useful Chrome extension - UI5 Inspector

$
0
0

There is a useful Chrome Extension for UI5 which could be downloaded via url:

clipboard1.png

Once installed, there will be a new tab "UI5" in Chrome development tool.

 

Within this tab, instead of displaying the native HTML dom elements in traditional "Elements" tab, it will display UI5 controls together with their properties. See the navigation back button for example.

clipboard2.png


Compare with the original property display for this navigation button:

clipboard3.png

Through comparison we can easily find out that the Chrome extension provides us a more neat view which can help us concentrate on those UI5 properties.

 

In the Bindings tab, there are more detail information regarding a control if it is bound to a given model field, for example the binding path, the current value of the model field, the field type and model type, as displayed below:

clipboard4.png

The Application Information tab contains general information of current UI5 application, so it is not necessary for you to press Ctrl+Alt+Shift+P to get this information displayed.

clipboard5.png

Experimenting with extending apps with Web IDE on SAP Fiori, demo cloud edition

$
0
0

Hi,

in this blog, I would like to share some experience on how easily you can extend a view of an application with the WYSIWYG editor of SAP Web IDE.

 

Here is what I did to extend the Approve Purchase Orders app in my SAP Fiori demo cloud edition account:


1. In SAP Web IDE, I first went to Extensibility Pane and decided to redesign the Details view on the right side of the app. So, I selected this view (S3) in the Outline panel and extended it by replacing it with a copy of the original view, so I did not have to start from scratch.

S3.png

 

2. I went back to Code Editor and there, right-clicked my new extended view (S3Custom.view.xml) and selected Open with Layout Editor.


3. First of all, I had to connect the new xml view to the right data set, so I could later bind my controls on the screen to real data from the backend system. So in the properies of the xml view I selected data set HeaderDetailCollection.

xml.png

 

4. As first change to my view, I decided to created a new tab and added the items list to that tab. This was quite easy. From the controls panel on the right, I chose the right control (Icon Tab Filter from the Container section) and dragged and dropped it to between the information and the notifications tab.

 

dragdrop.png

I changed its colors to blue like the others by setting the icon color to default, the title to items and of course I wanted to display the number of items next to the icon, so I used the link icon to bind the property Count to {NumberofItems}. Then I had to fill my new tab with content which I did by just dragging the item list on the bottom of the page to the white area for the content of your new tab.

 

draglist.png

 

Here it is important to select the complete table. You can do that by clicking several times into the list, first you just select a list element, but each time you click in the same location, the selection changes one level up in the hierarchy of the xml. In the header of the properties panel and in the outline panel, you can always see which element is currently selected.

 

 

5. As a second change, I decided to change the header area and replace the name of the supplier with the name of the person who created the purchase order. Instead, I wanted to add the name of the supplier to the list on the information tab. So, I just clicked on {Supplier Name} to select the Object Header and set Title to {CreatedbyName} in its properties. Then I right-click  the second, smaller {CreatedbyName} entry and select Delete, as you do not need this entry twice.

DataBinding.png

 

I switched to the first tab to add the supplier name to the list. There, I just clicked {PONumber} in the list twice to select the complete Form Element. Then right-clicked my selection and chose Copy. Finally, I right-clicked my selection again and chose Paste After. Now I just had to adapt the properties of the new label {i18n…} and text. You can replace the label with an expression like before, so your label can be displayed  in different languages, or just with a plain text. For finding the right expression, you need to take a look at the file i18n > i18n.properties of the original Approve Purchase Orders application.

 

I also tried using the Outline for adding the new list item - by either copying it there (which worked fine as well) or creating it "manually" using the + sign. This second option turned out to be a bit lengthy and complicated, so I would recommend using copy-paste wherever possible.

 

6. Then I took a look at my new app in the preview. If you DO NOT see your changes, don't worry, but just think about deleting the browser cache. If you do not see any purchase orders, it seems that all of them have just been approved or rejected by other demo users. So, either wait or run your preview with mock data.

 

7. Now I just deplayed my application to SAP HANA Cloud Platform and registered it to SAP Fiori launchpad.

 

And that's it: Now I can launch it from my launchpad.

 

Result.png

 

 

Have fun exploring it,

Sibylle

SAP UI5 Basics Part 1 - HTML

$
0
0
Are you an ABAP veteran, too? If anyone needs a function module or a new report, you quickly turn to the SE37 or SE80 and feel at home? No matter which module, you know every table? And now the management has agreed to go new ways and convert some of your applications to the new SAP Development Toolkit SAPUI5 and it's your job to take over the development. However, you haven't really heard anything about SAPUI5 before? Then this post is for you!
After years of working with the Workbench, ABAP and SAP GUI it can be difficult to look forward to new tools and IDEs.
Switching to new technologies and programming languages is not always easy, because the syntax can be radically different. But be honest: companies often use old versions of the workbench without features such as auto completion. Only few ABAP developers have access to the newest versions. That is the reality in the SAP consultant business. SAP UI5 (and web development in generela) can be developed with modern IDEs, such as Eclipse.
In this blog series I want to show you the basics of SAP UI5 development. If you want to dive into the world of the SAP Netweaver UI Development Toolkit for HTML5, short SAPUI5, you should take a look at the open web standards HTML5, CSS, jQuery and Javascript. This post is the first part of the series which contains three parts. The parts contain a short entry into the following technologies:

 

  1. HTML5
  2. CSS
  3. JavaScript (DOM Tree)

 

HTML

HTML stands for Hypertext Markup Language and I am sure that most of you have already heard of it. It is used the describe websites. It structures content, let it be text, images and so on. Version 5, the newest version, allows you to insert video, audio and several other interesting features like 3D graphics.
To develop a webpage with HTML5 all you need is a texteditor and a modern browser (Chrome, Safari, Firefox, IE). It is important for you to know that it makes a difference which browser you use. They contain different rendering engines and therefore the output is not always the same. You should always test your website on the most popular browsers to make sure that your website will be presented correctly to most of the users. A lot of companies still use old versions of browsers. Therefore it is always a good idea to test your site on old browsers like IE6.HTML is a markup language that consists of HTML elements, like the element p, which represents a paragraph. These elements are called 'Tags'. The h1-tag represents a header. It could look like this:
<h1> I am a header</h1>
An opening tag looks like this "<tag>" and a closing tag looks like this "</tag>". This syntax tells the browser, that the text between "<h1>" and "</h1>" is a header. The HTML tags are inserted into fixed parts of a HTML website. These parts are called the "head" and the "body" of the page. A standard HTML5 page is declared as follows:

 

<!DOCTYPE HTML PUBLIC „-//W3C//DTD HTML 4.01 Transitional//EN“ http://www.w3.org/TR/html4/loose.dtd>

<html xmlns=http://www.w3.org/1999/xhtml“>
     
<head>
          
<meta http-equiv=„Content-Type“ content=„text/html; charset=utf-8″ />
          
<title>New Web Project</title>
     
</head>
     
<body>
          
<h1>New Web Project Page</h1>
     
</body>

</html>


A lot of IDEs will generate this basic HTML frame for you. In general it is enough to define a html document like this:
<!DOCTYPE html>

 

 

Your website is defined by the <html>-tag. The <head>-tag contains the header of the page. It contains meta information like the charset. This is important if you use certain special symbols.
The <body>-tag contains the content of your website.To increase the readability of your HTML-code you can insert spaces or tabs between your tags. You should always try to use indentation and blank lines to make your code readable.

I will now present the most common tags:

I already mentioned the headers <h1> to <h6>. The higher the number the smaller is the header font size. This correlates to the headers in Microsoft Word.

The tag <p> is a paragraph in which you can add text.

<ol> is a sorted list, <ul> a list, <li> is a list entry, <br> is a carriage return and another often used element is <div>. <div> can be used as a frame for neary every other element.

A very simple page could look like this:

<!DOCTYPE HTML PUBLIC „-//W3C//DTD HTML 4.01 Transitional//EN“

http://www.w3.org/TR/html4/loose.dtd>

<html xmlns=http://www.w3.org/1999/xhtml“>
    <head>
           
<meta http-equiv=„Content-Type“ content=„text/html“; charset=“utf-8″ />
           
<title>New Web Project</title>
     
</head>
     
<body>
          
<h1>SAP UI5 Basics</h1>
          
<h2>SAP NetWeaver UI Development Toolkit for HTML5</h2>
          
<div>
               
<p>On the website of our <i>  department</i>
                    
<a href="http://www.example.com"> Mission Mobile</a>

                you can find interesting news and articles <br>

                covering current topics in the field of <b>mobile applications</b>.
              
</p>
          
</div>
     
</body>

</html>

Insert this snippet into a common texteditor and save the file with the ending ".html". If you double click on the file your browser should open and display the following content:

1.PNG

The tags <i> and <b> format the text. <i> stands for italic and <b> for bold. The element <a> is a link. The attribute href of the tag defines the destination of the link. In this case it is the homepage of my company.

 

Let's wrap it up

 

HTML is used to structure content on a webpage. I hope, that you could get a little glimpse into the world of web development und understand the core concept of it. I can only recommend using the internet, books and forums to strengthen your knowledge in this field.

 

Maybe you have already noticed that the standard elements a far away from looking fresh and modern. How can you implement a corporate design? This brings me to the second part of this series: CSS or cascading style sheets. This technology is used to format your html website.
If you have any question feel free to ask me in the comment section.

SAPUI5 - Upload file, "slug" with special characters

$
0
0

Hello guys!

 

I'm going to be short in this blog for I believe it can help a lot.

 

 

When uploading files using sap.m.UploadCollection component, if we need to pass aditional information it's necessary to use a parameter called SLUG. To define this parameter value we use the component sap.m.UploadCollectionParameter.

The SLUG parameter is used to pass any sort of information, most used are: file name and some description about the file.

 

 

 

Exemple JS:

var oHeaderParameter = new sap.m.UploadCollectionParameter({  name : "slug",  value : sFilename + "|" + sFileDescription
});

 

 

Exemple XML:

<UploadCollection>  <headerParameters>       <UploadCollectionParameter name="slug" value="Filename.txt|Some Description" />  </headerParameters></UploadCollection>

 

 

Lately I had some problems uploading files with the SLUG containing information with special characters. As in the exemple above, our app Fiori/UI5 needed to inform the file name and a description. Our customer was a Brazilian company, they always had some special character passed to the SLUG parameter.

Even with the application defined with codepage UTF-8  and SAP Gateway + ECC were unicode, the SLUG always came with error in the special characters.

 

Error exemple:

"Descrição" was shown as "Descri��o".



To fix this error, I had to encode the SLUG value on client side and decode in the server side.

 


Encode - Client side (*.controller.js):

var oHeaderParameter = new sap.m.UploadCollectionParameter({  name : "slug",  value : encodeURIComponent( sFilename + "|" + sFileDescription )
});



Decode - Server side (SAP Gateway):

CLASS ZCL_xxxxx_DPC_EXT
METHOD /IWBEP/IF_MGW_APPL_SRV_RUNTIME~CREATE_STREAM
lv_unescaped_val = cl_http_utility=>unescape_url( iv_slug ).


 

In the Fiori/UI5 application's controller, the JavaScript function encodeURIComponent() is responsible for replacing the special characters in a string for the UTF-8 (unicode) representation.

In the SAP Gateway, the method CL_HTTP_UTILITY=>UNESCAPE_URL() is responsible to do the reverse process.

If we were using SAP Fiori with SAP HANA Cloud, we could use the JavaScript function decodeURIComponent() in the file .XSJS which receive the data from the app to decode the string.

 


Hope it help.

Thanks


OData Server for Node.js - WebIDE Example

$
0
0

In my last blog from Nov. 14th I wrote about my Open Source project in which I develop a OData server for node.js. In this blog I want to show you how easy it is to write a Fiori app in SAP Web IDE that connects to an onpremise node.js backend application that uses my n-odata-server npm package.

 

I will not go into the details of writing the backend application here but only focus on the frontend application in Web IDE and configuration of the connection between the node.js server and hcp. If you are interested in writing the backend application you should have a look at my github repository. There you find a simple example that shows how you can create such an app in a few minutes.

 

The app I create here is a Master-Detail Fiori app that displays some customer data (see last screenshot for the apps output).

 

Prerequisites

The prerequisites for this blog are that you have created a backend application and that this is started (by simply entering node . at the command line). The default port of such a backend application is 3000. So the complete local URL is

http://localhost:3000

Additionally you should have installed the SAP Cloud Connector (CC) and be registered on the HANA Cloud platform (HCP).

 

So lets start developing our frontend application.

 

Configure Cloud Connector (CC)

Before you can connect to your locally started node.js server application that acts as the OData server you have to start and configure your CC. After you have started the CC you can connect to the Admin-UI by calling the URL

https://localhost:8443/

You have to connect the CC to your hcp account (see CC documentation). When you have done this go to the menu item Access Control and add a new mapping for your local node.js server. Use the settings of the following screenshot.

SAP HANA Cloud Connector.png

This setting in the upper table maps your locally running host to a virtual host with name n-odata-server-local. In the lower table you give hcp access to all URLs of port 3000 on your localhost.

 

Create destination on HCP

In this step you create a destination on HCP that you later use in your application. This destination leads to your local node.js application. Enter the following settings for this destination.

hanatrial.Destinations.png

In the field URL you enter the URL of your virtual host that is exposed by CC. The additional properties on the right side are also important. If you don't add them you will not be able to choose this destination in the next steps.

 

Create Fiori app

In this step you create a Fiori app with the Master-Detail template of SAP Web IDE. This is the same as if you use a SAP Gateway or any other destination. Therefore I will not go into much detail here, the screenshot should be self-explanatory.

So start the SAP Web IDE. If you don't remember the URL you find it under menu item Subscriptions and then webide or have a look here for more details.

 

Create a new project

Create a new project in Web IDE by right-clicking on any node in Web IDE and selecting New->Project from Template.

Bildschirmfoto 2015-12-22 um 13.38.22.png

Choose Template Master-Detail

Bildschirmfoto 2015-12-22 um 13.40.13.png

Insert project name

Choose a project name of your choice.

Bildschirmfoto 2015-12-22 um 13.41.39.png

 

Choose destination

In the next step of the wizard you have choose the destination you want to use for your application.

Select "Service URL" as Source and then select the before created destination.

Bildschirmfoto 2015-12-22 um 14.19.04.png

After you chose your destination you have to enter the URL of the OData service. The default setting for the n-odata-server is /odata. So enter this in the URL field.

Bildschirmfoto 2015-12-22 um 14.19.34.png

After you have clicked on the arrow or left the field you will see all Entityset that your OData service exposes. In the following step we are interested in the Customers entityset.

Click next to configure your app in detail.

 

App configuration

In this step you configure which entityset (collection) of your OData service you want to use and which field should be displayed on the screens. Take the following screenshot as template.

Bildschirmfoto 2015-12-22 um 14.43.04.png

 

Finish app creation

In the last wizard step you simply have to press Finish to finally create your application. The sourcecode for your application is now generated.

Bildschirmfoto 2015-12-22 um 14.43.26.png

 

Run application

After your project is generated you can simply run it by right-clicking on the project node and choosing Run --> Run as --> Web Application.

Bildschirmfoto 2015-12-22 um 14.44.08.png

Cause the generator created two start files you have to choose the one you want to use. Selecting index.html is fine here.

Bildschirmfoto 2015-12-22 um 14.44.40.png

See the output of your app

Web IDE opens a new TAB/Window that is running your app. You can now browse through all the customers of node.js application.

Bildschirmfoto 2015-12-22 um 14.45.22.png

 

Conclusion

You see that working with the n-odata-server is as easy as using a SAP Gateway server Odata service. But you don't need to have a full blown SAP R/3 or a HANA system in the backend. You can run the node.js server with a minimal amount of resources (memory, disk space). Even though you can use a local or corporate database with the n-odata-server you are not forced to. The n-odata-server can save all it's data into a single file in the filesystem. This is mostly sufficient in the development and functional testing phase.

But the n-odata-server may also be a choice if you want to write Fiori apps that use data from corporate databases that are in use for a long time and that you don't want to or cannot migrate to HANA or any other OData-friendly technology.

 

I highly appreciate your comments and if you want to contribute to the project you're welcome. 

SAP UI5 Basics Part 2 - CSS

$
0
0
Welcome to the second part of my blog series about the foundations of SAP UI5. These blogs are targeted at experienced ABAP developers and SAP GUI experts. They should support and motivate you to learn the basics of web development to guarantee an easy switch to SAP UI5 development.
In the last blog we created a simple website in a text editor and learned about the basics of HTML. With these bascis it will be easy for you to expand your knowledge. In the not so distant future you will be able to develop much more complex websites.
One thing that is really important today is design and the standard elements of HTML simply do not look good. And they certainly do not fit your corporate design. The question is: how can we implement our own design to make our website unique? The answer is the topic of this blog post: CSS. CSS stands for Cascading Style Sheets. This technology is used to format the HTML elements.The principal of CSS is rather easy. You define a selector and a declaration. The selector "selects" the HTML elements that will be changed by a layout. You surely remember the paragraph element <p> from the first blog post. A selector for this element could look like this:

 

p{ font-size: 12px;

color:red; }


The code above defines the following rule: every paragraph of your website has the font size of 12 and font color red. But what can we do, if we want to treat paragraphs differently? This brings classes and IDs onto the table. You can assign IDs to your HTML elements.

 

<p id=„footer“>This is my favourite footer</p>
As you can see here the paragraph has the unique ID "footer". Now you can adress this paragraph by ist ID. Which format makes sense for a footer? Most of the time small fonts in a light grey color are used.Often times the text is centered and of course it is located at the bottom of the page.
IDs are adressed with a "#". The following rule defines that the footer is small, grey, centered and at the bottom of the website:

 

#footer{
font-size: 12px;
color:gray;
text-align: center;
padding-top: 90%;

}

The result looks like this:

CSS can be inserted directly into HTML with the <style> tag. It must be part of the header or a reference to an external file. This can be done using the tag <link>:
<link href=„style.css“ rel=„stylesheet“>
You can also define classes. These classes can be assigned to several objects. The attribute "class" of an HTML element can be used here.
<p class=„information“>This text is located in a paragraph which has the class information</p>
Classes are referenced in CSS with a leading ".".

 

.information{
font-size: 12px;
color:blue;

}

Another possibility to define CSS is inline in the HTML element definition. Use the style attribute here:

<p id=“footer“ style =“color:red“ >Besuchen Sie uns auch auf <a href=“http://www.mindsquare.de“> Mindsquare.de</a></p>

Now a question arises: What happens if you have defined a rule in your CSS file but you overwrite it inline? Then the CSS hierarchy decides:

  • universal selector
    • this selector applies to every element
  • type selector
    • this selector applies to elements of a certain type, like <p>
  • id selector
    • this selector applies to the element #ID
  • class selector
    • this selector applies to all elements of the class .CLASS
  • descendant selector
    • this selector is like type selector but it is only valid if the element is inside the correct elements

 

The following rule applies: if all selectors are the same then the last defined rule is valid.

 

Universal selector:

*{ font-size: 12px; }

Type selector:

h1{ font-size: 18px;
 color:red; }

ID selector:

#footer{
font-size: 12px;
color:gray;
text-align: center;
padding-top: 90%;

}

Class selector:

.adress{
font-size: 9px;
color:gray;

}

Descendant selector:

p a{
font-size: 12px;
color:blue;

}

In this example a <a>-element will only have blue color and font size 12 if it is placed inside a paragraph.
I hope that I could give you a first insight into CSS that maybe piques your curiosity. You can find a really great and detailed reference about both HTML5 and CSS at http://www.w3schools.com.In the next part of this blog series I will present the script language JavaScript and the DOM-tree. You may have noticed already that web development is vastly different compared to ABAP but it is very interesting and can be a lot of fun. You should know these technologies because SAP UI5 is based on them.
As always: if you have any question about the article then post a comment and I will answer as fast as I can.

SAP UI5 Basics Part 3 - Javascript

$
0
0

Introduction

This is the third part of my blog series about the basics of UI5 development. The first two parts are about building and theming a website. This was achieved by using HTML and CSS. This blog concentrates on the interaction between the website and the user. This will be done using JavaScript, a script language that descended from C. It enables the webmaster to offer interaction to the user (for example triggering events).

Since this blog series is targeted at veteran ABAP developers I want to ease your transition by comparing ABAP to JavaScript to teach you the basic syntax. After that you can turn to advanced literature to deepen your skills.

JavaScript is essential to developing applications with SAP UI5. Similar to CSS the JavaScript code will be embedded into your website. It is placed as you have learned in part 2 of the blog series in the HTMl tag <head>. However you can insert your JavaScript file everywhere in its own HTML5 tag.

Data types

Contrary to the development in SAP and ABAP Javascript does not have a Data Dictionary to create data elements, structure and tables. It is very loosely typed. There are the following data types:
• Boolean
• Number
• String
• Objects

In ABAP there are four char-like data types alone:
• Char ( C )
• Numchar (N)
• Date (D)
• Timestamp (T)

Declaring variables

The declaration of variables is easier compared to ABAP, where the declaration begins with DATA and a concrete data type or element. For example:
DATA lv_sales_order TYPE VBAK-VBELN.
JavaScript declares by allocation and it uses the keyword "var" instead of "data". For example:

var text = "I am a string";

This declares the variable "text" and allocates the string "I am a string". Instead of the "."-notation in ABAP the statements in JavaScript end with ";".

You may wonder what would happen if you just wrote "var text;". This would declare the variable text but it would have the state "undefined". This can be compared to INITIAL in ABAP. INITIAL does not exist in JavaScript. There are the states "undefined", "not defined", "NaN" (not a number) and "null". "null" is only relevant to objects.

Objectorientation and dot-notation

JavaScript is object oriented and the declaration of objects is easy:

var dateObj = new Date();

In this example I created a date object with the name "dateObj". This can be referenced by the dot-notation to execute ist class methods.

Outputting the current weekday as an example:

var dateObj = new Date( );
 var day = dateObj.getDay();

The variable day holds the current weekday now as a number. Monday would be a 1, Tuesday a 2 and so on.

In ABAP an object has to be declared first with "TYPE REF TO". To instantiate an object you use the command "CREATE OBJECT" and to execute a methode you use the "->" arrow.

Im ABAP muss das Objekt zuvor deklariert werden. Hierfür dient die Syntax „TYPE REF TO“. Um ein Objekt zu instanziieren dient der Befehl „CREATE OBJECT“ und um eine Methode aufzurufen wird eine „->“ – Pfeilnotation genutzt.

Example:

DATA lo_date_object TYPE REF TO ZCL_DATE_INFORMATION.
DATA lv_day TYPE i.

CREATE OBJECT lo_date_object.

*return day as number

lv_day = lo_date_object->getDay( ).

Functions

Here's a greate advantage of JavaScript: functions. They can be created fast and easy and can be used directly on the website. There doesn't need to be a return-paramenter and the user can embed the function everywhere on the website:

Example function:

function addNumbers( num1 , num2 ){

alert( num1 + num2 );
}

This simple function returns the sum of "num1" and "num2" using the alert-function. This creates a popup in the browser.

As you can see the curly brackets are used to define a function block. Inside of this block you can create as many local variables as you want.

If you want to use local data in a SAP report you used internal tables. They use a row type or structure. A short example:
DATA: lt_interal_table_of_sales_orders TYPE TABLE OF VBAK.
DATA: ls_line_structure_of_sales_order TYPE VBAK.

With these commands we created an internal table of the DDIC table VBAK and a structure to read rows from this table.

To read data from the internal table you can use a LOOP or READ TABLE.

In this case we want to read the first line of the table:
READ TABLE lt_internal_table_of_sales_orders INTO ls_line_structure_of_sales_order INDEX 1.

Arrays

JavaScript uses arrays, a data structure that is very similar to internal tables in ABAP. They contain a set of elements, which don't need to be of the same type. The index starts at 0 and inserting, updating or deleting of elements is always possible. Creating an array can be compard to instantiating an object.

var exampleArray = new Array( );

You can directly insert values, too:

var exampleArrayWithValues = new Array( „Value1″ , „Value2″, „Value3″);

To read the second value type this:

var a = exampleArrayWithValues[ 1 ];

Variable "a" will now contain the string "Value2". You can also create the array using only the literals:

var exampleArray2 = [ „Value1″, „Value2″ , „Value3″ ];

And that is about it. You don't need to know more to start using JavaScript, a must-have in the toolbox of an UI5 developer.

A first example

In this little example you will create a button with HTML which defines an event onClick (trigged by a click). This event will call the function "buttonClicked".

<html>

     <head>

          <title>Button-JavaScript</title>

          <script type="text/javascript">

               function buttonClicked(){

                    alert("I was clicked!");

               }

          </script>

     </head>

     <body>

          <button onclick="buttonClicked()">Click me</button>

     </body>

</html>

As mentioned before the JavaScript code will be placed inside the header. The function "buttonClicked" does nothing more that creating an alter-popup with the text "I was clicked!". The body of the page contains a button that calls the function "buttonClicked" if the event onClick occurs. And that's it. You created your first interaction between website and user.

Here you can see the website in action:

2.PNG

3.PNG

I hope that I could give you a short overview over the basics of SAP UI5. Maybe I could pique your curiosity and you will start learning more about these technologies. If you have any questions or feedback feel free to contact me.

UI5 Classes and objects

$
0
0

Dear UI5 Developers,

 

As you all know, UI5 is a JavaScript-based HTML5 framework for building desktop and mobile applications. JavaScript is a very flexible object-oriented language when it comes to syntax. But Objects in JavaScript are class-free. There is no constraint on the names of new properties or on the values of properties. Objects are useful for collecting and organizing data. Objects can contain other objects, so they can easily represent tree or graph structures.You can read more about JavaScript Objects in the book "JavaScript: The Good Parts".

 

JavaScript is class-free, but you can somewhat simulate classes. There are multiple ways to simulate classes and so has UI5 his own way to simulate classes.


In this blog I'll show you how you can create a class and how to create an object of this class. I'll also show you how you can use this objects in your JSON model.


We start with creating a class by extending the component/class: "sap.ui.base.Object" . 


The extended class has a constructor. This has the same functionality as in ABAP or Java. It will be called when you create an object of your class.


With the "this" object you can refer to the object itself and store properties like firstname, lastname, ...


Like every other language, you can also create function in your class. But it's not possible to create private, protected or public functions. SAP defines protected function by starting a function with a underscore, for example _privetFunction:function(){}.


An example of a basic UI5 class with properties, functions and a constructor:


sap.ui.define([  "sap/ui/base/Object",  "sap/ui/model/json/JSONModel"
], function(Object, JSONModel) {  "use strict";  return Object.extend("be.wl.objects.model.Person", {    constructor: function(data) {      if (data) {        this.firstname = data.firstname;        this.lastname = data.lastname;        this.fullname = this.getFullName();      }      this.model = new JSONModel();      this.model.setData(this);    },    getFullName: function() {      return this.firstname + " " + this.lastname;    },    getModel: function() {      return this.model;    }  });
});

Now you can create an object of your class in the controller of your view like this:

 

this.p = new Person({firstname:"Wouter",lastname:"Lemaire"});

The constructor of my class already creates a JSON model for every object. This means I can just use my function getModel() to get the created model of the object "p":

 

this.getView().setModel(this.p.getModel(),"person");

 

After setting the model of the view with the object "p", we can access all the properties of the object in our view:


<Input value="{person>/firstname}" editable="false"></Input>    <Input value="{person>/lastname}" editable="false"></Input>    <Input value="{person>/fullname}" editable="false"></Input>

This will look like this:

voorbeeld.png


Working this way seperates your model from your view and controller. This will also reduce coding in the controller.

 

You can find the full example on Plunker:


http://plnkr.co/edit/izg0IciJ5URv5oYIQs49?p=preview


Try using objects, it will make your code easier to read and accelerates your developements.


Next topic - Inheritance: UI5 Classes and objects - Inheritance


Find out how to use this in your UI5 project: UI5 Classes and Objects - Putting it all together


Kind regards,

Wouter

UI5 Classes and objects - Inheritance

$
0
0

Dear UI5 Developers,


In my previous blog I've talked about the basics of classes and objects in UI5:

UI5 Classes and objects


Now I'll extend this with inheritance.


This example will use a parent class for creating the JSON model and will have a get function for the model. It extends from the sap.ui.base.Object class.


The constructor will set the current object as data for the model. The "getModel" function will be used to fetch the model.


Parent class:

sap.ui.define([  "sap/ui/base/Object",  "sap/ui/model/json/JSONModel"
], function(Object,JSONModel) {  "use strict";  return Object.extend("be.wl.objects.model.BaseObject", {      constructor: function() {           this.model = new JSONModel();            this.model.setData(this);      },  getModel:function(){       return this.model;  }    });
});


If we want to use this class as parent for others classes we'll have to extend this class instead of extending "sap.ui.base.Object" . Besides extending the parent class, we'll also have to call the constructor of the parent in the contructor of the child. Therefore we use <name of parent class>.call(this).


See how I've changed the example of my previous blog to work with the parent class.


The constructor will call the constructor of the parent class: "BaseObject.call(this)"


sap.ui.define([    "be/wl/objects/model/BaseObject"
], function(BaseObject) {  "use strict";  return BaseObject.extend("be.wl.objects.model.Person", {      constructor: function(data) {   BaseObject.call(this);        if(data){          this.firstname = data.firstname;          this.lastname = data.lastname;          this.fullname = this.getFullName();        }      },      getFullName:function(){        return this.firstname+" "+this.lastname;      }    });
});

I don't need to create the model in the constructor of my Person class and I don't need the function "getModel". This is done in the parent class. When creating an object of the class "Person" the object will also have the functions of the parent class.

 

The coding of the controller stays the same with or without parent class:

onInit:function(){     this.p = new Person({firstname:"Wouter",lastname:"Lemaire"});     this.getView().setModel(this.p.getModel(),"person");
}

All the properties of the object can be used in the view:

    <Input value="{person>/firstname}" editable="false"></Input>    <Input value="{person>/lastname}" editable="false"></Input>    <Input value="{person>/fullname}" editable="false"></Input>

It will look the same as without the parent class:

voorbeeld2.png


You can find the full example on Plunker:

http://plnkr.co/edit/b1XmYA1wBxm6q0u3iRBx?p=preview


See how you can put it all together:

UI5 Classes and Objects - Putting it all together


Kind regards,

Wouter

Viewing all 789 articles
Browse latest View live




Latest Images