Repeating Shemoneh Esrei if forgot to say Ata Chonantanu and did Melacha:
Within the Shemoneh Esrei of Maariv recited on Motzei Shabbos, one is obligated to recite Havdala. This prayer of Havdala is referred to as “Ata Chonantanu,” in name of its beginning words. It is recited within the blessing of “Ata Chonein” as printed in Siddurim.
If one forgot to say Ata Chonantanu: If one forgot to say Ata Chonantanu then he is to continue with Shemoneh Esrei as usual. If he remembered prior to saying Hashem’s name in the end of the blessing of Ata Chonein, he is to say it then and continue with “Vichaneinu Meitcha” and finish the blessing. If he remembered only after he already finished the blessing of Chonen Hadaas, or after having already said Hashem’s name in the end of the blessing, he is to continue with Shemoneh Esrei as normal. He may not go back and repeat the blessing of Ata Chonein. Likewise, he is not to add Ata Chonantanu anywhere else in the prayer. [However, some Poskim rule that he is to say it in Elokaiy Netzor prior to the second Yehiyu Leratzon.] In all cases that one forgot to say Ata Chonantanu then [although he is not required to repeat Shemoneh Esrei and fulfills his obligation] nevertheless, if he desires, he may repeat Shemoneh Esrei as a Tefilas Nedava following its relevant laws. [However, one is required to repeat it in a case that one did not say Ata Chonantanu and does not expect to have wine to say Havdala until Sunday night, as will be explained next.]
The law if one did not say Ata Chonantanu in Davening and did Melacha prior to Havdala:
In all cases that one forgot Ata Chonantanu, he is to beware to say Havdala, or say “Baruch Hamavdil Bein Kodesh Lechol,” prior to doing any Melacha. If one did not adhere by the above and did (Melacha of Issur) [prior to saying Baruch Hamavdil and] prior to saying Havdala over wine, then he must repeat Shemoneh Esrei with Ata Chonantanu, and then say Havdala over wine. [Some Poskim rule that this only applies if one did a time consuming Melacha. However, one is not required to repeat Shemoneh Esrei if he did a Melacha which does not take much effort to do, such as lighting a candle and the like. However, from Admur here it is implied that if any form of Melacha is done, one is required to repeat Shemoneh Esrei. See Q&A regarding Rabbinical Melacha!]
If one forgot to say Ata Chonantanu within Shemoneh Esrei he may not do any Melacha until he recites Havdala or says Baruch Hamavdil. If he did Melacha prior to saying Baruch Hamavdil, he must repeat Shemoneh Esrei with Ata Chonantanu.
If one did Rabbinical Melacha prior to saying Baruch Hamavdil or Havdala, such as moving Muktzah, must he repeat Shemoneh Esrei?
Seemingly he is required to repeat Shemoneh Esrei. However, some Poskim rule that he is not required to repeat Shemoneh Esrei for Rabbinical Melacha. According to this opinion, if one moved a Muktzah item he is not required to repeat Shemoneh Esrei. [Practically, one is to Daven again as a Toras Nedava.]
If one forgot to say Ata Chonantanu in his second Shemoneh Esrei which he had to repeat due to eating or Melacha, what is the law?
He must repeat Shemoneh Esrei a third time. If he remembers prior to concluding Shemoneh Esrei, it follows the same law as stated above.
If one is in doubt as to whether he said Atah Chonantanu, and then accidently did Melacha prior to saying Hamavdil, must he repeat Shemoneh Esrei?
Seemingly one is to repeat Shemoneh Esrei as a Tefilas Nedava.
If one said Havdala over wine before repeating Shemoneh Esrei in a scenario that he was required to do so must he still repeat Shemoneh Esrei?
Some Poskim write it is questionable whether he must repeat Shemoneh Esrei. Other Poskim rule he must still repeat Shemoneh Esrei. Some Poskim conclude based on this dispute that one should not repeat Shemoneh Esrei, as Safek Brachos Lehakel. Practically, in such a case one is to repeat Shemoneh Esrei as a Toras Nedava.
 Admur 294:1; Michaber 294:1; Brachos 33a
