Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

SAP CRM WebUI : Sorting custom columns (custom attributes)

Hi to everybody,

i have a little problem on SAP CRM WebUI.

I created a whole custom view inside factsheet page, component BP_FACTSHEET.

I have already filled inside method GET_P_* the following code :

WHEN if_bsp_wd_model_setter_getter=>fp_sortable.

rv_value = 'TRUE'.

but data is NOT being sorted by custom columns.

How can i solve this problem? Someone could you help me,please?

Thanks in advance.

Best regards.

Dario.

Tags:
replied

Hi Dario

In the event eh_onsort, you can add the following code

lv_attr_name  = lv_thtmlb_tableview->column_key.
    CHECK lv_attr_name IS NOT INITIAL.
*   get sorting direction
    CASE lv_thtmlb_tableview->column_sort_direction.
      WHEN 'U'.
        lv_sort_order = cl_bsp_wd_collection_wrapper=>sort_ascending.
      WHEN 'D'.
        lv_sort_order = cl_bsp_wd_collection_wrapper=>sort_descending.
      WHEN OTHERS.
        RETURN.
    ENDCASE.


    IF lv_attr_name EQ 'VALID_TO' OR lv_attr_name  EQ 'VALID_FROM'.
      gv_sort_field = lv_attr_name .
      lv_attr_name = if_bol_col_sorting=>custom .
      lr_sort_callback = me .
    ELSE.
      CLEAR gv_sort_field .
    ENDIF.

*   sort
    TRY.
        me->collection_wrapper->sort( iv_attr_name     = lv_attr_name
                                      iv_sort_order    = lv_sort_order
                                      iv_stable        = lv_stable
                                     iv_sort_callback = lr_sort_callback
                                     ).
      CATCH cx_crm_cic_parameter_error.
*     could be a renamed attribute or field which does not belong to the collection
    ENDTRY.

And in the method IF_BOL_COL_SORTING~IS_A_GREATER_B, add the code

CASE gv_sort_field.
    WHEN 'VALID_FROM' OR 'VALID_TO'.
      rv_result = cl_crm_uiu_bp_tools=>is_date_a_greater_b(
                             iv_a          = iv_a
                             iv_b          = iv_b
                             ir_tv_node    = me
                             iv_node_name  = '//BUILPAYMENTCARD/'
                             iv_sort_field = gv_sort_field  ).
  ENDCASE .

where gv_sort_field is a global variable in the context node class.

Regards

Leon

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question