Step through fields in a table via Fieldref and recref

jensthomsen
jensthomsen Member Posts: 173
I want to step through all the fields in a table, to see where there are any data (across companies in a database). I'm aware that Fieldref and RecRef can do the trick, but how?

Comments

  • kine
    kine Member Posts: 12,562
    1) If there is some record, there are some data (you cannot say that if the field is empty, that there is no data, or if in integer is 0, it means no data..., if some record exists, there are data...)
    2) If there is some record in the table you can find out in File-Database-Informations-Tables
    3) This table is "across companies".
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • jensthomsen
    jensthomsen Member Posts: 173
    kine wrote:
    1) If there is some record, there are some data (you cannot say that if the field is empty, that there is no data, or if in integer is 0, it means no data..., if some record exists, there are data...)

    No, I want to check it on field basis: If the datattype is Date, the field isn't empty if the fieldvalue <> 0D, if the type code the field isn't empty if it <>'' etc.
  • NaviDev
    NaviDev Member Posts: 365
    sample of mine.

    declare this variables:

    item as record subtype item
    refItem as recordref
    fldItemFields as fieldref
    Ctr as integer
    tmpClass as Text 100
    tmpType as text 200
    tmpValue as text 1024

    IF Item.FIND('-') THEN REPEAT
      refItem.GETTABLE(Item);
      FOR Ctr := 1 TO refItem.FIELDCOUNT DO BEGIN
        fldItemFields := refItem.FIELDINDEX(Ctr);
        tmpClass := FORMAT(fldItemFields.CLASS);
        tmpType := FORMAT(fldItemFields.TYPE);
        tmpValue := fldItemFields.VALUE;
        MESSAGE(tmpClass);
        MESSAGE(tmpType);
        MESSAGE(tmpValue);
      END;
    UNTIL Item.NEXT = 0;
    
    Navision noob....