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

Overview of available platforms for SAPUI5 development using Eclipse and SAP NetWeaver Gateway 2.0

$
0
0

In this blog I’d like to compare the available platforms for SAPUI5 development. The below table shows three systems with access to SAP NetWeaver Gateway 2.0 and their features.


All of the following systems allow to work with the Eclipse environment. This is possible after installing the UI development toolkit for HTML5. To learn how to install UI development toolkit for HTML5 please view this presentation http://scn.sap.com/docs/DOC-46226 or refer the link https://tools.hana.ondemand.com/#sapui5.


What is more, if you install Eclipse Juno you can use The Gateway Productivity Accelerator. For more information please refer the link http://scn.sap.com/docs/DOC-52235.



So, if you want to know:


  • how to access each of these systems
  • if the system allows you to create services
  • if the system has a UI-Add-On 1.0
  • if the system allows you to include a program on the server ABAP
  • whether you have to pay for access to the system


you have to immediately read this blog!



About access to these systems:


SAP NetWeaver Gateway Demo System:

ABAP Trial 7.02 SP11 Win 64 bit Version with Gateway 2.0 SP04

 

SAP NetWeaver Application Server ABAP 7.4 on SAP MaxDB




 

SAP NetWeaver Gateway Demo SystemABAP Trial 7.02 SP11 Win 64 bit Version with Gateway 2.0 SP04SAP NetWeaver Application Server ABAP 7.4 on SAP MaxDB
Hosting platformCloud provided by SAP

On-Premise

Cloud provided by Amazon Web Services
Possibility to create own services (1)Impossible (User are not authorized to create)PossiblePossible
UI-Add-On 1.0Not availableNot availableAvailable
Deployment in ABAP serverImpossible (User are not authorized to create)Possible (2)Possible (3)
CostFreeFreePaid (depending on the price of Amazon Web Services)


  1. To learn how to develop a Gateway Service using code based implementation please view this document http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/f0efbaca-45ba-3010-b7bb-8c1c5aa109ab?QuickLink=index&overridelayout=true&58475979909212
  2. ABAP Trial 7.02 SP11 Win 64 bit Version with Gateway 2.0 SP04 it’s possible only manually deployment. For more information please refer the blog http://scn.sap.com/community/developer-center/front-end/blog/2012/12/07/building-a-crud-application-with-sapui5-and-icf-restjson-service--part-3.
  3. If you want to learn how to deploy and run SAPUI5 application on ABAP Server in Eclipse, please refer this blog http://scn.sap.com/docs/DOC-42820.

 

 

 

Best regards

Marcin


Client-side search in Master-Detail Fiori like Apps

$
0
0

While creating project from template for SAP Fiori Master Detail Application in Web IDE, by defaults we get onSearch method created in Template. In onSearch method we havesap.ui.model.Filterto use and we can add any number of filters and at last we can bind like this:

 

this.getView().byId("list").getBinding("items").filter(filters);

 

In this way, we are calling backend odata services to search and performance wise we experience slowness to get search results. We can modify this method to search in client-side and we can get search as Fiori apps. Here I will show the updated method:

 

