Purpose
Sometimes on a table view, you want to sort the list by a field, you select “Sort Ascending” or “Sort Descending” on the field, but it does not provide the accurate result you expect.
One example: you log on with SALESPRO business role, open an account, go to the “ERP Sales Order” assignment block, click on field “Sales Order ID”, select “Sort Ascending”, the result looks like:
This is not the result you expect. I will explain here why the result looks like this.
Get the model information
1. Press F2 button on the Sales Order ID field and get the technical data:
component/view: BP_ERPBT/ERPTransactionsOV
context node: ERPQRORDER
attribute: VBELN
2. Go to component workbench (TCode BSP_WD_CMPWB), open component/view BP_ERPBT/ERPTransactionsOV, find the context node ERPQRORDER, as shown in the screenshot the base entity of the context node is ERPQROrder. This is the object model used.
Get the data type information
Run TCode GENIL_MODEL_BROWSER, check the radio button Component and enter ERP, then click Display button, expand Query Result Objects, and find the model ERPQROrder, expand the attribute structure, and locate the VBELN attribute
Double click on the VBELN attribute, see the Date Type is CHAR.
So even the value of the Sales Order ID field are numbers, the date type used for Sales Order ID field is CHAR therefor it will be sorted as TEXT. This is why you see the result as shown in the first screenshot.
You can also set a breakpoint in method SORT_INTERNAL of class CL_CRM_BOL_BO_COL, and check how the sorting works. In this method it will get the date type of the attribute you select to sort, and then execute different coding for different data type, like Date, Time, CHAR, etc.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
13 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
5 | |
4 |