NAV 2009 Coding Issues

damodar123damodar123 Member Posts: 36
In navision i am writing one complex function with n no of parameters , when i say compile in the function passing parameters it is giving message "reduce the expression so it is less complex"

what to do for that

thanks in advance
Damodar

Comments

  • kapamaroukapamarou Member Posts: 1,152
    I think there is a limit to the number of parameters you can use (I think it is 19). You'll need to reduce the parameters or restructure them (pass them as an array or a record variable). I usually use a record parameter.
  • kinekine Member Posts: 12,562
    Yes, this limit is there since first versions... I hit this limit few times too...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • krikikriki Member, Moderator Posts: 9,110
    You can also hit that error when you create a very complex expression, like one (or multiple) of your parameters is not just a value or a variable but a complicated calculation.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • krikikriki Member, Moderator Posts: 9,110
    [Topic moved from 'NAV/Navision' forum to 'NAV 2009 (formerly NAV 5.1/'6.0')' forum]
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • damodar123damodar123 Member Posts: 36
    Dear All,

    Txs for all your replies,

    the problem is mine expression is passing to function is exceeding the line due to which i am enterting the remaining expression splitting in multiple lines but still i am getting the error,

    the work around techinque is i have split the expression 2,3 parts and each part is stored in separate variables. when am combining all parts using concatenation then passing it to same as parameter still same error raised

    expecting any other method to solve my issue
  • SrivasSrivas Member Posts: 89
    I think it doesn't matter if you store it in separate variables. its number of paramteres you have defined in the called function. if you use fewer number of parameteres in the function , it may reolve your issue.
    cheers
  • damodar123damodar123 Member Posts: 36
    dear srivas,

    but in my case i have to use more number of parameters :)
  • SrivasSrivas Member Posts: 89
    I think its best to break function in to multiple functions and call each function in orderly manner.
  • kinekine Member Posts: 12,562
    You need to use array to store more parmeters in one "parameter of the function". Or use some table or record to pass the value as one parameter. Or use Global variables if the function is claled locally to "pass" the parameters. There is no way how to use "more" parameters in standard way. You need to think about some workaround as described in previous posts...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • kinekine Member Posts: 12,562
    Srivas wrote:
    I think its best to break function in to multiple functions and call each function in orderly manner.

    This way is used in standard NAV e.g. when creating reservation entries etc. (Sequence of few functions, which set some global variable in the codeunit and these global variables are used in the last function to do what you want...)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • DenSterDenSter Member Posts: 8,304
    The number of variables is a system limitation, there is no way around that, so you can ask the same question ten times, it's not going to change that, so you will have to do something different. Splitting the call up into multiple functions is the right way to go.

    So instead of:
    MainFunction(Par1,Par2,...,Par100);
    
    you would do this:
    SetFirstVariables(Par1,Par2,...,Par10);
    SetSecondVariables(Par11,Par12,...,Par20);
    ....
    SetTenthVariables(Par91,Par92,...,Par100);
    MainFunction();
    
    The SetVariable functions would store your parameter values in global variables, and the MainFunction would process those values.
  • ara3nara3n Member Posts: 9,256
    You can always pass a record and the record can have all the data instead of parameters.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • DenSterDenSter Member Posts: 8,304
    If you can find a table that has a field for all parameters that could be a solution, but it's not ideal is it. What about unused fields? what about field validation? What about fields that have names that don't make sense for your purpose?

    You could consider creating a table with the fields with a number that is far outside the allowed numbering range, and use a temporary variable, which I've heard works. BUT: I have never actually tried that myself, so I would not know for sure if that would work.
  • ara3nara3n Member Posts: 9,256
    you can also pass an array variable as parameter. :mrgreen:
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • iceborgiceborg Member Posts: 67
    ara3n wrote:
    you can also pass an array variable as parameter. :mrgreen:

    Yeah, Text all simpe datatypes and pass it in a Array of Text :-({|=
Sign In or Register to comment.