Can i create totals in a master/detail form

Hello, i have created a master/detail form of which i wants to sum totals on the details form which is an editable grid.
need help

In the detail, yoy can use “Totalling”
Snap1
or calcullate manually (with, by example, a “SELECT SUM…”, and then use sc_master_value to update the total field in the Master procedure…

	{MontoReTotal} = 0;
	$sql2 = "SELECT TOTAL FROM CarroComprasBS WHERE id_session = '". [SesionActiva]."'";
	sc_lookup(rsAux, $sql2);
	foreach({rsAux} as $cat) {
		{MontoReTotal} += $cat[0];
	}
$CadenaTotal = "$ ".number_format({MontoReTotal}, 2, ',', ' ');
sc_master_value('TotalRetotal',$CadenaTotal);