There are no secrets to success. It is the result of preparation, hard work, and learning from failure.

Tuesday, 29 May 2018

Multi Model implementation in SAPUI5

Click here and follow my SAP UI5/FIORI snippets and information Page
I have made multi model implementation example,below I have shown Application Structure,View Part,Controller Part,JSON and Result.Go through it and please let me know in case of any issue/doubt.

Application Structure


// Here I am setting model to view.If I will not use concept of ALIAS then second model will be binded in both tables.

Note: Always use ALIAS in this type of situations.I have given ALIAS name("empData").ALIAS name is a free text but give meaningful name.

View Part

<mvc:View controllerName="MultiModelConcept.controller.S1" xmlns:html="http://www.w3.org/1999/xhtml" xmlns:mvc="sap.ui.core.mvc"
displayBlock="true" xmlns="sap.m" xmlns:l="sap.ui.layout">
<App>
<pages>
<Page title="{i18n>title}" class="sapUiSizeCompact">
<content>
<l:Grid defaultSpan="L12 M12 S12">
<Table items="{/Result}">
<headerToolbar>
<Toolbar>
<ObjectIdentifier title="Table First"/>
</Toolbar>
</headerToolbar>
<columns>
<Column>
<ObjectIdentifier title="Name"/>
</Column>
<Column>
<ObjectIdentifier title="Mobile"/>
</Column>
<Column>
<ObjectIdentifier title="E-mail"/>
</Column>
<Column>
<ObjectIdentifier title="Address"/>
</Column>
</columns>
<ColumnListItem>
<cells>
<Text text="{name}"/>
<Text text="{mobile}"/>
<Text text="{mail}"/>
<Text text="{address}"/>
</cells>
</ColumnListItem>
</Table>
<Table items="{empData>/Result}">
<headerToolbar>
<Toolbar>
<ObjectIdentifier title="Table Second"/>
</Toolbar>
</headerToolbar>
<columns>
<Column>
<ObjectIdentifier title="Name"/>
</Column>
<Column>
<ObjectIdentifier title="Mobile"/>
</Column>
<Column>
<ObjectIdentifier title="E-mail"/>
</Column>
<Column>
<ObjectIdentifier title="Address"/>
</Column>
</columns>
<ColumnListItem>
<cells>
<Text text="{empData>name}"/>
<Text text="{empData>mobile}"/>
<Text text="{empData>mail}"/>
<Text text="{empData>address}"/>
</cells>
</ColumnListItem>
</Table>
</l:Grid>
</content>
</Page>
</pages>
</App>
</mvc:View>

Controller Part

sap.ui.define([
"sap/ui/core/mvc/Controller"
], function(Controller) {
"use strict";
return Controller.extend("MultiModelConcept.controller.S1", {
onInit: function() {
// JSON model first....
var json = new sap.ui.model.json.JSONModel("model/record.json");
//Setting model to view...
this.getView().setModel(json);
// JSON model second....
var json1 = new sap.ui.model.json.JSONModel("model/record1.json");
//Setting model to view with concept of ALIAS("empData")...
this.getView().setModel(json1, "empData");
}
});
});

record.json

{
"Result": [{
"name": "Vikas Singh",
"mobile": 8828054345,
"mail": "info.vikaskumar41@gmail.com",
"address": "Bihar,INDIA"
}, {
"name": "Kunal Singh",
"mobile": 3434343456,
"mail": "info.kumalkumar@gmail.com",
"address": "Bihar,INDIA"
}, {
"name": "Rajeev Singh",
"mobile": 4568235678,
"mail": "info.Rjeeev@gmail.com",
"address": "Bihar,INDIA"
}, {
"name": "Senjeev Singh",
"mobile": 2345678765,
"mail": "senjeev41@gmail.com",
"address": "Bihar,INDIA"
}

]
}

record1.json

