cancel
Showing results for 
Search instead for 
Did you mean: 

Help - Sort field custom.

0 Kudos
335

guiding myself with some threads I tried to sort the table using the custom fields. the problem that does not order them correctly. I have read that the fields filled in in the get do not store the data in the node. and I have propagated using the set but it does not allow the change. so I only have to order with the data shown instead of the node. I need some help to do it.

https://archive.sap.com/discussions/thread/2107351

https://wiki.scn.sap.com/wiki/pages/viewpage.action?pageId=237176002

without result

get_zznombre

METHOD get_zznombre.
    DATA: current TYPE REF TO if_bol_bo_property_access.
    DATA: dref    TYPE REF TO data.
    value = 'BTQRAct not bound'.

    IF iterator IS BOUND.
      current = iterator->get_current( ).
    ELSE.
      current = collection_wrapper->get_current( ).
    ENDIF.

    TRY.
        TRY.
*{ 17.04.2018 - TFS - Ampliacion de campos Nombre y Apellidos.
*            dref = current->get_property( 'ZZNOMBRE' ).     "#EC NOTEXT

            DATA: lv_name      TYPE bu_namep_f,
                  ls_atributos TYPE crmst_query_r_act_btil.

            CALL METHOD current->get_properties
              IMPORTING
                es_attributes = ls_atributos.

            SELECT SINGLE name_first
                            FROM but000
                                INTO lv_name
                                    WHERE partner = ls_atributos-activity_partner
                                    .

*} 17.04.2018 - TFS - Ampliacion de campos Nombre y Apellidos.
          CATCH cx_crm_cic_parameter_error.
            value = 'Error en Parametro'.
        ENDTRY.

      CATCH cx_sy_ref_is_initial cx_sy_move_cast_error
            cx_crm_genil_model_error.
        value = 'cx_sy_ref_is_initial cx_sy_move_cast_error'.
        RETURN.
    ENDTRY.

*{ 17.04.2018 - TFS - Ampliacion de campos Nombre y Apellidos.
*    IF dref IS NOT BOUND.
    IF lv_name IS INITIAL.
*} 17.04.2018 - TFS - Ampliacion de campos Nombre y Apellidos.

      value = 'BTQRAct/ZZNOMBRE not bound'.                 "#EC NOTEXT
      RETURN.
    ENDIF.
    TRY.
*{ 17.04.2018 - TFS - Ampliacion de campos Nombre y Apellidos.
        value = lv_name.
*        value = if_bsp_model_util~convert_to_string( data_ref = dref
*                                    attribute_path = attribute_path ).
*} 17.04.2018 - TFS - Ampliacion de campos Nombre y Apellidos.
      CATCH cx_bsp_conv_illegal_ref.
        FIELD-SYMBOLS: <l_data> TYPE data.
        ASSIGN dref->* TO <l_data>.
*       please implement here some BO specific handler coding
*       conversion of currency/quantity field failed caused by missing
*       unit relation
*       Coding sample:
*       provide currency, decimals, and reference type
*       value = cl_bsp_utility=>make_string(
*                          value = <l_data>
*                          reference_value = c_currency
*                          num_decimals = decimals
*                          reference_type = reference_type
*                          ).
        value = '-CURR/QUANT REF DATA MISSING-'.
      CATCH cx_root.
        value = '-CONVERSION FAILED-'.                      "#EC NOTEXT
    ENDTRY.
  ENDMETHOD.

eh_onsort

  METHOD eh_onsort.
    DATA:
      lr_bo               TYPE REF TO if_bol_bo_property_access,
      lr_thtmlb_tableview TYPE REF TO cl_thtmlb_table_view,
      lv_attr_name        TYPE name_komp,
      lv_sort_order       TYPE char1,
      lv_stable           TYPE abap_bool VALUE abap_false,
      gv_sort_field       TYPE string,
      lr_sort_callback    TYPE REF TO IF_BOL_COL_SORTING.
    TRY.
        lr_thtmlb_tableview ?= htmlb_event_ex.
      CATCH cx_sy_move_cast_error.
        EXIT.
    ENDTRY.
    IF lr_thtmlb_tableview IS BOUND.

      CHECK lr_thtmlb_tableview->event_type = cl_thtmlb_table_view=>co_header_click.

      lv_attr_name = lr_thtmlb_tableview->column_key.
      CHECK lv_attr_name IS NOT INITIAL.

*   get sorting direction
      CASE lr_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 'ZZNOMBRE' OR lv_attr_name  EQ 'ZZAPELLIDOS'.
        gv_sort_field = lv_attr_name .
*        lv_attr_name = if_bol_col_sorting=>custom .
        lr_sort_callback = me->typed_context->btqract .
      ELSE.
        CLEAR gv_sort_field .
      ENDIF.

*   sort
      TRY.
          me->typed_context->btqract->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.
          DATA lv TYPE string VALUE 'Variable para quitar error en code inspector'.
      ENDTRY.
      RETURN.
    ELSE.
      CALL METHOD super->eh_onsort
        EXPORTING
          htmlb_event    = htmlb_event
          htmlb_event_ex = htmlb_event_ex.
    ENDIF.
  ENDMETHOD.

GET_P_ZZNOMBRE

METHOD GET_P_ZZNOMBRE.


  CASE iv_property.
    WHEN if_bsp_wd_model_setter_getter=>fp_fieldtype.
      "rv_value = cl_bsp_dlc_view_descriptor=>field_type_input.
    WHEN if_bsp_wd_model_setter_getter=>fp_sortable.
      rv_value = 'TRUE'.


    "WHEN IF_BSP_WD_MODEL_SETTER_GETTER=>...
      "...
  ENDCASE.


ENDMETHOD.

Accepted Solutions (0)

Answers (0)