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:

Screenshot1.png

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.

component workbentch.png

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

/wp-content/uploads/2015/11/model_829287.png

Double click on the VBELN attribute, see the Date Type is CHAR.

data element.png


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.

/wp-content/uploads/2015/11/coding_831003.png

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply