Why does my dog whine to go outside and then just eats his poop?

The dog whines to go outside because it needs to use the bathroom. The reason it eats the poop is something the vet will need to check out.