Help, why it not funtionating

MandASoftMandASoft Member Posts: 8
Hello all,

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

Comments

  • matttraxmatttrax Member Posts: 2,309
    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.
  • MandASoftMandASoft Member Posts: 8
    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 Function
    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;
    }
    
    So that the funktion says that GL Account of 1575 is Client Account and not the VAT.
    I have write another function
    FindGLAccountType (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.eu
  • matttraxmatttrax Member Posts: 2,309
    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.
  • MandASoftMandASoft Member Posts: 8
    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 this
    There are always a way
    http://www.mandasoft.eu
  • matttraxmatttrax Member Posts: 2,309
    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');
    
  • MandASoftMandASoft Member Posts: 8
    edited 2010-02-08
    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.eu
  • MandASoftMandASoft Member Posts: 8
    Anywan hase the same problem?
    There are always a way
    http://www.mandasoft.eu
  • matttraxmatttrax Member Posts: 2,309
    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.
Sign In or Register to comment.