"Field Check" CU 104015 compilation error

remarkremark Member Posts: 122
Hello,

I am trying to migrate NAV 5.0 SP1 native to SQL Server db. When using Migrate.fob file, after importing 104015 codeunit from a generated .txt file it is impossible to compile this imported 104015 codeunit.
I get an error:
"FIELDNAME is not a function, and only functions can be called with '(...'.

Please, help me with an advise, how it can be solved?

Answers

  • ara3nara3n Member Posts: 9,256
    can you paste the code where the compiler stops?

    My guess you have some field name that causing this issue.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • rdebathrdebath Member Posts: 383
    Well of course I would suggest this ...

    http://www.mibuso.com/dlinfo.asp?FileID=1149

    Just run it with default options.
  • remarkremark Member Posts: 122
    ara3n wrote:
    can you paste the code where the compiler stops?

    My guess you have some field name that causing this issue.

    Thanks Rashed!
    Here it is (I pointed out the line of error by line comment):
    A17235.CHANGECOMPANY(F.GetCompanyName);
    B17235.CHANGECOMPANY(F.GetCompanyName);
    F.UpdateKey(A17235.CURRENTKEY);
    A17235.MARKEDONLY := F.Modify;
    IF A17235.FIND('-') THEN
      REPEAT
        B17235 := A17235;
        B17235.SETRECFILTER;
        F.Update(B17235.GETFILTERS);
        F.CheckText(B17235.FIELDNAME("TableName"),MAXSTRLEN(B17235."TableName"),B17235."TableName"); //error occurs on this line after "FIELDNAME"
        F.CheckText(B17235.FIELDNAME("FieldName"),MAXSTRLEN(B17235."FieldName"),B17235."FieldName");
        F.CheckText(B17235.FIELDNAME("Type Name"),MAXSTRLEN(B17235."Type Name"),B17235."Type Name");
        F.CheckText(B17235.FIELDNAME("Field Caption"),MAXSTRLEN(B17235."Field Caption"),B17235."Field Caption");
        F.CheckCode(B17235.FIELDNO("Division"),B17235.FIELDNAME("Division"),MAXSTRLEN(B17235."Division"),B17235."Division");
        F.CheckCode(B17235.FIELDNO("Header"),B17235.FIELDNAME("Header"),MAXSTRLEN(B17235."Header"),B17235."Header");
        F.CheckCode(B17235.FIELDNO("Component Line ID"),B17235.FIELDNAME("Component Line ID"),MAXSTRLEN(B17235."Component Line ID"),
    B17235."Component Line ID");
        IF F.Modify THEN BEGIN
          A17235.DELETE;
          B17235.INSERT;
        END ELSE
          IF NOT A17235.MARK THEN
            A17235.MARK := F.Mark;
      UNTIL A17235.NEXT = 0;
    
  • remarkremark Member Posts: 122
    rdebath wrote:
    Well of course I would suggest this ...

    http://www.mibuso.com/dlinfo.asp?FileID=1149

    Just run it with default options.

    Thank you, I will try it.
    Is this "Field Check" supposed to be as a replacement to Migrate.fob or just as a tool for additional checking before using standard methodology with Migrate.fob?
  • rdebathrdebath Member Posts: 383
    It's a replacement for everything except the code field classification that, I think, is supposed to help you decide if you want to set the SQL type on code fields when you port from native to sql.
  • remarkremark Member Posts: 122
    OK, thank you, Robert!
  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    remark wrote:
    "FIELDNAME is not a function, and only functions can be called with '(...'.

    Please, help me with an advise, how it can be solved?
    A few days ago I had the error "FIELDNO is not a function, etc." when I was using migrate.fob. This was caused by a table, which had a field called "FieldNo". Because FIELDNO is used as a function in this codeunit 104015, NAV does not know if you want to reference the field, or if you want to use the function with the same name.

    My guess is that you have a field called "Fieldname" in table 17235. If you rename that field, the codeunit will compile.
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • remarkremark Member Posts: 122
    A few days ago I had the error "FIELDNO is not a function, etc." when I was using migrate.fob. This was caused by a table, which had a field called "FieldNo". Because FIELDNO is used as a function in this codeunit 104015, NAV does not know if you want to reference the field, or if you want to use the function with the same name.

    My guess is that you have a field called "Fieldname" in table 17235. If you rename that field, the codeunit will compile.

    Thank you, Luc!
    Yes, there was a field called "Fieldname" in table 17235. I renamed it to "Fieldname1" and then tried to compile, but got another error:

    When the function is called, the minimum number of parameters should be used. For example:

    MyFunc( .. , .. , .. )
    ROUND(MyVar)
    ROUND(MyVar,0.05)


    And the error occured on the same line of code (trigger Table17235), but after the first parameter "TableName" (I pointed it out by a line comment):
    A17235.CHANGECOMPANY(F.GetCompanyName);
    B17235.CHANGECOMPANY(F.GetCompanyName);
    F.UpdateKey(A17235.CURRENTKEY);
    A17235.MARKEDONLY := F.Modify;
    IF A17235.FIND('-') THEN
      REPEAT
        B17235 := A17235;
        B17235.SETRECFILTER;
        F.Update(B17235.GETFILTERS);
        F.CheckText(B17235.FIELDNAME("TableName"),MAXSTRLEN(B17235."TableName"),B17235."TableName"); //the error is here, after the first "TableName"
        F.CheckText(B17235.FIELDNAME("FieldName"),MAXSTRLEN(B17235."FieldName"),B17235."FieldName");
        F.CheckText(B17235.FIELDNAME("Type Name"),MAXSTRLEN(B17235."Type Name"),B17235."Type Name");
        F.CheckText(B17235.FIELDNAME("Field Caption"),MAXSTRLEN(B17235."Field Caption"),B17235."Field Caption");
        F.CheckCode(B17235.FIELDNO("Division"),B17235.FIELDNAME("Division"),MAXSTRLEN(B17235."Division"),B17235."Division");
        F.CheckCode(B17235.FIELDNO("Header"),B17235.FIELDNAME("Header"),MAXSTRLEN(B17235."Header"),B17235."Header");
        F.CheckCode(B17235.FIELDNO("Component Line ID"),B17235.FIELDNAME("Component Line ID"),MAXSTRLEN(B17235."Component Line ID"),
    B17235."Component Line ID");
        IF F.Modify THEN BEGIN
          A17235.DELETE;
          B17235.INSERT;
        END ELSE
          IF NOT A17235.MARK THEN
            A17235.MARK := F.Mark;
      UNTIL A17235.NEXT = 0;
    

    Then I tried to rename yet another field in the table 17235 - TableName. I changed its name to TableName1. Then trying to compile I get an error on the same line (and exactly the same point) of code. The error message is following:

    A field from a record variable was expected. For example:

    Record.Field
    Customer.Name
  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    Did you generate the CU 104015 again, after you have modified the fieldnames in the table?
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • remarkremark Member Posts: 122
    Did you generate the CU 104015 again, after you have modified the fieldnames in the table?

    Thanks! That was the reason!
    I changed back the TableName1 field to TableName, regenerated CU 104015, imported it again and, yes, it compiled without problems.

    Should I return the initial name of a FieldName field in the table 17235 before running CU 104015 for scanning database?
  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    remark wrote:
    Should I return the initial name of a FieldName field before running CU 104015 for scanning database?
    No, you run the codeunit with the modified fieldnames. When your codeunit is finished, and you have done the prosposed data changes, then you can rename the fields back to their original names.
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • remarkremark Member Posts: 122
    Luc, thank you very much! :D
  • David_SingletonDavid_Singleton Member Posts: 5,479
    Reserved words should NEVER under any circumstances EVER be used for variables or Field Names. This is why it is so important to read the style guide and follow the rules.

    The scariest thing here is the field number 17,325 meaning that its a localization done by whoever localized this version. This is disastrous that a, so called, developer was able to do this.

    This needs to be reported to Microsoft. And they need to fix this.
    David Singleton
Sign In or Register to comment.