Ok sorry, I initially thought your problem was linked to the 1st of the month... (which you could solve via a decision process).
First things first, let's verify the actions suggested in the error message:
Did you check the SM21 log at all? If so, what did it say? Is your MDX_PARSER connection correctly defined (did you check in SM59 as suggested by the error message)?
Did you by any chance run an authorization check (SU53) afterwards (to rule out any security issues)?
Secondly, you mention that with an input variable it works? Did you use the same value as the user exit variable would come up with (I assume you did, but just want to make sure)? Is your user exit code "performant"? Does your query run fine outside of the APD?
From the error message itself, I don't believe it has anything to do with your query though.