If you want the ABAP coding, perhaps you should look at the way the Wage Type Reporter or the Remuneration Statement do it.
Otherwise, for every WT, you have to compare the Payroll Results for the Actual pay (ex. PP 01.2016 in 08.2016) to the Previous time that pay was calculated (ex. PP 01.2016 in 03.2016).