Codeunits can be treated as objects − one codeunit variable can be assigned to another codeunit variable, which creates a new reference to the same codeunit instance. In other words, the codeunit variables then use the same set of internal variables
But i dont know how to assiagn one codeunit variable to another coudeunit variable thats why i posted it.
And it's important how it's stated.
It's not how we thought: copying over the values of the variables. It's literally how it's stated: "...which creates a new reference to the same codeunit instance. In other words, the codeunit variables then use the same set of internal variables ".
After assignment,
if changing a variable in CU1, it'll be changed in CU2 as well. It is a reference to the same thing.
So now I wouldn't know anymore why this would be useful.. :-k
So now I wouldn't know anymore why this would be useful.. :-k
Me too. In my NAV-life, I have written a lot of (kriki-)code but I don't remember to have used this possibility once. :-k
This is very useful when you are posting and need to pass CU 22 or CU 12 to your own functions. These codeunits keep track of variables e.g. LastEntryNo. etc.
So if you are inserting additional Item journal line entries or GL Entries, you can use the variable that is used in CU 80 or 90.
Btw I've used this once and worked out well.
Ahmed Rashed Amini
Independent Consultant/Developer
Comments
mycu1 ---> codeunit 50000
mycu2 ---> codeunit 50000
it doesn't give you compile error, but what's the point in doing this? :-k
"Never memorize what you can easily find in a book".....Or Mibuso
My Blog
Eric Wauters
MVP - Microsoft Dynamics NAV
My blog
:? it is what i thought...but maybe i've done something wrong because it doesn't transfer global variables...
i've done this:
and in cu and cu2 .fntgetpartest there is:
debugging it, when cu2.fntgetpartest is called, par1 and par2 have 0 value...am i missing something? :-k
"Never memorize what you can easily find in a book".....Or Mibuso
My Blog
try switching cu and cu2.
Eric Wauters
MVP - Microsoft Dynamics NAV
My blog
"Never memorize what you can easily find in a book".....Or Mibuso
My Blog
paska juttu
Eric Wauters
MVP - Microsoft Dynamics NAV
My blog
"Never memorize what you can easily find in a book".....Or Mibuso
My Blog
Eric Wauters
MVP - Microsoft Dynamics NAV
My blog
Thanks for your Reply.
I read one pdf file like below
Codeunit Assignment:
Codeunits can be treated as objects − one codeunit variable can be assigned to another codeunit variable, which creates a new reference to the same codeunit instance. In other words, the codeunit variables then use the same set of internal variables
But i dont know how to assiagn one codeunit variable to another coudeunit variable thats why i posted it.
Lakshman Routu
http://lakshman-routu.blogspot.in/
Eric Wauters
MVP - Microsoft Dynamics NAV
My blog
"Never memorize what you can easily find in a book".....Or Mibuso
My Blog
It's not how we thought: copying over the values of the variables. It's literally how it's stated: "...which creates a new reference to the same codeunit instance. In other words, the codeunit variables then use the same set of internal variables ".
After assignment,
if changing a variable in CU1, it'll be changed in CU2 as well. It is a reference to the same thing.
So now I wouldn't know anymore why this would be useful.. :-k
Eric Wauters
MVP - Microsoft Dynamics NAV
My blog
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
This is very useful when you are posting and need to pass CU 22 or CU 12 to your own functions. These codeunits keep track of variables e.g. LastEntryNo. etc.
So if you are inserting additional Item journal line entries or GL Entries, you can use the variable that is used in CU 80 or 90.
Btw I've used this once and worked out well.
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n