Excretion and osmoregulation are brought about by Malpighian tubules that open into the ileum in cockroaches.
The tubules that are lined by glandular, cuboidal, brush-boarded cells extract nitrogenous waste from the hemolymph and discharge it into the ileum as uric acid (uricotelism).
Excretion via the gut conserves water by reabsorption from waste matter.
This is necessary because cockroaches cannot drink water.
Some waste matter is deposited in the fat body, cuticle, and nephrocytes (pericardial cells). This is excretion by storage.
The excretory organ in a cockroach is the malpighian tubule.