Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Sorting sequence


How can I define sorting sequence based on parameter selection in a prompt panel such that records gets sorted in that order ?

Also can I sort the data in individual parameter prompt for selection?


Karan Sheth

Former Member

Hi Karan,

Let's assume you're trying to dynamically set the sort direction for a string field (Name) using a prompt. Here's what you need to do:

1) Create a formula called Sort1 with this code:

If {?Sort_prompt} = 'Ascending' then '!'

else {Database_Name_Field}

2) Create a formula called Sort2 with this code:

If {?Sort_prompt} = 'Descending' then '!'

else {Database_Name_Field}

3) Go to Record Sort Expert > Add the first formula field > Choose 'Descending' as the 'Sort Direction'.

Next, add the second formula to the list and this time choose 'Ascending' as the 'Sort Direction'.

Another way to do this if you're using CR 2008 or higher is to use the Sort Control feature. To use this feature, first add the database field you wish to sort on in the Record Sort Expert > Right-click the column header on the report > Select 'Bind Sort Control' > Choose the database field from the list.

This places two arrows on the column header for changing the sort direction at runtime.

For the second question please post a new discussion with a brief description of what you're trying to achieve.


0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question