LENIENCIES OF TEFILAH DUE TO KEVOD HA'BRIYOS [Kevod ha'Briyos :Tefilah]
Rava had fixed times to learn with Talmidim, so he was forced to delay bowel movements.
Makos 16a (Rav Achai): If one urgently needs to excrete and holds it in, he transgresses "v'Lo Seshaktzu" (do not make yourselves detestable).
Berachos 23a (Beraisa): If one feels a need to defecate, he may not pray. If he prays, his prayer is an abomination.
Version #1 (Rav Zevid or Rav Yehudah): This is only if he cannot wait (before relieving himself), but if he can wait, his prayer is valid.
(Rav Sheshes): He must be able to wait the time it takes to walk a Parsah (about four kilometers, i.e. 72 minutes).
(R. Shmuel bar Nachmani): If one feels a need to move his bowels, he may not pray -- "Hikon Likras Elokecha Yisrael."
24b (a reciter of Beraisos): If one feels a need to emit gas during prayer, he walks back four Amos, passes wind, waits for the odor to go away, returns to his Tefilah and says "Ribon ha'Olamim... our shame is revealed in front of You..."
He resumes praying.
Rif (Berachos 14a): If one feels a need to defecate, he may not pray. If he prays, his prayer is an abomination, i.e. if he cannot wait. If he can wait the time to walk a Parsah, it is permitted.
Rosh (Berachos 3:24): The Rif's text says that if he can wait, he may pray. I disagree, for a Beraisa afterwards forbids l'Chatchilah if one feels a need. Most texts say that if he can wait, i.e. the time to walk a Parsah, his Tefilah is valid.
Rif and Rosh (15b and 3:41): If one feels a need to emit gas during prayer, he walks back four Amos, passes wind, waits for the odor to go away, says "Ribon..." and prays.
Rambam (Hilchos Tefilah 4:10): One who needs to eliminate may not pray. If he did, it is an abomination. He must pray again after eliminating. If he could have walked a Parsah, his Tefilah was valid. L'Chatchilah one may not pray until checking himself.
Rambam (12): If one feels a need to emit gas during prayer, and he is in great pain and he cannot withhold himself, he walks four Amos backwards, waits for the odor to go away, says "Ribon ha'Olamim...", and returns to his place and prays.
Rashba (1:131): If one checked himself before Tefilah and felt no need, and in the middle he got an urge, he does not interrupt, even if the urine is dripping, like the Gemara says. To distance oneself from urine is only mid'Rabanan; to avoid interrupting Tefilah, we rely on Torah law. All the more so, if he can hold it in until he finishes, he does so. The same applies to Gedolim.
Terumas ha'Deshen (16, brought in Beis Yosef OC 103 DH Kasuv bi'Serumas): The Gemara says that if one needs to pass wind during Tefilah, he steps back... says "Ribon ha'Olamim...", and resumes. I never saw anyone do so, even meticulous people, even though surely the need arises! I heard one Gadol say that he would force himself not to pass the gas until he finished his Tefilah. I find this difficult, for the Rosh brings from the Gemara that one who delays Nekavav transgressed Bal Teshaktzu. However, the Rambam supports the Gadol. He wrote "...if he cannot withhold himself...", but if he could withhold himself, this is fine. It seems that Bal Teshaktzu applies only when his body is disgusting with excrement or urine. There was no decree about holding in gas. However, if one cannot withhold himself, the only Heter not to walk back is due to disgrace. The Tzibur will notice, especially if he is the Shali'ach Tzibur. It is disgraceful to leave a meal in the middle for one's bowels (Shabbos 82a). All the more so it is difficult to interrupt Tefilah, and all the more so if people will sense that the Shali'ach Tzibur's body was not clean in front of the King! Kevod ha'Briyos is great. It seems that also he need not say the text Ribon ha'Olamim. Perhaps it was enacted only for one who distanced himself, for then his shame is felt. The text of it suggests so. Based on this, the obligation to distance and say Ribon ha'Olamim is only for one who prays alone, for there is no disgrace. We find that Rava had fixed times to learn with Talmidim, so he was forced to delay bowel movements. We find that many Chachamim became sterile from Rav Huna's lectures (Yevamos 64b), through delaying urinating. Presumably, they and Rava delayed due to shame, therefore they were not concerned for Bal Teshaktzu. The same applies here. However, it is hard to make up distinctions without any hint in the Gemara or ruling from the Ge'onim about this.
Shulchan Aruch (OC 92:1): If one needed to eliminate, he may not pray. If he did, it is an abomination and he must pray again. This is only if he could not wait the time to walk a Parsah.
Mishnah Berurah (7): If one teaches Torah to many, and in the middle he has an urge, even for Gedolim, he may delay it. Bal Teshaktzu is mid'Rabanan, and Kevod ha'Briyos overrides it.
Bi'ur Halachah (DH Hayah): If a Shali'ach Tzibur has an urge to eliminate before Chazaras ha'Shatz, if he could withhold himself for the time to walk a Parsah, in which case b'Di'eved the Tefilah is valid, since Kevod ha'Briyos applies here, surely he may rely on the Rif who is lenient [and permits praying] l'Chatchilah. It seems that even the stringent opinions agree here, due to Kevod ha'Briyos. If he could not withhold himself for the time to walk a Parsah, all agree that the Tefilah was an abomination. What is the law? Do not bring a proof to be lenient from the Magen Avraham, who is lenient for one who felt an urge in the middle of his Tefilah. He permits him to finish even if Bal Teshaktzu applies, for Kevod ha'Briyos overrides it. Seemingly, the same should apply here. However, I distinguish. There his Tefilah is not an abomination, since he checked himself beforehand and began b'Heter. Even the Rema, who is stringent, admits there that b'Di'eved, if he did not interrupt, his Tefilah was valid for this reason. Here, he had an urge before beginning. Chachamim decreed that his Tefilah is an abomination. His Berachos are l'Vatalah and he transgresses "Lo Sisa [Es Shem Hash-m Elokecha la'Shav]." Perhaps Kevod ha'Briyos does not enable being lenient. Or, perhaps Chachamim removed their Isur, so there is no Berachah l'Vatalah. This requires great investigation. If this occurred to one called to read from the Torah, surely he may read, for b'Di'eved his reading was valid. All the more so if an urge arose in the middle of reading, he may finish it.
Kaf ha'Chayim (7): One may delay due to Kevod ha'Briyos if he is amidst people and he does not want to make them rise, or to appear to walk on their heads. One should prepare in advance to be able to pray in cleanliness and not need to burden others.
Shulchan Aruch (2): If during Shemoneh Esre one felt an urge to eliminate, he waits until he finishes, and does not interrupt.
Beis Yosef (DH veha'Rashba, citing the Rashba): If one felt a need from the start, and prayed without relieving himself, it is an abomination if he could not wait the time to walk a Parsah. If he got an urge only in the middle, he does not interrupt.
Darchei Moshe (1): This is difficult, for Terumas ha'Deshen connotes that one may not delay for Gedolim or Ketanim, and one must interrupt. Perhaps here we do not discuss a great urge to which Bal Teshaktzu applies, but he cannot wait a Parsah.
Rema: This is only if he does not need to eliminate so badly that Bal Teshaktzu applies. If it applies, it is better to interrupt.
Magen Avraham (2): Even the Terumas ha'Deshen agrees in a Tzibur, for Kevod ha'Briyos overrides mid'Rabanan laws.
Shulchan Aruch (103:2): If one is in Shemoneh Esre and needs to pass wind and he cannot withhold himself, he walks back four Amos, emits the gas, waits until the odor ceases, says "Ribon ha'Olamim...", returns to his place and resumes where he interrupted.
Rema: This refers to one who prays in his house. If he prays b'Tzibur, this would be very embarrassing, so he need not step back at all, nor say "Ribon..." He just waits until the smell passes. This is the custom.
Magen Avraham (4): Some Gedolim would force themselves to hold in the gas. In any case of embarrassment, we are not concerned for an Isur mid'Rabanan (Bal Teshaktzu). The Terumas ha'Deshen was reluctant to make a new distinction. Above, (92:2), I brought that the Rashba permits (even when one needs to move his bowels), and all the more so to delay gas.
Gra (DH v'Yesh): The primary opinion is like the Beis Yosef said, that it is difficult to make new distinctions from reasoning.
Kaf ha'Chayim (12): Even though the Terumas ha'Deshen said that it is difficult to make new distinctions from reasoning, the Acharonim agreed that b'Tzibur one need not distance himself nor say the text.
Mishnah Berurah (9): It is good to think the text in his heart.
Kaf ha'Chayim (13): Beis Oved says that even one who prays alone and steps back should only think the text in his heart. This was the Gemara's intent. It is good to do so, to avoid a Hefsek in Tefilah.