cancel
Showing results for 
Search instead for 
Did you mean: 

How to sort asceding order based on ageing field in result list?

former_member198180
Active Participant
0 Kudos

Hi team,

I wanto to sort ageing in days  field ,in ascending order.i have created this field through AET, and i have implemented on Get method. i have added in  service order result screen.So could you please help here how to sort ascending order.

Now the ageing in days values are coming like as below.

500

10

524

535

100

34

but i want all the values in acending order how to do it..and could you please help any code?

Thanks

kalpana

                                                                         


Accepted Solutions (0)

Answers (2)

Answers (2)

Webster_Cui
Advisor
Advisor
0 Kudos

Algorithm area is more suitable for your issue.


Considering the performance I suggest you use Quicksort algorithm.

See the link for reference.

QuickSort Algorithm

former_member198180
Active Participant
0 Kudos

HI Webster,

Thanks for your reply..

See i have added the logic on SORT method as below..

 

 

METHOD sort

.
CALL METHOD super->sort

.

DATA: lv_thtmlb_tableview TYPE REF TO cl_thtmlb_table_view,
lr_cn
TYPE REF TO cl_bsp_wd_context_node_tv,
lv_event
TYPE REF TO cl_htmlb_event_tableview.

DATA : lv_sort_order TYPE char1,
lv_sort_callback
TYPE REF TO if_bol_col_sorting,
lv_stable
TYPE abap_bool,
lv_attr_name
TYPE name_komp.

IF gv_sort_column IS NOT INITIAL AND gv_sort_direction IS NOT INITIAL.
* get sorting direction

TRY .
lv_attr_name
= gv_sort_column."'AET FIELD
lv_sort_order
= gv_sort_direction.
lv_sort_callback
= me.
*

me
->typed_context->btqrsrvord->collection_wrapper->sort(
EXPORTING
iv_attr_name
= lv_attr_name " Component Name
iv_sort_order
= lv_sort_order " Sort Sequence
iv_stable
= abap_true " Flag: Stable Sorting
iv_sort_callback
= lv_sort_callback " Callback Interface for Applic.-Controlled Collection Sorting
).

CATCH cx_crm_cic_parameter_error.

ENDTRY.

ENDIF.

And GET_P method

 

METHOD

get_p_/rcrm/f004b.

CASE iv_property.
WHEN if_bsp_wd_model_setter_getter=>fp_sortable.
rv_value
= 'TRUE'.
ENDCASE.

ENDMETHOD

.

In do_prepare_out put method

method DO_PREPARE_OUTPUT.
*if iv_first_time = abap_true.
*CALL METHOD SUPER->DO_PREPARE_OUTPUT
*  EXPORTING
*    iv_first_time = iv_first_time.
**    .
*else.
    prepare_toolbar( ).

  sort( ).
*endif.
endmethod.

But still it is not working ...Could you please suggeset where i need to do change..

Thanks

kalpana

former_member198180
Active Participant
0 Kudos

Hi Team,

Still iam looking help here..This AET custom filed..here i have just displayed value not save in data base,,,posting days-system date = 20 days like that i have just displayed data..

Thanks

kalpana

dharmakasi
Active Contributor
0 Kudos

Hi Kalpana,

Keep break point in sort method and check what values are coming in gv_sort_name variable.

I think your aet field name is not passed to this global variable.

You can try passing direct field name here,

lv_attr_name = gv_sort_column



Best Regards,

Dharmakasi..

former_member198180
Active Participant
0 Kudos

Hi Kasi,

I have tried already ..but still is doesnt work ,idid changes in code as below please help..i want to descending order in that custom field,in service order ,service request,complaint screen..

So  ihave addded code in SORT method as below./This is AET field na,just i have displayed the value in result.but data is n ot saved in ATADMINH..please check my code

SORT Method

 

METHOD sort

.
CALL METHOD super->sort.
** .


DATA: lv_thtmlb_tableview TYPE REF TO cl_thtmlb_table_view,
lr_cn
TYPE REF TO cl_bsp_wd_context_node_tv,
lv_event
TYPE REF TO cl_htmlb_event_tableview.

DATA : lv_sort_order TYPE char1,
lv_sort_callback
TYPE REF TO if_bol_col_sorting,
lv_stable
TYPE abap_bool,
lv_attr_name
TYPE name_komp.

IF gv_sort_column IS NOT INITIAL AND gv_sort_direction IS NOT INITIAL.
* get sorting direction

TRY .
lv_attr_name
= gv_sort_column.
lv_sort_order
= gv_sort_direction.
lv_sort_callback
= me.
*

me
->typed_context->btqrsrvord->collection_wrapper->sort(
EXPORTING
iv_attr_name
= lv_attr_name " Component Name
iv_sort_order
= lv_sort_order " Sort Sequence
iv_stable
= abap_true " Flag: Stable Sorting
iv_sort_callback
= lv_sort_callback " Callback Interface for Applic.-Controlled Collection Sorting
).

