on 03-17-2011 10:45 AM
Hi, Can we sort a result set(table view) with multiple fields at a time.
In General we use a sort statement as:
Sort TTT table by f1 f2 f3.
but, in this table view i'm trying to sort a collection.
me->typed_context->resultnode->collection_wrapper->SORT( iv_attr_name = 'GROWER_NAME' ).
with the above sort, the result set is sorted w.r.t to one field.
Can we sort the collection with multiple fieds at a time.
I tried this, but coudnot get.
Pls provide some pointers on this.
Hi,
Check this option.
1. Using 'get_propertiesu2019, get required fields information and store it into an internal table. Once all the entities data is stored to internal table, sort the internal table based on required sort order (sort order based on multiple fields). Now the internal table having the data in required sort order.
2. Store the 'collection_wrapper' data into temporary collection and clear the existing data , now loop through the internal table and read the collection using 'IF_BOL_BO_COLFIND' Method , find the object and add it to the collection using 'if_bol_bo_coladd'.
3. Now the data collection will be in required sort order.
Thanks
L Appana
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I doubt whether the sort method offers such fucntionality.
You can try sth like this as a workaround, though it may not sound wise.
me->typed_context->resultnode->collection_wrapper->SORT( iv_attr_name = ATTR1 ).
Now the collection wrapper is sorted on ATTR1, use the sort method again though this time pass different attribute name.
Rg,
Harshit Kumar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
it is possible to sort a result table based on multiple fields: To do so, an instance of IF_BOL_COL_SORTING can be provided by the caller of the SORT method. During the sort process the method IS_A_GREATER_B of the instance is called
whenever two values are compared. Implement this method and provide the interface to influence the sort order as needed.
Kind regards,
Carl
Srikanth,
You need to sort it twice with the iv_stable parameter set to true, the second time. The behaviour is the same as normal ABAP sort statement with the "stable" addition.
sort itab by field1 field2
is the same as
sort itab by field2.
sort itab stable by field1.
Apply the same logic when you call the if_bol_bo_col~sort method.
Regards,
Arun Prakash
User | Count |
---|---|
5 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.