Might be a good idea to be really strict about feeding times and access to food.
Meaning don't leave food out all day - only during mealtime.
Many dogs tend to want to go 20 minutes or so after eating - so perhaps try taking the dog out then.
For better advice you'd need to describe how you feed the dog, and how the dog poops. (Where do you take the dog to poop? are you with the dog? has the dog ever pooped outside? if so what do u do when the dog poops outside - what do u do when the dog poops inside?)
Hope this may help.