Thursday, 19 January 2017

Count von Count. I love to count.... normally


In trying to improve performance on one of my UI5 applications, I've spotted that there's a dozen or so calls to count the number of entries that sit in an entityset.


Now it's quite straightforward to switch this off using 

oDatamodel.setCountSupported(false)

from https://archive.sap.com/discussions/thread/3519523

However, WHY would I want a count of all this guff? I don't even know if it's being used yet, and even when it's being used, I just want the damn list. I can do a count of items in a list using javascript, it's one of the array properties!!??

Then it occurred to me, it's for the FIORI tiles, if you're using them : The beautiful poster-child of SAP's UX in all it's glory : 



Yeah, looks beautiful, but it's not in my design, so I'm going to get rid of these counts. Owing to the way JS pings these requests all off in parallel, I'm not expecting it to make much of a difference to performance, but at least it will make my console that much less cluttered.




Thursday, 8 December 2016

PI JAVA Hanging

So in trying to investigate a PI issue, I discovered that the client was running pure Java stack. I've not spent loads of time there, but was sure I could pick it up once I was in the correct transactions : Going to

NWA/Configuration just left me with the spinny-circle-of-boringness... PI was hanging.

An OSS Note (I forget which) said that JAVA PI systems hanging can be fixed by making a setting in Configuration... WTF? I can't even reach that, because the system is hanging! Maybe I got the wrong note.

In the end, this was fixed by:

Installing the newer version of Java
https://java.com/en/download/

Adding the URL of the application to the exceptions list:
http://neo.jpl.nasa.gov/orbits/java_exception.html

Also, in the place where you can set the exceptions, ramping the security down to minimum.


And now I can do all my PI config!

I'm looking forward to the next time I run eclipse, and seeing what the problems with that are!

This is one of the usual complaints about Java, there's a whole bunch of incompatibilities that mean you can only really purpose Java for one thing at a time! That and that SAP/Eclipse/IE never seem to keep up with what Java is doing...


Thursday, 10 November 2016

Can't see my Service in IWFND/MAINT_SERVICE

When trying to add my service, from my ED2(300) server, I can't see it in the Gateway IWFND/MAINT_SERVICE



It's definitely there in the backend, I've activated SEGW...

The way round this (for reasons unknown...) was to create a SEGW Project in the Gateway with the same name as the project in the backend. 
You don't need to populate it with the data entries, mappings to fms etc, just needs to be a faux shell.

Once that's done, go back into the IWFND/MAINT_SERVICE transaction, and try and add the Service again.

This time round, the Service was there, and the transaction even seems to have picked up that it needs to be looking at ED2(300). My guess as to why the latter should be the case is that this was a previously used service that was deleted then re-inserted.

Thanks a lot to Manu for this one... :D

Wednesday, 2 November 2016

oData Cacheing

Hi guys,
 Caching eh? Supposed to make things a lot faster, prevent unnecessary trips to the server to get data the browser thinks it's got already.

Except it doesn't... 

Here was our scenario : We had a UI5 application that dragged data from SAP into the browser. The user could change this, and save the changes back to SAP. So far so good... 

except

when the user went out of the document, then back in again, they got the OLD version of the data. This took a bit of analysis to get to the bottom of.

Of course the first thing I tried was to put a breakpoint in the backend function, to see if that was even getting hit. It wasn't.

The next thing I tried was switching on debug mode (F12 in the browser - IE in my case) and using "Network"->"Monitor" to see what requests were going to the backend. Now, since my browser console is set to "Always refresh data from server" this then called SAP, and my breakpoint was hit...

The inconsistency here is really frustrating, as you can be debugging and see one set of results, tell your user that the problem is fixed, then have them see a different set of results.

So the issue here is that the oData results had been cached.

There were 2 ways round this... one "hackier" than the other...

1 : Spoof a filter option, that the backend then ignores...
This was a colleagues idea, and I liked it as it solved the problem without significant additional investigation. We included a dummy timestamped filter, which made the URL unique, and so the browser HAD to go to the backend because it couldn't find a cached result for that URL.

2: Switch off Caching : 
https://blogs.sap.com/2014/05/28/disabling-cache-for-crudfi-odata-scenarios-for-a-ui5-application-using-ie/

Really liked this guys style!

Thursday, 25 August 2016

Naming your Models in UI5


Once again, I'm indebted to the ABAP community for their generosity of spirit and sharing. This post explains really succinctly how you can mix and mash up your models by naming them as you set them. 

http://scn.sap.com/thread/3948723

The biggest learning point for me was that the setModel method, which I'd thought indicated "Set the Model for the View" (i.e. you can only have one...)

this.getView().setModel(oSTModel,"TableModel")

Actually you can do this multiple times, setting several Models against the view. This is great, as we're now at the point where we need to draw data from several different places, and have them consolidated on the front end.

The named models can then be referred to by the XML view : 

<core:ListItem text="{TableModel>Description}" additionalText="{TableModel>Key}" />




Tuesday, 23 August 2016

view.byID

So I'd seen code examples all over the place referring to "view.byID"
When I coded them in, they never worked.

It's because the view variable needs to be declared.

Once that's been done, you can re-use the variable over and over.

Really simple, but if no-one's told you, it's not apparent!

How to loop around a JSON result...

Okay, I spent ages looking for how to do this. The tricky part I found was marrying up the data in the response from the server, and the labels that people were giving different parts of the request... Soooooo I'm going to add to the noise, and hopefully help a few people out.

First up - the address of my service that's providing the JSON data:

/sap/opu/odata/sap/ZPD_RR_SRV/RepairActivitySet

Although clearly, that's the oData, so with the JSON tag on the end:

/sap/opu/odata/sap/ZPD_RR_SRV/RepairActivitySet?$format=json

This returns a list of Repair Activities (viewed from Gateway):




Note that it has the structure d/results/{Rakey/Radesc}

This is what I wanted to loop around in my UI5 javascript application, in one of my ViewControllers.

Here's the complete code that reads the lot: 

var NRAModel = new sap.ui.model.json.JSONModel();
NRAModel.loadData("/sap/opu/odata/sap/ZPD_RR_SRV/RepairActivitySet", null, false); 
var NRAModelArray = NRAModel.getData();


var myResults = [];

myResults = NRAModelArray.d.results;
console.log(myResults.length);

for( i = 0; i < myResults.length; i++) {
     var obj = myResults[i];
      console.log(myResults[i]);
      console.log(myResults[i].Rakey );
      console.log(myResults[i].Radesc);

}


The thing to note here, is that myResults is declared as an Array, and is populated by passing the d.results content from the original NRAModel.getData

d.results, you'll notice, is the same path as that provided by my Service, in the first screenshot.

Using console.log as you go along really helps with understanding what each of the variables are doing.