Refresh Master form in a Master/Detail app

Hello…
I have a form, whit a grid, in a master/details scheme.
I need, after insert, edit or delete a record in a grid, calculate some values in the master record…
How i can do? I’m not find the place to call the calculus rutine.
Some sample?
Thanks…

In each event for insert, deelte o update you must use the macro: sc_master_value(‘field_for_total’, $my_total);

This events are in the detail grid…
But the calculo is very complex, and more fields are update in the master…