Rules on Civil Procedure
Section 6. Pleading grounds as affirmative defenses. - If no motion to dismiss has been filed, any of the grounds for dismissal provided for in this Rule may be pleaded as an affirmative defense in the answer and, in the discretion of the court, a preliminary hearing may be had thereon as if a motion to dismiss had been filed. (5a)
The dismissal of the complaint under this section shall be without prejudice to the prosecution in the same or separate action of a counterclaim pleaded in the answer. (n)