Endoscopic retrograde cholangiopancreatography (ERCP) is a procedure that combines upper gastrointestinal (GI) endoscopy and X-rays to treat problems of the bile and pancreatic ducts. The bile ducts are tubes that carry bile from the liver to the gallbladder and duodenum.