Register Hereor login if you are already a member
Obviously, the first option is to use SQLRPGLE and use a Select with the Group on clause.
And if logical files can't be used then we will push for an Open Query File. It's the last option that will present the records to the program in the desired order.
Without any of these options the program gets interesting.