Skip to Content

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

Changing sort order of columns of different types

I have created a formula on a subreport to change sorting based on variables.

select {?Pm-@Sorting}

case "property_type_desc ASC" :

{owned_property.property_type_desc}

case "property_type_desc DESC" :

{owned_property.property_type_desc}

case "item_no ASC" :

{owned_property.item_no}

case "item_no DESC" :

{owned_property.item_no}

default:

({owned_property.property_type_cd}; )

property_type_desc is a string and item_no is a number. If I use "CStr" on item_no, it doesn't sort correct (i.e. putting "100" ahead of "2"). How can I do this?

Secondly, how can I change the sort order ascending and descending using the same formula??

Thanks, Jessica

replied

I've run into the same problem trying to do parameter based sorting on both character and numeric fields. I was able to resolve by using "totext" and specifying the format:

totext({owned_property.item_no},"000")

That will covert your "2" to "002". Just be sure to add enough "0"s in the format mask to cover the max length of your field.

You can also use the same technique for date fields, totext(,"yyyy-MM-dd")

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