Using array in temporary tables does not work
thegunzo
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.
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
Gunnar Gestsson
Microsoft Certified IT Professional
Dynamics NAV MVP
http://www.dynamics.is
http://Objects4NAV.com
0
Comments
-
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 Kowalewski0 -
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 message0 -
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.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.0 -
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 ? :-kKai Kowalewski0 -
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
0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 323 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions
