A. - 4 years old is too old to be regularly doing this. You've tried the nice approach, and he is not listening. This is where it becomes a discipline issue, because a 4 year old is very aware and able to understand requests/commands and consequences.
In my opinion the next time this happens you need to tell him that's it, that's the last time this happened. Have him help you clean it up, like suggested earlier, and then say "From now on if you poop in your pants you'll have a time out because you're a big boy and can make it to the bathroom in time. Let me know when you need to go, and I'll come with you if you want", etc. Don't be menacing or angry, just lay it out. Then if it happens, do and say the same thing all over again, and calmly put him in the time out. Repeat as necessary. If he does make it a whole day, celebrate! Use a sticker chart or something, like was also suggested.
Calm discipline with potty training doesn't scar children or make them afraid of the toilet like some would lead you to believe. It is just another time when kids learn who's in charge - them when the poop when/where ever they want to, or you when you have your child potty trained and make sure they behave politely in human society!
I wouldn't ever shame a child or do this with a two year old, but at this point for your son I think it's the proper response.
js