cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Code Based OData. How to implement orderby

suwandi_cahyadi
Contributor
5,230

Hello,

How to implement orderby in Code based OData? I try CDS based OData expose as RDS in SEGW and create the UI using Fiori Elements List Report. Then I redefine the GET_ENTITYSET in DPC_EXT class and I do not call the super class.

Here is how I currently implement the orderby

    SELECT ....
      INTO TABLE @DATA(lit_data)
....

    " order by
    CALL METHOD /iwbep/cl_mgw_data_util=>orderby
      EXPORTING
        it_order = it_order
      CHANGING
        ct_data  = lit_data.
....
implement paging & stuff

I can debug and show that the internal table it is actually sorted correctly. But somehow, in the List Report application, the record is not shown as in the same order as in the internal table.

How to implement order by correctly?

Thank you.

View Entire Topic
suwandi_cahyadi
Contributor
0 Likes

Hi,

I solve this by specifying the correct keys in the CDS. So, in the report result there are actually 2 fields that make each record unique, but in the CDS I only specify 1 of those 2 field as the key. I set 2 fields as keys correctly and now the sorting works.

Thank you.