In this case you will have to check logic in custom coding with the help of ABAPer as no one will be able to judge what code and logic has been written in that program.
Check whether it has some logic other than you are aware of which is picking some other sales order number.
Regards
Rahul