{
"Result": [{
"name": "Vikas Singh 1",
"mobile": 8828054345,
"mail": "info.vikaskumar41@gmail.com",
"address": "Bihar,INDIA"
}, {
"name": "Kunal Singh 1",
"mobile": 3434343456,
"mail": "info.kumalkumar@gmail.com",
"address": "Bihar,INDIA"
}, {
"name": "Rajeev Singh 1",
"mobile": 4568235678,
"mail": "info.Rjeeev@gmail.com",
"address": "Bihar,INDIA"
}, {
"name": "Senjeev Singh 1",
"mobile": 2345678765,
"mail": "senjeev41@gmail.com",
"address": "Bihar,INDIA"
}

]
}

Result

Friday, 18 May 2018

View Binding of Grid/UI Table with JSON

Click here and follow my SAP UI5/FIORI snippets and information Page
I have made Grid Table example, Below I have shown Application Structure, View Part, Controller Part, Formatter, JSON and Result.Go through it and please let me know in case of any issue/doubt.

Application Structure

View Part

<mvc:View controllerName="GridTable.controller.S1" xmlns:html="http://www.w3.org/1999/xhtml" xmlns:mvc="sap.ui.core.mvc" displayBlock="true"
xmlns="sap.ui.table" xmlns:m="sap.m" xmlns:u="sap.ui.unified" xmlns:c="sap.ui.core">
<m:App>
<m:pages>
<m:Page title="Grid Table Example">
<m:content>
<Table selectionMode="None" rows="{/Result}" visibleRowCount="4">
<columns>
<Column>
<m:Label text="First Column"/>
<template>
<m:VBox>
<m:ObjectStatus text="{first}"/>
<m:Link text="Demo Link" visible="{path:'FI',formatter:'GridTable.util.Formatter.LinkDisplay'}"/>
</m:VBox>
</template>
</Column>
<Column>
<m:Label text="Second Column"/>
<template>
<m:Input value="{second}"/>
</template>
</Column>
<Column>
<m:Label text="Third Column"/>
<template>
<m:Label text="{third}"/>
</template>
</Column>
<Column>
<m:Label text="Fourth Column"/>
<template>
<m:Text text="{fourth}"/>
</template>
</Column>
<Column>
<m:Label text="Fifth Column"/>
<template>
<m:Text text="{fifth}"/>
</template>
</Column>
<Column>
<m:Label text="Sixth Column"/>
<template>
<m:Text text="{sixth}"/>
</template>
</Column>
<Column>
<m:Label text="Seventh Column"/>
<template>
<u:Currency value="{Price}" currency="{CurrencyCode}"/>
</template>
</Column>
</columns>
</Table>
</m:content>
</m:Page>
</m:pages>
</m:App>
</mvc:View>

Controller Part

// Loading formatter....
jQuery.sap.require("GridTable.util.Formatter");
sap.ui.define([
"sap/ui/core/mvc/Controller"
], function(Controller) {
"use strict";
return Controller.extend("GridTable.controller.S1", {
onInit: function() {
// Loading json file....
var json = new sap.ui.model.json.JSONModel("model/Record.json");
// Setting json to current view....
this.getView().setModel(json);
}
});
});

Formatter.js

// Declaring formatter file....
jQuery.sap.declare("GridTable.util.Formatter");
GridTable.util.Formatter={
LinkDisplay:function(path){
if(path!==null){
if(path==="R"){
return true;
}else{
return false;
}
}
}
};

Record.json

{
"Result": [{
"first": "Demo First",
"FI": "R",
"second": "Demo Second",
"third": "Demo Third",
"fourth": "Demo Fourth",
"fifth": "Demo Fifth",
"sixth": "Demo Sixth",
"Price": 1010,
"CurrencyCode": "INR"
}, {
"first": "Demo First 1",
"FI": "R",
"second": "Demo Second 1",
"third": "Demo Third 1",
"fourth": "Demo Fourth 1",
"fifth": "Demo Fifth 1",
"sixth": "Demo Sixth 1",
"Price": 1010,
"CurrencyCode": "INR"
}, {
"first": "Demo First 2",
"second": "Demo Second 2",
"third": "Demo Third 2",
"fourth": "Demo Fourth 2",
"fifth": "Demo Fifth 2",
"sixth": "Demo Sixth 2",
"Price": 10188,
"CurrencyCode": "INR",
"FI": ""
}, {
"first": "Demo First 3",
"second": "Demo Second 3",
"third": "Demo Third 3",
"fourth": "Demo Fourth 3",
"fifth": "Demo Fifth 3",
"sixth": "Demo Sixth 3",
"Price": 1016,
"FI": "R"
}, {
"first": "Demo First 4",
"second": "Demo Second 4",
"third": "Demo Third 4",
"fourth": "Demo Fourth 4",
"fifth": "Demo Fifth 4",
"sixth": "Demo Sixth 4",
"Price": 10567,
"CurrencyCode": "INR",
"FI": ""
}]
}

