By "one is given B z-hat" do you mean you are given only the z-component of grad A?
Then there are many solutions. For example, if we are given that the z-component of grad A, then A can be any function of x,y- as long as it has no dependence on z, the z-component of grad A is 0.

Since the grad of a function is a derivative, the "mathematical operation" you would use to find A is the anti-derivative or "indefinite" integral.