Endoscopic retrograde cholangiopancreatography, or ERCP, is a procedure to diagnose and treat problems in the liver, gallbladder, bile ducts, and pancreas. It combines X-ray and the use of an endoscope—a long, flexible, lighted tube.