Result




Sunday, 29 April 2018

Custom Currency Formatter

Click here and follow my SAP UI5/FIORI snippets and information Page
I have made custom currency formatter example,below I have shown Application Structure, View Part, Controller Part, Formatter, JSON and Result.Go through it and please let me know in case of any issue/doubt.

Application Structure


View Part

<Page title="{i18n>title}">
<content>
<f:SimpleForm editable="true" layout="ResponsiveGridLayout" labelSpanXL="3" labelSpanL="3" labelSpanM="3" labelSpanS="12"
adjustLabelSpan="false" emptySpanXL="4" emptySpanL="4" emptySpanM="4" emptySpanS="0" columnsXL="1" columnsL="1" columnsM="1"
singleContainerFullSize="false">
<f:content>
<Label text="Amount"/>
<Input value="{parts:[{path:'amo'}],formatter:'currency1.util.formatter.currencyMethod'}"  id="inId"></Input>
</f:content>
</f:SimpleForm>
</content>
</Page>

Controller Part

onInit:function(){
// Loading formatter at the time of application initialization....
jQuery.sap.require("currency1.util.formatter");
// Loading json file....
var json = new sap.ui.model.json.JSONModel("model/record.json");
// Binding form with json value....
this.getView().bindElement("/0");
// Setting json to current view....
this.getView().setModel(json);
}

formatter.js

// Declaring formatter file....
jQuery.sap.declare("currency1.util.formatter");
currency1.util.formatter = {
currencyMethod: function(val) {
var amount = parseFloat(val);
var finalResult = amount.toLocaleString('en-US', {
style: 'currency',
currency: 'USD'
});
return finalResult.replace("$", '');
}
}

record.json

[{
"amo":"2344000"
}]

Result



Wednesday, 25 April 2018

How to use custom CSS(Cascading Style Sheet) in SAPUI5

Click here and follow my SAP UI5/FIORI snippets and information Page
I have shown below, how to use custom CSS(Cascading Style Sheet) in SAPUI5. Go through it and please let me know in case of any issue/doubt.

Application Structure

View Part

<Page title="{i18n>title}">
<content>
<f:SimpleForm editable="true" layout="ResponsiveGridLayout" labelSpanXL="3" labelSpanL="3" labelSpanM="3" labelSpanS="12"
adjustLabelSpan="false" emptySpanXL="4" emptySpanL="4" emptySpanM="4" emptySpanS="0" columnsXL="1" columnsL="1" columnsM="1"
singleContainerFullSize="false">
<f:content>
<Label text="Full Name"/>
<Input></Input>
<Label text="E-mail"/>
<Input/>
<Label text="Mobile Number" class="colorClassCustom"/>
<Input></Input>
<Label text="Address"/>
<Input/>
</f:content>
</f:SimpleForm>
</content>
</Page>

style.css

// Custom CSS(Cascading Style Sheet) class....
.colorClassCustom{
color: red;
font-weight: bold;
    font-size: 20px;
    }

Note: Load CSS(Cascading Style Sheet) either from index.html,component.js or manifest.json

index.html
<link rel="stylesheet" type="text/css" href="css/style.css">

component.js
"includes" : ["css/style.css"]

manifest.json
"resources": {
"css": [{
"uri": "css/style.css"
}]
}

Result



Tuesday, 13 March 2018

How to configure Northwind OData service in SAP Web IDE