CATCH cx_crm_cic_parameter_error.

ENDTRY.

ENDIF.

**

---------------------------------------

DO_PREAPRE_OUTPUT

 

gv_sort_direction

= 'D'.
gv_sort_column
= '/RCRM/F004B'.
sort( ).

-----------------------------------------------

but still it doesnt work..

Please guide me.

Thanks

Kalpana


dharmakasi
Active Contributor
0 Kudos

Hi Kalpana,

Is this the technical name '/RCRM/F004B of your attribue?

Which view you have added this code. It should be the result view do prepare output method.

Best Regards,

Dharmakasi.

former_member198180
Active Participant
0 Kudos

Hi Dharma kasi,

yes this is my attribute..I have added the code in

Component -BT120S_CPL(Complaint )

view - BT120S_CPL/AdvSearchComplRL

compoent - BT116S_SRVO (Service order)

view - BT116S_SRVO/AdvancedSRL

Thanks

Kalpana

dharmakasi
Active Contributor
0 Kudos

Hi Kalpana,

Please keep a break point in EH_ONSORT event and then click on sort ascending or descending in your ageing attribute in web ui. You can cross check the attribute name  gv_sort_column  = lv_thtmlb_tableview->column_key.

One more important thing, once you are called sort method in do prepare out. add below code

btqrsrvord->build_table( ). method.

Best Regards,
Dharmakasi.

former_member198180
Active Participant
0 Kudos

Hi kasi,

i have checked in run tume in line -gv_sort_column  = lv_thtmlb_tableview->column_key ,iam getting Attribute name.

i have added the logic in do_prepare_output

 

CALL METHOD super->do_prepare_output.

* DATA : lr_ref TYPE REF TO /rcrm/16s_s_advancedsrl_impl.
* CREATE OBJECT lr_ref.

gv_sort_direction
= 'D'.
gv_sort_column
= '/RCRM/F004B'.

sort( ).
BTQRSRVORD
->build_table( ).

Here iam getting BTQRSRVORD is uknown.

Thanks

Kalpana


dharmakasi
Active Contributor
0 Kudos

Hi Kalpana,

Check in super class do_prepare_output, how they are calling build_table method in standard code.


You can try by giving typed_context->BTQRSrvOrd->build_table after sorting is done.

You have to follow the same procedure. Once you have done the sort on result list you have to call the build table. So that system will display the sorted result list in web ui.

Best Regards,

Dharmakasi.

former_member198180
Active Participant
0 Kudos

Hi Kasi,

Thanks for your reply .i have added the code in do_prepare_output method as like as below.

 

CALL METHOD

super->do_prepare_output.

* DATA : lr_ref TYPE REF TO /rcrm/16s_s_advancedsrl_impl.
* CREATE OBJECT lr_ref.

gv_sort_direction
= 'D'.
gv_sort_column
= '/RCRM/F004B'.

sort( ).
gr_result_list_cnode
->build_table

( ).

Now Result should be displayed like as below.Descending order is not works properly..but ascending order is working fine..descending order check the scren shot below.could you please help here.

Thanks

Kalpana


dharmakasi
Active Contributor
0 Kudos

Hi Kalpana,

What is the code in your sort method?

Use this code in sort method and try.

gr_result_list_cnode->collection_wrapper->sort( iv_attr_name  = gv_sort_column

                                                       iv_sort_order = gv_sort_direction

                                                       iv_stable     = abap_true ).

Best Regards,

Dharmakasi.

former_member198180
Active Participant
0 Kudos

Hi Kasi,

Thanks for your reply..SORT method code is as below..

 

METHOD sort

.
CALL METHOD super->sort.

DATA: lv_thtmlb_tableview TYPE REF TO cl_thtmlb_table_view,
lr_cn
TYPE REF TO cl_bsp_wd_context_node_tv,
lv_event
TYPE REF TO cl_htmlb_event_tableview.

DATA : lv_sort_order TYPE char1,
lv_sort_callback
TYPE REF TO if_bol_col_sorting,
lv_stable
TYPE abap_bool,
lv_attr_name
TYPE name_komp.

IF gv_sort_column IS NOT INITIAL AND gv_sort_direction IS NOT INITIAL.
* get sorting direction

TRY .
lv_attr_name
= gv_sort_column.
lv_sort_order
= gv_sort_direction.
lv_sort_callback
= me.
*

me
->typed_context->btqrsrvord->collection_wrapper->sort(
EXPORTING
iv_attr_name
= lv_attr_name " Component Name
iv_sort_order
= lv_sort_order " Sort Sequence
iv_stable
= abap_true " Flag: Stable Sorting
iv_sort_callback
= lv_sort_callback " Callback Interface for Applic.-Controlled Collection Sorting
).

