Update Employee table when report is run

kolaboy
Member Posts: 446
Hi,
I have created a report that computes number of days an employee is entitle for leave.
We have categories and their corresponding no. of days leave entitlements in a table called categories.
There is another table called the absence registrations were the report runs through to see any absence that is deductible and subtracts that no. of days from the no. of days entitle for leave which is obtained from the category table. If not deductible, no subtraction takes place.
Now my problem is when the report is run, and deductions are made from each employee total leave entitlements, the employee table should be updated with the remaining no. of day an employee is entitled for a leave.
Also after each year 10 0r 20 more days are added to each remaining leaves depending on the category an employee is.
How can i go about with this issue. Sample codes are welcome.
Here is my report:
I have created a report that computes number of days an employee is entitle for leave.
We have categories and their corresponding no. of days leave entitlements in a table called categories.
There is another table called the absence registrations were the report runs through to see any absence that is deductible and subtracts that no. of days from the no. of days entitle for leave which is obtained from the category table. If not deductible, no subtraction takes place.
Now my problem is when the report is run, and deductions are made from each employee total leave entitlements, the employee table should be updated with the remaining no. of day an employee is entitled for a leave.
Also after each year 10 0r 20 more days are added to each remaining leaves depending on the category an employee is.
How can i go about with this issue. Sample codes are welcome.
Here is my report:
OBJECT Report 50026 Leave Computation { OBJECT-PROPERTIES { Date=21/02/08; Time=18:30:54; Modified=Yes; Version List=; } PROPERTIES { } DATAITEMS { { PROPERTIES { DataItemTable=Table5200; OnAfterGetRecord=BEGIN Cats.GET(Catagory); EmpName :="First Name" + Space + "Middle Name" + Space + "Last Name"; // Testing Below //Cats.GET(Employee.Catagory); //"Employee Absence".SETRANGE("Employee No.",Employee."No."); //Cats.SETRANGE(Catagories, Employee.Catagory); RemLeave := Cats."Leave entitle"; AnnLeave := 0; //IF "Employee Absence".FIND('-') //THEN BEGIN //AnnLeave := "Employee Absence".Quantity; //IF "Employee Absence".NEXT <> 0 //THEN REPEAT //AnnLeave := AnnLeave + "Employee Absence".Quantity; //UNTIL "Employee Absence".NEXT = 0; //RemLeave := Cats."Leave entitle" - "Employee Absence".Quantity; //END //ELSE BEGIN //RemLeave := Cats."Leave entitle"; //AnnLeave := 0; //END; {IF empAbse.FIND('-') THEN BEGIN AnnLeave := empAbse.Quantity; IF empAbse.NEXT <> 0 THEN REPEAT AnnLeave := AnnLeave + empAbse.Quantity; UNTIL empAbse.NEXT = 0; RemLeave := Cats."Leave entitle" - AnnLeave; END ELSE BEGIN RemLeave := Cats."Leave entitle"; AnnLeave := 0; END;} // Updating RemLeave and AnnLeave on Employee Table. {Employee.RemLeave := RemLeave; Employee.AnnLeave := AnnLeave; Employee.MODIFY();} END; } SECTIONS { { PROPERTIES { SectionType=Header; SectionWidth=17250; SectionHeight=2115; } CONTROLS { { 1000000011;Label ;1500 ;1269 ;9150 ;423 ;FontSize=12; FontBold=Yes; CaptionML=ENU=STAFF LEAVE COMPUTATION REPORT } { 1000000016;TextBox;12150;0 ;3750 ;423 ;HorzAlign=Right; SourceExpr=FORMAT(TODAY,0,4) } { 1000000018;TextBox;13050;846 ;2850 ;423 ;HorzAlign=Right; SourceExpr=USERID } { 1000000015;TextBox;0 ;0 ;1800 ;423 ;SourceExpr=COMPANYNAME } { 1000000017;TextBox;14400;423 ;1500 ;423 ;SourceExpr=CurrReport.PAGENO } { 1000000019;Label ;12900;423 ;1500 ;423 ;HorzAlign=Right; CaptionML=ENU=Page } } } { PROPERTIES { SectionType=Body; SectionWidth=17250; SectionHeight=1269; } CONTROLS { { 1000000014;Label ;0 ;0 ;2250 ;423 ;FontSize=9; FontBold=Yes; CaptionML=ENU=Employee No.: } { 1000000000;TextBox;2250 ;0 ;1350 ;423 ;FontSize=8; SourceExpr=Employee."No." } { 1000000005;Label ;3900 ;0 ;1200 ;423 ;FontSize=9; FontBold=Yes; CaptionML=ENU=Name: } { 1000000002;TextBox;5250 ;0 ;6900 ;423 ;FontSize=8; SourceExpr=EmpName } { 1000000006;Label ;0 ;423 ;1650 ;423 ;FontSize=9; FontBold=Yes; CaptionML=ENU=Category: } { 1000000001;TextBox;1800 ;423 ;900 ;423 ;HorzAlign=Left; FontSize=8; SourceExpr=Employee.Catagory } { 1000000003;Label ;2850 ;423 ;2550 ;423 ;FontSize=8; FontBold=Yes; CaptionML=ENU=Leave Entitle To } { 1000000007;TextBox;5550 ;423 ;1500 ;423 ;HorzAlign=Left; FontSize=8; SourceExpr=RemLeave } } } } } { PROPERTIES { DataItemIndent=1; DataItemTable=Table5207; OnAfterGetRecord=BEGIN //Cats.GET(Employee.Catagory); empAbse.SETRANGE("Employee No.",Employee."No."); empAbse.SETRANGE(Deductible,TRUE); Cats.SETRANGE(Catagories, Employee.Catagory); IF empAbse.FIND('-') THEN BEGIN AnnLeave := empAbse.Quantity; IF empAbse.NEXT <> 0 THEN REPEAT AnnLeave := AnnLeave + empAbse.Quantity; UNTIL empAbse.NEXT = 0; RemLeave := Cats."Leave entitle" - AnnLeave; END ELSE BEGIN RemLeave := Cats."Leave entitle"; AnnLeave := 0; END; // Updating RemLeave and AnnLeave on Employee Table. empAbse.Quantity := RLeave; //Employee.AnnLeave := ALeave; Employee.MODIFY(); END; DataItemLink=Employee No.=FIELD(No.); } SECTIONS { { PROPERTIES { SectionType=Header; SectionWidth=17250; SectionHeight=423; } CONTROLS { { 1000000020;Label ;0 ;0 ;1350 ;423 ;HorzAlign=Left; FontBold=Yes; CaptionML=ENU=From Date: } { 1000000022;Label ;1350 ;0 ;1050 ;423 ;HorzAlign=Left; FontBold=Yes; CaptionML=ENU=To Date: } { 1000000024;Label ;2850 ;0 ;2100 ;423 ;HorzAlign=Left; FontBold=Yes; CaptionML=ENU=Cause of Absence: } { 1000000026;Label ;6150 ;0 ;5850 ;423 ;HorzAlign=Left; FontBold=Yes; CaptionML=ENU=Description: } { 1000000028;Label ;13350;0 ;1800 ;423 ;HorzAlign=Left; FontBold=Yes; CaptionML=ENU=No. of days: } { 1000000031;Label ;15150;0 ;1500 ;423 ;HorzAlign=Left; FontBold=Yes; CaptionML=ENU=Deductible } } } { PROPERTIES { SectionType=Body; SectionWidth=17250; SectionHeight=846; } CONTROLS { { 1000000004;TextBox;0 ;0 ;1200 ;423 ;HorzAlign=Left; SourceExpr="From Date" } { 1000000021;TextBox;1200 ;0 ;1200 ;423 ;HorzAlign=Left; SourceExpr="To Date" } { 1000000023;TextBox;2850 ;0 ;2700 ;423 ;HorzAlign=Left; SourceExpr="Cause of Absence Code" } { 1000000025;TextBox;6150 ;0 ;6450 ;423 ;HorzAlign=Left; SourceExpr=Description } { 1000000027;TextBox;13350;0 ;1800 ;423 ;HorzAlign=Left; SourceExpr=Quantity } { 1000000029;TextBox;15150;0 ;1500 ;423 ;HorzAlign=Left; SourceExpr=Deductible } } } { PROPERTIES { SectionType=Footer; SectionWidth=17250; SectionHeight=1269; } CONTROLS { { 1000000009;Label ;0 ;0 ;3150 ;423 ;FontSize=9; FontBold=Yes; CaptionML=ENU=Annual Leave Taken: } { 1000000010;TextBox;3150 ;0 ;1050 ;423 ;HorzAlign=Left; FontSize=8; SourceExpr=AnnLeave } { 1000000012;Label ;4200 ;0 ;3900 ;423 ;HorzAlign=Left; FontSize=9; FontBold=Yes; CaptionML=ENU=Annual Leave Remaining: } { 1000000013;TextBox;8100 ;0 ;1050 ;423 ;HorzAlign=Left; FontSize=8; SourceExpr=RemLeave } { 1000000008;TextBox;0 ;423 ;17250;423 ;HorzAlign=Left; FontSize=9; FontBold=Yes; SourceExpr=Line2 } } } } } } REQUESTFORM { PROPERTIES { Width=9020; Height=3410; } CONTROLS { } } CODE { VAR Space@1000000001 : TextConst 'ENU=" "'; Cats@1000000000 : Record 50025; RemLeave@1000000002 : Integer; EmpName@1000000003 : Text[180]; AnnLeave@1000000004 : Integer; Line1@1000000005 : TextConst 'ENU=......................................................................................................................................................'; Line2@1000000006 : TextConst 'ENU=------------------------------------------------------------------------------------------------------------------------------------------------------'; DedOption@1000000007 : Boolean; empAbse@1000000008 : Record 5207; RLeave@1000000009 : Integer; ALeave@1000000010 : Integer; BEGIN END. } }Thanks.
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