Click here and follow my SAP UI5/FIORI snippets and information Page
I have shown below,how to configure Northwind OData service in SAP Web IDE.Go through it and please let me know in case of any issue/doubt.

Service: http://services.odata.org/V3/northwind/northwind.svc

Step 1: Login to SAP Cloud Platform Cockpit.
Step 2: Expand the connectivity tab.I have shown below in the screenshot.

You will get below screen.

Step 3: Click on "Destinations".You will get below screen.

Click on "New Destination".I have shown above in the screenshot.
You will get below screen.

Provide details as below.
Namenorthwind
TypeHTTP
DescriptionNorthwind OData Service
URLhttp://services.odata.org
Proxy TypeInternet
Cloud Connector version2
AuthenticationNoAuthentication

Add also the following additional properties.

WebIDEEnabledtrue
WebIDESystemNorthwind
WebIDEUsageodata_gen

For adding new property,Click on "New property" .I have shown above in the screenshot.

Step 4: Click on "Save". You will get below screen.

Step 5: Click on "Check Connection".You will get below screen.

Now Connection to Northwind OData service has been established successfully.

Thursday, 15 February 2018

Google Map with SAPUI5

Click here and follow my SAP UI5/FIORI snippets and information Page
I have integrated google map API with SAPUI5 and below I have shown Application structure,View Part,Controller Part and index.html.Go through it and please let me know in case of any issue/doubt.
View Part
<core:View xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc"
xmlns="sap.m" controllerName="map.S1" xmlns:html="http://www.w3.org/1999/xhtml" xmlns:l="sap.ui.layout">
<Page>
<content>
<l:Grid defaultSpan="L6 M6 S6">
<Panel id="pid" height="580px"></Panel>
<Panel id="pid1" height="580px"></Panel>
</l:Grid>
</content>
</Page>
</core:View>

Controller Part
sap.ui.controller("map.S1", {
onInit : function () {
var that = this;

//Called function....
function initialize() {
//LATITUDE AND LONGITUDE of Vashi, Navi Mumbai, Maharashtra, India....
var myCenter=new google.maps.LatLng(19.0771,72.9990);  
 //LATITUDE AND LONGITUDE of Aurangabad District, Bihar India....
var myCenter2=new google.maps.LatLng(24.7033,84.3542); 
//Properties of map....
var mapProp = {
center:myCenter,
zoom:5,
disableDefaultUI:false,
mapTypeId:google.maps.MapTypeId.ROADMAP
};
//Properties of map....
var mapProp2 = {
center:myCenter2,
zoom:6,
disableDefaultUI:false,
mapTypeId:google.maps.MapTypeId.SATELLITE
};
//Setting Properties to map....
var map1=new google.maps.Map(document.getElementById(that.getView().byId("pid").sId), mapProp);
//Setting Properties to map....
var map2=new google.maps.Map(document.getElementById(that.getView().byId("pid1").sId), mapProp2);
//Marker object...
var marker=new google.maps.Marker({
position:myCenter,
animation:google.maps.Animation.BOUNCE
});
//Setting marker to map....
marker.setMap(map1);
//Marker object...
var marker1=new google.maps.Marker({
position:myCenter2,
icon:'image/stick.png',
animation:google.maps.Animation.BOUNCE,
});
//Setting marker to map....
marker1.setMap(map2);
}
// This will call "initialize" function(Calling function)....
google.maps.event.addDomListener(window, 'load', initialize);
}
});

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

<!-- Load this external file for google map -->
<script src="http://maps.googleapis.com/maps/api/js"></script>

<script src="resources/sap-ui-core.js" id="sap-ui-bootstrap"
data-sap-ui-libs="sap.m" data-sap-ui-theme="sap_bluecrystal">
</script>
<script>
sap.ui.localResources("map");
var app = new sap.m.App({
initialPage : "idS11"
});
var page = sap.ui.view({
id : "idS11",
viewName : "map.S1",
type : sap.ui.core.mvc.ViewType.XML
});
app.addPage(page);
app.placeAt("content");
</script>
</head>
<body class="sapUiBody" role="application">
<div id="content"></div>
</body>
</html>

Result