ERCP is indicated in cancer patients primarily for diagnostic and therapeutic purposes. It is used to identify and assess biliary obstructions, obtain tissue for biopsy, and perform therapeutic interventions like stent placements to relieve obstructions caused by tumors. It is particularly useful in cases where non-invasive imaging techniques are inconclusive.