Failing to reset variable for group totals for each FA subclass.

SH2010
Member Posts: 21
The problem I am facing is that the variable FASubclasstot is not resetting after the FA Subclass changes. It keeps accumulating from the prior class and its now acting as a running total.Help me how do I use the ONPRE DATA ITEM, ON AFTER GET Record and ON POST DATA
ON PREDATA ITEM - I put this code**********************
FA_Appreciation_Tot:=0;
FA_Acquistion_Tot:=0;
FA_Depreciation_Tot:=0;
FA_Disposal_Tot:=0;
FA_Writedown_Tot:=0;
FA_NBV_Tot:=0;
FASubclassNum:="Fixed Asset"."FA Class Code";
ON After GETRECORD************************************
IF FASubclassNum="Fixed Asset"."FA Class Code" THEN
"FA Depreciation Book".RESET;
"FA Depreciation Book".SETFILTER("FA No.","Fixed Asset"."No.");
"FA Depreciation Book".SETRANGE("FA No.","Fixed Asset"."No.");
BEGIN
FA_Acquistion_Tot:="Acquisition Cost"+FA_Acquistion_Tot ;
FA_Appreciation_Tot:=Appreciation+FA_Appreciation_Tot;
FA_Depreciation_Tot:=Depreciation+FA_Depreciation_Tot;
FA_Writedown_Tot:="FA Depreciation Book"."Write-Down"+FA_Writedown_Tot;
FA_Disposal_Tot:= "Proceeds on Disposal"+FA_Disposal_Tot;
// FA_NBV_Tot:= "Book Value" + FA_NBV_Tot;
FA_NBV_Tot:=FA_Acquistion_Tot+FA_Appreciation_Tot+FA_Disposal_Tot+FA_Depreciation_Tot+FA_Writedown_Tot
END;
IF FASubclassNum <>"Fixed Asset"."FA Class Code" THEN
BEGIN
FASubclassGrpTot:=0;
FA_Appreciation_Tot:=0;
FA_Acquistion_Tot:=0;
FA_Depreciation_Tot:=0;
FA_Disposal_Tot:=0;
FA_NBV_Tot:=0;
FASubclassNum:="Fixed Asset"."FA Class Code"
END;
ON POST DATA----no code
ON PREDATA ITEM - I put this code**********************
FA_Appreciation_Tot:=0;
FA_Acquistion_Tot:=0;
FA_Depreciation_Tot:=0;
FA_Disposal_Tot:=0;
FA_Writedown_Tot:=0;
FA_NBV_Tot:=0;
FASubclassNum:="Fixed Asset"."FA Class Code";
ON After GETRECORD************************************
IF FASubclassNum="Fixed Asset"."FA Class Code" THEN
"FA Depreciation Book".RESET;
"FA Depreciation Book".SETFILTER("FA No.","Fixed Asset"."No.");
"FA Depreciation Book".SETRANGE("FA No.","Fixed Asset"."No.");
BEGIN
FA_Acquistion_Tot:="Acquisition Cost"+FA_Acquistion_Tot ;
FA_Appreciation_Tot:=Appreciation+FA_Appreciation_Tot;
FA_Depreciation_Tot:=Depreciation+FA_Depreciation_Tot;
FA_Writedown_Tot:="FA Depreciation Book"."Write-Down"+FA_Writedown_Tot;
FA_Disposal_Tot:= "Proceeds on Disposal"+FA_Disposal_Tot;
// FA_NBV_Tot:= "Book Value" + FA_NBV_Tot;
FA_NBV_Tot:=FA_Acquistion_Tot+FA_Appreciation_Tot+FA_Disposal_Tot+FA_Depreciation_Tot+FA_Writedown_Tot
END;
IF FASubclassNum <>"Fixed Asset"."FA Class Code" THEN
BEGIN
FASubclassGrpTot:=0;
FA_Appreciation_Tot:=0;
FA_Acquistion_Tot:=0;
FA_Depreciation_Tot:=0;
FA_Disposal_Tot:=0;
FA_NBV_Tot:=0;
FASubclassNum:="Fixed Asset"."FA Class Code"
END;
ON POST DATA----no code
0
Answers
-
So the totals for acquisition, appreciation, depreciation etc are not resseting after the subclass code changes0
-
your code for resetting should come before the value is assigned at onafterget trigger.0
-
Are you sure you have posted the code correctly here? The reason I ask is that there is no variable called FASubclasstot and although there is one called FASubclassGrpTot this never gets assigned a value.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