R.R.
Since he's 4 and knows where you expect him to poop I would show him the diapers and say, "When these are gone there's no more. What does that mean?" If he says he will have to poop in the potty agree and say, "That's right!" If he says he doesn't know or that you'll need to get more tell him, "No, there's no more to buy, no more diapers, you'll have to use the potty to poop in." Show him how many diapers are left each time he uses one so there's no surprise. Also make sure you have him take the poopie diaper he uses and dump the poop in the toilet to reinforce that poop goes in the toilet, and have him flush it away.
When they're gone do NOT give in and buy more if he wails for some. Tell him he knew there would be no more and there isn't. Make using the potty/toilet HIS responsibility, no reminding him to go or taking him, he needs to own it. If he poops in his pants have him dump the poop in the toilet and flush it, rinse his undies in the sink and scrub them with a bar of soap, put them and any dirty bottoms in the dirty laundry, and get in the shower and wash the mess off himself with soap. Make sure it takes awhile so he misses being away from playing or watching TV, you want to impress upon him that it's easier to use the potty/toilet to poop in.
If you have a washer and dryer in your home you can also tell him he used the last clean undies (hide any clean ones) and tell him he needs to wait for you to do the laundry so he can have new ones and get dressed. Inconvenience him as much as possible without making a fuss or criticizing him for pooping in his pants, just say something matter-of-fact like, "Oh, you pooped in your pants, you need to clean your underwear and wash yourself up." Of course you can supervise but it's his to do.
I recently came across a new (to me) way to use a reward for getting a child to poop in the potty. Find out what HIS power reward is, (this I did know) something that means something to him, not the boy down the street, as each child is different. Ask him what would help him to remember to use the potty to poop in and buy it. Have it ready so when he successfully poops in the potty and not his pants, on his own without you reminding or taking him, and allow him to use it for 30-60 minutes. YOU retain ownership of it, he earns the privilege of using it rather than a new possession, and therefore he still has an incentive to keep pooping in the potty rather than his pants, which he wouldn't if he owned it.
Hang in there, L., and hopefully he'll see soon it's better for him to use the potty than his pants!