This Space has blogs on various topics in the field of SAP. These blogs point out solutions to various technical and functional issues that consultants face during implementation or support of SAP Projects. Readers/followers are welcome to contribute to this space by emailing your content at bohra.mohammadi@gmail.com. You will be rewarded according to the topic/number of words/complexity of the topic/issue which are you addressing in your blog.
Monday, May 22
SAPUI5 Table Binding with Data Coming from Backend
The Data that need to be displayed on SAPUI5 Table control resides of a backend system. The Data is fetched via oData services read call and rendered in table UI Control in below fashion
oModelECST_FETCH.read(url5,null, null, true, function(oData, oResponse){ debugger;
oInvoices = new sap.ui.model.json.JSONModel({ "Invoices" : oData.results }); oInvoices.iSizeLimit = 100000;
var tab =this.getView().byId("invoicestable"); // invoicestable is the ID of Table UI Control
tab.setModel(oInvoices);
var i=0;
tab.bindAggregation("items", {
path: "/Invoices",
template: new sap.m.ColumnListItem({
cells: [
//
new sap.m.CheckBox({visible:invoicesThat.strtoBool(oData.results[tableIndex1].Count)}).setSelected(true),
new sap.m.CheckBox("cbinv",{visible:"{Count}", selected:"{Sel}"}),
new sap.ui.commons.TextView({ text: "{InvNo}", design:"Standard", semanticColor:"Default"}),
new sap.ui.commons.TextView({ text: "{InvDate}", design:"Standard", semanticColor:"Default"}),
new sap.ui.commons.TextView({ text: "{Tin}" , design:"Standard", semanticColor:"{semCol}"}),
// new sap.ui.commons.TextView({ text: "{FormNum}", design:"Standard", semanticColor:"Default"}),
new sap.ui.commons.TextView({ text:"{TypeOfTx}",design:"Standard",semanticColor:"Default"}),
new sap.ui.commons.TextView({ text: "{TaxableGoodsVal}", design:"Standard", semanticColor:"Default"}),
new sap.ui.commons.TextView({ text: "{AmtTaxVal}", design:"Standard", semanticColor:"Default"}),
new sap.ui.commons.TextView({ text: "{InclTaxVal}", design:"Standard", semanticColor:"Default", visible:inctaxval}),
new sap.ui.commons.TextView({ text: "{LabourChrgesVal}", design:"Standard", semanticColor:"Default",visible:labchargval}),
new sap.ui.commons.TextView({ text: "{OtherChrgesVal}", design:"Standard", semanticColor:"Default"}),
//new sap.ui.commons.TextView({ text: "{LabourChrgesVal}", design:"Standard", semanticColor:"Default"}),
new sap.ui.commons.TextView({ text: "{GrossTotalVal}", design:"Standard", semanticColor:"Default"}),
]
})
});
},function(err){
debugger;
});
oModelECST_FETCH.read(url5,null, null, true, function(oData, oResponse){ debugger;
oInvoices = new sap.ui.model.json.JSONModel({ "Invoices" : oData.results }); oInvoices.iSizeLimit = 100000;
var tab =this.getView().byId("invoicestable"); // invoicestable is the ID of Table UI Control
tab.setModel(oInvoices);
var i=0;
tab.bindAggregation("items", {
path: "/Invoices",
template: new sap.m.ColumnListItem({
cells: [
//
new sap.m.CheckBox({visible:invoicesThat.strtoBool(oData.results[tableIndex1].Count)}).setSelected(true),
new sap.m.CheckBox("cbinv",{visible:"{Count}", selected:"{Sel}"}),
new sap.ui.commons.TextView({ text: "{InvNo}", design:"Standard", semanticColor:"Default"}),
new sap.ui.commons.TextView({ text: "{InvDate}", design:"Standard", semanticColor:"Default"}),
new sap.ui.commons.TextView({ text: "{Tin}" , design:"Standard", semanticColor:"{semCol}"}),
// new sap.ui.commons.TextView({ text: "{FormNum}", design:"Standard", semanticColor:"Default"}),
new sap.ui.commons.TextView({ text:"{TypeOfTx}",design:"Standard",semanticColor:"Default"}),
new sap.ui.commons.TextView({ text: "{TaxableGoodsVal}", design:"Standard", semanticColor:"Default"}),
new sap.ui.commons.TextView({ text: "{AmtTaxVal}", design:"Standard", semanticColor:"Default"}),
new sap.ui.commons.TextView({ text: "{InclTaxVal}", design:"Standard", semanticColor:"Default", visible:inctaxval}),
new sap.ui.commons.TextView({ text: "{LabourChrgesVal}", design:"Standard", semanticColor:"Default",visible:labchargval}),
new sap.ui.commons.TextView({ text: "{OtherChrgesVal}", design:"Standard", semanticColor:"Default"}),
//new sap.ui.commons.TextView({ text: "{LabourChrgesVal}", design:"Standard", semanticColor:"Default"}),
new sap.ui.commons.TextView({ text: "{GrossTotalVal}", design:"Standard", semanticColor:"Default"}),
]
})
});
},function(err){
debugger;
});
Access UI Control and Its Children at Runtime to Modify Properties | UI5
Based on user actions/output of user action, sometimes, other UI control's properties change. This behavior can be achieved by accessing UI controls mAggregation node at run time and setting desired values in UI control properties. Example of modifying 'enabled' property of a button which resides within a List's Custom list Items at place number 2. First UI control is a label, Second is the Button whose property is required to be modified
Get Currently Logged in User in SAPUI5 application
Some times to your oData calls, you want to send logged in user as one of the attributes to the call. This is how you can obtain currently logged in user within SAPUI5 application.
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);
oLoggedinID = oUserData.id;
}
};
xmlHttp.open( "GET", y, false );
xmlHttp.send(null);
oLoggedinID will contain the login id of the person who has logged on.
thank you !
Mohammed Bohra
+91 8898030972
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);
oLoggedinID = oUserData.id;
}
};
xmlHttp.open( "GET", y, false );
xmlHttp.send(null);
oLoggedinID will contain the login id of the person who has logged on.
thank you !
Mohammed Bohra
+91 8898030972
UI5 screen not launching from MII Navigation menu
hi Aravinth,
When you run the application from MII navigation menu, perform a network trace to see which call is failing. Based on that further analysis can be done. Let me know if you can share your screen using AnyDesk software to enable me debug this further.
thank you !
Mohammed
Sunday, May 21
How modify the portal URL to browser default
Change the default portal URL to give users more user friendly URL that they are adapted to from the Internet. The following steps will show you how modify the URL from the default port of 50000 to 80 which is browser default
To Change the Port:
Switch to the J2EE Visual Administrator
Goto -> Cluster -> Dispatcher -> Services -> HTTP Provider
Choose Ports
Change the port number to 80 for HTTP and 443 for HTTPS (SSL)
Choose Update and save.
Stop and Start the HTTP Provider service.
Result:
http: http://hostname.company.com:50000/irj/portal to http://hostname.company.com
https: https://hostname.company.com:50000/irj/portal to https://hostname.company.com
To Change the Port:
Switch to the J2EE Visual Administrator
Goto -> Cluster -> Dispatcher -> Services -> HTTP Provider
Choose Ports
Change the port number to 80 for HTTP and 443 for HTTPS (SSL)
Choose Update and save.
Stop and Start the HTTP Provider service.
Result:
http: http://hostname.company.com:50000/irj/portal to http://hostname.company.com
https: https://hostname.company.com:50000/irj/portal to https://hostname.company.com
Subscribe to:
Posts (Atom)
