Since y is being treated as a constant, the constants A and B may be functions of y: u(x,y)= f(y)cos(x)+ g(y)sin(x). That is not quite the same thing. For example, f(y)cos(x) satisfies the differential equation but is not a function of y times cos(x)+ sin(x).