onSearch: function() {       this.oInitialLoadFinishedDeferred = jQuery.Deferred();       var searchString = this.getView().byId("searchField").getValue();       var masterScreenList = this.getView().byId("list");       var items = [];       for (var i = 0; i < masterScreenList.getItems().length; i++) {            masterScreenList.getItems()[i].setVisible(false);       }       for (var k = 0; k < recoveryArray.length; k++) {            masterScreenList.getItems()[k].setVisible(true);       }       for (var i = 0; i < masterScreenList.getItems().length; i++) {            var banktype = masterScreenList.getItems()[i].getTitle();            var paymenttype = masterScreenList.getItems()[i].getNumber();            var sDate = masterScreenList.getItems()[i].getAttributes()[0].getText();            var eDate = masterScreenList.getItems()[i].getAttributes()[1].getText();            if (banktype.toString().toUpperCase().indexOf(searchString.toUpperCase()) === -1            && paymenttype.toString().toUpperCase().indexOf(searchString.toUpperCase()) === -1            && sDate.toString().toUpperCase().indexOf(searchString.toUpperCase()) === -1            && eDate.toString().toUpperCase().indexOf(searchString.toUpperCase()) === -1) {                 var aItem = masterScreenList.getItems()[i];                 items.push(aItem);            }       }       for (var j = 0; j < items.length; j++) {            items[j].setVisible(false);       }       //On phone devices, there is nothing to select from the list       if (sap.ui.Device.system.phone) {            return;       }  }

The recoveryArrayvariable has to be declared global inMaster.controller.jsand initialize it at selectFirstItem method created in template like this:


this.recoveryArray = this.getView().byId("list").getItems();

 

Every time model changes, callselectFirstItem to load all items in recoveryArray and show/hide according to search.

SAPUI5 is now delivered via Akamai CDN

$
0
0

Hi all,

Web performance is critical in today’s world. There are 3 main factors that influence it- network latency, java script execution time and pixels rendering on the screen (the last two depend on the computing power of the client device). Common approach to fight against network latency, especially in scenarios with clients distributed across the globe, is to use a Content Delivery Network (CDN) solution. We, the SAPUI5 team, have chosen Akamai, a leading CDN vendor with more than 200,000 servers in 2,000 data centers. Akamai serves significant part of the internet traffic. It is already well adopted in SAP and used for business critical solutions like Service Marketplace, SCN and HANA Cloud Platform. 

Since Mar-17, SAPUI5 running on HANA Cloud Platform (https://sapui5.hana.ondemand.com/) is delivered via Akamai. Instead of fetching the SAPUI5 runtime, SDK and documentation from HANA Cloud Platform landscapes, the end user will now retrieve them from the closest to him Akamai server. That significantly improves the performance and the end user experience, especially for more distant locations from the existing data centers. The dynamic content and the first requests before Akamai cache is filled are still served by the HANA Cloud Platform. Benefiting from the synergy between HANA Cloud Platform multiple data centers and Akamai route-optimization capabilities those requests are routed to the closest location- either Germany, Australia or USA. The original SAPUI5 application running on HANA Cloud Platform is still accessible directly via the subdomain “eu1”, “us1” and “ap1”, like “sapui5.eu1.hana.ondemand.com”. OpenUI5, our open source version under Apache license, is as welldelivered via Akamai

To get performance benefit from Akamai the applications should refer SAPUI5 libraries from the cloud instead of bundling them as part of the application.As a next step we plan SAPUI5 multi-version support. It would be then fully up to the application to switch to a newer SAPUI5 version, referring it directly from the cloud.

SAPUI5 team




Analysis Path Framework – a hidden Gem for Creating Awesome Analytical Apps

$
0
0

Working Capital Analytics (especially Days Sales Outstanding) and was a demo case shown at several SAP keynotes of major events. It showed perfectly the combined power of SAP HANA and UI5. For me it was a huge inspiration and I started to build my own UI prototypes using crossfilter.js and dc.js (and of course d3.js). These are extremely cool frameworks and help doing visualization with multiple filters. Aggregation and Filtering are extremely useful for exploring huge data sets but you’ll need some JavaScript skills: DC is very easy to use but you should wrap it in a control to be compliant with MVC paradigm. With crossfilter this is easy but it takes more effort to use it.

 

But today you can to better: fortunately the infrastructure of Working Capitals Analytics turned out to be very powerful and was created into a general framework called Analysis Path Framework. This framework has become as guideline Fiori Analytics Apps and covers the following use cases:

  • the end user need flexibility in drill-down sequences to explore data in a Fiori resp. UI5 applications
  • when doing this he or she uses several drilldown dimensions on multiple data sources by defining filters and creates an analysis path
  • analysis may be required to switch between different KPIs  working in real time on operational data

 

This is done very easily since APF is a consumable UI5 library and is integrated in Fiori and SAP Smart Business. So if you have HANA license (and so HANA Live) and SAPUI5 you can start: use views of the SAP Virtual Data Model or create own calculation views in SAP HANA and start do configuration.

https://sapui5.hana.ondemand.com/sdk/test-resources/sap/apf/demokit/app/index.html

 

On Youtube you find some videos that show how powerful APF is. Here is an overview of APF based apps:

 

This shows how an analysis path is created:

 

Further options of analysis paths are described here:

 

And here it is shown how to use filters in APF and how the filter works in detail:

 

In fact APF and Smart Business are related:

 

To use this feature you need Smart Business (Fiori Wave 7 and an Fiori Launchpad) and you can create KPI tiles based on APF.

 

Last week in Walldorf I had a talk with Dirk Degrell, Product Owner, and Wolfgang Schaper, Solution Manager of APF:

 

Which SAP products are using APF?


Wolfgang: “Several products make use of APF. This holds for SAP Financials for instance. Additional products, like SD or Fashion Management, are currently validating APF.”


What’s the connection from APF to Fiori?


Dirk: “APF is a Fiori App, meaning APF uses the technical Fiori infrastructure, and follows Fiori design guidelines.”


In products like Working Capital Analytics or Smart Business APF comes out of the box. Can I use any entities of VDM in the APF?


Wolfgang: “All appropriate HANA views of the VDM can be used in APF. “Appropriate” means the views have to fulfill some simple requirements, e.g. they have to be aggregating views.”


Can I use APF also in sidecar scenarios or only with primary persistence on HANA?


Dirk: “Sidecar scenario or HANA as primary database does not make a difference for APF. Both is fine.”


Does APF support custom made VDM entities?


Dirk: ”Whether the HANA views are developed and shipped by SAP or built on customer site does not matter for APF.”


Can I use APF in own Fiori/UI5 applications?


Wolfgang: “An APF based application is a Fiori application on its own already, so it comes with a certain UI that ensures compatibility with Fiori Design Guidelines, that provides responsiveness (i.e. the application can be executed on desktop/laptop as well as tablet devices), etc. You can use APF in your own applications in the sense that you navigate from your application (e.g. Smart Business KPI tile) to an APF based application for further analysis and out of this analysis you may navigate again to another application of yours, e.g. to take action. In this navigation you can of course take over the business context of your analysis in your application (e.g. all parameter settings and selections/filters). A UI integration of APF into another application is currently not possible as an APF based application is much more than a (smart) control only … as said it is an application on its own.”

 

You can find more information about APF in the BI space of SCNhttp://scn.sap.com/docs/DOC-59620. I can’t wait to get my hands on APF and hope to find the time to build a prototype, soon. What do you think? What’s your experience with APF? IMHO this would be a real cool showcase for an SAP CodeJam since you can use it to analyze operational data (perhaps from IoT) by using HANA and Fiori.

From ABAP to SAP/OpenUI5 - Setup webserver with proxy

$
0
0

The context

 

As most people who come from the ABAP world, I started my journey into SAPUI5 by using SAP's tools: Eclipse and the SAPUI5 plugin. It appears to make our lives easier by setting up a local server for testing and running the proxy servlet to handle CORS problems. I say "appears" because then we see in the forums a lot of people with proxy related problems. In Eclipse you use something like this in your oData URLs


proxy/http/<server>:<port>/sap/opu/data/sap/<service>


At the very least this is bad because you need to change your code when you deploy to a SAP server (or create a bunch of ifs to validade where your call if being made). What you should have is this:

 

 

/sap/opu/data/sap/<service>


and let the host be determined automatically by the server config. At first you are happy Eclipse handles this (albeit poorly), after a while you will want more control. This is how to do it.

 

The solution

 

Let me make this clear: Eclipse is a terrible SAPUI5 editor. You will want to get rid of it and I will help you do it. First step: running your own webserver with proxy. The solution - Node.js and Grunt.

 

First you must install Node.js from https://nodejs.org. This will install the NPM javascript package manager that will be your friend for a lot of tasks. Then open terminal and run (with sudo/administrator if necessary):

 

npm install -g grunt-cli


Grunt is a javascript based task runner that handles repetitive development tasks for you. Setting up a webserver with proxy is such a task. There are two important files that you should put in your project folder (which you see in every Github project):

- package.json: Describes your project and its dependencies (for Node/NPM);

- gruntfile.js: Describes the tasks that should be run (for Grunt)

 

I'll write another blog to describe these in more detail, but for the time being lets focus on the gruntfile.js that will setup the server and proxy:

 

var proxySnippet = require('grunt-connect-proxy/lib/utils').proxyRequest;
var mountFolder = function(connect, dir){  return connect.static(require('path').resolve(dir));
};
module.exports = function(grunt){    require('load-grunt-tasks')(grunt, {scope: 'devDependencies' });    grunt.initConfig({        connect: {            server: {                options: {                    port: <desired local port>,                    hostname: 'localhost',                    keepalive: true,                    middleware: function (connect, options){                        return [                            proxySnippet,                            connect.static(options.base[0]),                            connect.directory(options.base[0]),                        ]                    }                },                proxies:[                    {                        context: '/sap/opu/odata',                        host: '<sap_host>',                        port: '<sap_port>',                        https: false                    }                ]            }        }    });    grunt.registerTask('default',[        'configureProxies:server',        'connect'    ]);
}

 

The server-options setups the local webserver and the proxies setting redirects all URLs that begin with '/sap/opu/odata' to the specified remote server. Notice that you can configure several proxies for different URLs inside the [ ].

 

To run the script, just navigate to the project directory in Terminal, and then run "grunt". You should get something like this:


Captura de ecrã 2015-04-4, às 10.48.11.png

 

Well ... after you install the dependencies anyway :). To do this, save this simple package.json in your main project folder:

 

{  "name": "<Project name>",  "version": "0.1.0",  "description": "<Descrition>",  "main": "Component.js",
}

And then run these commands on the terminal (since you are not using the global install "-g" you won't need sudo or administrator):


npm install grunt-contrib-connect --save-dev
npm install grunt-connect-proxy --save-dev
npm install load-grunt-tasks --save-dev

 

Now just run grunt again and you will get the screenshot I showed before. Remove the hostname and port from your oData calls, and they will be redirected according to the grunt file using the /sap/opu/odata path.

 

To confirm the redirections are being correctly handled, you can run grunt with the --verbose setting. If you do, every redirection made by the proxy will show up in the terminal:

 

Captura de ecrã 2015-04-4, às 11.03.59.png

 

Now that you don't need Eclipse to setup the webserver and proxy, you are one step closer to not needing it. Further steps on the next blog.


Side notes

 

If you look at the package.json you will see that entries have been added to the devDependencies. We will use this later to automatically install the dependencies using "npm install" - you don't have to perform all these steps manually every single time.


Finally, to make it clear how powerful these open source tools are becoming, I would like to point out that even Microsoft has included them in Visual Studio 2015 templates. You now see package.json and gruntfile.js (and bower.json) on ASP.Net projects

TreeTable using json data

$
0
0

Hi Everyone,

I want to share how to display json data in treetable.

 

 

//Create an instance of the table control

var oTreeTable = new sap.ui.table.TreeTable({

  title:"",

  width : "100%",

 

 

columns: [

   new sap.ui.table.Column({

       label: "",

       template: ""

   }),

   new sap.ui.table.Column({

       label: "",

       template: ""

   }),

   new sap.ui.table.Column({

       label: "",

       template: ""

   }),

 

],

selectionMode: sap.ui.table.SelectionMode.None,

enableColumnReordering: false,

expandFirstLevel: false,              //if true expand whole tree showing all of its root elements

toggleOpenState: function(oEvent) {

 

 

}

})

//binding json data to treetable

 

var data = {

        root: nOdata,

    };

 

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

    oTreeModel.setData(data);

    oTreeTable.setModel(oTreeModel);

    oTreeTable.bindRows({

        path: '/root',

    });

 

 

 

//odata into json

 

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

var oData = [

      {

        "__metadata" : {

          "id" : "http://url",

          "uri" : "http://url",

          "type" : "Entity name"

        },

        "Child1" : "",

        "Child2" : "",

        "Child3" : "",

        "Child4" : "",

        "Child5" : "",

        "Child6" :

      },

] // write all elements over here

 

 

 

var nOdata = [];

var tmpArr = [];

 

 

for (key in oData) {

   nID = oData[key]['child1'];

   pID = oData[key]['child2'];

 

   if(pID == "") {

     tmpArr = oData[key];

     tmpArr['children'] = [];

     newOdata.push(tmpArr);

   }

   else {

     found = searchAndAddNode(nOdata, oData[key]);

     //console.log(found);        

   }

}

function searchAndAddNode(node, nodeToAdd) {

  found = false;

     for (key in node) {

       if(node[key]['child1'] == nodeToAdd['child2']) {

         tmpArr = nodeToAdd;

         tmpArr['children'] = [];

         node[key]['children'].push(tmpArr);

      

       found = true;

       return found;

       }

     }

  if(!found) {

    for (key in node) {

      found = searchAndAddNode(node[key]['children'], nodeToAdd);

    }

  } 

  return found;

}

 

 

 


OFFLINE Data Storage

$
0
0

Hi,

 

As we know SAP Next transformations are SAP Fiori/UX design approach. The main agenda for this transformations are to reduce more number of clicks in SAP Screen and Code Once RUN on ANY DEVICE.

 

Scenarios:

 

- Tablet/Mobile

- WareHouse Area

- Wifi Health : weak

- Assume my user id have thousands of records. If I am calling all the time to hit GW services, my application performance will move to Bad health. So what to do?

 

Sol: OFFLINE DATA

 

 

Here is the solution to solve this problem. While rendering SAP UI5/Fiori application (view) we should call services at one time and use below code to store all user details into local memory ( Not in application memory).

 

var filePath = "MyFileName.JSON";

window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(FS) {

     FS.root.getFile(filePath, {create:false, exclusive:false},

         function(fileEntry) {

             fileEntry.file(function(file) {

          var reader = new FileReader();

 

 

          reader.onloadend = function(e) {

          funCall(this.result);

          };

          reader.readAsText(file);

          });

         }, fail);

  }, fail);

 

 

function fail(){

  var objJSON = null;

  funCall(objJSON);

  }

 

Based on create:false/true flag, we can read or create new file from/to local memory.

 

This way will helps you to do offline functionality .

 

Thanks,

Karthik A

How to get UserName and other login info in SAP UI5 application

$
0
0

Hi Everyone,

 

I am writing this blog to get login info into SAP UI5 application, where you can display User ID, FirstName, LastName, FullName, Email etc... in any of your SAP UI5 Apps.

 

Here is the sample code where you can fetch all the information into JSON format.

 

//Get User details once logged in

 

   //Get User details by using srv;

    var y = "/sap/bc/ui2/start_up";

    var xmlHttp = null;

    xmlHttp = new XMLHttpRequest();

    xmlHttp.onreadystatechange = function() {

    if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {

       var oUserData = JSON.parse(xmlHttp.responseText);

          console.log(oUserData);

       }

    };

    xmlHttp.open( "GET", y, false );

    xmlHttp.send(null);

 

or we can also use JSON Model

 

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

oModel.loadData("/sap/bc/ui2/start_up");


Note: This will only run on SAP UI5 BSP application but not on local SAP UI5 application.


Contacts: Use Cordova plugin Contacts to add to Device Contacts and an external plugin to call with SAPUI5 app

$
0
0

Introduction

 

SAP Web IDE is an Integrated Development Environment for SAPUI5 and Fiori applications.

In this blog we shall see how to use Cordova plugin Contacts and an external plugin, from within a SAP UI5 mobile app. (along with Kapsel plugin Logon Manager)

 

 

Objective

To develop an SAPUI5 app from one of the standard templates which takes data from a backend system. We will use the OData service "CB_CUSTOMER_SRV" for getting the customer information from the backend. We will add some custom code and do the following:

Add a button to add back end Customer Contact details to the mobile device Contacts.

Add a button to Call the Customer directly from within the app without adding it to the Device Contacts.

 

Once the app is ready, we will mobilize it using the Hybrid Application Toolkit and the trial HCPms system.


The final app will look somewhat like this: (with 2 buttons on the detail view of Customer) FinalApp.png


Prerequisites

  • SAP Web IDE 1.9.3 and later (you can register at SAP HANA Cloud Platform to get your development environment)
  • Hybrid Application Toolkit 1.2.6 downloadable from here
  • An HCPms account configurable as described here
  • SAP HANA Cloud Cloud connector(latest version preferred) downloadable from here
  • An Android device which is recognizable using your PC. (An android simulator can be used only to add contacts, but to call contacts directly an actual Android device is needed)
  • 'Call Contact' Plugin (you can find it here)

 

All the above prerequisites must be properly configured, before moving forward with this guide


Walkthrough

This is the list of all the steps we'll go through:

  1. Create a destination and connect it to Cloud Connector
  2. Create a new Application in the HCPms
  3. Create a new Kapsel app with SAP Web IDE
  4. Add buttons to the Detail view
  5. Add the necessary custom code for the new buttons
  6. Deploy the app with HAT
  7. Clone the Call number Repository and Add the external plugin to Call Contact
  8. Build the project from command line
  9. Run the project on a mobile device

 

1. Create a destination and connect it to the Cloud Connector

We have to create a connection to the backend system. We can create a new destination to reach the CB_CUSTOMER_SRV service located on the ABAP system called GM6.

Start the SAP HANA Cloud Connector and create an access control row for the resource path on the ABAP system

 

1HanaCloudConnector.png

Access your HANA Trial environment and create a new destination which points to the Cloud Connector item created in the previous step

 

2Destination.png

2. Create a new Application in the HCPms

Create a new application in the HCPms system. You can follow this blog to learn how to enable your HCPms environment.

Go on https://hcpmsadmin-<your_user>trial.dispatcher.hanatrial.ondemand.com where you need to replace the string "<your_user>" with your user account.

Click on Applications

Create a new Application with the following parameters and click on Save

 

ParameterValue
Application IDcom.test.customer
Version1.0
NameCustomer
TypeHybrid
DescriptionCustomer Application
VendorSAP
Security ConfigurationNone

 

3HcpmsApplication.png


Switch to the Backend tab and specify the Backend URL together with the Authentication Type and the Proxy Type. After this click on Save.

 

ParameterValue
Backend URL<the backend URL defined in the destination>
Authentication TypeNo Authentication
Maximum Connections500
Certificate Alias<leave it blank>
Rewrite ModeRewrite URL on HANA Mobile Server
Relative Paths<leave it blank>
Proxy TypeOnPremise

 

4HcpmsApplicationBackend.png

5HcpmsApplicationPing.png

 

3. Create a new SAPUI5 app with SAP Web IDE

Open SAP Web IDE

Create a new SAPUI5 project from the template SAPUI5 Master Detail Kapsel Application

 

6ProjectFromTemplate.png

 

Enter a project name (i.e. Customer)

Define the OData connection information to the CB_CUSTOMER_SRV service

7ProjectName.png

8ChoseService_CB_Customer_srv.png

Choose the fields you want to see in the application and click on Next.

NOTE: It's important, for the goal of this guide, to choose fields related to contact information like phone number, email address etc.,


9OdataFields.png

 

Click on Finish to end the procedure

You can test the application by running it in the desktop preview mode

 

10RunApp.png

Right click on the name of the project in SAP Web IDE and choose Project Settings --> Device Configuration. Specify the App Name, the App ID (it needs to match the Application ID used in the HCPms configuration) and the description.

 

ParameterValue
App NameCustomer
App IDcom.test.customer
DescriptionCustomer Application
Version1.0.0

 

Also choose what platforms you want to build your app for. In this case it's Android

 

11a_DeviceConfig.png



 

Specify the Cordova and Kapsel Plugins to use: In this case Contacts and Logon Manager

 

11CordovaPlugin.png

12KapselPlugin.png

 

     Enter the information about the SMP server and click on Save.

 

ParameterValue
Hosthcpms-<your_user>trial.hanatrial.ondemand.com
Port443

 

13SMPServer.png

 

 

4. Add buttons to the detail view

In SAP Web IDE open the Detail view (view/Detail.view.xml) of the app.

Add the following code on the footer toolbar with tag <Toolbar> and save the file

 

<Button id="addToContact" icon="sap-icon://add-contact" tooltip="Add to Contacts" press="addToContacts"></Button>

<Button id="callContact" icon="sap-icon://outgoing-call" tooltip="Call Contact" press="callContact"></Button>

 

14Code.png

 

5. Add the necessary custom code for the new buttons

Now open the Detail view controller (view/Detail.controller.js) and add the following function at the beginning of the file, just after the onInit function. Save the file.


//Handle Success / Error on addToContacts

    onSuccess: function(contact) {

        sap.m.MessageBox.show("Customer Contact successfully saved into Device Contacts ", sap.m.MessageBox.Icon.SUCCESS, "Add to Contacts");

    },

 

    onError: function(contactError) {

        sap.m.MessageBox.show("Failed to save Customer Contact into Device Contacts ",sap.m.MessageBox.Icon.ERROR, "Add to Contacts");

    },

 

addToContacts: function(oEvent) {
    var oView = this.getView();
    var sPath = oEvent.getSource().getBindingContext().getPath();
    var custData = oView.getModel().getData(sPath);
    //Get Customer Contact information
    var customerName = custData.CustomerName;
    var customerPhone = custData.MobilePhoneNumber;
    var customerEmail = custData.EmailAddress;
    //Cordova Contact Object
    var contact = navigator.contacts.create();
    contact.displayName = customerName;
    contact.nickname = customerName;
    //name

      var name = new ContactName();

      name.givenName = customerName;

      contact.name = name;

  //phoneNumbers
  var phoneNumbers = [];
  phoneNumbers[0] = new ContactField("work", customerPhone, true);
  contact.phoneNumbers = phoneNumbers;
  //emails
  var emails = [];
  emails[0] = new ContactField("email", customerEmail, false);
  contact.emails = emails;

        //Save

        contact.save(this.onSuccess,this.onError);

},


    onSuccessCall: function(contact){

    },

    onErrorCall: function (contactError) {

         sap.m.MessageBox.show("Call to Customer failed ",sap.m.MessageBox.Icon.ERROR, "Call Customer");

    },

    callContact: function(oEvent)

    {

        var oView = this.getView();

        var sPath = oEvent.getSource().getBindingContext().getPath();

        var customerData = oView.getModel().getData(sPath);

        //Get Customer Contacts data

        var custPhone = customerData.MobilePhoneNumber;

        window.plugins.CallNumber.callNumber(this.onSuccessCall, this.onErrorCall, custPhone);

    },

 

15Code1.png

 

6. Deploy the app with HAT

Let us now deploy the project using Hybrid Application Toolkit.

Right click on the name of the project in SAP Web IDE and choose Deploy --> Deploy to local Hybrid Toolkit

After some time you need to specify the Download folder to save the application package coming from SAP Web IDE

 

15DeployToLocalHAT.png

 

7. Clone the Call Number repository

When the deployment finishes, open a Command window

Use Git to clone the repository where your external plugin to call Contact is located. In our case we want to use the external plugin for calling a contact from within the app. This is located here so we go in a new folder (in my case "/Users/i033917/myplugins") and we clone this repository with the following command:

 

git clone https://github.com/Rohfosho/CordovaCallNumberPlugin.git


16ExternalCordovaPlugin.png

Add the Call Number plugin to the project

In command window

Go in the SAPHybrid folder normally located in your home directory

Navigate to the Customer/hybrid subfolder and type the following command to add the external plugin you cloned, to your project:

 

cordova plugins add <path_to_the_plugin> (in my case it is "cordova plugins add /Users/i033917/myplugins/CordovaCallNumberPlugin/")


17AddPluginToProject.png

8. Build the project from command line

Type the command

cordova build

to completely build the project from the command line (you cannot build from SAP Web IDE otherwise you will lose the plugin you just added). Ensure you get a Build successful message.


18CordovaBuild.png

18_aBuildSuccessful.png

9. Run the project on a mobile device

Go back to SAP Web IDE

Select the index.html file of the app, right click on it and choose Run --> Run on --> Android device (Ensure you have plugged in the Android device onto the USB and is recognized)

Once the application starts, provide the credentials for the backend server in the Kapsel Logon.

Switch On the Secure switch and click on Register


20Registration.png

Then create a new passcode or disable it and click on Submit

21PassCode.png

 

This will give you the list of Customers. Click on any relevant Customer which brings you to the Customer Details.


At the bottom tool bar you should be able to see 2 buttons: Add to Contacts and Call Contact

 

22CustomerData2.png

 

Press the first button Add to Contacts to add the Customer Contact details to the Device Contacts

23CustomerDetail.png

 

You should get a success message on successful addition of the device Contacts.

 

24AddToContactsSuccessful.png

 

Press ok.

 

You could also call the customer even without adding the Customer to the Contacts list using the second button Call Contact.

 

26CallContact.png

 

This should trigger the Call Contact.

 

IMG_20150407_103231.jpg

 

After you have successfully added the Customer Contact details to Device Contacts using the button, you can also check if the Contact details is indeed added to the Device Contacts.

 

25CustomerDataAddedToContacts.png

 

This ends the Contacts demo! Thank You!

Export To Excel customization in UI5

$
0
0

Dear SAP Developers,

SAP Explored Provided to download Table data in csv view without format.

https://sapui5.hana.ondemand.com/sdk/explored.html#/sample/sap.m.sample.TableExport/preview

But, most of the time we want to download as in format. here is the code, you can download the data in excel with format.

Add here you can export ObjectIdentifier, ObjectNumber, Link,... Controllers also.

 

In Xml View,

<Table id="idTable"  items="{odata>/modelData}" >

            <headerToolbar>

                <Toolbar>

                    <ToolbarSpacer></ToolbarSpacer>

                    <Button icon="sap-icon://download" tooltip="DownLoad XL" press="exportToExcel" />

                </Toolbar>

            </headerToolbar>

          

            <columns>

                <Column minScreenWidth="Tablet" demandPopin="true">

                    <Label text="Label1" />

                </Column>

                .....

    </columns>

            <items>

                <ColumnListItem id="itemsID" vAlign="Middle">

                    <cells>

                        <Text text="{odata>Attribute1}" />

                        <ObjectIdentifier  title="{odata>Attribute2}" text="{odata>Attribute13}"/>

                        <ObjectNumber number="{path:'odata>Attribute14', formatter: 'your_Formatter'}" unit="{odata>Attribute5}" />  

                    </cells>

                </ColumnListItem>

            </items>

        </Table>

      

In controller,  

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

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

//Add these 2 require.

exportToExcel: function()

{

    var table = this.getView().byId("idTable");

        var oModel = table.getModel("odata");//odata is the model, which is binding to the table

      

    var cols = table.getColumns();

        var items = table.getItems();

         var cellId = null;

         var cellObj = null;

         var cellVal = null;

         var headerColId = null;

         var headerColObj = null;

         var headerColVal = null;

         var column = null;

         var json = {}; var colArray = []; var itemsArray = [];

         //push header column names to array

         for(var j=0; j<cols.length;j++){

                column = "";

                column = cols[j];

                headerColId = column.getAggregation("header").getId();

                headerColObj = sap.ui.getCore().byId(headerColId);

                headerColVal = headerColObj.getText();

                if(headerColObj.getVisible()){

                    json={name: headerColVal};

                    colArray.push(json);

                }

            }

            itemsArray.push(colArray);

          //push table cell values to array

          for (i = 0; i < items.length; i++) {

              colArray = [];

              cellId = "";   cellObj = "";  cellVal = "";

              headerColId = null; headerColObj = null; headerColVal = null;

              var item = items[i];

                for(var j=0; j<cols.length;j++){

                    cellId = item.getAggregation("cells")[j].getId();

                    cellObj = sap.ui.getCore().byId(cellId);

                    if(cellObj.getVisible()){

                        if(cellObj instanceof sap.m.Text ||cellObj instanceof sap.m.Label ||cellObj instanceof sap.m.Link) cellVal = cellObj.getText();

                        if(cellObj instanceof sap.m.ObjectNumber){

                            var k = cellObj.getUnit();

                            cellVal = cellObj.getNumber()+" "+k;

                        }

                        if(cellObj instanceof sap.m.ObjectIdentifier){

                            var objectIdentifierVal = "";

                            if(cellObj.getTitle() != undefined && cellObj.getTitle() != "" && cellObj.getTitle() != null )

                                objectIdentifierVal = cellObj.getTitle();

                            if(cellObj.getText() != undefined && cellObj.getText() != "" && cellObj.getText() != null )

                                objectIdentifierVal = objectIdentifierVal+" "+cellObj.getText();

                          

                            cellVal = objectIdentifierVal;

                        }

                        if(cellObj instanceof sap.ui.core.Icon){

                            if(cellObj.getTooltip() != undefined && cellObj.getTooltip() != "" && cellObj.getTooltip() != null )

                            cellVal = cellObj.getTooltip();

                        }

                        if(j==0){

                            json={ name:  "\r"+cellVal};

                        }

                        else

                        {

                            json={ name:  cellVal};

                        }

                        colArray.push(json);

                    }

                }

                itemsArray.push(colArray);

              

              

            }

         //export json array to csv file

          var oExport = new sap.ui.core.util.Export({

                // Type that will be used to generate the content. Own ExportType's can be created to support other formats

                exportType: new sap.ui.core.util.ExportTypeCSV({

                    separatorChar: ","

                }),

                // Pass in the model created above

                models: oModel,

                // binding information for the rows aggregation

                rows: {

                    path: "/"

                },

                // column definitions with column name and binding info for the content

                columns: [itemsArray]

            });

          oExport.saveFile().always(function() {

                this.destroy();

            });

  

}

SAP Web IDE: The Simple Way to Build and Extend SAPUI5 Applications (SAP TechEd Lecture of the Week)

$
0
0

I recently lectured about SAP Web IDE: a rich and comprehensive web-based development environment powered by SAP HANA Cloud Platform. SAP Web IDE enables developers to easily build, extend and deploy responsive SAPUI5 apps which apply the Fiori UX.

 

In this session given at SAP TechEd Las Vegas, I reviewed the product capabilities and its roadmap. I also demoed how simple it is to develop a Fiori application using SAP Web IDE wizards, templates and code editor.

 

We also had a great customer story on stage. David Arfa, Senior Manager, PepsiCo Global Business Solutions, joined me in this session and talked about SAP Web IDE usage at PepsiCo. David also presented a really interesting demo of how his team used SAP Web IDE to extend Fiori applications at PepsiCo. One of my favorite parts was when David described the value that SAP Web IDE provided to PepsiCo as: "decreased development time and effort using powerful wizard-driven tools out of the box", "optimized to support SAP Fiori and SAPUI5 applications" etc.

 

Since SAP Web IDE was released as a Beta version in last SAPPHIRE, it gained a lot of momentum among our customers. Up to date, we have over 5000 customers trying the product and creating additional success stories!

 

At next SAPPHIRE, only a month from now, we have a lot of planned activities for SAP Web IDE where we will share the latest product offering, innovative demos and more success stories.

 

I hope you'll enjoy this session's recording. And see you at SAPPHIRE 2015…

 

5 easy steps to create a Fiori app using an EDMX file & testing it by leveraging the #SAPWebIDE mock service

$
0
0

Dear All,

 

We have seen many posts talking about connecting the SAP Web IDE to a remote backend system and creating Fiori based apps and getting the data from the backend system. As title speaks everything, i am going to show you how we can create a Fiori app with no backend system but using an EDMX file which contains the model of the OData service and could leverage SAP Web IDE mock service to test the application.

 

This kind of approach is useful in that case when backend is not ready (or no connectivity to backend system) and development for frontend and backend is done in parallel.

 

Pre-requisite:

 

 

 

Steps:

 

1. Activating external plugin OData model Editor

 

              preferences.PNG

  • Select the checkbox for the plugin OData model Editor> Save> Reload SAP Web IDE to see the new functionality

 

              plugin.png

 

 

2. Now, i am going to create a schema file in a separate folder that could be used for future projects. Right click on the root folder Local > New > Folder

          schemafolder.PNG

 

    Give it a name as EDMX_files.  Now, right click on EDMX_files folder > New>OData Model File

 

          edmxfile.PNG

 

          name it as ArticleService and choose OData Version as 2.0

          odatamodel.PNG

 

    Replace it's content with attached file content. It should look like below:

 

    artcileservice.PNG

 

3. Create a new project File > New > Project from Template > SAP Fiori Master Detail Application

  • Project name: ArticleSeviceWithMockData
  • Under Data Connection > Workspace > select desired edmx file
  • scroll down and click on SELECT and then NEXT

    select.png

 

 

    (You could direct point to .edmx file if it is available on your local machine. No need of step #2. Select Workspace >Browse)

 

 

  •     Enter below details for Project settings, Master Section and Details Section > Next >Finish

 

    masterscreen.png

 

 

    details.PNG

Note: With the value for Project namespace (in above app it is articlemock_ns) we can assign a kind of group definition to project files. In future exercises when we create a new view, the Project Namespace value will indicate that the new view and its controller belong to your app or the respective app that you are going to extend.

 

4. Test the data with mock-data

 

Note: By default, in each and every running SAP Web IDE app there is random mock-data. As mentioned earlier, this will help application developers to test Fiori apps from design and front-end development perspectives even though there is no connectivity to backend systems.

 

Select index.html > Run >Run with Mock data

 

          runwithmockdata.PNG

 

This is how it should look like:

 

    mockdataresult.PNG

 

5. Modify and personalize your mock-data

 

    SAP Web IDE provides an easy table form to edit mock-data directly in the project that could reflect our specific needs properly.

 

Expand Model > right click metadata.xml > Edit Mock Data

 

          editmockdata.PNG

 

    Click on Add Row > enter test data

 

Note: PRICE is a complex type binded to ArticleSet entityset.

 

          mockdatavalues.PNG

 

          SAP Web IDE creates a new mock-data file Article.json in the folder model.

 

          articlejson.PNG

 

(SAP recommends JSON format to work with mock-data. You could also import an JSON file directly into model folder > Right click model > Import >File)

 

To test again, repeat step #4, select index.html > Run >Run with Mock Data

 

        newdata.PNG

 

(Inputs have taken from openSAP course build your own Fiori App in Cloud)

Hope you enjoyed it. Your comments and feedback are most welcome.

 

Regards,

Jitendra Kansal

Have some fun around UI5

Generate .edmx and/or .xml file for Fiori App developed using SAP Web IDE

$
0
0

Currently I am going through openSAP course onBuild Your Own SAP Fiori App in the Cloud and there come across one question about creation of EDMX file.


There are different ways to create edmx file as answered in the course discussion forum by Yoram Friedman

This is a common scenario in many big projects, since you do want to work on the UI in parallel to the team creating the business logic. The best solution is to reach an early agreement on the "interface" between the two and use this as a starting point. If at this stage you want to generate an EDMX schema you can't do it from the service as the service does not exist yet. You need to either use a third party EDMX generator or use the WebIDE ODATA Model Editor (which is not part of this specific training)

Check out this video: https://www.youtube.com/watch?v=xs0cSan05mw

Now in case if you are not able to use 3rd party EDMX generator tools or find it difficult to use SAP Web IDE OData Model Editor and want to leverage the efforts of OData modelling done on backend OData developer team then there is simple way for it.

 

Assuming that backend developers (SAP Gateway OData developers) at least started creating OData service using transaction SEGW with properly defined OData artifacts such as entity, entitySet, association/navigation etc. but they do not want to spend time to implement complete backend logic. In such scenarios, if OData service is registered then in Gateway Client transaction /IWFND/GW_CLIENT using $metadata query we can see the complete metadata of OData service as shown below.

 

You can either select menu Goto -->Service Metadata

edmx1.png

Or after executing $metadata, click on Response in Browser

edmx2.png

In both cases, it will open the metadata file in the browser as shown below,

edmx3.png

Now you can simply save this file as .edmx or .xml and can easily use it for creation of mock data inside your Fiori application from SAP Web IDE.

 

As shown below, we can use .xml or .edmx file

edmx4.png



you can refer 5 easy steps to create a Fiori app using an EDMX file & testing it by leveraging the #SAPWebIDE mock service by Jitendra Kansal for further steps and details.

 

-Chandra

Using the SAP HCP User API in SAP Web IDE

$
0
0

SAP HCP provides a service which can be used to obtain user information as well as log off the user.  The details regarding the userapi can be found at

 

https://help.hana.ondemand.com/help/frameset.htm?1de599bf722446849d2b2e10132df42a.html

Here's two simple examples on how this can be acheived within SAP Web IDE.

 

Adding the User Details to a View

 

Add a route into the neo-app.json to reference the userapi

 

{        "path": "/services/userapi",        "target": {            "type": "service",            "name": "userapi"        }    }

Create a json model to call the service

 

var userModel = new sap.ui.model.json.JSONModel("/services/userapi/currentUser");
sap.ui.getCore().setModel(userModel, "userapi");

Now within a view create some fields to display the data returned by the service

 

<Label text="User Name"></Label><Text xmlns="sap.m" text="{userapi>/name}"></Text><Label text="First Name"></Label><Text xmlns="sap.m" text="{userapi>/firstName}"></Text><Label text="Last Name"></Label><Text xmlns="sap.m" text="{userapi>/lastName}"></Text><Label text="Display Name"></Label><Text xmlns="sap.m" text="{userapi>/displayName}"></Text><Label text="Email"></Label><Text xmlns="sap.m" text="{userapi>/email}"></Text>

 

Adding a Logout Button to Your Application

 

In a view add a button to call a function

 

<Button xmlns="sap.m" text="Log Out" press="logUserOut"></Button>

Within the corresponding controller add the function to process the event.

 

logUserOut: function(){     $.ajax({          "url":"/services/userapi/logout",          "success": function(){              sap.m.URLHelper.redirect("SAP Web IDE - Enablement | SCN", false);          }      });
}

NOTE: When testing this it will log you out of Web IDE and HCP.  Also make sure to not test it in the preview frame, this may cause same origin or https issues.  This can be set in the run configuration by unchecking "open with frame".

 

Regards,

Jamie Cawley


SAP UI5 CHIP hide fullscreen icon

$
0
0

Hello!

 

I had toclose thefull-screen displayon a chip, I have not foundanything suitable, the solution was as follows:123.png

To hide thefull screen displayon a chip, it is necessary in the controllerapplication, add the following code:

       

    onAfterRendering: function() {

               $("#"+this.getView().getParent().getId().split("--")[0] + "--laneView--fullscreen").hide();

          },​

 

 

 

 

 

Thank you for yourhelpDiaghilevIvan

 

How to develop right pane plugin for Web IDE (Part 2) - Facebook integration

$
0
0

Hi ,

This blog post is part 2 of "How to develop right pane plugin for Web IDE".

In part 1 you learned the following:

  • Web IDE plugin concept (plugin.json, plugin service and commands)
  • Web IDE right pane plugin creation

In part 2 i will take you one step further and show how to aggregate your Facebook feed inside Web IDE right pane area.


Prerequisites

Please notice! the following blog contains hundreds lines of code that should be copied from here into your Web IDE environment. In blog posts it is not possible to do pretty print to lines of code so after you paste the code to Web IDE you can use the Beautify option that will do pretty print to your code. The keyboard shortcut of beautify command is Ctrl + Alt + B


Let's get started

 

Create Facebook App

 

In this section you will create a new Facebook app which will enable interaction from Web IDE to Facebook API.In order to integrate with Facebook API's you will need to use Facebook JavaScript SDK. Details about how to use Facebook JavaScript SDK with user guides and examples can be found here:
https://developers.facebook.com/docs/javascript
For creating a new Facebook App please do the following steps:

  • go to Facebook Developers
  • Under My Apps select add a new app
    1.png
  • a dialog asking for the required platform will be opened there you need to select Website
    2.png
  • Type the name of the new app - you can type any name that you like i typed "WebIDERightPanePlugin" and then click on Create new Facebook App ID button
    3.png
  • Leave Is this a test version of another app unchecked and select Education under the application category and then click on Create App ID button

    4.png
  • Next you will see a JavaScript code snippets describing how to initialize the application that you've just created and a place to configure your Facebook website URL's.
    Under site URL you need to copy and paste your Web IDE URL do so by copy your WebIDE URL and paste it into the site URL field of your Facebook App.


    5.png

  • If everything went well you should see a checkmark icon with Finished! label under it

    6.png

Setup Web IDE

 

In this section you will enhance your plugin to work with MVC approach and prepare the view that will hold your Facebook feed.

  • Open your WebIDE instance on a different browser tab and expand the project that you created in part 1. The project name is myfirstrightpaneplugin
    there you will find all the resources that you've created in part 1 of this blog.

7.png

  • Create a new view and controller files (MVC pattern SAPUI5 SDK - Demo Kit) that will contains the right pane content.
    • Select the view folder
    • right click --> New --> Component . A wizard for create new Component will be opend

      8.png
    • Click Next in the first step of the wizard
    • In the second step select SAPUI5 View and then click on Next

      9.png
    • The first step of the wizard should contain the following fields:
      • View Type: Select JavaScript (the default value is XML just change it to JavaScript)
      • Namespace: write rpaneplugin
      • View Name: write feed

              
               10.png

    • Click Next and then Finish
    • 2 new files will be added under the view folder under myfirstrightpaneplugin  project
      11.png
  • Connect the view and controller files to your plugin runtime
    • Under your project expand the service folder and double click on Player.js file (was created on part 1 of this blog)
    • Define a new parameter with name _oView above the init method.
      12.png
    • replace the getContent method with the following code:
  var that = this;  if (this._oView === undefined) {  return this.context.service.pluginmanagement.getPluginPath("rpaneplugin").then(function(sResult) {  jQuery.sap.registerModulePath("rpaneplugin", sResult);  that._oView = sap.ui.view({  id: "fbfeedview",  viewName: "rpaneplugin.view.feed",  type: sap.ui.core.mvc.ViewType.JS,  viewData: {  context: that  }  }).addStyleClass("FB_View");  return that._oView;  });  } else {  return this._oView;  }


The getContent method returns the content that should be aggregated into the right pane content area. The old code returns a layout which contain one button, now we change it to return a view instance since we want to work with MVC. 
In the view code we will build all the necessary UI elements and in the controller we will take care on the business logic, events etc.

Test your plugin

select the feed.view.js file which located under view folder and open it for editing
Replace the content of createContent method with the following:
var oButton = new sap.ui.commons.Button({
    text: "Test button"  });  return oButton;

 

    • Test your plugin: right click on plugin.json --> Run --> Run Plugin Project .

      a new browser tab will be opened with another instance of Web IDE.
      13.png
    • From the main toolbar select View --> Toggle Player

      14.png
    • The result will be a button that will be located inside the right pane content

      15.png

If everything works you are now ready to start with aggregating your Facebook feed.


Facebook Integration

 

In this section you will add the actual feed from Facebook to right pane view.The result of the following steps will be that you will be able to see a very basic info from your Facebook home feed inside the Web IDE right pane.The info that will be shown will be a list of posts with the name and profile picture of the user who created the post and the post content.
Using the same API calls you will also be able to show additional data like: number of likes, comments, attached videos or photos, links and more.

  • Select the Player.js file which located under service folder
  • Copy and paste the following code inside the init function

FB.init({       appId: '{your_facebook_app_id}',       xfbml: true,       version: 'v2.1'  });
  • replace '{your_facebook_app_id}' placeholder with your Facebook app id that you created in previous steps.
    • Go to Facebook Developers
    • Select My Apps --> Click on the app name that you created

      16.png
    • Copy the number under the App ID field and replace it with '{your_facebook_app_id}' placeholder.

      17.png
  • Load Facebook JavaScript SDK resources
    • Change the first line of Player.js file

               from

                

    • define(["sap/watt/common/plugin/platform/service/ui/AbstractPart"], function(AbstractPart) {
      to

      define(["sap/watt/common/plugin/platform/service/ui/AbstractPart", "//connect.facebook.net/en_US/sdk.js"], function(AbstractPart) {
  • Create the Feed UI
    • Select feed.view.js file which located under  view folder
    • Replace the createContent function content with the following content:


 

 

 var oLayout = new sap.ui.layout.VerticalLayout({       width: "100%",       height: "100%"  }).addStyleClass("FB_VLayout");  this.oUserDetailsLayout = new sap.ui.layout.HorizontalLayout({  width: "100%",  visible: false  }).addStyleClass("FB_UserDetailsLayout");  var oUserProfilePicture = new sap.ui.commons.Image({  width: "40px",  height: "40px"  }).addStyleClass("FB_UserProfilePicture");  this.oUserDetailsLayout.addContent(oUserProfilePicture);  var oUserDisplayNameLabel = new sap.ui.commons.Label({  text: "user display name"  });  this.oUserDetailsLayout.addContent(oUserDisplayNameLabel);  oLayout.addContent(this.oUserDetailsLayout);  this.oFeedRowRepeater = new sap.ui.commons.RowRepeater({  numberOfRows: 70,  design: sap.ui.commons.RowRepeaterDesign.Transparent,  noData: new sap.ui.commons.TextView()  }).addStyleClass("FB_FeedRowRepeater");  // Row repeater template  this.oFeedRowRepeaterTemplate = new sap.ui.layout.HorizontalLayout({    width: "70%"  }).addStyleClass("FB_RowRepeaterTemplateLayout");  var oPostedByImage = new sap.ui.commons.Image({      height: "40px",      width: "40px"  }).addStyleClass("FB_UserProfilePicture");  oPostedByImage.bindProperty("src","picture");  this.oFeedRowRepeaterTemplate.addContent(oPostedByImage);  var oPostedByName = new sap.ui.commons.Label().addStyleClass("FB_PostedByLabel");  oPostedByName.bindProperty("text","from");  var oPostContent = new sap.ui.commons.TextView({      wrapping: true  }).addStyleClass("FB_PostTextView");  oPostContent.bindProperty("text","message");  var oFeedContentLayout = new sap.ui.layout.VerticalLayout().addStyleClass("FB_PostContent");  oFeedContentLayout.addContent(oPostedByName);  oFeedContentLayout.addContent(oPostContent);  this.oFeedRowRepeaterTemplate.addContent(oFeedContentLayout);        this.oFeedRowRepeater.bindRows("/data", this.oFeedRowRepeaterTemplate);  oLayout.addContent(this.oFeedRowRepeater);  return oLayout;

 

    • Replace the content of style.css which located under css folder with the following content




.FB_VLayout {    width: 100%;    height: 100%;    background-color: white !important;    position: absolute;    top: 0;    left: 0;    overflow-y: auto;    overflow-x: hidden;
}
.FB_View {    background-color: white;    position: relative;    height: 100%;    overflow-x: hidden;
}
.FB_UserDetailsLayout {    background-color: #4e69a2;    color: white;    font-size: 15px;    width: 100%;    padding: 10px;
}
.FB_PostContent {    margin-left: 10px;
}
.FB_UserProfilePicture {    height: 40px;    width: 40px;    border-radius: 20px;
}
.FB_PostedByLabel  {    color: #3b5998;    font-weight: bold;    padding: 0;
}
.FB_FeedRowRepeater {    text-align: center;    margin-top: 10px;    overflow-x: hidden;
}
.FB_RowRepeaterTemplateLayout {    width: 90%;    border-bottom: 1px solid #e9eaed;    text-align: left;    padding-top: 5px;    padding-bottom: 5px;
}
.FB_FeedTitle {    padding: 10px;
}
.FB_PostTextView {    height: auto !important;    width: 90%;    font-size: 14px;
}
    • Last but not least replace all the content of feed.controller.js with the following content:




sap.ui.controller("rpaneplugin.view.feed", {  _oFbUser: undefined,  onInit: function() {  var that = this;  FB.getLoginStatus(function(response) {  if (response.status === 'connected') {  FB.api('/me', {}, function(response) {  if (response && !response.error) {  that._oFbUser = response;  that._setUserDetails(that._oFbUser);  }  });  } else {  // Login user  FB.login(function(response) {  if (response && !response.error) {  FB.api('/me', {}, function(response) {  if (response && !response.error) {  that._oFbUser = response;  that._setUserDetails(that._oFbUser);  }  });  }  }, {  scope: 'read_stream'  });  }  });  },
_setUserDetails: function(oUser) {  var oView = this.getView();  var oUserDisplayNameLabel = oView.oUserDetailsLayout.getContent()[1];  var oUserProfilePicture = oView.oUserDetailsLayout.getContent()[0];  oUserDisplayNameLabel.setText(oUser.name);  oView.oUserDetailsLayout.setVisible(true);  oView.oFeedRowRepeater.setBusy(true);  FB.api(  "/me/picture",  function(response) {  if (response && !response.error) {  oUserProfilePicture.setSrc(response.data.url);  }  }  );  FB.api(  "/me/feed",  function(response) {     oView.oFeedRowRepeater.setBusy(false);  if (response && !response.error) {     var oResults = {         data: []     };     for (var i=0; i < response.data.length; i++){         var oRecord = response.data[i];         var sMessage = oRecord.message !== undefined ? oRecord.message : oRecord.story;         var sPictureUrl = "//graph.facebook.com/" + oRecord.from.id + "/picture";         oResults.data.push({            message: sMessage,            from: oRecord.from.name,            picture: sPictureUrl         });     }  var oModel = new sap.ui.model.json.JSONModel(oResults);  oView.oFeedRowRepeater.setModel(oModel);  }  }  );  }
});

 

 

 

    • Quick explanation on the code above:
      • onInit - If the user is already logged in to your app then display the user feed immediately, otherwise display a Facebook connect login screen to the user. The "read_stream" scope request permissions from the user to access his feed.
      • _setUserDetails - Display the logged in user name and profile picture and the user home feed from Facebook
    • The above lines of code presents only the following details:
      • Logged in user display name and profile picture
      • Logged in user home feed with the following fields:
        • Name of the user who created the post
        • Profile picture of the user who created the post
        • The post title (either if it is a message or a story)

    • In order to show more fields and perform additional interactions with Facebook API please refer to the following: Facebook SDK for JavaScript Reference

See the results

 

Your last step is to review the results of what you just created.

  • Select plugin.json which located under the root folder
  • Right click --> Run --> Run Plugin Project

    18.png
  • a new instance of Web IDE will be opened in a new browser tab
  • From the main toolbar select View --> Toggle Player

    19.png
  • If you already gave permissions to the Facebook App before you will see the results immediately otherwise, you will see a pop up that will ask for your permissions 

    20.png

          21.png

 

 

 

 

 

Congratulations! you have completed developing a plugin which presents your Facebook feed in your Web IDE environment.

You are now ready to rock and create amazing and innovative stuff for Web IDE.

My first Mobile app in 20 seconds

$
0
0


SAPUI5 provides an additional control library called sap.m, which is optimized for mobile devices, but also runs fine in desktop browsers.


Procedure-step1

 

  1. Create an HTML page called mobile.html
  2. Add the HTML5 doctype definition:<!DOCTYPE html>" in the first line and the Internet Explorer-specific meta tag :<meta http-equiv="X-UA-Compatible" content="IE=edge" />" are the beginning of<head>element.This ensures that all browsers use the latest version of their rendering engine.
  3. Add a second meta tag:<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>.This lets all browsers treat the file as UTF-8 encoded (assuming that you use this encoding when editing/saving the file)
  4. In the HTML <body> there needs to be a place where the App HTML will go. Here we add a<div>element to<body>. The "sapUiBody" class should always be added to the<body>tag to initialize font and colors for the whole page:
    <body class="sapUiBody"><!--Thisiswhere the App will live:--><div id="content"></div></body> 
    • You can equally use thebodyitself, omitting the extradiv. In this case give the body the idcontent.

Initialize the Mobile App-step2

 

The sap.m library provides a control calledAppwhich is meant to be the root control of a mobile application. It provides the initialization of the HTML page, sets some meta tags to ensure an as-native-as-possible look&feel, and can manage different pages and the animations between them.

Procedure

 

Create the control and define the page that you want to display first:

  // create a mobile App// it initializes the HTML page for mobile use and provides animated page handlingvar app =new sap.m.App("myApp",{initialPage:"page1"});// page1 should be displayed first

 

  • Instead of using the Appcontrol, you can also usejQuery.sap.initMobile()to set up the HTML and use other full screen controls, such assap.m.Pageorsap.m.Carouselas root element of your app.

Add Content Pages

 

Typical mobile applications are often composed of a number of pages/views/screens between which the user can navigate. You now add two of them to your app.

Procedure-3

 

  1. Onesap.m.Pagecontrol is created, its title is set and the content is just one button:

     

    // create the first page of your applicationvar page1 =new sap.m.Page("page1",{ title:"Initial Page", content :new sap.m.Button({// content is just one Button text :"Go to Page 2", press :function(){ app.to("page2");// when pressed, it triggers drilldown to page 2}})});

     

    When the Button is pressed, it triggers a drilldown navigation by callingapp.to("page2"), where page2 is the ID of the second page. You could also give the animation type. The default is a slide animation from right to left.

    sap.m.Pagecontrols can be used as pages, and the aggregation is called pages, but other controls could be used as well.

  2. Add the following to the<script>section of the HTML page below the part, where you've initialized the app:

     

    // create the second page of your applicationvar page2 =new sap.m.Page("page2",{ title:"Page 2", showNavButton:true,// page 2 should display a back button navButtonPress:function(){ app.back();// when tapped, the back button should navigate back up to page 1}, icon:"http://www.sap.com/global/ui/images/global/sap-logo.png", content :new sap.m.Text({text:"Hello Mobile World!"})});

     

    showNavButtonis set totrueto get a Back button displayed. When this button is pressed, the handler callsapp.back(). This causes an inverse animation, which leads back to the main page.

  3. Add the two pages to the App:

     

    // add both pages to the App app.addPage(page1).addPage(page2);

     

  4. Finally place the app into the content area you've defined earlier.

      app.placeAt("content");// place the App into the HTML document

Prerequisites-step4

 

Assumption for these instructions to work exactly as described: you have a Windows Computer (other operating systems will work as well, but the instructions may differ) and a current browser.

 

Procedure

 

  1. Right-click on your desktop and choose Start of the navigation pathNewNext navigation stepText DocumentEnd of the navigation path.
  2. Enter a name for the new file, for example mobile.html, and confirm the extension change warning.
  3. Right-click on the new file and choose Edit. Make sure it opens in Notepad and not in MS Word.
  4. Copy and paste the HTML code below and save the file. Keep in mind that the SAPUI5 URL may need to be adapted.
  5. Drag and drop the file into the browser window.
  6. To load the example on a mobile device, you put the file on a server.
  7. To load the SAPUI5 JavaScript file, that contains the library, add the following script tag in the<head>:
    <script src="http://<server>:<port>/sapui5/resources/sap-ui-core.js" id="sap-ui-bootstrap" data-sap-ui-libs="sap.m" data-sap-ui-theme="sap_bluecrystal"></script>

    Replace <server> and <port> with your local SAPUI5 installation.

    NoteOnly "sap.m" library and "sap_bluecrystal" theme are loaded

    Note that you are only loading thesap.mcontrol library and thesap_bluecrystal

    theme.


    i have run the below code in https://account.hanatrial.ondemand.com


    SAPWEBID

     

     

    <!DOCTYPE HTML>
    <html>
     
    <head>
      
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
      
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>

      
    <title>MobileAppin23SecondsExample</title>




      
    <!-- only load the mobile lib "sap.m"and the "sap_bluecrystal" theme -->

      
    <script>

      
    // create a mobile App
      
    // it initializes the HTML page for mobile use and provides animated page handling
      
    var app =new sap.m.App("myApp",{initialPage:"page1"});// page1 should be displayed first
      
      
      
    // create the first page of your application
      
    var page1 =new sap.m.Page("page1",{
      title
    :"Initial Page",
      content
    :new sap.m.Button({   // content is just one Button
      text
    :"Go to Page 2",
      press
    :function(){
      app
    .to("page2");   // when pressed, it triggers drilldown to page 2
      
    }
      
    })  
      
    });
      
      
      
    // create the second page of your application
      
    var page2 =new sap.m.Page("page2",{
      title
    :"Page 2",
      showNavButton
    :true,   // page 2 should display a back button
      navButtonPress
    :function(){
      app
    .back();   // when pressed, the back button should navigate back up to page 1
      
    },
      content
    :new sap.m.Text({text:"Hello Mobile World!"})
      
    });
      
      app
    .addPage(page1).addPage(page2);// add both pages to the App
      
      app
    .placeAt("content");// place the App into the HTML document
      
      
    </script>

     
    </head>
     
    <body class="sapUiBody">
      
    <div id="content"></div>
     
    </body>
    </html
    >



    output:


    Capture1.PNGCapture2.PNG






How To Install SAP Web IDE Locally for Trial in Windows

$
0
0

 

1. Introduction

This blog details out step-by-step procedure to local trial installation of SAP Web IDE 1.8 for test and evaluation purposes. You can experience the SAP Web IDE capabilities and see how simple it is to create and extend SAP Fiori/SAPUI5 applications with SAP Web IDE. Additionally, the blog will also If you want to experience the trail version of SAP Web IDE on HANA Cloud Platform then please follow,Getting Started with SAP Web IDE on HANA Cloud.

 

Please note: This is a trial version for non-productive usage only. This version is not updated with the latest features in the way the SAP HANA Cloud version is. It contains a subset of SAP Web IDE functionality, leaving out cloud-specific features such as plugin/template development, consumption of optional plugins and collaboration support.

 

 

2. Prerequisites

  • JVM (Java Virtual Machine) should be 6.0 or higher. JVM can be downloaded fromhere(only JRE is required).

 

3. SAP Web IDE Installation Process

3.1 Download the SAP Web IDE Local Installation package here by filling a simple form and following the instructions thereby.


SAP Store.png


3.2  Download Eclipse Orion package for Windows Platform from here.

Orion-Eclipse.png


3.3 Download Eclipse Director package can be downloaded from here:

    http://www.eclipse.org/downloads/download.php?file=/tools/buckminster/products/director_latest.zip

 

3.4 On successful download of the files mentioned in steps would get you the following:

     a. Local Web IDE Installer : SAP_Web_IDE_Local_Inst.zip

     b. Eclipse Orion : eclipse-orion-5.0-win32.win32.x86_xx.zip

     c. Eclipse Director : director_latest.zip


3.5Create a new folder on the C drive named “SAPWebIDE


SAPWebIDE-Folder.png


3.6Extract the Eclipse Orion package into C:\SAPWebIDE


extract-orion.png


3.7Extract the Eclipse Director into C:\SAPWebIDE


extract-director.png


3.8 YourC:\SAPWebIDE should now have the following folder structure


extract-result.png



3.9 Extract "SAP_Web_IDE_Local_Inst.zip”. Once extracted, you will find two zip files named "SAP_HAT_local.zip" and “updatesite.zip”.


extract-webide.png


3.10 Open Command Promt and go to the C:\SAPWebIDE\director folder


cmd-director.png



3.11 Run this command in order to install the SAP Web IDE package into Eclipse Orion:


director -repository jar:file:/<location of the downloaded zip file>!/ -installIU com.sap.webide.orionplugin.feature.feature.group -destination c:\SAPWebIDE\eclipse


In our example, the complete command is

director -repository jar:file:C:\XXXXXX\Downloads\updatesite.zip!/ -installIU com.sap.webide.orionplugin.feature.feature.group -destination c:\SAPWebIDE\eclipse


NOTE: If the path to the downloaded zip file contains spaces, you need to wrap the entire path with double quotes (i.e. jar:file:”C:\Users\path with some spaces\Downloads\updatesite.zip”).


installed-success.png


You have successfully installed your local copy of SAP Web IDE.




4. Configuring and Starting SAP Web IDE

Before starting Eclipse Orion you should modify the port of the Orion server from the standard 8080 to 9090. This is an optional step, but since there could    be other software running on that port, it’s a best practice to change it. Navigate to Eclipse Orion folder using Windows Explorer and double click on the file orion.ini.

 

     orion-ini.png

 

 


4.1Locate the line “-Dorg.eclipse.equinox.http.jetty.http.port=8080”, change the port number to 9090 and save the file


   orion-ini-port.png   


4.2 Double click on the Eclipse Orion executable to start it


   orion-start.png


4.3 If you get this message, Click on Run

    

   orion-sec-run.png


4.4 You will get a new command prompt window like this: don’t close it!


    orion-run-cmd.png         


4.5Open your Internet browser and type http://localhost:9090/webide/index.html


   open-chrome.png


4.6 The Eclipse Orion home page will be loaded. Click on Create a new account


   orion-logon.png


4.7 Enter the required information and click on Sign up


   ide-signup.png



4.8 You have successfully started your local SAP Web IDE.

   ide-loaded.png


Note : Should you need to close SAP Web IDE and Eclipse Orion, close first the browser page containing SAP Web IDE and then select the console that Eclipse Orion opened when you started it up. Type the command “close” and then hit ENTER. Confirm to close it by pressing “y”.

    

close_orion.png    

 


5. Testing Installation by Connecting to Remote System

   

Now that we have configured our SAP Web IDE, we might also want to connect it to a remote system to get some data. There are basically 4 ways to do it and for a couple of them you need to create a special destination file, which gives to SAP Web IDE all the needed connection information. In particular, we might want to connect to a generic OData source or to an ABAP system.

 

Let’s give a look to how we can create the destination files for connecting to the public sample gateway system “sapes1.sapdevcenter.com”. You can get more information and register to it by going to the page Getting started with the SAP Netweaver Gateway Service Consumption System


5.1 Open Command Prompt and type

          cd C:\SAPWebIDE\eclipse\config_master\service.destinations\destinations

     goto_destinations.png

5.2 Type

          echo #ServiceDestination > ES1

    goto_es1.png


5.3 Type

          notepad es1

     open_es1.png


5.4 Append the following lines to the file:

              

Description=es1

Type=HTTP

TrustAll=true

Authentication=NoAuthentication

WebIDEUsage=odata_gen

Name=es1

WebIDEEnabled=true

URL=https\://sapes1.sapdevcenter.com

ProxyType=Internet

WebIDESystem=es1

 

 

5.5 The ES1 file in notepad should now look like

   es1_notepad.png


5.6 Close SAP Web IDE, if it was already open, and restart it. You will probably need to sign again in Eclipse Orion.

   

5.7 Create a new project using File > New > Project from Template and choose 'SAP Fiori Master Detail Application'.


5.8 At the step “3 - Data Connection” you can do the following:

 

      1. Click on Service URL.
      2. Select the es1 destination.
      3. Enter the path to the resource (it will be concatenated with the URL specified in the destination). In this example we can use “/sap/opu/odata/IWFND/RMTSAMPLEFLIGHT/”.
      4. Click on Select.
      5. After entering the credentials for accessing the gateway system, you will get the list of the available OData entities.

               data_connection.png


          5.9 You have successfully tested the connection to an OData source, you can click on Next and continue with the project creation.

 


 

6. Connecting to an External Git Repository

Since you need to pass through a proxy you cannot access your Git repositories. For this you need to do some configuration. First of all you need to configure the orion.ini file to allow the SAP Web IDE to pass through the proxy.


     6.1 Close SAP Web IDE and exit from Eclipse Orion by first closing the browser page containing SAP Web IDE and then selecting the console that Eclipse          Orion is opened when you started it. Type the command “close” and then hit ENTER. Confirm to close it by pressing “y”.

       close_orion.png   

 

     6.2 Go in the C:\SAPWebIDE\eclipse folder with Windows Explorer

 

     6.3 Double click on the orion.ini file to open it in the editor

          orion-ini.png

    

     6.4 Add the following lines to the file, just after the -vmargs line.

                   

-Dhttp.proxyHost=<proxy>

-Dhttp.proxyPort=<port>

-Dhttps.proxyHost=<proxy>

-Dhttps.proxyPort=<port>

-Dhttps.nonProxyHosts=<hosts to be excluded from proxy>


In our example it’s


 

-Dhttp.proxyHost=proxy.xxxx.sap.corp

-Dhttp.proxyPort=8080

-Dhttps.proxyHost=proxy.xxxx.sap.corp

-Dhttps.proxyPort=8080

-Dhttps.nonProxyHosts=*.sap.corp|localhost


     6.5 After the changes to orion.ini save the file.

       orion_proxy.png


     6.6 Restart Eclipse Orion and reopen SAP Web IDE.


     6.7 You need now to configure the account settings for the SAP Web IDE Git Client. Click on Tools > Git Settings

          git_menu.png
    

      6.8 Provide your account information and click on Update

          git_account_update.png

    

     6.9 You have successfully configured your Git client with a proxy. You can test it by simply going to File > Git > Clone Repository.

          git_clone.png

    

     6.10 Enter the name of a repository you want to clone in your environment, provide your credentials and click on OK

          clone_details.png


     6.11 The project has been cloned successfully and connection to external git repository has been established successfully.

          clone_success.png


 

 

Brought to you by theSAP Technology RIG


Step by Step Video tutorials for Installing SAPUI5 tools in Eclipse

$
0
0

This is my first blog to SCN community.


When i started working with SAPUI5, i faced a little problem in initial phases as this was totally new to me and Eclipse was also new for me.

I wasted a lot of time, searching that how to install SAPUI5 tools.


I downloaded NetWeaver eclipse version and Eclipse JUNO, KEPLER and LUNA but was unable to download the SAPUI5 tools.

For this installation i recorded a video where i tried to cover every single steps for installing SAPUI5 tools to eclipse.

And this will surely help UI5 beginners.


 

 

 

Thank You.

Viewing all 789 articles
Browse latest View live




Latest Images