How to adjust BTPKEY
Since you are building a new B-tree named DATES, the BTPKEY subroutine has to be modified as usual to specify the order of sorting in the B-tree. Remember, the ID argument will have a multivalue number appended with an asterisk when the DATES B-tree is used, so BTPKEY needs a CASE clause like the following:
CASE ROOT = "DATES"
KEY = (ITEM<7,FIELD(ID,"*",2)> "R#5"):nul:ID
The above example keeps items sorted by the current multivalue in attribute 7. The current multivalue is determined by using the FIELD function to extract the number that is appended to ID with an asterisk. Since the actual multivalued data are dates stored as numerics in internal Pick format, R#5 is used. As required by BTPKEY, ID is appended to the expression to guarantee uniqueness and provide the final sort order.