Tuesday, 16 May 2017

UI5 oData Gotcha...


Sending a request to my oData service with 2 filter parameters (Postcode and Distance)

/sap/opu/odata/sap/YPD_PL1_SRV/OTabset?$filter=Postcode eq 'TQ8 8JT' and Distance eq '10'

was yielding me the following error:

<message xml:lang="en">Invalid parametertype used at function 'eq' (Position: 36)</message>

And the problem was... since my SEGW declaration of Distance was Edm.Decimal the interface gets a bit pissy that it's being asked to look at something in single-quotes...

So the fix is, remove the single quotes on that variable - 

Now we have:

/sap/opu/odata/sap/YPD_PL1_SRV/OTabset?$filter=Postcode eq 'TQ8 8JT' and Distance eq 10

and this yields my beautiful oData:


Yay! Simple mistake, but I couldn't find it when Googling for Invalid ParameterType and it took me a while to spot, so hopefully helpful to someone out there.

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!