Help, why it not funtionating

MandASoft
Member Posts: 8
Hello all,
I have make a funktion:
Sombody now this problem?
Very thanks for the answar.
I have make a funktion:
FindGLAccountType (GLAcc : Code 20) { TMPGLAccountType[GLAccountType::Client].SETRANGE("No.", GLAcc); TMPGLAccountType[GLAccountType::VAT].SETRANGE("No.", GLAcc); CASE TRUE OF TMPGLAccountType[GLAccountType::Client].FINDFIRST: EXIT(GLAccountType::Client); TMPGLAccountType[GLAccountType::VAT].FINDFIRST: EXIT(GLAccountType::VAT); ELSE EXIT(GLAccountType::Diferent); END; } InitGLAccount { GLAccountType := GLAccountType::VAT; IF VATPostingSetup.FINDSET THEN REPEAT InsertTMPGLAcc(VATPostingSetup."Sales VAT Account"); InsertTMPGLAcc(VATPostingSetup."Sales VAT Unreal. Account"); InsertTMPGLAcc(VATPostingSetup."Purchase VAT Account"); InsertTMPGLAcc(VATPostingSetup."Purch. VAT Unreal. Account"); InsertTMPGLAcc(VATPostingSetup."Reverse Chrg. VAT Acc."); InsertTMPGLAcc(VATPostingSetup."Reverse Chrg. VAT Unreal. Acc."); UNTIL VATPostingSetup.NEXT = 0; // Insert Client Accounts GLAccountType := GLAccountType::Client; IF CustomerPostingGroup.FINDSET THEN REPEAT InsertTMPGLAcc(CustomerPostingGroup."Receivables Account"); UNTIL CustomerPostingGroup.NEXT = 0; IF VendorPostingGroup.FINDSET THEN REPEAT InsertTMPGLAcc(VendorPostingGroup."Payables Account"); UNTIL VendorPostingGroup.NEXT = 0;The variable TMPGLAccountType is a Temp variable with 3 dimensions. Now if I call funtion
REPEAT IF FindGLAccountType(CalcGLEntry."G/L Account No.") = GLAccountType::Client THEN EXIT(TRUE); UNTIL CalcGLEntry.NEXT = 0; EXIT(FALSE);and it returns VAT Account. Exemple I want to now if account 1575 (German VAT Account) ir Client I give this to the function FindGLAccountType and I get that it is Client Account.
Sombody now this problem?
Very thanks for the answar.
There are always a way
http://www.mandasoft.eu
http://www.mandasoft.eu
0
Comments
-
Well, I don't quite understand, but I can at least tell you why what you're doing isn't working.
You don't appear to have any other filters on your TMPGLAccountType record variable. Only the account number is filtered.
To explain a little clearer, you are doing the exact same thing, regardless of whether or not it is a client account or a VAT account.
If you were looking at a G/L Account card, how would you know whether it is a client account or a VAT account? That's where you should start. I don't see any need for dimensions.0 -
This is like if you use the same variable buth with dimensions. Example I make that
GLAccountType := GLAccountType::VAT; IF VATPostingSetup.FINDSET THEN REPEAT InsertTMPGLAcc(VATPostingSetup."Sales VAT Account"); InsertTMPGLAcc(VATPostingSetup."Sales VAT Unreal. Account"); InsertTMPGLAcc(VATPostingSetup."Purchase VAT Account"); InsertTMPGLAcc(VATPostingSetup."Purch. VAT Unreal. Account"); InsertTMPGLAcc(VATPostingSetup."Reverse Chrg. VAT Acc."); InsertTMPGLAcc(VATPostingSetup."Reverse Chrg. VAT Unreal. Acc."); UNTIL VATPostingSetup.NEXT = 0;
So I insert into TMPGLAccountType[GLAccountType::VAT]."No." a GLAccount of value 1575
and into// Insert Client Accounts GLAccountType := GLAccountType::Client; IF CustomerPostingGroup.FINDSET THEN REPEAT InsertTMPGLAcc(CustomerPostingGroup."Receivables Account"); UNTIL CustomerPostingGroup.NEXT = 0; IF VendorPostingGroup.FINDSET THEN REPEAT InsertTMPGLAcc(VendorPostingGroup."Payables Account"); UNTIL VendorPostingGroup.NEXT = 0;
And into TMPGLAccountType[GLAccountType::Client]."No." a GLAccount of value 1410
Now in the Main Program I try tu find what type of GLAccount is the 1575 (I need that for other things). Buth the FunctionFindGLAccountType (GLAcc : Code 20) { TMPGLAccountType[GLAccountType::Client].SETRANGE("No.", GLAcc); TMPGLAccountType[GLAccountType::VAT].SETRANGE("No.", GLAcc); CASE TRUE OF TMPGLAccountType[GLAccountType::Client].FINDFIRST: EXIT(GLAccountType::Client); TMPGLAccountType[GLAccountType::VAT].FINDFIRST: EXIT(GLAccountType::VAT); ELSE EXIT(GLAccountType::Diferent); END; }
So that the funktion says that GL Account of 1575 is Client Account and not the VAT.
I have write another functionFindGLAccountType (GLAcc : Code 20) { CASE TRUE OF TMPGLAccountType[GLAccountType::Client].Get(GLAcc): EXIT(GLAccountType::Client); TMPGLAccountType[GLAccountType::VAT].Get(GLAcc): EXIT(GLAccountType::VAT); ELSE EXIT(GLAccountType::Diferent); END; }
But this not work too.There are always a way
http://www.mandasoft.eu0 -
If it is important for you to know what type of G/L Account it is, why not just add a field to the G/L Account Table? An Option field for example.0
-
matttrax wrote:If it is important for you to know what type of G/L Account it is, why not just add a field to the G/L Account Table? An Option field for example.
I have do this in the erlay version of this solution, Now I want make it bether, it will work much faster and you do not need make additional setups of thisThere are always a way
http://www.mandasoft.eu0 -
I disagree that this solution is faster. There's no way that loading all of that data into temp tables is faster than:
GLAccount.GET("No."); EXIT (GLAccount.Type);
Additional setup, sure. But faster execution, no way.
Why even bother with the temp tables?IF VATPostingSetup.FINDSET THEN REPEAT IF (MyNumber = VATPostingSetup."Sales VAT Account") OR (MyNumber = VATPostingSetup."Sales VAT Unreal. Account") OR (all other conditions) THEN EXIT('VAT'); UNTIL VATPostingSetup.NEXT = 0; IF CustomerPostingGroup.FINDSET THEN REPEAT IF MyNumber = CustomerPostingGroup."Receivables Account" THEN EXIT('Client'); UNTIL CustomerPostingGroup.NEXT = 0; EXIT('Something Else');
0 -
Yes it is faster if you have a lot of GL Entrys, you need just tu get the temp table and not get the GL Account from the base.
Secound Question for the performace, you have just once to reade the GL ACCounts from the tables, and not for every Entry.
This solution muss check every GL Entry and if the Client Account do something, if there a VAT do something else, and all others somthing new, this is a report for a client.
If you make a lot of setups there may change somthing or forget, and the report will not show the right. I have all accounts that I need in Setup Tables, so I do not need additional Setup.
And make a 3 Temporary tables, is not a solution, becouse there will be more, and to the future will be esey to change this and not others programing code.There are always a way
http://www.mandasoft.eu0 -
-
The problem is that when you use a temp record variable as an array (with dimensions) it doesn't matter what index you insert the record in. It will appear in all of them. I believe this is discussed in one of the How To's by Kriki.
I still really think you should just add a field to the card. You can prepopulate it based on current data, and then make it a required field when they add an account. The Chart of Accounts for a company doesn't change very often from my experience so future setup shouldn't be that big of a deal.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
- 320 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