Endoscopic retrograde cholangiopancreatography (ERCP) is a technique that uses X-ray to view the patient's bile and pancreatic ducts. The most common reason why someone would need an ERCP is because of a blockage of one of these ducts (often due to gallstones).