An endoscopic retrograde cholangiopancreatogram (ERCP) test checks the tubes (ducts) that drain the liver , gallbladder , and pancreas . A flexible, lighted scope (endoscope) and X-ray pictures are used. The scope is put through the mouth and gently moved down the throat.