Quantcast
Channel: SCN : All Content - SAPUI5 Developer Center
Viewing all 6178 articles
Browse latest View live

Error while importing application from SAPUI5 ABAP Repository

$
0
0

Hello everyone,

 

I am doing a project which need customization of an already existing app.

While trying to import the application from SAPUI5 ABAP Repository, I am getting the following error:

Capture.PNG

I have the destination file written as the following:

 

Description=xxxx

Type=HTTP

TrustAll=true

Authentication=BasicAuthentication

User=xxxx

Password=xxxx

Name=xxxx

ProxyType=Internet

URL=https://xxxx:44300

WebIDEUsage=odata_abap,ui5_execute_abap,dev_abap

WebIDESystem=xxxx

WebIDEEnabled=true

sap-client=130

 

Further,on loading the url https://xxxx:44300/sap/bc/adt/discovery, a file is being returned.

 

Can any one suggest any possible reasons for this error.

 

Thanks.


Sap.ui.table check box tick issue

$
0
0

Hi,

 

 

I have created sap.ui.table in that ,I have two column for checkbox.

Here is the snapshot of UI table.

 

uitableCheckbox.jpg

 

As you can see in the image, I have checked the row bearing number 01000000377.The checked data is not the first row of the table, it is being shown after scrolling.But when u scroll upward ,the situation in the below image to occurs.

 

uitableCheckbox1.jpg

 

 

On scrolling upward, the immediate upward checkbox also get checked(only one).

 

The orginal position of checked checkbox is 01000000377 and as you scroll upwards at every row checkbox is getting checked once.

 

 

code :

 

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

  {

  label : new sap.ui.commons.Label({

  text : "Test"

  }),

 

 

  template : new sap.ui.commons.CheckBox(

  {

  checked : {

 

 

  parts : [

  {

  path : "Test"

  },

 

 

 

  ],

  formatter : function(

  v) {

  if (v === 'X') {

  // this.setEnabled(false);

  return true;

  } else {

  // this.setEnabled(true);

  return false;

  }

  }

  },

  enabled : {

  parts : [

 

  {

  path : "Indicator"

  },

 

 

 

  ],

  formatter : function(

  s)

  if (s === 'X') {

 

 

  return false;

  }

  }

  },

 

 

  change : function(e) {

 

  flag = 1;

  flag_chk = 1;

 

 

  var path = e

  .getSource()

  .getBindingContext().sPath;

  var obj = oTable

  .getModel()

  .getProperty(

  path);

  var len = e

  .getSource()

  .getBindingContext().oModel.oData.modelData.length;

  data = e

  .getSource()

  .getBindingContext().oModel.oData.modelData;

  obj.testChk = this

  .getChecked();

  Array.prototype.remove = function(

  v) {

  this

  .splice(

  this

  .indexOf(v) == -1 ? this.length

  : this

  .indexOf(v),

  1);

  }

  if (finalArr != undefined) {

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

  var Num = thatMaster

  .getView()

  .byId(

  "MasterTable")

  .getModel()

  .getData().modelData[this

  .getParent()

  .getIndex()].Num;

  if (Num == finalArr[i]) {

 

 

  finalArr

  .remove(Num);

  // break;

  } else {

  // break;

  }

  }

  }

  var cgNum = e

  .getSource()

  .getBindingContext().oModel.oData.modelData[0].Num

  if (obj.accPostChk == true) {

  e.getSource().oParent.mAggregations.cells[15]

  .setChecked(false);

 

 

  thatMaster

  .getView()

  .byId(

  "MasterTable")

  .getModel()

  .getData().modelData[this

  .getParent()

  .getIndex()].TestInd = "X";

  thatMaster

  .getView()

  .byId(

  "MasterTable")

  .getModel()

  .getData().modelData[this

  .getParent()

  .getIndex()].Test1Ind = ""

 

 

  } else {

  thatMaster

  .getView()

  .byId(

  "MasterTable")

  .getModel()

  .getData().modelData[this

  .getParent()

  .getIndex()].TestInd = "";

  }

  }

  }),

 

 

 

  }));

 

 

 

 

On the checkbox, I am capturing the index of the table. Based upon the result, I am saving the 'X' for checked value in the modaldata and unchecking the checkbox of second column.

 

Please post in your suggestions on how to tackle this issue.

 

Thanks,

 

Saurabh.

Set language in SAPUI5 application after login to application server

$
0
0

