cancel
Showing results for 
Search instead for 
Did you mean: 

Sorting in Result list not working in the result list !!!

former_member224405
Participant
0 Kudos

Hi All,

I have a requirement to sort the result list display in the table view using transaction id in Ascending OR Descending order.

I went to the personilization tab and selected the sort in ascending order and saved it.

but it is not sorted in the ascending order when the transaction id are displayed in the result list.

Plz provide inputs where i can verify or there is some SAP NOTES for the same.

Thanks,

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi Anjum,

Please check the GET_P_XXX method of that Attribute, sortable property has to be set as "TRUE".

You can put the below code in P method & try :

CASE iv_property.

WHEN if_bsp_wd_model_setter_getter=>fp_sortable.

rv_value = 'TRUE'.

ENDCASE.

Please let us know if it helps & resolves your issue.

Thanks.

Arnab Midde

former_member224405
Participant
0 Kudos

Hi Sugan,

Plz let me know where to place the code which you have given.

Thanks,

deepika_chandrasekar
Active Contributor
0 Kudos

Hi Anjum,

Check your code in EH_ONSORT method in implementation class.

If code is not there check this one

me->typed_context->contextnode name->eh_on_sort(

       iv_htmlb_event    = htmlb_event

       iv_htmlb_event_ex = htmlb_event_ex ).

Regards,

Deepika.

Former Member
0 Kudos

Hi Anjum,

   In our scenario when we are searching a BP we need to sort the list. So we placed this code in EH_ONSEARCH of impl class.

  If that could be the case for you, Please paste this in Search event. After Get query result.

Thanks

Sugan

Former Member
0 Kudos

Hi,

  Check the below code, Here we are sorting based on last changed time.

Data : lr_copy TYPE REF TO if_bol_bo_col.

CONSTANTS : lc_lastchange_time type NAME_KOMP value 'LASTCHANGETIME'.

lr_copy ?= me->typed_context->builheader->collection_wrapper->get_copy( ).

   IF lr_copy IS BOUND.
*   Sort collection by Date and time
     CALL METHOD lr_copy->sort
       EXPORTING
         iv_attr_name  = lc_lastchange_time
         iv_sort_order = cl_bsp_wd_collection_wrapper=>sort_descending.

     *   Clear and set the collection
     me->typed_context->builheader->collection_wrapper->clear_collection( ).
     me->typed_context->builheader->collection_wrapper->set_collection( lr_copy ).
   ENDIF.



Cheers!!!

Sugan

Former Member
0 Kudos

Hello

If you still do not have the solution for your problem here are my ideas how to solve this:

1. Implement onsort method for the view controller which you want to sort the data one.

2. In the DO_PREPARE_OUTPUT method put code to sort the result list:

IF iv_first_time = abap_true.

  me->typed_context->srvreq->collection_wrapper->sort(

      iv_attr_name    = NAME_OF_COLUMN

      iv_sort_order   = SORT_ORDER_U_OR_D

      iv_stable       = abap_false ).

ENDIF.

regards