Quantcast
Channel: SCN : Popular Discussions - SAPUI5 Developer Center
Viewing all 728 articles
Browse latest View live

Bind a single OData entry to table

$
0
0

Hi friends,

 

I want to know how to bind a single read output (not a collection) of an OData service into a table. If I use table.bindRows it doesn't work.

 

Thanks

Krishna


System expected the element '{http://www.w3.org/2005/Atom}entry

$
0
0

hi,

 

i am trying to consume the Netweaver Gateway service via $.ajax().

the GET (Read) operation is successful, but when i am trying to create a new record i.e. POST, i am getting the following error:

System expected the element '{http://www.w3.org/2005/Atom}entry.

 

Following is the approach i am following :

1) using $.ajax() & type= 'GET' to fetch the X-CSRF-Token.

2) in the success of $.ajax (), trying to consume the type='POST' & sending the above fetched CSRF token, so as to create a new record.

 

the token is successfully fetched, but thereafter the above mentioned error comes.

 

following are the 2 headers i am using :

 

headers : {

                    "X-Requested-With" : "XMLHttpRequest",

                    "Content-Type" : "application/atom+xml",

                    "DataServiceVersion" : "1.0",

                    "X-CSRF-Token" : "Fetch",

                    "xmlns" : "http://www.w3.org/2005/Atom"

                },

                

                    type: 'GET',

                    url : oDATA_URL,

                    dataType : 'json',

                    username : uId,

                    password : pWd,

 

& once the token is fetched :

 

   headers : {
   "X-Requested-With" : "XMLHttpRequest",
   "Content-Type" : "application/atom+xml", //application/json ,application/atom+xml;type=entry
   "DataServiceVersion" : "2.0",
   "Accept" : "application/atom+xml,application/xml,application/atomsvc+xml",
   "X-CSRF-Token" : header_xcsrf_token,
  
  
   },
    
   type: "POST",
   url : oDATA_URL,
   dataType : "json",
   username : uId,
  

password : pWd,

 

the exact error message is :

 

"<?xml version="1.0" encoding="utf-8"?><error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"><code>CX_ST_MATCH_ELEMENT/544FAE4641562346A1372144E7396586</code><message xml:lang="en">System expected the element '{http://www.w3.org/2005/Atom}entry'</message><innererror><transactionid>CC5966E34FB8F166A726001F29E5DD9A</transactionid><errordetails/></innererror></error>"


Please help !!


regards,

Viren

How to fetch X-CSRF-Token

$
0
0

Hi,

 

I am trying to read the X-CSRF-Token from GW read service without success. Any idea? As far as I know sap.ui.model.odata.ODataModel does not have the provision to pass the header data. So I tried with OData from datajs library, but the response header is always blank. I am able to get the X-CSRF-Token when I run the service uisng firefox REST client.

 

Here is the code I am using.

headers:

{

"Content-Type": "application/x-www-form-urlencoded",

"X-CSRF-Token":"Fetch"

}

 

Thanks

Abhilash

How to add rows to the table in SAPUI5?

$
0
0

Hi,

 

I want to display a table which is having both columns and rows as headers.

 

I can add the columns by using

 

oTable.addColumn(new sap.ui.table.Column({

                                  label: new sap.ui.commons.Label({text: "Gender"})

                        }));


It's working fine.

 

When I want to add the Row by using


oTable.addRow(new sap.ui.table.Row({

                                label: new sap.ui.commons.Label({text: "Name"})

                      }));


It's showing error in console that

The control manages the rows aggregation. The method "addRow" cannot be used programmatically! -

 

But in my table I need both columns and Rows with Headers  like below


Column1Column2Collumn3
Row1


Row2


Row3






 

so, Please help me to solve this issue.

 

Thanks&Regards

Sridevi

Themes in SAPUI5 desktop application

$
0
0

Hello,

 

We are developing an SAPUI5 desktop application.

In the index.html file we have  script tag with themes as: data-sap-ui-theme="sap_goldreflection" ;

The theme can have four possible values "sap_platinum", "sap_highcontrastblack" and a custom theme(in the form of .css)

 

Could anyone suggest how to apply a custom theme?

 

