Objective: The need of enhancement is to Sort any field in BOL to perform Sorting with a Custom Order ( Not Alphabetically ).
Example Hypothetical Scenario:
Custom Field (Customer Type) in Search Result View to be Sorted in an arbitrary order so that first Alphabets of description string has order as ( Direct > Internet Sales > Distributor ). This sort order is not alphabetical.
The sorting should be custom in nature & on the relevant field only.
STEPS:
me->typed_context->customers->collection_wrapper->sort(
exporting iv_attr_name = 'DESCRIPTION'
iv_sort_callback = me
iv_sort_order = 'D' ).
Because of interface attached to class, a new method is now available i.e,
IF_BOL_COL_SORTING~IS_A_GREATER_B. This method takes the two values IV_A & IV_B to compare & return rv_result as ‘X if IV_A is greater than B else ‘ ‘.
Within this method we can use Simple Application of Bubble sort Algorithm to Sort in a custom order.
Logic |
---|
if value1 = 'Direct'. case value2. when 'Direct'. if lv_bu_partner2 > lv_bu_partner1. rv_result = ' '. else. rv_result = 'X'. endif. when 'Internet Sales'. rv_result = 'X'. when 'Distributor'. rv_result = 'X'. when 'Archive'. rv_result = ' '. when others. rv_result = 'X'. endcase. endif. if value1 = 'Internet Sales'. case value2. when 'Direct'. rv_result = ' '. when 'Internet Sales'. if lv_bu_partner2 > lv_bu_partner1. rv_result = ' '. else. rv_result = ' '.endif. when 'Distributor'. rv_result = 'X'. when 'Archive'. rv_result = ' '. when others. rv_result = 'X'. endcase. endif. if value1 = 'Distributor'. case value2. when 'Direct'. rv_result = ' '. when 'Internet Sales'. rv_result = ' '. when 'Distributor'. if lv_bu_partner2 > lv_bu_partner1. rv_result = ' '. else. rv_result = 'X'. endif. when 'Archive'. rv_result = ' '. when others. rv_result = 'X'. endcase. endif. |
We can always Extend this Sorting solution for more fields or number if entries
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
2 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |