No, It is not mandatory. You can book your flight before or after you have your visa. The decision is up to you.