Using array in temporary tables does not work

thegunzothegunzo Member Posts: 274
I create a new report. Put in a global variable named Buffer of type Record 49. In Properties I set Dimensions to 10 and Temporary to Yes.
I also put in a global variable named i of type Integer.

In OnPreReport trigger I enter the following code:

FOR i := 1 TO ARRAYLEN(Buffer) DO
Buffer.INSERT;

And the I run the report. Navision does not create 10 different temporary tables like it should do.

Regards, Gunnar Gestsson
Saudarkrokur, Iceland.
________________________________
Gunnar Gestsson
Microsoft Certified IT Professional
Dynamics NAV MVP
http://www.dynamics.is
http://Objects4NAV.com

Comments

  • KowaKowa Member Posts: 926
    If you use temporary tables you need to read the record first and then assign it to the temporary record variable.
    Create another record variable (non-temporary) InvPostBuf for table 49 and then :


    InvPostBuf.FIND('-');
    FOR i := 1 TO ARRAYLEN(Buffer) DO BEGIN
    Buffer := InvPostBuf;
    Buffer.INSERT;
    END;
    Kai Kowalewski
  • SteveOSteveO Member Posts: 164
    When Navision uses an array on a table (whether temporary or not) the individual elements of the array do not act as seperate instances of the specified table. Instead, they act as "pointers" to different records within the same table (ie, all elements share common data but they can each be reading a different record within that table)

    Hope this makes sense. If not I can provide an examle of what I mean.
    This isn't a signature, I type this at the bottom of every message
  • Tim81Tim81 Member Posts: 68
    SteveO wrote:
    When Navision uses an array on a table (whether temporary or not) the individual elements of the array do not act as seperate instances of the specified table. Instead, they act as "pointers" to different records within the same table (ie, all elements share common data but they can each be reading a different record within that table)

    Hope this makes sense. If not I can provide an examle of what I mean.
    This is exactly the problem. A record has already two dimensions. So if you do it with the code sample above Navision always writes to the same table. If i = 1 then it writes the first record, if i = 2 then the second and so on. Be careful with dimensions and records. This is not a error in navision, but a error in reasoning.
  • KowaKowa Member Posts: 926
    Sorry , the INSERT statement above was wrong.

    InvPostBuf.FIND('-');
    FOR i := 1 TO ARRAYLEN(Buffer) DO
    Buffer := InvPostBuf;

    The code stated above creates you 10 copies of the first record for further processing, but every alteration on one will alter the others too.
    AND
    keep in mind that Table 49, as all buffer tables, is empty and only used while posting is in progress. The records are deleted afterwards.
    It would be helpful if you would tell us what you are actually trying to do ? :-k
    Kai Kowalewski
  • ajhvdbajhvdb Member Posts: 672
    I always thought that a record var defined with a dimension of 5 are just 5 pointers to the same table.

    If you also define it also as temp it will be 5 pointers to the same temp table...or did you just explain this :)
Sign In or Register to comment.