Well, even though I’ve been building services for a while, I realize there is a lot I don’t know. Today (well, let’s be honest, for the past few days) I’ve been trying to figure out why my grouping and sorting just doesn’t work in my first UI5 application. Well, it turns out that checking that nice little box as sortable in SEGW doesn’t really do anything for you. I’m still checking it, but it doesn’t appear to be helping me at all.
https://scn.sap.com/thread/3746888
and especially
http://scn.sap.com/community/gateway/blog/2013/09/03/sap-gw–implement-a-better-orderby-for-cust-ext-class
finally opened my eyes. It’s not something I was missing, just not something that the gateway does. Which seems a little crazy. They 2nd post above does a great job of showing me what needed to be done… but let me add a bit of clarification.
First off, remember to make these changes in the _DPC_EXT class. I know this obvious to most, but since I’m still learning, it took me a few trials. next, once you get into the correct method:
/IWBEP/IF_MGW_APPL_SRV_RUNTIME~GET_ENTITYSET
You still need to do some data transformation. this took me a bit, so let me add this here:
DATA output_get_entityset TYPE /jvs/cl_prx_prodsup_mpc=>tt_prxprodsupoutput.
FIELD-SYMBOLS:
<ls_data> TYPE ANY.
ASSIGN ER_ENTITYSET->* TO <ls_data>.
output_get_entityset = <ls_data>.
when you get into this method, you only have the abstract data of ER_ENTITYSET. which can’t be used for much. so I needed to transform it to be the same type as my table. Then I could use the method provided in the post to do the sorting. Then don’t forget to transform it back when you are done.
<ls_data> = output_get_entityset.
I won’t pretend this is the best solution, but it is working for me, and I’m more than a little excited about that. My UI5 journey is going slower than I expected, but not having a lot of experience with js or xml, it’s going alright.
thanks for reading,
As always, thanks for reading and don't forget to check out our SAP Service Management Products at my other company JaveLLin Solutions,Mike