Assignment blocks usually contain tables. The content of these tables can be sorted by clicking the header column and selecting ascending or descending. This sorting feature is supported out of the box and managed by the Web UI framework.
However, this feature is supported only for attributes which are part of the business object layer (BOL entity level). It is not working for calculated (virtual) attributes which are implemented at the context node level only.
To support real and virtual attributes you have to implement a solution similar to
- Use a callback method to perform the comparison by implementing interface if_bol_col_sorting. You can place this method in context node class by implementing the sorting interface. There is no need to implement a independent class.
- Use a method cl_crm_uiu_bp_tools=>is_a_greater_b, cl_crm_uiu_bp_tools=>is_date_a_greater_b or similar to perform the comparison on context node level instead of BOL entity level.
- Perform custom or multiple-field sorting in method ON_NEW_FOCUS after reading/refreshing collection. Use method me->collection_wrapper->if_bol_bo_col~sort. Attribute name must be if_bol_col_sorting=>custom and iv_sort_callback must be the class implementing interface if_bol_col_sorting.
- Ensure that you are calling method CLEAR_LAST_LINE before performing sorting otherwise sorting might going wrong on next round trip.