I have a sharp pain in my upper abdomen when I cough?

Muscle strain. of the upper abdominal musculature is the most common reason; however, lung infection or pleuritis ( an inflammation of the protective sac around the lungs) can cause pain on deep inspiration.
Muscle strain. If truly in the upper abdomen, then you may have muscle strain from the intense coughing. If the pains are in the chest then you likely have costochondritis - a benign inflammation in a rib joint between cartilage ("gristle") and bone. These are not serious. If, however, you note worsening pain, shortness of breath, persistent fever, nausea or vomiting then see a clinician. Hope that helps. .