Play designed to reduce the number of trumps held in the long trump hand. You do this by ruffing, usually in preparation for a trump coup or endplay.
The general technique is for declarer to reduce his trumps to the same length as the defender’s.
In this four-card ending, spades are trumps, the lead is in dummy and South needs three of the four tricks.
As South starts with a trump more than West, an immediate endplay would not work because West could win the spade cheaply and exit with a heart. Instead, you ruff a heart, reducing your trump length to West’s, before giving up a spade.