I have a 3 1/2 yr old son, and we went thorugh the same thing with him just a few weeks ago. He would not poop in a potty if his life depended on it. It was heartbreaking, knowing your child has a horrible stomach ache, and the only thing to make it better is to poop, but your child doesn't want to. Through this site I got some great advice and it has worked for my son.
You may have to break out the little training potty to build confidence, then have him dump the poop into the big potty, if you don't need that, he might like a step-stool to rest his feet on.
First I gave mine lots of apple juice to help make it easier to go, you can water it down of course. Then about 20 minutes after he eats, take him to the potty. My child is one of those who does better in private, than with mom or dad sitting in there with him. As hard as it is, he's got to sit there and try.
We also used long term and short term goals with him. Along with praise, if he pooped in the potty, that very same day, he got to have a bubble bath or bath fizzies that changed the water colors, little things like that, but he also got a star to go on a fun outing. We started out with a small goal, like after 5 poops (stars), we went out for ice cream. Then after 7 more, we took him to Kangaroo Jak's, 15 more was a trip to Chuck-E-Cheese. That was the last goal we had to use.
It's been weeks now, and we no longer have to fight with him to go potty, in fact he will go on his own. We have left his potty seat in the downstairs bathroom, so that when he is down here playing, he will just go, do his business and come back. Wal-Mart even has fold up potty seats that you can take with you, I keep Reece's in his backpack that we take when we leave the house, it has come in handy when we have been out. After getting this far with him, the last thing I wanted to tell him was hold it til we get home.
Also, one little thing, my son thought was cool, was getting his own toilet paper. We went to Wal-mart and bought him a package of the Huggies Clean team wipes, he likes the fact that this is his very own, no one else can use it.