You can trian a horse to pee on command. Just whistle in the barn when they pee, eventually when you whistle they will pee. It is really helpful at a show for a horse that only pees in sawdust. If they can't find a place to pee they will dance and be really bad. My horse will pee before I take him out of his stall so he won't have to go while we are riding. Also I would think pooping on command would be possible, all you would have to do would be something like whistling while you pee, such as ring a bell for them to poop.
My horse also only poops and pees in the back of his stall. You can get them to do this by moving everything to the back of their stall during the day. If they poop in the middle of their stall move it to the back. Eventually they will learn the poop goes in the back of the stall.