cancel
Showing results for 
Search instead for 
Did you mean: 

LocalStorage and sort

MariusStoica
Active Participant
0 Kudos

Hi guys,

I've been having an issue with my data in my local storage.

The online request for the data is sorted out by the field I want it to by the back-end system.


SORT <fs_mtnrs> BY maktx.

As you can see the data is ordered by description.

But when I read the data from my local store, the things change. The list no longer keeps the sort from he back-end, and I have no other sort in the definition of the request.

I even wrote the request as it should be with no success: "/Materials?$filter=Brand eq 'TR'&orderby=Description"

Any ideas on why does it behave like this?

Thank you in advance,

Marius

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member182372
Active Contributor
0 Kudos

order is implemented explicetly by GW service, it is not out of the box

like

  DATA:

    lt_tech_order TYPE /iwbep/t_mgw_tech_order,

    otab          TYPE abap_sortorder_tab,

    oline         TYPE abap_sortorder.

  FIELD-SYMBOLS:

    <column>      LIKE LINE OF lt_tech_order.

  lt_tech_order = io_tech_request_context->get_orderby( ).

  LOOP AT lt_tech_order ASSIGNING &lt;column&gt;.

    oline-name = <column>-property.

    IF <column>-order = 'desc'.

      oline-descending = 'X'.

    ENDIF.

    APPEND oline TO otab.

    CLEAR oline.

  ENDLOOP.

SORT et_entityset BY (otab).

MariusStoica
Active Participant
0 Kudos

Hi Maksim,

Where should I write this code in order to make i work? In a class on the GW system or in my data class of the service?

Thank you,

Marius

former_member182372
Active Contributor
0 Kudos

in get entity set method  in *DPC_EXT class

MariusStoica
Active Participant
0 Kudos

Hi Maksim,


I have like 80+ classes ... could you be more specific ? Is it on GW server or ERP ?


Thank you,

Marius

former_member182372
Active Contributor
0 Kudos

>>GW server or ERP

it depends is it hub or embedded GW installation

the DPC_EXT class is the one you are gatting your data from

MariusStoica
Active Participant
0 Kudos

Hi Maksim,


I have 2 different servers, ERP and GW.

I get my data from the class Z_CL_SFA_MATERIALS_DATA.

1. You are saying that I have to add the code to my class and not to a standard class?

2. If "order is implemented explicitly by GW service" why does the sort work when I see the data Online?

Regards,

Marius

Private_Member_15166
Active Contributor
0 Kudos

goto SEGW tcode and find out your project. Expand your project and there in entityset or service implementation you will find entityset method for corresponding entityset name. Go there and write your code in that get_entityset_method.

MariusStoica
Active Participant
0 Kudos

Thanks Dhananjay,

My Class is not created with SEGW. It's all hand made.

The "&orderby=Description" addition to my URL doesn't get passed.  "lt_tech_order" is empty.

Any ideas ?

Regards,

Marius

MariusStoica
Active Participant
0 Kudos

Even if I input manually the values in the sort table the "answer" is still the same.

The data from the offline store is not sorted. Not by primary key, not by the sort addition to the url.

Any other ideas?

Regards,

Marius

former_member182372
Active Contributor
0 Kudos

dpc_ext is generated based on on project in segw

former_member182372
Active Contributor
0 Kudos

offline store -???


i thought we are talking about ODataModel and GW


so what mode ldo you use with what data source? your descriptions is confusing a little bit

karthikarjun
Active Contributor
0 Kudos

Hi Marius,


How you are pass your data to local storage?


If you want to sort an array/list. you can use .sort function.

for example:

var SORTKEY = "someSortKey";
  var DESCENDING = true;
  var GROUP = false;
  var oList = this.getView().byId("someList");
  var oBinding = oList.getBinding("items");
  var aSorter = [];
  // you may use foo.bar.CustomSorter instead:
  aSorter.push(new sap.ui.model.Sorter(SORTKEY, DESCENDING, GROUP));
  oBinding.sort(aSorter);


refer from: xml - How to set sorter of a List in Controller in SAPUI5? - Stack Overflow



Thanks,

Karthik A

MariusStoica
Active Participant
0 Kudos

Hi Karthik A,

Indeed, there is the sort option of the list, bu that messes up with other functionalities based on the OData data, and not the list data. If you sort the list, the indexes are not the same between the OData indexes and the list indexes, ergo it's not a viable option.

Thank you,

Marius