CATCH cx_crm_cic_parameter_error.

ENDTRY.

ENDIF.



ENDMETHOD

.

Thanks

Kalpana

dharmakasi
Active Contributor
0 Kudos

Hi Kalpana,

Instead of the below code

me->typed_context->btqrsrvord->collection_wrapper->sort(
EXPORTING
iv_attr_name
= lv_attr_name " Component Name
iv_sort_order
= lv_sort_order " Sort Sequence
iv_stable
= abap_true " Flag: Stable Sorting
iv_sort_callback
= lv_sort_callback " Callback Interface for Applic.-Controlled Collection Sorting

).



Add the below code


gr_result_list_cnode->collection_wrapper->sort( iv_attr_name  = gv_sort_column

                                                       iv_sort_order = gv_sort_direction

                                                       iv_stable     = abap_true ).


Best Regards,

Dharmakasi.


former_member198180
Active Participant
0 Kudos

Hi kasi ,

i have added same code..but still it doesn't work ..descending order criteria is same as thing....please help here.

Thanks

kalpana

former_member198180
Active Participant
0 Kudos

Hi kasi,

Could you please help here..

Thanks

Kalpana


dharmakasi
Active Contributor
0 Kudos

Hi Kalpana,

What code you have added in sort method?

Can you send me the code in sort method, i have informed in my earlier post

Add the below code


gr_result_list_cnode->collection_wrapper->sort( iv_attr_name  = gv_sort_column

                                                       iv_sort_order = gv_sort_direction

                                                       iv_stable     = abap_true ).


did you add this instead of your existing code?


You can keep break point inside sort method and see what values are coming in gv_sort_column and gv_sort_direction values.

Best Regards,

Dharmakasi.

former_member198180
Active Participant
0 Kudos

Hi Kasi,

i have added the below code in SORT method..in debugging iam getting values in debuging .but still values are not displayed in proper descending order in result screen ..please help .

METHOD sort

.
CALL METHOD super->sort.
DATA: lv_thtmlb_tableview TYPE REF TO cl_thtmlb_table_view,
lr_cn
TYPE REF TO cl_bsp_wd_context_node_tv,
lv_event
TYPE REF TO cl_htmlb_event_tableview.

DATA : lv_sort_order TYPE char1,
lv_sort_callback
TYPE REF TO if_bol_col_sorting,
lv_stable
TYPE abap_bool,
lv_attr_name
TYPE name_komp.

IF gv_sort_column IS NOT INITIAL AND gv_sort_direction IS NOT INITIAL.
* get sorting direction

TRY .
lv_attr_name
= gv_sort_column."'/RCRM/F004B'.
lv_sort_order
= gv_sort_direction.

gr_result_list_cnode
->collection_wrapper->sort( iv_attr_name = gv_sort_column
iv_sort_order
= gv_sort_direction
iv_stable
= abap_true
iv_sort_callback
= lv_sort_callback ).


* ).

CATCH cx_crm_cic_parameter_error.

ENDTRY.

ENDIF.
ENDMETHOD

.

former_member198180
Active Participant
0 Kudos

Hi kasi,

Still iam looking help here..could you please help..It is not working ..and i want to do same thing service request also..please help.

Thanks

Kalpana

dharmakasi
Active Contributor
0 Kudos

Hi Kalpana,

I do not see any issues in code. But can you check the Descending sort order using your custom field on result list assignment block in web ui?

Before checking comment your changes in do_prepare_output so that system will work as per the standard.

Best Regards,

Dharmakasi.

former_member198180
Active Participant
0 Kudos

Hi kasi,

I have commented the code in DO_PREAPRE_OUTPUT..i have clicked Descending order in result list ,it is not working..if we click Ascending order then it is working fine..Descending order is not working ..What changes we need to do..please help

And i want to do same functionality in service request screen.

component - SRQM_INCIDENT_S

VIew - SRQM_INCIDENT_S/IncidentSRL

Thanks

Kalpana

former_member198180
Active Participant
0 Kudos

Hi kasi,

i have checked in result of service order ,and commented on code DO_PREPARE_OUTPUT,if we click descending order in result list its getting ascending order in correct format.see below image.

.if we click again descending order it is coming as below..Ascending order functionality doesnt work.plesae help here.

i want to do same changes in service request component also.

component - SRQM_INCIDENT_S

VIew - SRQM_INCIDENT_S/IncidentSRL

Thanks

kalpana

former_member198180
Active Participant
0 Kudos

HI kasi,

Could you please help here.

Thanks

kalpana

dharmakasi
Active Contributor
0 Kudos

Hi Kalpana,

I hope there is already sort code in standard do_prepare_output itself. I checked in my system i can see the below code in do_prepare_output standard code.

   prepare_toolbar( ).

   sort( ).

   gr_result_list_cnode->build_table( ).


