How to solve the Error:"The vertex set or edge attribute outside a DML block cannot be referred."

I am creating a query for my graph. But there is something wrong. I change for a lot of means but still doesn’t work out. I really need urgent help, because it is part of my graduation project. Help me PLZ!
CREATE QUERY formAdmittanceMatrix(SET initial_Vm,SET initial_Va
) FOR GRAPH busBranchGraph{
SumAccum @sumG = 0;
SumAccum @sumB = 0;
T0 = {TopoND.};
T0.Vm = initial_Vm;
T0.Va = initial_Va;
T1 = SELECT v FROM T0:v
ACCUM
v.P = (v.GenP - v.LdP);
v.Q = (v.GenQ - v.LdQ);
v.@sumG = v.G;
v.@sumB = v.B;
T2 = SELECT v FROM T1:v-(connected:e)->:t
ACCUM
IF (e.K == 0) THEN
v.@sumG += e.G,
v.@sumB += -1
e.B + 0.5e.hB
ELSE
v.@sumG += 1/(e.K
e.K)* e.G,
v.@sumB += 1/(e.Ke.K)(-1e.B) + 0.5e.hB
END;
}
It tells there is the ERROR:
Semantic Check Error in query formAdmittanceMatrix (SEM-105): line 11, col 7
The vertex set or edge attribute outside a DML block cannot be referred.
Saved as draft query with type/semantic error: [formAdmittanceMatrix].