Selection parameters in the query for movements by items

Hello, I am trying to put a "location" field in the query for stock movements by items so that it can filter the movements it shows. I have modified the screen and added the field

then in criteria I created a formula to get the ones that matched, but if I left the field blank none came out, so I tried to create a function so that if the field had something it would select those that had that value and otherwise it would get all of them.

I find that I get an error when Evaluating the formula and I don't know where the error could be.

I am a Sagex3 trainee,

  • 0

    You are not passing the alphanumerical values that need to be evaluate, instead you are passing their data value. Encapsulate your parameter's in quotes:

    func SPEZJB01.JBIF("[M:SMV1]='' ","[F:STJ]LOC=[F:STJ]LOC","[F:STJ]LOC=[M:SMV1]LOC")

  • Thank you
    REGARD HULSBOS.

    But I still get "error when evaluating the formula"

  • 0 in reply to [email protected]

    This formula evaluates the content of the string, if the defined variables within the formula do not exist at the time of evaluation, you will receive an error. Where are you running this formula? Generally best practice would be to include a condition to ensure the variable exist, to do this use the "dim" function to determine if the variable existing within context. I.e., your formula would be updated as follows:  

    func SPEZJB01.JBIF("dim([M:SMV1]LOC)>0 & [M:SMV1]LOC='' ","[F:STJ]LOC=[F:STJ]LOC","[F:STJ]LOC=[M:SMV1]LOC")

     

    Otherwise encapsulate your code within an "Onerrgo" statement to capture any errors that could occur.