cancel
Showing results for 
Search instead for 
Did you mean: 

sorting is not working for Z component

Former Member
0 Kudos

Hi,

i have Z component which contains few fields, i added sorting option to this field by enhancing get_P and sort method.

when i am clicking on the column....sort method is triggering and showing the sort order(U or D), but values are not sorting. sort icon is showing on column.

pls help me on this.

Thanks,

Neelam

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Neelam,

Is custom AB built on BOL structure or has all value attributes?

If you are trying sorting on value attributes then try this code:

Redefine method EH_ONSORT of IMPL class and write following code:

* Variables declaration
  DATA: lo_thtmlb_tableview TYPE REF TO cl_thtmlb_table_view, "Element-Handler: <thtmlb:tableView>
        lv_attr_name        TYPE name_komp,  "Attribute name
        lv_sort_order       TYPE char1,      "Sort order
        lv_stable           TYPE abap_bool VALUE abap_false. "Flag

  CLEAR: po_sort_attr_name, po_sort_order, po_sort.

  TRY.
      lo_thtmlb_tableview ?= htmlb_event_ex.
    CATCH cx_sy_move_cast_error.
      EXIT.
  ENDTRY.

  CHECK lo_thtmlb_tableview IS BOUND..
* Check whether its really a sorting event
  CHECK lo_thtmlb_tableview->event_type = cl_thtmlb_table_view=>co_header_click.
* Get name of column to be sorted
  lv_attr_name  = lo_thtmlb_tableview->column_key.

  CHECK lv_attr_name IS NOT INITIAL.

  po_sort ?= me.

  po_sort_attr_name = lv_attr_name.

* get sorting direction
  CASE lo_thtmlb_tableview->column_sort_direction.
    WHEN 'U'.
      po_sort_order = cl_bsp_wd_collection_wrapper=>sort_ascending.
    WHEN 'D'.
      po_sort_order = cl_bsp_wd_collection_wrapper=>sort_descending.
    WHEN OTHERS.
      RETURN.
  ENDCASE.

Now add interface IF_BOL_COL_SORTING to IMPL class and implement method IF_BOL_COL_SORTING~IS_A_GREATER_B:

    CASE po_sort_attr_name.

    WHEN 'Zfield1'.
*Get the first entity
      lv_input = iv_a.
* Read value in variable
lv_value_a


*Get the second entity
      lv_input = iv_b.
* Read value in variable lv_value_b

endcase.

Compare lv_value_a and lv_value_b and return higher value to rv_result.

Hope it helps.

Regards,

Shikha

Former Member
0 Kudos

Hi Neelam,

   call    lr_core->modify( ).

   it will send the the sorted data to from the UI Layer to BOL Layer.

   i hope this will solve your issue.

Regards,

Kishore

Former Member
0 Kudos

Hello Neelam ,

First of all you need to understanding that in CRM : you can only sort on one field.

Check the below code and Parameters which you have passed to that.

  typed_context->zcdp_clc_cat->collection_wrapper->sort( iv_attr_name  = 'ZZCDP_CAT_RANK'
                                                         iv_sort_order = 'A'
                                                         iv_stable     = abap_true ).

Try doing this inDO_PREPARE_OUTPUT.

Thanks and Regards,

Nikhil Kulkarni

Former Member
0 Kudos

Hi Kulakarni,

Thanks for your reply, it's working problem is wrong parameter passed to sort method inside the do_prepare_output. actually i took one global variable from IMPL class there i am setting the sort order from ON_SORT method.

but here inside do_prepare_output i am passing wrong parameter that is the reason it is not sorting.

Regards,

Neelam

Former Member
0 Kudos

cool 🙂

Former Member
0 Kudos

HI Kulkarni,

i have another issue where i need to pass my event name from one component to another component.

i don't know the procedure how to create that value node for component controller and pass it to another component.

can you help me on this.

Regards,

Neelam

Former Member
0 Kudos

 

Former Member
0 Kudos

Hi Kulkarni,

Thanks for reply, i need to take this event name from one comp. to another, because based on this event name i will display what evr configuration required, becuase in bt126h_appt i have multiple configurations with diff. subtypes...

so each configuration have different fields on screen.

so if i get this event name from source comp.....then it will be good to set the configuration based on this .

i have crated value node with same name in both components,

i have redefined the we_usage_initialize() method.

but i don't know how to pass this event name to value node attribute.

i tried with suggestion of Rajarama,

and when i try to fill the value node collection inside event method.....there i am getting error says

value node BUTTONNAME is unknown, but there is BUTTONSAVE is available...

when i see inside the comp.interface under context this BUTTONSAVE and BUTTONNAME both are there...but here BUTTONNAME is showing as model node, BUTTONSAVE is showing as value node...

is it the problem ????

pls help me any otherway to pass this event name from source comp. to target comp.

Thanks,

Neelam

Former Member
0 Kudos

Hello Neelam ,

  I understand your requirement.

The reason for that error might be : you might have missed any one of these steps.

Check the following steps.

A  and  B are your component names.

A is component where your component name is there and B is where you are going to access the value of that.

So create a Value node in the component controller of the component A .

Create value node in the component controller of Component B .

Next Implement the wd_usage_initialize method of component B.

The reason for the error may be also : in the Component A's , the data type of your value node-attribute is not matching in the component's B.

Thanks and Regards,

Nikhil Kulkarni