You can replace a MC224 stepper system with the MC4/5/6 range of Motion Coordiantors but a lot of things will be different. The P240 has open collector 24V pulse and direcation outputs, the P874 has 5V RS422 differential outputs. P240 has square 50% duty cycle waveform and the P874 outputs short pulses.
Also The P297 profibus board has a different configuration to the Anybus module and is different from the PLC's point of view.
So both electrical and software changes will be needed to the Trio part and to the other components in the system.
Each P240 axis has a stepper output and encoder input. The P874 has only one per axis, so for 4 axes of stepper+encoder you need 8 axes, 4 stepper and 4 encoder.
4 axes: P861+P874+P875 anybus carrier and P891 Profibus module
5 axes: P861+P874+P879+P875+P891