The Amida recited during all the prayer services of Shabbat differs from the Amida recited during the weekday. Although the first three and last three Berachot of the Shabbat Amida are the same as those in the weekday Amida, the middle section of the Amida is different on Shabbat. Thus, after one recites the Beracha of "Ha'Kel Ha'kadosh" on Shabbat, instead of continuing with "Ata Honen," he instead recites a special section for Shabbat.
If a person began reciting the weekday text of "Ata Honen" on Shabbat, how should he proceed?
The Shulhan Aruch (Orah Haim 268:2) rules that the person in this case should complete the Beracha he was reciting when he realized his mistake, and then begin the proper middle section for that prayer service. During Arbit, for example, he would complete the Beracha in which he realized his mistake, and then begin the proper text of "Ata Kidashta."
This Halacha applies to the Amida recitation during Arbit, Shaharit and Minha. The authorities debate the question of whether it also applies to the Musaf prayer. According to the Rambam (Rabbi Moshe Maimonides, Spain-Egypt, 1135-1204), one who mistakenly began reciting the weekday Amida during Musaf must stop immediately, as soon as he realizes his mistake, and begin the special middle section for Musaf ("Tikanta Shabbat"). Others, however, maintain that even during Musaf one should complete the Beracha during which he realized his mistake, and only then begin the proper text for Musaf.
The Bet Yosef (commentary to the Tur by Maran, author of the Shulhan Aruch) cites both views and writes that Halacha follows the position of the Rambam. Interestingly, however, in the Shulhan Aruch he again records both views. The first he mentions plainly ("Setam"), whereas he introduces the Rambam's view with the expression, "Ve'yesh Omerim" ("There are those who say…"). Hacham Ovadia Yosef cites a rule from the Sedeh Hemed (Halachic encyclopedia by Rav Haim Hizkiya Medini, 1833-1905) that whenever the Shulhan Aruch presents two views in this fashion, and the second view is the position accepted in the Bet Yosef, Halacha follows that second view. Thus, one who realizes during the Shabbat Musaf prayer that he began reciting the weekday text of the Amida must immediately discontinue the recitation and switch to the proper text of "Tikanta Shabbat."
In the subsequent Halacha (268:3), the Shulhan Aruch addresses the unique case of a person who recited the word "Ata" with the intention of reciting the weekday text ("Ata Honen…"), and then immediately realized his mistake, before proceeding to the next word. The Halacha in such a case depends on what exactly the individual's intention was. If he recited the word "Ata" thinking that it was a weekday, and then realized that it was in fact Shabbat, then he must complete the Beracha of "Ata Honen" and then begin the special Shabbat section. If, however, he realized it was Shabbat, but by force of habit he recited "Ata" with the intention of continuing with "Honen," then he does not complete the Beracha. Since he realized it was Shabbat, and he said only the word "Ata," which begins the middle section of the Friday night Amida, he is not considered as having begun reciting a weekday prayer, and he therefore does not complete the Beracha. If this occurred on Friday night, when the Shabbat section also begins with the word "Ata" ("Ata Kidashta…"), then he may simply continue with the word "Kidashta." If this occurred during Shaharit or Minha, then he simply begins with the appropriate recitation (either "Yismah Moshe" or "Ata Ehad").
Summary: If a person mistakenly began reciting the weekday text of the Amida during the Shabbat Musaf prayer, then as soon as he realizes his mistake he should switch to the proper text for Musaf ("Tikanta Shabbat"). If this happened during one of the other Shabbat prayer services, then he should complete the Beracha during which he realized his mistake, and then switch to the proper text ("Ata Kidashta," "Yismah Moshe" or "Ata Ehad"). The exception to this rule is where one recited the single word "Ata" (from the Beracha of "Ata Honen") with the intention of proceeding with the weekday Amida, but realized his mistake before reciting the next word, "Honen." In such a case, even in Arbit, Shaharit and Minha he simply switches to the proper text, and does not have to complete the Beracha. If, however, he recited the word "Ata" thinking that it was a weekday, but then remembered that it was Shabbat, he must first complete the Beracha.