Finding the biggest of 2 CODE's

Hi A little problem: I have 2 variable of type CODE - Var1 and Var2. How do I in the easyist way find the “biggest” of the 2 variabels? Var1 and Var2 would look like this: 222,222x,123,124,125x etc where 222x is bigger than 222 and 222 is (of course!!) bigger than 221!

As the ‘>’ operator is NOT working (result: 223 is not bigger than 222x) I would propose to define a TEMPORARY record variable of a table that has a Code variable as primary key (e.g. T3 Payment Terms). Insert two records with the primary key values of your Var1 and Var2. Find the last record and you have the bigger of the two Vars.

How should the list be sorted ? 2222,2221,222,221,223 ???

The sort order is different according to the type. The sort order of CODE type is : ‘9’<‘123’<‘124’< ‘222’ < ‘AAx’ <‘125x’ < ‘22x’ Numeric value following by Text values The sort order of TEXT type is : ‘AAx’ < ‘123’< ‘124’ < ‘125x’ < ‘222’ < ‘222x’ <‘9’ Be careful, in Navision, characters ‘0’…‘9’ are bigger than ‘A’…‘Z’ With Excel or Sql, it’s not the same → ‘0’ < ‘9’ < ‘A’ … Hope this help you Have a nice day Patrick