Who says it is not possible to be friends with your ex? You may not get back together, but it is possible to maintain a good relationship with him/her outside romance. Usually, it will take a year or more to reach this status, since both of you need to move on first (See: How to Move On After a Relationship Ends: 15 Ways to Freshen Up).
Sometimes, friendship could be the only way to keep you connected to someone you still care for. This could be a complicated process, but with respect and mutual consent, creating a new kind of relationship with your ex can be smooth.
If you want to keep your ex part of your life as a friend, you can try the following ways.