https://help.sap.com/saphelp_uiaddon20/helpdata/en/8f/93bf2b2b13402e9f035128ce8b495f/content.htm
Explore Fiori
Here you can find excerpts for commonly used ODATA and UI5/Fiori codes... It's evolving
Friday, November 11, 2016
Create new global JSON Model in a Fiori App
Step-1:
IN manifest.json
in node "sap.ui5"-> "models":{}
Add custom model name after i18n
"models": {
"i18n": {
"type": "sap.ui.model.resource.ResourceModel",
"settings": {
"bundleName": "chg.i18n.i18n"
}
},
"": {
"dataSource": "mainService",
"preload": true
},
"op":{
"type": "sap.ui.model.odata.JSONModel"
}
},
Step 2:
In Component.js
Create model and add dummy data to model
var oData = {
recipient : {
name : "World"
}
};
var oModel = new sap.ui..model.json.JSONModel(oData);
this.setModel(oModel,'op');
Step3:
In any controller u can use this model and get / store data.
in main.controller.js
var data = this.getView().getModel('op').getData();
IN manifest.json
in node "sap.ui5"-> "models":{}
Add custom model name after i18n
"models": {
"i18n": {
"type": "sap.ui.model.resource.ResourceModel",
"settings": {
"bundleName": "chg.i18n.i18n"
}
},
"": {
"dataSource": "mainService",
"preload": true
},
"op":{
"type": "sap.ui.model.odata.JSONModel"
}
},
Step 2:
In Component.js
Create model and add dummy data to model
var oData = {
recipient : {
name : "World"
}
};
var oModel = new sap.ui..model.json.JSONModel(oData);
this.setModel(oModel,'op');
Step3:
In any controller u can use this model and get / store data.
in main.controller.js
var data = this.getView().getModel('op').getData();
Create new global JSON Model in a Fiori App
Step-1:
IN manifest.json
in node "sap.ui5"-> "models":{}
Add custom model name after i18n
"models": {
"i18n": {
"type": "sap.ui.model.resource.ResourceModel",
"settings": {
"bundleName": "chg.i18n.i18n"
}
},
"": {
"dataSource": "mainService",
"preload": true
},
"op":{
"type": "sap.ui.model.odata.JSONModel"
}
},
Step 2:
In Component.js
Create model and add dummy data to model
var oData = {
recipient : {
name : "World"
}
};
var oModel = new sap.ui..model.json.JSONModel(oData);
this.setModel(oModel,'op');
Step3:
In any controller u can use this model and get / store data.
in main.controller.js
var data = this.getView().getModel('op').getData();
IN manifest.json
in node "sap.ui5"-> "models":{}
Add custom model name after i18n
"models": {
"i18n": {
"type": "sap.ui.model.resource.ResourceModel",
"settings": {
"bundleName": "chg.i18n.i18n"
}
},
"": {
"dataSource": "mainService",
"preload": true
},
"op":{
"type": "sap.ui.model.odata.JSONModel"
}
},
Step 2:
In Component.js
Create model and add dummy data to model
var oData = {
recipient : {
name : "World"
}
};
var oModel = new sap.ui..model.json.JSONModel(oData);
this.setModel(oModel,'op');
Step3:
In any controller u can use this model and get / store data.
in main.controller.js
var data = this.getView().getModel('op').getData();
Thursday, November 10, 2016
Wait in OData operation - 2 commits in OData operation
We have a requirement for create operation of 20 properties.
10 properties are updated by BAPI
and 10 other fields are table update.
So the process goes like
1. <code for BAPI Create for first 10 fields Update>
2. call function 'BAPI_TRANSACTION_COMMIT'
exporting wait = 'X'.
3. wait upto 5 seconds.
4.<Update table for other fields based on key from BAPI >
Note: in this case with out step 3 everything works with debugging and doesn't work when u run on GWClient
10 properties are updated by BAPI
and 10 other fields are table update.
So the process goes like
1. <code for BAPI Create for first 10 fields Update>
2. call function 'BAPI_TRANSACTION_COMMIT'
exporting wait = 'X'.
3. wait upto 5 seconds.
4.<Update table for other fields based on key from BAPI >
Note: in this case with out step 3 everything works with debugging and doesn't work when u run on GWClient
Saturday, November 5, 2016
Find content type or mimetype of file from extension or path or name
if I know only file name abc.docx and if I want to find mime type in ABAP,
Use fm "CRM_KW_SPLIT_FILENAME" to find mime type
Use fm "CRM_KW_SPLIT_FILENAME" to find mime type
Thursday, November 3, 2016
URL options in ODta Query
in url:
....srv/headerSet?$filter=OrderDate eq datetime'2014-03-11T14:49:52'
String Operations
in body:
{
"OrderDate":"2012-01-01T00:00:00",
"OrdeTime":"PT12H32M88S"
}
OrderDate is EDM.DateTime
OrderTime is EDM.Time
....srv/headerSet?$filter=OrderDate eq datetime'2014-03-11T14:49:52'
String Operations
/People?$filter=endswith(LastName,'Smith') and startswith(FirstName,'Mary')
in body:
{
"OrderDate":"2012-01-01T00:00:00",
"OrdeTime":"PT12H32M88S"
}
OrderDate is EDM.DateTime
OrderTime is EDM.Time
Sunday, October 30, 2016
hanadb sample Queries for sensor handling
IQA tables :
create column table "sensor.master"
(SENSORID Integer not null primary key generated by default as IDENTITY,
SENSORMODEL nvarchar(30),
SENSORSERIAL nvarchar(30),
RESPONSIBLE nvarchar(20)
);
create column table "sensor.transaction"
(TXNID Integer not null primary key generated by default as IDENTITY,
SENSORID Integer,
TXNDATE Timestamp,
SENSORVAL Decimal(15,2),
FOREIGN KEY (SENSORID) REFERENCES "<schema>"."sensor.master"
);
create column table "sensor.transaction.spatials"
(TXNID Integer not null primary key generated by default as IDENTITY,
SENSORID Integer,
TXNDATE Timestamp,
SENSORVAL Decimal(15,2),
LOCATION ST_POINT,
FOREIGN KEY (SENSORID) REFERENCES "<schema>"."sensor.master"
);
___________
Add data
insert into "<schema>"."sensor.master" (SENSORMODEL,SENSORSERIAL,RESPONSIBLE)
values('motog','abcxyz','phani');
insert into "<schema>"."sensor.transaction" (SENSORID,TXNDATE,SENSORVAL)
values(1,'2015-01-01t00:00:00',1100);
insert into "sensor.transaction.spatial" (SENSORID,TXNDATE,SENSORVAL,LOCATION) values (24,'2015-03-01T00:23:33',1.2,new ST_POINT(51.5033630, -0.1276250));
______________
get latest record
select * from "sensor.transaction.spatial" where TXNID = (select max(TXNID) from "sensor.transaction.spatial" where SENSORID=22 );
get latest record with co-ordinates
select *,location.ST_ASGeoJson() from "sensor.transaction.spatial" where TXNID = (select max(TXNID) from "sensor.transaction.spatial" where SENSORID=22 )
___________
xsodata code:
service namespace "namespace democloud.<schema>.exer.iqa.services"{
"<schema>"."sensor.master" as "sensors";
"<schema>"."sensor.transaction" as "sensordata";
}
annotations{
enable OData4SAP;
}
___________
url:
https://<tenant>.ap1.hana.ondemand.com/democloud/<schema>/exer/iqa/services/services.xsodata/sensors?$format=json
https://<tenant>.ap1.hana.ondemand.com/democloud/<schema>/exer/iqa/services/services.xsodata/sensordata?$format=json
___________
create sensor
x
get latest values
https://<tenant>.ap1.hana.ondemand.com/democloud/<schema>/exer/iqa/services/services.xsodata/sensordata?$format=json&$orderby=TXNID%20desc&$filter=SENSORID%20eq%2022&$top=1
create spatial values
https://<tenant>.ap1.hana.ondemand.com/democloud/<schema>/exer/iqa/services/operations.xsjs?method=addspatialvalue&SENSORID=22&SENSORVAL=2.434&LAT=1.234&LONG=-2.34
get latest spatial value of sensor
https://<tenant>.ap1.hana.ondemand.com/democloud/<schema>/exer/iqa/services/operations.xsjs?method=getlatestspatialvalue&SENSORID=22
Create FullText Index "tweets" ON "TEAM14"."Tweets"("text") configuration 'EXTRACTION_CORE_VOICEOFCUSTOMER' ASYNC FLUSH EVERY 1 MINUTES LANGUAGE DETECTION ('EN') TEXT ANALYSIS ON;
create column table "sensor.master"
(SENSORID Integer not null primary key generated by default as IDENTITY,
SENSORMODEL nvarchar(30),
SENSORSERIAL nvarchar(30),
RESPONSIBLE nvarchar(20)
);
create column table "sensor.transaction"
(TXNID Integer not null primary key generated by default as IDENTITY,
SENSORID Integer,
TXNDATE Timestamp,
SENSORVAL Decimal(15,2),
FOREIGN KEY (SENSORID) REFERENCES "<schema>"."sensor.master"
);
create column table "sensor.transaction.spatials"
(TXNID Integer not null primary key generated by default as IDENTITY,
SENSORID Integer,
TXNDATE Timestamp,
SENSORVAL Decimal(15,2),
LOCATION ST_POINT,
FOREIGN KEY (SENSORID) REFERENCES "<schema>"."sensor.master"
);
___________
Add data
insert into "<schema>"."sensor.master" (SENSORMODEL,SENSORSERIAL,RESPONSIBLE)
values('motog','abcxyz','phani');
insert into "<schema>"."sensor.transaction" (SENSORID,TXNDATE,SENSORVAL)
values(1,'2015-01-01t00:00:00',1100);
insert into "sensor.transaction.spatial" (SENSORID,TXNDATE,SENSORVAL,LOCATION) values (24,'2015-03-01T00:23:33',1.2,new ST_POINT(51.5033630, -0.1276250));
______________
get latest record
select * from "sensor.transaction.spatial" where TXNID = (select max(TXNID) from "sensor.transaction.spatial" where SENSORID=22 );
get latest record with co-ordinates
select *,location.ST_ASGeoJson() from "sensor.transaction.spatial" where TXNID = (select max(TXNID) from "sensor.transaction.spatial" where SENSORID=22 )
___________
xsodata code:
service namespace "namespace democloud.<schema>.exer.iqa.services"{
"<schema>"."sensor.master" as "sensors";
"<schema>"."sensor.transaction" as "sensordata";
}
annotations{
enable OData4SAP;
}
___________
url:
https://<tenant>.ap1.hana.ondemand.com/democloud/<schema>/exer/iqa/services/services.xsodata/sensors?$format=json
https://<tenant>.ap1.hana.ondemand.com/democloud/<schema>/exer/iqa/services/services.xsodata/sensordata?$format=json
___________
create sensor
x
get latest values
https://<tenant>.ap1.hana.ondemand.com/democloud/<schema>/exer/iqa/services/services.xsodata/sensordata?$format=json&$orderby=TXNID%20desc&$filter=SENSORID%20eq%2022&$top=1
create spatial values
https://<tenant>.ap1.hana.ondemand.com/democloud/<schema>/exer/iqa/services/operations.xsjs?method=addspatialvalue&SENSORID=22&SENSORVAL=2.434&LAT=1.234&LONG=-2.34
get latest spatial value of sensor
https://<tenant>.ap1.hana.ondemand.com/democloud/<schema>/exer/iqa/services/operations.xsjs?method=getlatestspatialvalue&SENSORID=22
Create FullText Index "tweets" ON "TEAM14"."Tweets"("text") configuration 'EXTRACTION_CORE_VOICEOFCUSTOMER' ASYNC FLUSH EVERY 1 MINUTES LANGUAGE DETECTION ('EN') TEXT ANALYSIS ON;
Subscribe to:
Posts (Atom)
Post Ads (Documentation Required)
Phani Kumar
I am a SAP Technology enthusiast.
I am working on SAP technologies and various integrations.
SAP Fiori
SAP Gateway OData Development
SAP UI5
SAP Hana Cloud Platform
Internet of Things
Augmented Reality and Virtual Reality