Regards,

Jagannathan R

Simple OData Binding with SAPUI5

$
0
0

Hi SAPUI5-experts,

 

I'm just going to learn the basics of OData & SAPUI5. I currently stand at a very simple problem, because i am only able to find OData SAPUI5 examples with charts or tables.

 

I want to code an simple OData HTML file. I want to load an OData Sservice (var oModel = new oModel .... ("http:// ....")) and then show the individual values of the Service ​​without a table or chart. For example, the OData Channel "ItemID" and contains "sales", this I would now like to show individually in HTML or saved into variables.

 

I have been trying to come up with "oModel.getProperty", but it doesnt work for me - if i am using code example with table and replacing the URL with my OData Service, it works, but i don't know how to show the values of the Service individually.

 

Its a very simple problem, but i hope you can help me! A small example of code would be the best way.

Binding an aggregation to Table (SAPUI5)

$
0
0

Hi all,

did somebody ever try binding an aggregation (i.e. having an analytic view with 4 attributes, 1 measure exposed via OData, but showing only 1 attribute + measure) to a table?

 

 

Lets say I have attributes (Transaction, TaskType, Program, Month) and the measure (Number of calls: Value)

Now I'd like only to look at Transactions+Number of Calls.

With OData, this is pretty easy:

../datasource.xsodata/Workload?$select=Transaction,Value

In the results there is only 1 line per transaction with the sum of calls. (pretty much like a Select distinct Transaction, SUM(Value) as "Value")

 

But when working with the ODataModel in SAPUI5, there seems to be no way of adding the $select parameter?

 

(t is a reference to the sap.ui.table.Table created in the view)

 

var oModel = new sap.ui.model.odata.ODataModel("../data/odata/performance.xsodata");
t.setModel(oModel);
t.addColumn(new sap.ui.table.Column({                                        label : "Transaction",                                        template: new sap.ui.commons.TextView().bindProperty("text", {path: "Transaction"})                                        }));
t.addColumn(new sap.ui.table.Column({                                        label : "Calls (Period)",                                        template: new sap.ui.commons.TextView().bindProperty("text", {path: "Value"})                                        }));
t.bindRows("/Workload");

 

When I try this, i have a lot of duplicate transactions (because they have been called in different months or with a different task type). There is no aggregation.

 

My "best" try so far was adding a

 

oModel.createBindingContext("/Workload", null, {select: "Transaction,Value"},function(a){});

 

which actually triggers the right OData Request. It also updates the values in the Table, BUT:

The number of Rows is kept :-(

Lets say with duplicates the result is 100 rows.

Without duplicates its only 40.

So with the createBindingContext, the first 40 rows are overwritten with the new (right!) results, but the other 60 rows are not deleted - which makes this not a viable solution.

 

I tried a lot of stuff - like using bindAggregation for the TextView instead of bindProperty - or supplying the parameters in these functions - but nothing works.

 

Did anybody do this before? Doesn't look like something special...

 

BTW: Whiling searching in the code I found an error in the SAPUI5 libraries:

in resources/sap/ui/core/Element-dbg.js Line 123 it says:

this.mBindingParametes = null;

Actually it should be

this.mBindingParameters = null;

 

 

Thanks for your help.

Fabian

Bind a single OData entry to table

$
0
0

Hi friends,

 

I want to know how to bind a single read output (not a collection) of an OData service into a table. If I use table.bindRows it doesn't work.

 

Thanks

Krishna


Use of Icons in SAPUI5

$
0
0

Hi there,

 

today I've tryed to use the iconset (icon font) that comes with SAPUI5, but it gives me some error. I Tryed the following:

 

var aNames = sap.ui.core.IconPool.getIconNames();

 

aNames is "sap-icon://accidental-leave".

 

Now I tryed to use this in a button:

 

new sap.ui.core.Icon( {                        src : sap.ui.core.IconPool.getIconURI( aNames[0] ),                        size : "32px",                        color : "#333333",                        activeColor : "white",                        activeBackgroundColor : "#333333",                        hoverColor : "#eeeeee",                        hoverBackgroundColor : "#666666",                        width : "60px",                    } ).addStyleClass( "fontIcon" ),                    tooltip : oBundle.getText( 'quotationsView.quotationsTable.toolbar.delete' ),                    press : oController.deleteQuote                } )

 

