Heteroarylpiperidine and -piperazine derivatives of the formula (I) in which the symbols RA1, RA2, X, Y, L1, L2, RB1, RB2, G, Q, p, R1, R2 and R10 are each as defined in the description, and salts, metal complexes and N-oxides of the compounds of the formula (I), and the use thereof for controlling phytopathogenic harmful fungi and processes for preparing compounds of the formula (I).