FILTERGROUP? problem?

teeterteeter Member Posts: 46
I'm having a problem with a Serenic Object, and I hope I'm not breaking any rules by asking here...

I'm running a payroll report that is taking forever and a day to finish running (have not yet waited more that 2 days to see if it finishes). I've narrowed down the problem to a codeunit using a function from a table with the wrong key. However it looks to me like its using the correct key...


Here is the function in the table (the commented out code is my own, trying to figure out what the #@!@% problem is):

ManualCalcSums()
CLEAR( PayrollLedger2 );

Rec.Amount := 0;
Rec."Taxable Amount" := 0;

PayrollLedger2.COPYFILTERS( Rec );
//PayrollLedger2.SETVIEW(Rec.GETVIEW);
//ERROR(PayrollLedger2.GETVIEW);
//PayrollLedger2.SETCURRENTKEY( "Employee No.", "Posting Date" );
IF PayrollLedger2.FIND( '-' ) THEN BEGIN
REPEAT
Rec.Amount := PayrollLedger2.Amount + Rec.Amount;
Rec."Taxable Amount" := PayrollLedger2."Taxable Amount" + Rec."Taxable Amount";
UNTIL (PayrollLedger2.NEXT = 0);
END;



here is the function in the codeunit which is using the function in the table:



ManualCalcField(VAR ControlTaxFormClass : Record "Pay Control Tax Form Class";SourceFieldNo : Integer) : Decimal
CLEAR( LedgerEntry );
CopyPCTFCFiltersToLedger( ControlTaxFormClass, LedgerEntry );
LedgerEntry.SETCURRENTKEY( "Employee No.", "Posting Date" );

LedgerEntry.ManualCalcSums();
CASE SourceFieldNo OF
ControlTaxFormClass.FIELDNO( "Payroll Amount" ): BEGIN
CalculatedAmount := LedgerEntry.Amount;
END;
ControlTaxFormClass.FIELDNO( "Taxable Amount" ): BEGIN
CalculatedAmount := LedgerEntry."Taxable Amount";
END;
ELSE BEGIN
ERROR( kERRMSG_SourceFieldInvalid, SourceFieldNo );
END;
END;


EXIT( CalculatedAmount );


Now it appears that the codeunit is setting the correct key, but when it runs it is using only the primary key "Entry No." and taking forever to go through the records. When I manually set the key in the function everything works dandy. Why isn't the key from the codeunit persisting to the table object?? The results from
//PayrollLedger2.SETVIEW(Rec.GETVIEW);
//ERROR(PayrollLedger2.GETVIEW);
give me a key and filters from somewhere else in the codeunit (FILTERGROUP?) but when the report actually runs, it says its only using "Entry No.".

I don't want to add code to the table's function as I don't know what else uses this function and I don't want to break too much of Serenic's code but I can't figure out how to get the key to persist.

I imagine that reading through my post is probably as easy as deciphering Serenic's code :( but any help would be greatly appeciated!.

note: i'm going to go ahead and put my hack in so the client can run the report today as it is critical, but I would like to know why this is happening and how i might be able to fix it for the future.

Comments

  • lphanlphan Member Posts: 10
    COPYFILTERS does not copy key over.

    In the table function ManualCalcSums(), because of the CLEAR(PayrollLedger2), it will clear all values, filters and reset the key to primary key.

    So you need to set the key after clearing the variable.
  • teeterteeter Member Posts: 46
    CLEAR( LedgerEntry );

    CopyPCTFCFiltersToLedger( ControlTaxFormClass, LedgerEntry );

    LedgerEntry.SETCURRENTKEY( "Employee No.", "Posting Date" );

    here it is being set again, but when i run the debugger and check the table it is being cleared when the function is called.

    Serenic support has gotten back to us , so hopefully one of their developers/support staff can walk me through whats going on \:D/
Sign In or Register to comment.