J’ai mangé cela
I have eaten that
Je l’ai mangé
I have eaten it.
Use “je l’ai mangé” when you speak of a definite thing known by the person you talk to.
Use “j’ai mangé ça” when you speak of something you can only point to, or something that is hard (or that you don’t want) to define. Ça can also have depreciative connotations in some contexts (which cela or ceci may also have).
This distinction only involve pronouns and is independent of the verb. For instance one use “je l’ai écrite” for a letter but “j’ai écrit ça” for the content (the first time you refer to it).