[solved] Temp record variable and RESET
CobaltSS
Member Posts: 137
Hi all,
The function below comes from CodeUnit 22, and is called from Codeunit 5705. My questions are what happens to a TEMP variable when a RESET is applied against it, and what is the impact of doing that as the first step in the function?
cheers,
The function below comes from CodeUnit 22, and is called from Codeunit 5705. My questions are what happens to a TEMP variable when a RESET is applied against it, and what is the impact of doing that as the first step in the function?
CollectItemEntryRelation(VAR TargetItemEntryRelation : TEMPORARY Record "Item Entry Relation") OK : Boolean
TempItemEntryRelation.RESET;
TargetItemEntryRelation.RESET;
IF NOT TempItemEntryRelation.FIND('-') THEN
EXIT(FALSE)
ELSE
REPEAT
TargetItemEntryRelation := TempItemEntryRelation;
TargetItemEntryRelation.INSERT;
UNTIL TempItemEntryRelation.NEXT = 0;
TempItemEntryRelation.DELETEALL;
EXIT(TRUE);
cheers,
0
Comments
-
A VAR parameter for a record also sends the filters to the function.
The RESET removes the filters and selects the primary key on the temptable, BUT DOES NOT TOUCH the records itself that are in the temptable.
So REPEAT-UNTIL will read all records that are in the temptable passed to the function by the calling program.Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
So in the function, the RESET on the first, TEMP var, should do nothing and should have no records, because it's not passed? The second line of the function is the passed variable. Then the IF statement references the TEMP var in the first line, so it's always FALSE?
cheers,0 -
If the calling program has records in its temptable and passes it to this function as the first parameter, the VAR makes sure the temptable has the same records and filters as the in the calling program.
So doing a RESET removes the filters, BUT IT DOESN'T TOUCH the records in the temptable.Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
Hi Alain,
I understand the RESET doesn't affect the values within the record variable, just the filters and keys. However, I'm a bit confused about what's happening within the function. Sorry for being obtuse.
There are 2 record variables involved in this function. This one is passed TargetItemEntryRelation to the function from another Codeunit. The function's first line is to RESET a differenet TEMP record TempItemEntryRelation.RESET;
which to me means there should be no records in TempItemEntryRelation because the called function is not part of a single instance codeunit, and TempItemEntryRelation is not part of a function call. Am I right? Then there's the FIND line on the (in my mind anyway) TEMP var, which should be false, but because of the NOT, is always true.
Maybe because it's Monday, but it's all clear as mud to me. Any insight greatly appreciated.
cheers,0 -
The variable "TempItemEntryRelation" is global variable in the codeunit. Records are inserted into this temporary table with another function in the same codeunit. This function is just copying the records from this temporary table into passed variable to be able to access these records from outside of this codeunit (you can access just functions, not global variables from outside...).0
-
I see now where the Codeunit was called earlier, so yes there are records in the TEMP record.
Thanks for your time, both of you.
cheers,0 -
-
At your service
Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!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
