Creating Payrun summary by fetching values from the employee payruns and adding them

Creating Payrun summary by fetching values from the employee payruns and adding them

I am trying to make a processing payrun module. I want on Form load to autofill payrun summary eg Total Deductions, Total employer contributions etc by fetching one value after the other in the employee payrun information. So it should loop through the record ID's of the employee pay runs and fetch the values, add them and fill them into this payrun form on loading it. How can i achieve this?