The "Exchange Lemma" in the decomposition of modules states that any decomposition of right $R$-modules $M_1⊕...⊕M_n=A⊕B$ with the endomorphism ring $End (A_R)$ local yields $M_i≈A⊕X$ for some $i$, $1≤i≤n$ and some right $R$-module $X$.
Now, let we have a decomposition $M^{(n)}≈B⊕Y$ for right $R$-modules with $B=e_1R⊕...⊕e_mR$ such that $e_j$ are idempotents in $R$ and $e_jR$ are distinct modules having local endomorphism rings. By the Exchange Lemma, each $e_jR$ is isomorphic to a direct summand of $M$. But, how could we use the lemma to show that $B$ is isomorphic to a direct summand of $M$?
Thanks!
This will only work in general if the $e_j R$ are assumed to be pairwise nonisomorphic. As you said yourself you know that each $e_j R$ is a direct summand of $M$. So we have $M = e_1 R \oplus M_1$ and by the Exchange Lemma you get for every $j \neq 1$ that $e_j R$ appears as a direct summand of either $e_1 R$ or $M_1$ and the first case, which would imply $e_1 R \cong e_2 R$, is excluded by the assumption, so you get $e_j R$ being a direct summand of $M_1$ for $j \neq 1$. Proceeding by induction over $m$ now shows that you have a decomposition $M = e_1 R \oplus \dots \oplus e_m R \oplus M_m \cong B \oplus M_m$ which is what you wanted.
If we allow $e_i R \cong e_j R$ for any $i \neq j$ then this will not work anymore. Simply take $M$ the direct sum of the $e_s R$ with $s \neq i$. Then $B$ is definitely isomorphic to a direct summand of $M \oplus M$ but not of $M$.