Historical background: Originally when the Anshei Kneses Hagedola instituted the recital of Havdala together with the other prayers, blessings and Kiddushim, they did not obligate Havdala to be said over wine, but rather within the prayer of Shemoneh Esrei. The reason for this is because when the Jews returned from exile in Babylon they were destitute and could not all afford wine for Havdala. [Admur 294:1; Brachos ibid] After the Jewish people became more financially stable the Sages instituted for Havdala to be said over wine. Later they once again became destitute and the Sages returned Havdala to be said only in Shemoneh Esrei. Now, in order to prevent Havdala from being constantly moved from the prayer to wine and from wine to prayer based on the Jewish economic state, the Sages instituted that in addition to reciting Havdala within prayer, one is also obligated, if wine is available, to also say Havdala over wine. If, however, there is no wine available, one fulfills his obligation of Havdala within Havdala said in prayer. [Admur 294:2; Michaber ibid; Rebbe Yochanon in Brachos ibid]
 Admur ibid; Michaber ibid; Tana Kama in Mishneh Brachos 33a
The reason: The Sages instituted for Havdala to be recited within Ata Chonantanu for two reasons: 1) The ability to distinguish between Shabbos and weekday is a wisdom, and therefore it was established to be said in the blessing of wisdom “Ata Chonantanu.” 2) It is forbidden for a person to request mundane matters from G-d on Shabbos. Similarly, it is forbidden to request matters from G-d after Shabbos until he says Havdala. Therefore, the Sages instituted Havdala in the blessing prior to the requests one asks in Shemoneh Esrei. [Admur 294:1; See also Admur 299:15; 619:11; however see 188:4 and 268:2 which implies that the normal Nussach of Shemoneh Esrei is not prohibited due to Bakashas Tzerachav. Perhaps however one can answer that since one is able to ask for his own personal requests within those Brachos of Shemoneh Esrei [see Admur 119:1] therefore the Sages instituted for it to be recited prior to any of the set blessings.]
Where within Ata Chonein is the prayer to be recited? Some learn based on Admur in the Siddur that one is to begin saying Ata Chonantanu as soon as he reaches the 4th blessing of Ata Chonein, and the sentence of Ata Chonen is to be omitted. [Shaar Hakolel 9:13] However, the custom is to first recite the sentence of Ata Chonein and only then to add in the paragraph of Ata Chonantanu. [Ketzos Hashulchan 93 footnote 4 in name of Radatz Chein; Sefer Haminhagim p. 67]
 Admur 294:3 and 7
 Admur 294:3; Michaber 294:1; Brachos 33a