But this gives me an error:

 

 

sap-ui-core.js (Zeile 55)

 

Error: "Element sap.ui.core.Icon#__icon0" is of type object, expected sap.ui.core.URI for property "icon" of Element sap.ui.commons.Button#__button0
Any sugesstions?
Thanks in advance!

 

System expected the element '{http://www.w3.org/2005/Atom}entry

$
0
0

hi,

 

i am trying to consume the Netweaver Gateway service via $.ajax().

the GET (Read) operation is successful, but when i am trying to create a new record i.e. POST, i am getting the following error:

System expected the element '{http://www.w3.org/2005/Atom}entry.

 

Following is the approach i am following :

1) using $.ajax() & type= 'GET' to fetch the X-CSRF-Token.

2) in the success of $.ajax (), trying to consume the type='POST' & sending the above fetched CSRF token, so as to create a new record.

 

the token is successfully fetched, but thereafter the above mentioned error comes.

 

following are the 2 headers i am using :

 

headers : {

                    "X-Requested-With" : "XMLHttpRequest",

                    "Content-Type" : "application/atom+xml",

                    "DataServiceVersion" : "1.0",

                    "X-CSRF-Token" : "Fetch",

                    "xmlns" : "http://www.w3.org/2005/Atom"

                },

                

                    type: 'GET',

                    url : oDATA_URL,

                    dataType : 'json',

                    username : uId,

                    password : pWd,

 

& once the token is fetched :

 

   headers : {
   "X-Requested-With" : "XMLHttpRequest",
   "Content-Type" : "application/atom+xml", //application/json ,application/atom+xml;type=entry
   "DataServiceVersion" : "2.0",
   "Accept" : "application/atom+xml,application/xml,application/atomsvc+xml",
   "X-CSRF-Token" : header_xcsrf_token,
  
  
   },
    
   type: "POST",
   url : oDATA_URL,
   dataType : "json",
   username : uId,
  

password : pWd,

 

the exact error message is :

 

"<?xml version="1.0" encoding="utf-8"?><error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"><code>CX_ST_MATCH_ELEMENT/544FAE4641562346A1372144E7396586</code><message xml:lang="en">System expected the element '{http://www.w3.org/2005/Atom}entry'</message><innererror><transactionid>CC5966E34FB8F166A726001F29E5DD9A</transactionid><errordetails/></innererror></error>"


Please help !!


regards,

Viren

SAP UI5 table with JSON format service data is not working

$
0
0

Please check below code:

 

Controller:

onInit: function() {                 var oModel = new sap.ui.model.json.JSONModel();                       $.ajax({               type: 'GET',               url: '......./sap/ZNAV_SM6_SRV/Output',             success: function (data) {                       oModel.setData({                            modelData : data                             });               }           });                                this.getView().setModel(oModel);                                var oTable = new sap.ui.table.Table;                                oTable = this.byId("oTab");                                oTable.setModel(oModel);              },

 

View:-

