Warning message in Error function

Aravindh_NavisionAravindh_Navision Member Posts: 258
Hi Friends,

When I compile an codeunit with the below ERROR function, I am getting the following warning:

A maximum of 11 parameters must be used when calling the function.
For example:

Myfunc(..,..,..)
Round(MyVar)
Round(MyVar,0.005)

ERROR('No valid combination found.\Game:%1 Jurisdiction:%2\C1:%3 C2:%4 C3:%5 C4:%6 C5:%7 C6:%8 C7:%9 C8:%10' +
                              'C9:%11 C10:%12 C11:%13 C12:%14 C13:%15 C14:%16 C15:%17 C16:%18 C17:%19 C18:%20',
         CompGame,CompJuris,CompArray[1],CompArray[2],CompArray[3],
         CompArray[4],CompArray[5],CompArray[6],CompArray[7],CompArray[8],
         CompArray[9],CompArray[10], CompArray[11],CompArray[12],CompArray[13],CompArray[14],
         CompArray[15],CompArray[16],CompArray[17],CompArray[18]);

Can anyone tell me what to do to overcome this issue?

Thanks,
Aravindh

Comments

  • lvanvugtlvanvugt Member Posts: 774
    Hi Aravindh,

    The message is clear as such: you cannot have more than 11 parameters in this function call. Apparently the ERROR function does allow for only 11 parameters, being the error string at the start followed by 10 other parameters. In your code you are using 20 parameters.
    Luc van Vugt, fluxxus.nl
    Never stop learning
    Van Vugt's dynamiXs
    Dutch Dynamics Community
  • mohana_cse06mohana_cse06 Member Posts: 5,504
    You can use STRSUBSTNO function but again the limit is 16 parameters only.
    ERROR(
      STRSUBSTNO(
        Text001,
        CompGame,CompJuris,CompArray[1],CompArray[2],CompArray[3],
        CompArray[4],CompArray[5],CompArray[6],CompArray[7],CompArray[8],
        CompArray[9],CompArray[10], CompArray[11],CompArray[12],CompArray[13],CompArray[14]));
    

    Text001 is TextConstant Created with
    No valid combination found.\Game:%1 Jurisdiction:%2\C1:%3 C2:%4 C3:%5 C4:%6 C5:%7 C6:%8 C7:%9 C8:%10 C9:%11 C10:%12 C11:%13 C12:%14 C13:%15 C14:%16
  • lvanvugtlvanvugt Member Posts: 774
    This could be a workaround by building up the message:
    String2 := STRSUBSTNO(Text002,CompArray[1],CompArray[2],CompArray[3],
                          CompArray[4],CompArray[5],CompArray[6],CompArray[7],CompArray[8],CompArray[9]);
    String3 := STRSUBSTNO(Text003,CompArray[10], CompArray[11],CompArray[12],CompArray[13],CompArray[14],
                          CompArray[15],CompArray[16],CompArray[17],CompArray[18]);
    String := STRSUBSTNO(Text001,CompGame,CompJuris,String2,String3);
    
    ERROR(String);
    

    with the following text constants:

    Text001: No valid combination found.\Game:%1 Jurisdiction:%2\%3 %4
    Text002: C1:%1 C2:%2 C3:%3 C4:%4 C5:%5 C6:%6 C7:%7 C8:%8 C9:%9
    Text003: C10:%1 C11:%2 C12:%3 C13:%4 C14:%5 C15:%6 C16:%7 C17:%8 C18:%9

    and String, String2 and String3 being text variables
    Luc van Vugt, fluxxus.nl
    Never stop learning
    Van Vugt's dynamiXs
    Dutch Dynamics Community
  • Aravindh_NavisionAravindh_Navision Member Posts: 258
    Hi Mohana and lvanvugt,

    Thanks for your reply. Sorry for delayed continuation in this thread.

    Both the solution are compiling without any error.

    Mohana, What should I do to extend the parameters to 20? Is there any alternative way to do so? Is there any alternative for ERROR function.

    lvanvugt, Your solution is compiling without any error, but it is not working out. Is there anyother solution?
  • mohana_cse06mohana_cse06 Member Posts: 5,504
    There is no workaround. but what is not working in Luc's suggestion?
  • Aravindh_NavisionAravindh_Navision Member Posts: 258
    The below code which is in ELSE part..
      ERROR('No valid combination found.\Game:%1 Jurisdiction:%2\C1:%3 C2:%4 C3:%5 C4:%6 C5:%7 C6:%8 C7:%9 C8:%10',
             CompGame,CompJuris,CompArray[1],CompArray[2],CompArray[3],
             CompArray[4],CompArray[5],CompArray[6],CompArray[7],CompArray[8]);
    

    ... few records are getting updated in a table if it correctly executed.

    The user demanded for addition of 10 more fields say CompArray[9] to CompArray[18]. So I need to include these 10 fields along with the above fields. I am struck up with this. If you want, I can send you the object also.
  • lvanvugtlvanvugt Member Posts: 774
    The below code which is in ELSE part..

    ... few records are getting updated in a table if it correctly executed.
    :?:
    Arvindh, I am lost. What ELSE part? I do not see one above ... Your question was about the ERROR message. Is that solved and are you asking about something else?
    Luc van Vugt, fluxxus.nl
    Never stop learning
    Van Vugt's dynamiXs
    Dutch Dynamics Community
  • Aravindh_NavisionAravindh_Navision Member Posts: 258
    Sorry for confusing you lvanvugt.

    Just ignore what I have said about ELSE part.

    I applied the solution that you gave in your previous reply. I am not getting any error or warning message.

    But previously, with the below code..
    ERROR('No valid combination found.\Game:%1 Jurisdiction:%2\C1:%3 C2:%4 C3:%5 C4:%6 C5:%7 C6:%8 C7:%9 C8:%10',
             CompGame,CompJuris,CompArray[1],CompArray[2],CompArray[3], CompArray[4],CompArray[5],CompArray[6],
             CompArray[7],CompArray[8]);
    

    .. a field in a table was updating with few values.

    After I approached your way...
    txtErrorMsg1 := STRSUBSTNO(Text001,CompArray[1],CompArray[2],CompArray[3],CompArray[4],CompArray[5],
                                                         CompArray[6],CompArray[7],CompArray[8],);
    txtErrorMsg2 := STRSUBSTNO(Text002,CompArray[9],CompArray[10], CompArray[11],CompArray[12], CompArray[13],
                                                         CompArray[14],CompArray[15],CompArray[16],CompArray[17],CompArray[18]); 
    txtErrorMsg := STRSUBSTNO(Text000,CompGame,CompJuris,txtErrorMsg1,txtErrorMsg2);
    ERROR(txtErrorMsg);
    
    Text Constants:
    
    Text000	No valid combination found.\Game:%1 Jurisdiction:%2\%3 %4
    Text001	C1:%1 C2:%2 C3:%3 C4:%4 C5:%5 C6:%6 C7:%7 C8:%8 C9:%9
    Text002	C10:%1 C11:%2 C12:%3 C13:%4 C14:%5 C15:%6 C16:%7 C17:%8 C18:%9
    

    .. I am not able to update the field. If I comment those lines, it is working fine. If you need the whole code, please let me know.
  • lvanvugtlvanvugt Member Posts: 774
    You can send me to code.
    Luc van Vugt, fluxxus.nl
    Never stop learning
    Van Vugt's dynamiXs
    Dutch Dynamics Community
  • Aravindh_NavisionAravindh_Navision Member Posts: 258
    Please find the code.
    CLEAR(FoundComp);
    
    IF SoftwareCompComb.FINDFIRST THEN
      REPEAT
        IF MaxComp >= 1 THEN BEGIN
        ProdOrderComp.RESET;
        ProdOrderComp.SETRANGE(Status,ProdOrder.Status);
        ProdOrderComp.SETRANGE("Prod. Order No.",ProdOrder."No.");
        ProdOrderComp.SETRANGE("Value Code",SoftwareCompComb."Component 1");
        IF ProdOrderComp.FINDFIRST THEN BEGIN
          ProdOrderComp."Version Code" := SoftwareCompComb."Component 1 Version";
          ProdOrderComp.MODIFY;
          FoundComp[1] := TRUE;
        END;
    
        END ELSE
          FoundComp[1] := TRUE;
    
        IF MaxComp >= 2 THEN BEGIN
    
        ProdOrderComp.SETRANGE("Value Code",SoftwareCompComb."Component 2");
        ProdOrderComp.SETRANGE("Version Code",'');
        IF ProdOrderComp.FINDFIRST THEN BEGIN
          ProdOrderComp."Version Code" := SoftwareCompComb."Component 2 Version";
          ProdOrderComp.MODIFY;
          FoundComp[2] := TRUE;
        END;
        END ELSE
          FoundComp[2] := TRUE;
    
        IF MaxComp >= 3 THEN BEGIN
        ProdOrderComp.SETRANGE("Value Code",SoftwareCompComb."Component 3");
        ProdOrderComp.SETRANGE("Version Code",'');
        IF ProdOrderComp.FINDFIRST THEN BEGIN
          ProdOrderComp."Version Code" := SoftwareCompComb."Component 3 Version";
          ProdOrderComp.MODIFY;
          FoundComp[3] := TRUE;
        END;
        END ELSE
          FoundComp[3] := TRUE;
    
        IF MaxComp >= 4 THEN BEGIN
        ProdOrderComp.SETRANGE("Value Code",SoftwareCompComb."Component 4");
        ProdOrderComp.SETRANGE("Version Code",'');
        IF ProdOrderComp.FINDFIRST THEN BEGIN
          ProdOrderComp."Version Code" := SoftwareCompComb."Component 4 Version";
          ProdOrderComp.MODIFY;
          FoundComp[4] := TRUE;
        END;
        END ELSE
          FoundComp[4] := TRUE;
    
        IF MaxComp >= 5 THEN BEGIN
        ProdOrderComp.SETRANGE("Value Code",SoftwareCompComb."Component 5");
        ProdOrderComp.SETRANGE("Version Code",'');
        IF ProdOrderComp.FINDFIRST THEN BEGIN
          ProdOrderComp."Version Code" := SoftwareCompComb."Component 5 Version";
          ProdOrderComp.MODIFY;
          FoundComp[5] := TRUE;
        END;
        END ELSE
          FoundComp[5] := TRUE;
    
        IF MaxComp >= 6 THEN BEGIN
        ProdOrderComp.SETRANGE("Value Code",SoftwareCompComb."Component 6");
        ProdOrderComp.SETRANGE("Version Code",'');
        IF ProdOrderComp.FINDFIRST THEN BEGIN
          ProdOrderComp."Version Code" := SoftwareCompComb."Component 6 Version";
          ProdOrderComp.MODIFY;
          FoundComp[6] := TRUE;
        END;
        END ELSE
          FoundComp[6] := TRUE;
    
        IF MaxComp >= 7 THEN BEGIN
        ProdOrderComp.SETRANGE("Value Code",SoftwareCompComb."Component 7");
        ProdOrderComp.SETRANGE("Version Code",'');
        IF ProdOrderComp.FINDFIRST THEN BEGIN
          ProdOrderComp."Version Code" := SoftwareCompComb."Component 7 Version";
          ProdOrderComp.MODIFY;
          FoundComp[7] := TRUE;
        END;
        END ELSE
          FoundComp[7] := TRUE;
    
        IF MaxComp >= 8 THEN BEGIN
        ProdOrderComp.SETRANGE("Value Code",SoftwareCompComb."Component 8");
        ProdOrderComp.SETRANGE("Version Code",'');
        IF ProdOrderComp.FINDFIRST THEN BEGIN
          ProdOrderComp."Version Code" := SoftwareCompComb."Component 8 Version";
          ProdOrderComp.MODIFY;
          FoundComp[8] := TRUE;
        END;
        END ELSE
          FoundComp[8] := TRUE;
    
    // Newly added fields - start
    
        IF MaxComp >= 9 THEN BEGIN
        ProdOrderComp.SETRANGE("Value Code",SoftwareCompComb."Component 9");
        ProdOrderComp.SETRANGE("Version Code",'');
        IF ProdOrderComp.FINDFIRST THEN BEGIN
          ProdOrderComp."Version Code" := SoftwareCompComb."Component 9 Version";
          ProdOrderComp.MODIFY;
          FoundComp[9] := TRUE;
        END;
        END ELSE
          FoundComp[9] := TRUE;
    
        IF MaxComp >= 10 THEN BEGIN
        ProdOrderComp.SETRANGE("Value Code",SoftwareCompComb."Component 10");
        ProdOrderComp.SETRANGE("Version Code",'');
        IF ProdOrderComp.FINDFIRST THEN BEGIN
          ProdOrderComp."Version Code" := SoftwareCompComb."Component 10 Version";
          ProdOrderComp.MODIFY;
          FoundComp[10] := TRUE;
        END;
        END ELSE
          FoundComp[10] := TRUE;
    
        IF MaxComp >= 11 THEN BEGIN
        ProdOrderComp.SETRANGE("Value Code",SoftwareCompComb."Component 11");
        ProdOrderComp.SETRANGE("Version Code",'');
        IF ProdOrderComp.FINDFIRST THEN BEGIN
          ProdOrderComp."Version Code" := SoftwareCompComb."Component 11 Version";
          ProdOrderComp.MODIFY;
          FoundComp[11] := TRUE;
        END;
        END ELSE
          FoundComp[11] := TRUE;
    
        IF MaxComp >= 12 THEN BEGIN
        ProdOrderComp.SETRANGE("Value Code",SoftwareCompComb."Component 12");
        ProdOrderComp.SETRANGE("Version Code",'');
        IF ProdOrderComp.FINDFIRST THEN BEGIN
          ProdOrderComp."Version Code" := SoftwareCompComb."Component 12 Version";
          ProdOrderComp.MODIFY;
          FoundComp[12] := TRUE;
        END;
        END ELSE
          FoundComp[12] := TRUE;
    
        IF MaxComp >= 13 THEN BEGIN
        ProdOrderComp.SETRANGE("Value Code",SoftwareCompComb."Component 13");
        ProdOrderComp.SETRANGE("Version Code",'');
        IF ProdOrderComp.FINDFIRST THEN BEGIN
          ProdOrderComp."Version Code" := SoftwareCompComb."Component 13 Version";
          ProdOrderComp.MODIFY;
          FoundComp[13] := TRUE;
        END;
        END ELSE
          FoundComp[13] := TRUE;
    
        IF MaxComp >= 14 THEN BEGIN
        ProdOrderComp.SETRANGE("Value Code",SoftwareCompComb."Component 14");
        ProdOrderComp.SETRANGE("Version Code",'');
        IF ProdOrderComp.FINDFIRST THEN BEGIN
          ProdOrderComp."Version Code" := SoftwareCompComb."Component 14 Version";
          ProdOrderComp.MODIFY;
          FoundComp[14] := TRUE;
        END;
        END ELSE
          FoundComp[14] := TRUE;
    
        IF MaxComp >= 15 THEN BEGIN
        ProdOrderComp.SETRANGE("Value Code",SoftwareCompComb."Component 15");
        ProdOrderComp.SETRANGE("Version Code",'');
        IF ProdOrderComp.FINDFIRST THEN BEGIN
          ProdOrderComp."Version Code" := SoftwareCompComb."Component 15 Version";
          ProdOrderComp.MODIFY;
          FoundComp[15] := TRUE;
        END;
        END ELSE
          FoundComp[15] := TRUE;
    
        IF MaxComp >= 16 THEN BEGIN
        ProdOrderComp.SETRANGE("Value Code",SoftwareCompComb."Component 16");
        ProdOrderComp.SETRANGE("Version Code",'');
        IF ProdOrderComp.FINDFIRST THEN BEGIN
          ProdOrderComp."Version Code" := SoftwareCompComb."Component 16 Version";
          ProdOrderComp.MODIFY;
          FoundComp[16] := TRUE;
        END;
        END ELSE
          FoundComp[16] := TRUE;
    
        IF MaxComp >= 17 THEN BEGIN
        ProdOrderComp.SETRANGE("Value Code",SoftwareCompComb."Component 17");
        ProdOrderComp.SETRANGE("Version Code",'');
        IF ProdOrderComp.FINDFIRST THEN BEGIN
          ProdOrderComp."Version Code" := SoftwareCompComb."Component 17 Version";
          ProdOrderComp.MODIFY;
          FoundComp[17] := TRUE;
        END;
        END ELSE
          FoundComp[17] := TRUE;
    
        IF MaxComp >= 18 THEN BEGIN
        ProdOrderComp.SETRANGE("Value Code",SoftwareCompComb."Component 18");
        ProdOrderComp.SETRANGE("Version Code",'');
        IF ProdOrderComp.FINDFIRST THEN BEGIN
          ProdOrderComp."Version Code" := SoftwareCompComb."Component 18 Version";
          ProdOrderComp.MODIFY;
          FoundComp[18] := TRUE;
        END;
        END ELSE
          FoundComp[18] := TRUE;
    
     // // Newly added fields - END
    
    // (1) Actual Code Commented - start
    {
        Found := FoundComp[1] AND FoundComp[2] AND FoundComp[3] AND FoundComp[4] AND
                 FoundComp[5] AND FoundComp[6] AND FoundComp[7] AND FoundComp[8];
    }
    // (1) Actual Code Commented - end
    
    // (1) Modified Code - start
    
        Found := FoundComp[1] AND FoundComp[2] AND FoundComp[3] AND FoundComp[4] AND
                 FoundComp[5] AND FoundComp[6] AND FoundComp[7] AND FoundComp[8] AND
                 FoundComp[9] AND FoundComp[10] AND FoundComp[11] AND FoundComp[12] AND
                 FoundComp[13] AND FoundComp[14] AND FoundComp[15] AND FoundComp[16] AND
                 FoundComp[17] AND FoundComp[18];
    
    // (1) Modified Code - end
    
        IF Found THEN BEGIN
          ProdOrderComp.RESET;
          ProdOrderComp.SETRANGE(Status,ProdOrder.Status);
          ProdOrderComp.SETRANGE("Prod. Order No.",ProdOrder."No.");
          ProdOrderComp.SETRANGE("Prod. Order Line No.",GamePOLineNo);
          ProdOrderComp.SETRANGE("Line No.",GameLineNo);
          IF ProdOrderComp.FINDFIRST THEN BEGIN
            ProdOrderComp."Version Code" := SoftwareCompComb."Game Version";
            ProdOrderComp."Value Code" := SoftwareCompComb.Game;
            ProdOrderComp.MODIFY;
          END;
          MESSAGE('The software versions are updated.');
        END;
      UNTIL (SoftwareCompComb.NEXT = 0) OR Found
    ELSE
    
    // (2) Actual Code Commented - start
    {
      ERROR('No valid combination found.\Game:%1 Jurisdiction:%2\C1:%3 C2:%4 C3:%5 C4:%6 C5:%7 C6:%8 C7:%9 C8:%10',
             CompGame,CompJuris,CompArray[1],CompArray[2],CompArray[3],
             CompArray[4],CompArray[5],CompArray[6],CompArray[7],CompArray[8]);
    }
    // (2) Actual Code Commented - end
    
    
    // (2) Modified code as you suggested - start
    
    txtErrorMsg1 := STRSUBSTNO(Text001,CompArray[1],CompArray[2],CompArray[3],
                                       CompArray[4],CompArray[5],CompArray[6],CompArray[7],CompArray[8]);
    
    txtErrorMsg2 := STRSUBSTNO(Text002,CompArray[9],CompArray[10], CompArray[11],CompArray[12],CompArray[13],CompArray[14]
                                       ,CompArray[15],CompArray[16],CompArray[17],CompArray[18]);
    
    txtErrorMsg := STRSUBSTNO(Text000,CompGame,CompJuris,txtErrorMsg1,txtErrorMsg2);
    
    ERROR(txtErrorMsg);
    
    // (2) Modified code as you suggested - end
    
    
    IF Found THEN BEGIN
    END ELSE
      ERROR('No combination is found.');
    
  • lvanvugtlvanvugt Member Posts: 774
    So this was your code (only relevant part)
    ELSE
      ERROR('No valid combination found.\Game:%1 Jurisdiction:%2\C1:%3 C2:%4 C3:%5 C4:%6 C5:%7 C6:%8 C7:%9 C8:%10',
             CompGame,CompJuris,CompArray[1],CompArray[2],CompArray[3],
             CompArray[4],CompArray[5],CompArray[6],CompArray[7],CompArray[8]);
    
    And this is what it should become (note use of BEGIN and END):
    ELSE BEGIN
      txtErrorMsg1 := STRSUBSTNO(Text001,CompArray[1],CompArray[2],CompArray[3],
                                       CompArray[4],CompArray[5],CompArray[6],CompArray[7],CompArray[8]);
      txtErrorMsg2 := STRSUBSTNO(Text002,CompArray[9],CompArray[10], CompArray[11],CompArray[12],CompArray[13],CompArray[14]
                                       ,CompArray[15],CompArray[16],CompArray[17],CompArray[18]);
      txtErrorMsg := STRSUBSTNO(Text000,CompGame,CompJuris,txtErrorMsg1,txtErrorMsg2);
      ERROR(txtErrorMsg);
    END;
    
    Due to you not using the BEGIN-END construct this code will always be executed after the preceding IF-ELSE statement:
    txtErrorMsg2 := STRSUBSTNO(Text002,CompArray[9],CompArray[10], CompArray[11],CompArray[12],CompArray[13],CompArray[14]
                                       ,CompArray[15],CompArray[16],CompArray[17],CompArray[18]);
    txtErrorMsg := STRSUBSTNO(Text000,CompGame,CompJuris,txtErrorMsg1,txtErrorMsg2);
    ERROR(txtErrorMsg);
    
    Luc van Vugt, fluxxus.nl
    Never stop learning
    Van Vugt's dynamiXs
    Dutch Dynamics Community
  • Aravindh_NavisionAravindh_Navision Member Posts: 258
    Thanks a lot lvanvugt !! It worked. :thumbsup: A very silly mistake of mine. ](*,)
  • lvanvugtlvanvugt Member Posts: 774
    You're welcome.
    A very silly mistake of mine.
    RML :D (just teasing)
    Please mark this issue as Solved.
    Luc van Vugt, fluxxus.nl
    Never stop learning
    Van Vugt's dynamiXs
    Dutch Dynamics Community
Sign In or Register to comment.