(a) It is narrated from Sayyiduna Abu Hurayrah (may Allah be pleased with him) that the Messenger of Allah (peace and blessings be upon him) said: "When the iqamah for the prayer is given, walk with tranquillity and dignity upon you; whatever you catch, pray it, and whatever you miss, complete it."
(b) Imam al-Shafi'i (may Allah have mercy on him) said: Whoever comes at the end of the prayer has missed being present for its adhan and iqamah. He does not then give the adhan and iqamah for himself. To my knowledge the ruling is this: if someone comes to the mosque when the imam has finished leading the prayer and is leaving, he prays without adhan and iqamah.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الصلاة / 1916