Hi all,

 

I have currently an issue with switching the language of an SAPUI5 application after the user have successfully passed the login of the application server. When the application is called with the default parameter in the uri to set the language (http://sapr3entw.com:8082/sap/bc/ui5_ui5/sap/zpropla/?sap-language=en) the login mask shows the correct language.

 

Capture.PNG

After a successfull authorization the browser forwards to the orignal requested application without the neccessary language-parameter in the uri and the application is loaded in German instead of English. After the user is logged in and the the uri with the language parameter (?/sap-language=en) is called again the language will successfully switched to English.

 

In the developer guide (https://sapui5.hana.ondemand.com/#docs/guide/91f21f176f4d1014b6dd926db0e91070.html) I have seen that there is an existing order how the language is set within the application, but there is no information how to get/set the language of the current logged in user of the application server (selected language in the login mask).

 

 

Any ideas how to set the language of an SAPUI5 application according to the language set from the login?

 

Would be thankful for any hint.

 

Kind regards

Martin

How to add a ScrollBar to Dialog control in SAP UI5?

$
0
0

Hello Everyone,

 

I have a Dialog control to which am adding Content to it. As the Content is more , The Content is not Scroll-able in Dialog.

 

How can i add an ScrollBar to Dialog so that i could view all the content which has been added ? or

Is there any alternative method to have a Pop-Up with an added content which is Scroll-able by Default ?

 

ThankYou.

Nagishetty

Upload csv, convert to json and display data in Tiles of sapui5

$
0
0

I have a csv file and on upload it gets converted to json .

the data after converting into json is in following format data is stored in an object called "data" as shown below in the code .sjson.PNG

And when we expand the data Object it is as shown below:-

Object.PNG

Now in data Object there are 14 Object each having 3 properties as Count , Percentage and Status . I want to display this values in tiles . And tried with bindAggregation the code for which is as shown below:-

 

code.PNG

But the Tile doesnot get displayed only blank screen is displayed as shown below :-

op.PNG

 

And even no error is displayed on console .

Can anyone help me with this issue?

ODATA Model Remove method success callback function not passing oData object.

$
0
0

Hi, As per the API documentation, oData remove method success callback function should send an argument oData, but its coming as undefined and also can you please help me with "is it possible to pass additional arguments to callback function"?

  deleteProduct:function(oEvent){

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

this.getModel().remove(sPath, {

context:sPath,

success:this._onDelSucc.bind(this),

error:this._onDelFail.bind(this)

} );

},

 

_onDelSucc:function(oData,response){

//OData object value is coming as undefined.

//MessageToast.show("product "+response.requestUri.split("('")[1].replace("')","")+" deleted " );

},

_onDelFail:function( ){

MessageToast.show("product can't be deleted " );

}

Issue with ui.viz.pie

$
0
0

I am still running on the older version of viz chart and in the pie chart I notice some unexpected rendering problem for the legend. At first I thought it was only on my local system but after which I tweak the testsuite (online version) it seems that the issue is random and real.

 

Apparently it seems that the pie chart legend is unable to render properly strings that are just 2 characters or what I thought as so.

 

Will be nice if someone has a solution to it. Just a note that would not be able to change to the latest charting control for the time being.

Problem in getting oModel in UI5 application

$
0
0

Hi Experts,

 

I have are requirement to set two different oModels to my xml view. I have worklist like  table in my xml view and on clicking on one of the rows it should navigate to another page. So far I have set the oModels to my view and am able to consume the odata inside my table.

I am able to navigate from the first table "Ticket Management" (PFA) to its detail page using the code in the controller on getting my bind context (PFA).

However I am struck with the navigation from the second table "Asset Base Details" (PFA) to its corresponding page.

I am getting the error "Cannot read property 'getModel' of undefined" .

Please provide suggestions as to where I am going wrong. I have attached my xml view and controller code.

 

 

Thanks,

Srinivasan


Understand extend function in Component.js in Fiori application

$
0
0

For every Fiori application we have Component.js, and there is a function extend() call. See one example below.

What is the purpose of this function call and what functionality would it achieve?

clipboard1.png

In order to understand the logic of extend, it is necessary to understand prototype concept in JavaScript.  Let's have a look at some more simple example.

 

See this simple html source code:

<html><script>
function Animal(name) {
this.sName = name;
console.log("constructor in Animal");
}
Animal.prototype.speak = function() {    console.log("My name is " + this.sName);
};
function Cat(name) {    Animal.call(this, name);    console.log("constructor in cat");
}
Cat.prototype = new Animal();
var animal = new Animal("Jerry");
animal.speak();
var cat = new Cat('Tom');
cat.speak();
console.log("cat is animal?" + ( cat instanceof Animal ));
console.log("cat is Cat?" + ( cat instanceof Cat ));
console.log(cat.constructor);</script></html>

I use prototype inheritance to achieve the class inheritance logic which is commonly used in other language like Java.

cat instanceof Animal and cat instanceof Cat both return true as expected.

 

There are two flaws of this inheritance solution:

1. every variable created by function constructor has one attribute __proto__, which points to the prototype object of its constructor. This could be verified by the fact that statement "cat.__proto__ === Cat.prototype " returns true.

In this example, you can find there are actually duplicate attribute sName, one in cat itself and the other one in its __prototype__.

clipboard2.png

2. in above code line 17, I try to build the inheritance relationship from Animal to Cat. Here a new instance of Animal is created. Suppose in productive code if we have a complex implementation of Animal, this initialization could consume unnecessary resource and memory to finish.

 

So another approach is used:

 

<html><script>
Function.prototype.extend = function(parent) {
function dummy() {};
dummy.prototype = parent.prototype;
this.prototype = new dummy();
this.prototype.constructor = this;
}
function Animal(name) {
this.sName = name;
console.log("constructor in Animal");
}
Animal.prototype.speak = function() {    console.log("My name is " + this.sName);
};
function Cat(name) {
Animal.call(this, name);
};
Cat.extend(Animal);
var cat = new Cat("Jerry");
cat.speak();
console.log("cat is Cat?" + (cat instanceof Cat));
console.log("cat is Animal?" + (cat instanceof Animal));
console.log(cat.constructor);</script></html>

Both flaws in first approach are avoided:

 

1. No duplicate attribute "sName" in prototype chain now.

2. The initialization of a new instance of Animal when trying to build prototype chain is avoided. Instead here I use a very light weighted, dummy function as a bridge to connect Animal and Cat. The trick is done among lines 5 ~ 8 below. Once done, every variable created by constructor Cat has its __proto__ points to Animal.

clipboard3.png

Now we have already enough knowledge to understand the extend() call done in Componnet.js in Fiori application.

 

1. extend call will call Metadata.createClass.

clipboard4.png

2. In Metadata.createClass, the essential idea of line 333 is just exactly the same as the code in my second prototype inheritance approach:

 

function dummy() {};

 

dummy.prototype = parent.prototype;

this.prototype = new dummy();

 

clipboard5.png

a. within jQuery.sap.newObject, a dummy object will be created:

clipboard6.png

b. here the argument oPrototype is the prototype of sap.ca.scfld.md.ComponentBase:

clipboard7.png

Once prototype chain is built, the function call jQuery.sap.setObject is called to expose cus.crm.opportunity.Component as a global JavaScript object:

clipboard8.png

Finally these below are what we have got:

 

1. we can directly access cus.crm.opportunity.Component in JavaScript code or console thanks to jQuery.sap.setObject call.

clipboard9.png

2. The prototype chain from sap.ca.scfld.md.ComponentBase to cus.crm.opportunity.Component is built, which could be confirmed by the picture below:

clipboard10.png

Now when I enter the context of my application, I can get the instance of this component via this(controller reference).getOwnerComponent().

 

From the belowing two test statement in console, I can ensure that the prototype chain is built:

 

1. ownComponent.__proto__.__proto__.constructor === sap.ca.scfld.md.ComponentBase returns true

2. ownComponent.hasOwnProperty("getMetadata") returns false and ownComponent.__proto__.__proto__.hasOwnProperty("getMetadata") returns true.

clipboard11.png

clipboard12.png


from returned metadata, we can find all the metadata information defined in the application and passed from extend call:

clipboard13.png

Pick value from combo box

$
0
0

Hello

 

I am trying to pick the value in combo box inserted inside a table. I am not getting any value. Below is my code:

 

<ComboBox id="cmb1" placeholder="Select..."

  forceSelection="false" selectionChange="onPress" items="{/items}">

  <core:Item key="{key}" text="{text}" />

  </ComboBox>

 

 

 

onPress: function(oEvent)

  {

  var oListItem = oEvent.getParameter("listItem") || oEvent.getSource();

 

     console.log('selected Combo Box Value::'+this.getView().byId("cmb1").getValue());

//console.log('selected Combo Box Val::'+ oListItem.getAggregation("cells")[4].getProperty("selectedKey"));     //Gives error Cannot read property '4' of null

 

  }

How to solve sap.viz library error.

$
0
0

Hello Friends


I have make one application and it's contain graph . It's working in my eclipse.

 

Now i have run on my hosting server so i use resource folder they are contain all library.

 

But application give me an error TypeError: sap.viz is undefined.

 

So i have serach in SCN and i found this thread link : Where can I download the sap.viz chart library? | SCN


I have downloaded viz library folder and put in recourse folder but still i getting this error : TypeError: sap.viz is undefined.


Please help me how to solve it.

Cache Issue in SAP UI5

$
0
0

Hi ,

 

        After moving some changes to Production in existing SAP Ui5 application, when we access SAP UI5 application from the browsers the new code is not getting reflected in the application. To make this work every time i need to clear the browser cache manually.

<script

   src="resources/sap-ui-core-all.js"

   id="sap-ui-bootstrap"

   data-sap-ui-libs="sap.m, sap.ui.commons,  sap.suite.ui.commons, sap.ui.table, sap.ui.ux3,sap.viz"

   data-sap-ui-theme="sap_bluecrystal"

    data-sap-ui-appCacheBuster="./"  >

</script>

 

Please suggest.

Stacked Bar Chart valueAxis

$
0
0

Hello All,

 

I am working with viz frame Stacked bar chart.

Now i need to display time vales on X-Axis.

I need to populate the time values from my JSON Object.But while displaying time values it is displaying as some garbage numbers instead of time.

How can i print the time values on X-Axis.

 

Below is my Code.

var DataSet = new sap.viz.ui5.data.FlattenedDataset({

  dimensions : [{name : "LossType",value : "{lossType}"},

               {name : "Machine",value : "{machine}"}],

  measures  : [

            

              {name : "TimeLoss",value : "{timeFrom}"

              },

             // {name : "MachineStatus",value : "{crStatus}"},

          

             

              ],

     data : {path : "/modelData"}

 

 

 

  });

 

Regards,

Shekar.

Canvas doesn't display

$
0
0

Hello guys

 

I'm pretty new in SAPUI5, and i'm not experimented in programmation. I explain my problem :

 

I have to make a radar Chart with the library chart.js (because the chart i want isn't available with vizFrame)

 

So i made the code of my chart in my controller :

 

onAfterRendering : function () {      //radar chart data    var radarData = {    labels : ["Performance","Security","Robustness","Changeability","Transferability",],    datasets : [    {    fillColor: "rgba(102,45,145,.1)",    strokeColor: "rgba(102,45,145,1)",    pointColor : "rgba(220,220,220,1)",    //pointStrokeColor : "#fff",    data : [70,70,70,70,70]    },    {           fillColor: "rgba(63,169,245,.1)",               strokeColor: "rgba(63,169,245,1)",    pointColor : "rgba(151,187,205,1)",    //pointStrokeColor : "#fff",    data : [70,70,70,70,70]    }    ]    }    //Create Radar chart    var pentagone = document.getElementById("radarChart").getContext("2d");    var myNewChart = new Chart(pentagone).Radar(radarData);    //new Chart(pentagone).Radar(radarData);    },

Of course, i included my library in my index.html :

 

<script type ="text/javascript" src="app/utils/Chart.js"></script>

 

And in my view, i called the canvas like this :

 

<!DOCTYPE xml>

 

 

<mvc:View controllerName="Metrology.controllers.Pentagone" xmlns="sap.m"

 

 

  xmlns:layout="sap.ui.layout"

 

 

    xmlns:mvc="sap.ui.core.mvc" xmlns:html="http://www.w3.org/1999/xhtml">  

 

 

    <!-- <core:html preferDOM="true" content="&lt;canvas id='radarChart' width='800' height='650'/&gt;" />  -->

 

 

  <html:canvas id="radarChart" width="800" height="650"></html:canvas>

 

 

</mvc:View>

 

But it doesn't work. I got no error message in debug, but the canvas is invinsible. I can select it, and inspect it in my browser, but there isn't my graph.

And i know my graph is good, i tried it in a html file on notepad, and it was working great.

 

Best Regards

deletion of single row in sap ui5

$
0
0

hi experts,

i have created rows dynamically and each row contains a delete button, if i click on that delete button the row should be deleted

please help me

 

my view.xml

 

<core:View xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc"

  xmlns="sap.m" controllerName="z_adding_rows.Main" xmlns:html="http://www.w3.org/1999/xhtml">

  <Page title="Title">

  <content>

  <Table id="idProductsTable" mode="SingleSelectMaster"

  selectionChange="onSelectionChange" items="{/}">

  <columns>

  <Column width="45%">

  <Label text="First Name" />

  </Column>

  <Column width="45%">

  <Label text="Last Name" />

  </Column>

  <Column width="10%">

  <Label />

  </Column>

  </columns>

  <items>

  <ColumnListItem>

  <cells>

  <Input value="{FirstName}" />

  <Input value="{LastName}" />

  <Button text="Delete" press="onDelete"/>

  </cells>

  </ColumnListItem>

  </items>

  </Table>

  <Button text="Add Row" press="onPress" />

 

  </content>

  </Page>

</core:View>

 

 

my controller.js

 

sap.ui.controller("z_adding_rows.Main", {

 

 

  onInit: function(oEvent) {

        var dataObject = [{

        FirstName: "Madhu",

        LastName: "Sudhan"

        }];

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

        oModel.setData(dataObject);

        sap.ui.getCore().setModel(oModel);

      },

 

  onPress: function(oEvent){

  var oTable = this.getView().byId("idProductsTable");

  var oModel = oTable.getModel().getProperty("/");

  var nObject = {FirstName:"", LastName:""};

  oModel.push(nObject);

  oTable.getModel().setProperty("/", oModel);

  },

 

 

      onSelectionChange: function(oEvent) {

        var oSelectedItem = oEvent.getParameter("listItem");

        var oModel = oSelectedItem.getBindingContext().getObject();

        alert(JSON.stringify(oModel));

      },

     

      onDelete : function(){

     sap.m.MessageBox.show(

       "Are you sure you want to delete this item", {

           icon: sap.m.MessageBox.Icon.WARNING,

           title: "Delete item",

           actions: [sap.m.MessageBox.Action.YES, sap.m.MessageBox.Action.NO],

           onClose: function(oAction) {

          if(oAction==="YES"){

          

          }else{

          

          }

           }

       }

     );

      }

 

 

});


Gantt Chart in UI5 application

$
0
0

Hello,

 

Is there any way I can build a gantt chart in my UI5 application? I cannot see any library feature for gantt chart.

 

Regards,

Charles

Installation of SAP_UI 750 SP00?

$
0
0

hi, we are facing several problems in Fiori Launchpad and one of solutions is to update SAP_UI to 750, unfortunately I cannot find SAP_UI 750 SP0000, only SP0001, can you pls help where to download it?

thanks

Juraj

Error while importing application from SAPUI5 ABAP Repository

$
0
0

Hello everyone,

 

I am doing a project which need customization of an already existing app.

While trying to import the application from SAPUI5 ABAP Repository, I am getting the following error:

Capture.PNG

I have the destination file written as the following:

 

Description=xxxx

Type=HTTP

TrustAll=true

Authentication=BasicAuthentication

User=xxxx

Password=xxxx

Name=xxxx

ProxyType=Internet

URL=https://xxxx:44300

WebIDEUsage=odata_abap,ui5_execute_abap,dev_abap

WebIDESystem=xxxx

WebIDEEnabled=true

sap-client=130

 

Further,on loading the url https://xxxx:44300/sap/bc/adt/discovery, a file is being returned.

 

Can any one suggest any possible reasons for this error.

 

Thanks.

sapui5 gantt chart data.json

$
0
0

hi all,Sap gantt chart data.json file not dowlond from explored.Can you share file data.json ?e111.PNG

SAPUI5 Explored

Can you use third party .dlls with SAPUI5?

$
0
0

I am redesigning a Reman service, which currently exists as a thick client application that receives SAP Optimization Jobs (from SAP), calculates the best way to optimize product use (custom code Optimizer, WILL REPLACE WITH third party .dll) and display the best optimization on the client (custom app). They can either edit or submit the optimization back to SAP

I am trying to create a SAPUI5 application that either: Reaches out to an external web server to run a small application (Optimizer) and returns the data back to the UI5 application, or, Load the third party dll into SAP UI5 and call the Optimizer (.dll) that way.

Is this possible? Can you use third party dlls in UI5?

Viewing all 6178 articles
Browse latest View live


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