Can constipation cause upper stomach pain?

Upper abdomen, maybe. If you mean like right under your ribs, sure. Your colon starts down low on your right, goes up under your diaphragm, across the top then down. So your transverse colon could hurt as it tries to move things along.