FILTERGROUP? problem?

teeter
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.
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

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.
0
Comments
-
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.0 -
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/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