The reason: He is not required to repeat Shemoneh Esrei, or go back, being that he will in any event say Havdala over wine and will hence fulfill his obligation then. [Admur ibid; Michaber ibid
 Admur 294:7; Bach 294; Elya Raba 294:4
 Admur ibid; Bach ibid
May one say Lamdeini Chukecha and repeat the blessing? One is not to conclude Lamdeini Chukecha in such a case. [Tehila Ledavid 294:7]
 Admur 294:3 and 7; Michaber 294:4; Riy in Tosafus Brachos 30b; Rosh Brachos 4:17Rabbeinu Yona Brachos 20a
The reason: He is not required to repeat Shemoneh Esrei, or go back, being that he will in any event say Havdala over wine and will hence fulfill his obligation then. [Admur 294:3; Michaber 294:1]
 Admuribid; Michaber 294:5; Poskim ibid
The reason: The above ruling applies even if one wants to be extra stringent, as it is forbidden to say an unnecessary blessing [Bracha Sheiyno Tzericha]. [Admur 294:7; Rosh Brachos 4:17] This is because he anyways fulfills his obligation of Havdala over Havdala said over the wine that night or the next day, and thus saying Ata Chonein is now deemed unnecessary.
 He may not add it in when he remembers as doing so is considered a Hefsek [interval] within the prayer. This applies even if he remembers right after concluding Chonein Hadaas, prior to beginning the blessing of Hashiveinu. [Admur 294:7; Rosh ibid] Likewise in such a case one is not to say Ata Chonantanu within Shema Koleinu, as the main Halacha follows those opinions who rule only requests may be recited within Shema Koleinu which is itself a request, and Ata Chonantanu is not a request. Nevertheless, this only applies if one expects to do Havdala over wine that night or on Sunday. If, however, one does not have wine or expect to receive wine until after Sunday, he is to recite it within Shema Koleinu, as will be explained later. [294:5]
Other Opinions: There are Poskim which rule one may say Ata Chonanatanu after Chonein Hadaas before beginning Hashiveinu. [see Kaf Hachaim 294:18; Siddur Yaavetz]
 Kaf Hachaim 294:17
 Admur ibid; Michaber 294:5; Rosh ibid
Must one novelize something in the prayer, and who may choose to repeat it as a Nedava? Admur ibid concludes “as explained in chapter 107” VeTzaruch Iyun as to what Admur is eluding to here, as if he is coming to include the necessity to novelize a prayer within Shemoneh Esrei, reciting Ata Chonantanu is itself the novelty. Perhaps then it is coming to add that only one who has meticulous concentration in prayer is to do so [as explained in 107:4] [So writes explicitly Ketzos Hashulchan 93 footnote 7 as the interpretation of Admur here; and so seems to learn Kaf Hachaim 294:17] Some Poskim however learn that saying Ata Chonantanu is not considered enough of a novelty, as it is the regular part of the night prayer of Motzei Shabbos, while the novelty must be recognizable. This however is not the opinion of Admur. [See Ketzos Hashulchan ibid]
 Admur 294:3
 Admur 294:3; M”A 294:2
The reason: As it is forbidden to do any Melacha prior to saying Baruch Hamavdil, as explained in 299:16.
 Parentheses in original
 Pashut! So rules Minchas Shabbos 96 footnote 5; See also Piskeiy Teshuvos 294 footnote 38;
 Admur 294:3 in parentheses; So rules Rashba, brought in Elya Raba and Rav Akiva Eiger 294:1; Peri Megadim 294 A”A 3 and M”Z 2; Derech HaChaim; Kitzur SH”A 96:1; Tehila Ledavid 294:2
The reason: In such a case that he omitted Ata Chonantanu in prayer [and then did Melacha] one does not fulfill his obligation by simply saying Havdala over wine as it is unbefitting of Havdala for him to have ate (or done Melacha) prior to it. [Admur ibid]
Analysis on opinion of Admur: See Ketzos Hashulchan 93 footnote 8 regarding this law in Admur being placed in parentheses. The Ketzos Hashulchan ibid concludes one is to repeat Shemoneh Esrei as a Tefilas Nedava. Kitzur Halachos Shabbos 294:8 records this ruling without brackets.
Other Opinions: Some Poskim rule there is no need to repeat Shemoneh Esrei if one did Melacha after Shemoneh Esrei of Maariv, prior to saying Baruch Hamavdil. [M”B 294 in Biur Halacha “Veim Taam”; Kaf Hachaim 294:8 that according to the Rambam Melacha is not relevant to this law. The reason is because since to be allowed to do Melacha one can simply say Baruch Hamavdil without a blessing, therefore it does not belittle the blessing of Havdala if he does Melacha prior to it.]
 Derech Hachaim brought in Minchas Shabbos 96 footnote 6; See Admur 299:18
 So is implied from Admur 294:3 who writes “Melacha Beiisur” implying any Issur. However, see 299:18 regarding different Melachas that are permitted before Havdala according to some opinions. Vetzaruch Iyun.
 So is implied from Admur 294:3 which writes “Melacha Beiisur” implying any Issur. However see 299:18 regarding different Melachas that are permitted before Havdala according to some opinions. Vetzaruch Iyun.
 Derech Hachaim brought in Minchas Shabbos ibid
 Piskeiy Teshuvos 294:4
 On the one hand Admur writes [in 108:18] that whenever there is doubt as to whether one is to pray again he should just pray a Tefilas Nedava. On the other hand the law of repeating Shemoneh Esrei when one did not say Ata Chonantanu and then did Melacha is brought by Admur in parentheses, and thus the Ketzos Hashulchan does not even rule this way in his summary, but rather brings it in the Badei Hashulchan and concludes that although the Biur Halacha rules that by Melacha one does not need to repeat Shemoneh Esrei, nevertheless one should Daven as a Nedava. However in a case that one is even in doubt if he perhaps did in fact say Ata Chonantanu, then there is room to learn that even to pray a Nedava is not required. As it is a double doubt. Perhaps however one can say that we follow one’s usual recital of Shemoneh Esrei which omits Ata Chonantanu, as is the law by a doubt of other additions, and hence we consider him to have certainly omitted it if he is in doubt, and it is hence not considered a doubt at all. See however Rama 422:1 that when in doubt if one recited Yaleh Veyavo in Shemoneh Esrei he does not need to repeat. The Levush [brought in M”A 422:4] explains this to be the case because one does not pass 30 days without saying Yaleh Veyavo and hence we cannot assume with certainty that he did not say it. The same would apply to Ata Chonantanu. And even more so, of which we do not pass 7 days without saying it. Now, although most Poskim argue on this conclusion of the Levush [see M”A and M”B ibid] perhaps it is enough of a doubt to not require one to repeat Shemoneh Esrei as a Nedava if he did Melacha. Practically since there still remains a doubt and one may always repeat a Nedava, one is to do so.
 Peri Megadim in 294 M”Z 2
 Derech Chaim, brought in Biur Halacha 294 “Tzarich”
 SSH”K 59 footnote 6
 Ketzos Hashulchan 93 footnote 8