If you have the same code in your standard do_prepare_output, just remove all your custom changes in sort method and do_prepare_output method.


Then pass the gv_sort_column with your custom field name and gv_sort_order with 'D' and then call the super class do_prepare_output.

gv_sort_column = 'Field name'

gv_sore_order = 'D'.


Call Super 'DO_PREPARE_OUTPUT'

iv_first_time = iv_first_time.


Best Regards,

Dharmakasi.


former_member198180
Active Participant
0 Kudos

HI kasi,

i have commented code in SORT method and in do_prepare_outpu method i have add code as below...but stil it does not work...and how to do it complaint screen ..same process we need to implement in complaint screen as well..

 

METHOD

do_prepare_output.
CALL METHOD SUPER->DO_PREPARE_OUTPUT
EXPORTING
iv_first_time
= iv_first_time. "ABAP_FALSE

gv_sort_direction = 'D'.
gv_sort_column
= '/RCRM/F004B'.

ENDMETHOD

.

Thanks

kalpana

former_member198180
Active Participant
0 Kudos

Hi Kasi,

bt120s_cpl

BT120S_CPL/AdvSearchComplRL

i want to do changes in sorting in reuslt screen.how to do it.could you please help here.here i have added the logic on sort method and do_prepare_output method

 

METHOD sort

.
CALL METHOD super->sort.

DATA: lv_thtmlb_tableview TYPE REF TO cl_thtmlb_table_view,
lr_cn
TYPE REF TO cl_bsp_wd_context_node_tv,
lv_event
TYPE REF TO cl_htmlb_event_tableview.

DATA : lv_sort_order TYPE char1,
lv_sort_callback
TYPE REF TO if_bol_col_sorting,
lv_stable
TYPE abap_bool,
lv_attr_name
TYPE name_komp.

IF gv_sort_column IS NOT INITIAL AND gv_sort_direction IS NOT INITIAL.
* get sorting direction

TRY .
lv_attr_name
= gv_sort_column.
lv_sort_order
= gv_sort_direction.
* lv_sort_callback = me.


me
->typed_context->RESULT->collection_wrapper->sort(
EXPORTING
iv_attr_name
= lv_attr_name " Component Name
iv_sort_order
= lv_sort_order " Sort Sequence
iv_stable
= abap_true " Flag: Stable Sorting
iv_sort_callback
= lv_sort_callback " Callback Interface for Applic.-Controlled Collection Sorting
).


*
* gr_result_list_cnode->collection_wrapper->sort( iv_attr_name = gv_sort_column
* iv_sort_order = gv_sort_direction
* iv_stable = abap_true ).
* ENDIF.
* CATCH cx_root.
* " return as it is just sorting.
* RETURN.
ENDTRY.

* ENDTRY.
ENDIF.



ENDMETHOD

.

--------------------

Do_prepare_output method

 

super

->do_prepare_output( ).
*
* DATA: lr_tcc TYPE REF TO cl_bt120s_c_bspwdcomponen_impl.
**
* lr_tcc ?= me->comp_controller.
*
* me->typed_context->result->gv_value_help_mode = lr_tcc->gv_value_help_mode.

gv_sort_direction
= 'D'.
gv_sort_column
= '/RCRM/F004B'.
me
->typed_context->result->build_table( ).

sort( ).

Thanks

kalpana

dharmakasi
Active Contributor
0 Kudos

Hi Kalpana,

Can you please completely whatevet i suggested in my earlier post and follow it. I asked you to check in standard do_prepare_output method. If the standard method itself has code for sort, you can make use of the standard code itself. I asked you to set gv_sort_direction and gv_sort_column values before calling the super class do_prepare_output.

You can follow the same procedure as your doing it for service orders or service requests.

Best Regards,

Dharmakasi.

former_member198180
Active Participant
0 Kudos

Hi Kasi,

I have tried what ever u suggested in earlier post..in standard do_prepare_output code is available.in sort method i have commented and in do_prepare_output method i have added the logic as below.

 

METHOD

do_prepare_output.

*CALL METHOD SUPER->DO_PREPARE_OUTPUT
* EXPORTING
* iv_first_time = ABAP_FALSE.

* super->do_prepare_output( ).

gv_sort_direction
= 'D'.
gv_sort_column
= '/RCRM/F004B'.

super
->do_prepare_output( ).


ENDMETHOD

.

But still it doesnt work..

Thanks

kalpana

former_member198180
Active Participant
0 Kudos

Hi Kasi,

Could you please help here.

Thanks

Kalpana

praveen_kumar194
Active Contributor
0 Kudos


if field is part of result list, why can not you use filter property to sort it.

or if you want your result list always be sorted based on ageing, then you can do that in the do prepare output method of your view implementation class by sorting the collection based on your required field.