Upvote:5
They do ask for a ticket to show that you are leaving the country but when you are at immigration you can buy a cheap bus ticket out of the country and they will accept it (even if you don't actually take the bus). There are always plenty of bus operators selling tickets. If you are on a tight budget you can print out flight details (without having paid for a flight) of any flight leaving Panama and they will usually accept it as well.
Regarding the boat to Colombia, you can book it once you are in Panama City. Any good hostel (including Luna's Castle) will help to organize it for you including stopping in the San Blas islands. If you are looking for a good deal, make friends with a few people and book it together. You can negotiate a better rate if there are 4 or 5 of you than if you are on your own!