var oTable = new sap.ui.table.Table({                        title: "Table Example",                  id: this.createId("oTab"),                        selectionMode: sap.ui.table.SelectionMode.Single,            columns: [                        new sap.ui.table.Column({                            label: new sap.ui.commons.Label({ text: "Field Label" }),                            template: new sap.ui.commons.TextView().bindProperty("text", "d/results/TrNo"),//                          sortProperty: "tr",                              width: "40px",                              hAlign: "Center"                        })                        ]            });
oTable.bindRows("/modelData");      //Bring the table onto the UI               oTable.placeAt("content");

 

HTML Page:

<!DOCTYPE HTML><html>       <head>              <meta http-equiv="X-UA-Compatible" content="IE=edge">                                   <script src="resources/sap-ui-core.js"                      id="sap-ui-bootstrap"                      data-sap-ui-libs="sap.ui.commons,sap.ui.core,sap.ui.ux3,sap.ui.table"                      data-sap-ui-theme="sap_goldreflection" >              </script>              <!-- add sap.ui.table,sap.ui.ux3 and/or other libraries to 'data-sap-ui-libs' if required -->                                   <script>                                       sap.ui.localResources("otable");                     var view = sap.ui.view({id:"idoTable1", viewName:"otable.oTable", type:sap.ui.core.mvc.ViewType.JS});                                          view.placeAt("content");                                   </script>       </head>       <body class="sapUiBody" role="application">              <div id="content"></div>       </body></html>

 

 

Service response:

{  "d": {    "results": [      {        "__metadata": {          "uri": "....p/opu/odata/sap/ZNAV_SM6_SRV/Output('SAMPLE2')",          "type": "ZNAV_SM6_SRV.OUTPUT"        },        "TrSys": "AB",        "SrSys": "PQ",        "TrNo": "SAMPLE2"      },
...etc.

 

This application is not returning any data. This is working fine if I convert oModel to new sap.ui.model.odata.ODataModel, which means I have issue with JSON format only.

 

I received bunch of help on same topic but nothing is working for me.. I thought http://scn.sap.com/thread/3308554 solution works for me.. But not sure where I am doing wrong... still checking... want to see if I can get any help!

 

 

Thanks,

Naveen

How to add rows to the table in SAPUI5?

$
0
0

Hi,

 

I want to display a table which is having both columns and rows as headers.

 

I can add the columns by using

 

oTable.addColumn(new sap.ui.table.Column({

                                  label: new sap.ui.commons.Label({text: "Gender"})

                        }));


It's working fine.

 

When I want to add the Row by using


oTable.addRow(new sap.ui.table.Row({

                                label: new sap.ui.commons.Label({text: "Name"})

                      }));


It's showing error in console that

The control manages the rows aggregation. The method "addRow" cannot be used programmatically! -

 

But in my table I need both columns and Rows with Headers  like below


Column1Column2Collumn3
Row1


Row2


Row3






 

so, Please help me to solve this issue.

 

Thanks&Regards

Sridevi

Binding an aggregation to Table (SAPUI5)

$
0
0

Hi all,

did somebody ever try binding an aggregation (i.e. having an analytic view with 4 attributes, 1 measure exposed via OData, but showing only 1 attribute + measure) to a table?

 

 

Lets say I have attributes (Transaction, TaskType, Program, Month) and the measure (Number of calls: Value)

Now I'd like only to look at Transactions+Number of Calls.

With OData, this is pretty easy:

../datasource.xsodata/Workload?$select=Transaction,Value

In the results there is only 1 line per transaction with the sum of calls. (pretty much like a Select distinct Transaction, SUM(Value) as "Value")

 

But when working with the ODataModel in SAPUI5, there seems to be no way of adding the $select parameter?

 

(t is a reference to the sap.ui.table.Table created in the view)

 

var oModel = new sap.ui.model.odata.ODataModel("../data/odata/performance.xsodata");
t.setModel(oModel);
t.addColumn(new sap.ui.table.Column({                                        label : "Transaction",                                        template: new sap.ui.commons.TextView().bindProperty("text", {path: "Transaction"})                                        }));
t.addColumn(new sap.ui.table.Column({                                        label : "Calls (Period)",                                        template: new sap.ui.commons.TextView().bindProperty("text", {path: "Value"})                                        }));
t.bindRows("/Workload");

 

When I try this, i have a lot of duplicate transactions (because they have been called in different months or with a different task type). There is no aggregation.

 

My "best" try so far was adding a

 

oModel.createBindingContext("/Workload", null, {select: "Transaction,Value"},function(a){});

 

which actually triggers the right OData Request. It also updates the values in the Table, BUT:

The number of Rows is kept :-(

Lets say with duplicates the result is 100 rows.

Without duplicates its only 40.

So with the createBindingContext, the first 40 rows are overwritten with the new (right!) results, but the other 60 rows are not deleted - which makes this not a viable solution.

 

I tried a lot of stuff - like using bindAggregation for the TextView instead of bindProperty - or supplying the parameters in these functions - but nothing works.

 

Did anybody do this before? Doesn't look like something special...

 

BTW: Whiling searching in the code I found an error in the SAPUI5 libraries:

in resources/sap/ui/core/Element-dbg.js Line 123 it says:

this.mBindingParametes = null;

Actually it should be

this.mBindingParameters = null;

 

 

Thanks for your help.

Fabian

Access denied Error for sap-ui-core.js in IE8 !

$
0
0

Hi All

I am developing a SAPUI5 application hosted on a local installation (localhost) of Tomcat server, trying to display all the sales order from the SAP ES Workplace ERP system using the SAP Demo Gateway services provided...

 

I am using the following REST service to fetch all Sales Order - http://gw.esworkplace.sap.com/sap/opu/odata/sap/SALESORDERS/SOHeaders

 

My HTML5 application is running on the local host..But when I try to run this on IE8, gives me a Access denied

 

 

But the sap-ui-core.js is indeed placed under the location mentioned above..If I write a simple application which only display some text, the same code works.

Here is the HTML code I have written

<!DOCTYPE html><html>    <head>        <meta http-equiv='X-UA-Compatible' content='IE=edge' />        <title>Fetch Sales Order via Gateway - SAPUI5</title>        <script id="sap-ui-bootstrap"           type="text/javascript"           src="../sapui5/resources/sap-ui-core.js"           data-sap-ui-theme="sap_goldreflection"           data-sap-ui-libs="sap.ui.commons, sap.ui.table">           document.domain = '*.sap.com'        </script>        <script src="scripts/fetchsalesorder_new.js"></script>     </head>    <body class="sapUiBody">    <div id="salesorders"></div>        <div id="lineitems"></div>    </body></html>

 

And the snippet of the script file

 

//supress the Same Origin Policy on IE8 & Chrome
var domainString = "document.domain";
domainstring = "*.com"
'Access-Control-Allow-Origin: *.sap.com'
'Access-Control-Allow-Headers: X-KEY'
var ODataModel = sap.ui.model.odata.ODataModel
var salesOrderService =         "http://gw.esworkplace.sap.com/sap/opu/odata/sap/SALESORDERS/SOHeaders",
 username = "GW@ESW",   password = "ESW4GW",
oModel = new sap.ui.model.odata.ODataModel("http://gw.esworkplace.sap.com/sap/opu/odata/sap/SALESORDERS/SOHeaders")
asJson = false,
salesOrderCollection = "SOHeader";
var salesDetailsTable = new sap.ui.table.DataTable({   title : "Available Sales Order",   width : "100%",   visibleRowCount : 5,   ExpandedVisibleRowCount : 20,   selectionMode : sap.ui.table.SelectionMode.Single,   editable : false  });
// connect the data table to the SalesOrder service
salesDetailsTable.setModel(oModel);
salesDetailsTable.bindRows("SOHeader");
//place table at the div element
salesDetailsTable.placeAt("salesorders");

 

What could be the issue here??

 

Appreciate any help.

 

Regards

Sandip

Simple OData Binding with SAPUI5

$
0
0

Hi SAPUI5-experts,

 

I'm just going to learn the basics of OData & SAPUI5. I currently stand at a very simple problem, because i am only able to find OData SAPUI5 examples with charts or tables.

 

I want to code an simple OData HTML file. I want to load an OData Sservice (var oModel = new oModel .... ("http:// ....")) and then show the individual values of the Service ​​without a table or chart. For example, the OData Channel "ItemID" and contains "sales", this I would now like to show individually in HTML or saved into variables.

 

I have been trying to come up with "oModel.getProperty", but it doesnt work for me - if i am using code example with table and replacing the URL with my OData Service, it works, but i don't know how to show the values of the Service individually.

 

Its a very simple problem, but i hope you can help me! A small example of code would be the best way.


Use of Icons in SAPUI5

$
0
0

Hi there,

 

today I've tryed to use the iconset (icon font) that comes with SAPUI5, but it gives me some error. I Tryed the following:

 

var aNames = sap.ui.core.IconPool.getIconNames();

 

aNames is "sap-icon://accidental-leave".

 

Now I tryed to use this in a button:

 

new sap.ui.core.Icon( {                        src : sap.ui.core.IconPool.getIconURI( aNames[0] ),                        size : "32px",                        color : "#333333",                        activeColor : "white",                        activeBackgroundColor : "#333333",                        hoverColor : "#eeeeee",                        hoverBackgroundColor : "#666666",                        width : "60px",                    } ).addStyleClass( "fontIcon" ),                    tooltip : oBundle.getText( 'quotationsView.quotationsTable.toolbar.delete' ),                    press : oController.deleteQuote                } )

 

But this gives me an error:

 

 

sap-ui-core.js (Zeile 55)

 

Error: "Element sap.ui.core.Icon#__icon0" is of type object, expected sap.ui.core.URI for property "icon" of Element sap.ui.commons.Button#__button0
Any sugesstions?
Thanks in advance!

 

Themes in SAPUI5 desktop application

$
0
0

Hello,

 

We are developing an SAPUI5 desktop application.

In the index.html file we have  script tag with themes as: data-sap-ui-theme="sap_goldreflection" ;

The theme can have four possible values "sap_platinum", "sap_highcontrastblack" and a custom theme(in the form of .css)

 

Could anyone suggest how to apply a custom theme?

 

Regards,

Jagannathan R

Bar code scanner in Android[Eclipse] using Phonegap Plugin

$
0
0

Hey Friends,

 

Anyone shall guide me how to Do a BAR CODE SCANNER APP, in Eclipse. Where I need to scan code and display the result in text view ?

neptune for UI development Pros and Cons

$
0
0

Hi ,

 

we are evaluating neptune for UI development for what are the pros and cons of using neptune.

 

i see only that webdynpro abap developer can be easily moved to neptune , some javascript knowledge is still required.

 

some question

 

1) can neptune make calls to odata services ? do that requires code in javascript or ABAP

 

2) any accelerators provided by neptune  like for workflow scenarios , list and details .

 

3) can sap standard fiori apps extensibility  or modification is possible through neptune

 

4) security if its accessing business functionality directly

 

 

regards

 

Yashpal

System expected the element '{http://www.w3.org/2005/Atom}entry

$
0
0

hi,

 

i am trying to consume the Netweaver Gateway service via $.ajax().

the GET (Read) operation is successful, but when i am trying to create a new record i.e. POST, i am getting the following error:

System expected the element '{http://www.w3.org/2005/Atom}entry.

 

Following is the approach i am following :

1) using $.ajax() & type= 'GET' to fetch the X-CSRF-Token.

2) in the success of $.ajax (), trying to consume the type='POST' & sending the above fetched CSRF token, so as to create a new record.

 

the token is successfully fetched, but thereafter the above mentioned error comes.

 

following are the 2 headers i am using :

 

headers : {

                    "X-Requested-With" : "XMLHttpRequest",

                    "Content-Type" : "application/atom+xml",

                    "DataServiceVersion" : "1.0",

                    "X-CSRF-Token" : "Fetch",

                    "xmlns" : "http://www.w3.org/2005/Atom"

                },

                

                    type: 'GET',

                    url : oDATA_URL,

                    dataType : 'json',

                    username : uId,

                    password : pWd,

 

& once the token is fetched :

 

   headers : {
   "X-Requested-With" : "XMLHttpRequest",
   "Content-Type" : "application/atom+xml", //application/json ,application/atom+xml;type=entry
   "DataServiceVersion" : "2.0",
   "Accept" : "application/atom+xml,application/xml,application/atomsvc+xml",
   "X-CSRF-Token" : header_xcsrf_token,
  
  
   },
    
   type: "POST",
   url : oDATA_URL,
   dataType : "json",
   username : uId,
  

password : pWd,

 

the exact error message is :

 

"<?xml version="1.0" encoding="utf-8"?><error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"><code>CX_ST_MATCH_ELEMENT/544FAE4641562346A1372144E7396586</code><message xml:lang="en">System expected the element '{http://www.w3.org/2005/Atom}entry'</message><innererror><transactionid>CC5966E34FB8F166A726001F29E5DD9A</transactionid><errordetails/></innererror></error>"


Please help !!


regards,

Viren

Viewing all 728 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>