Repeat Until Looping not working

namanupadhyay1
Member Posts: 3
Hi All,
I am doing a coding on Employee(Customized). I am finding on 1 table then calling the function to Fill in the values in another Table.
Count is giving me 4 records exist but repeat until is not going to 2nd record. It is only executing the function for first record.
PayEmpPayElement.RESET;
PayEmpPayElement.SETRANGE("Navision Company",NavCompany);
PayEmpPayElement.SETRANGE("Company No.",PayrollCompany);
PayEmpPayElement.SETRANGE("Payroll No.",PayrollNo);
PayEmpPayElement.SETRANGE("Employee No.",Employee."Employee No.");
PayEmpPayElement.SETRANGE("End Date",0D);
IF PayEmpPayElement.FINDFIRST THEN
REPEAT
IF PayEmpPayElement."Fixed Income" THEN
-->InsertPayEmpDetails(Employee,PayEmpPayElement,Payroll,DaysPresentforFixedIncome)
ELSE
InsertPayEmpDetails(Employee,PayEmpPayElement,Payroll,DaysPresentforVariableIncome);
UNTIL PayEmpPayElement.NEXT = 0;
After executing the function for the first time, it is coming out of the repeat until loop. I am inserting the values in the different Table when I call the marked function.
Thanks in advance for the help.
I am doing a coding on Employee(Customized). I am finding on 1 table then calling the function to Fill in the values in another Table.
Count is giving me 4 records exist but repeat until is not going to 2nd record. It is only executing the function for first record.
PayEmpPayElement.RESET;
PayEmpPayElement.SETRANGE("Navision Company",NavCompany);
PayEmpPayElement.SETRANGE("Company No.",PayrollCompany);
PayEmpPayElement.SETRANGE("Payroll No.",PayrollNo);
PayEmpPayElement.SETRANGE("Employee No.",Employee."Employee No.");
PayEmpPayElement.SETRANGE("End Date",0D);
IF PayEmpPayElement.FINDFIRST THEN
REPEAT
IF PayEmpPayElement."Fixed Income" THEN
-->InsertPayEmpDetails(Employee,PayEmpPayElement,Payroll,DaysPresentforFixedIncome)
ELSE
InsertPayEmpDetails(Employee,PayEmpPayElement,Payroll,DaysPresentforVariableIncome);
UNTIL PayEmpPayElement.NEXT = 0;
After executing the function for the first time, it is coming out of the repeat until loop. I am inserting the values in the different Table when I call the marked function.
Thanks in advance for the help.
0
Answers
-
Done. the record variable was reset.0
-
You should not use FINDFIRST with a REPEAT UNTIL loop but FINDSET. This will lead to more optimized queries to the SQL db.0
-
namanupadhyay1 wrote:Hi All,
I am doing a coding on Employee(Customized). I am finding on 1 table then calling the function to Fill in the values in another Table.
Count is giving me 4 records exist but repeat until is not going to 2nd record. It is only executing the function for first record.
PayEmpPayElement.RESET;
PayEmpPayElement.SETRANGE("Navision Company",NavCompany);
PayEmpPayElement.SETRANGE("Company No.",PayrollCompany);
PayEmpPayElement.SETRANGE("Payroll No.",PayrollNo);
PayEmpPayElement.SETRANGE("Employee No.",Employee."Employee No.");
PayEmpPayElement.SETRANGE("End Date",0D);
//IF PayEmpPayElement.FINDFIRST THEN
IF PayEmpPayElement.FIND('-') THEN
REPEAT
IF PayEmpPayElement."Fixed Income" THEN
-->InsertPayEmpDetails(Employee,PayEmpPayElement,Payroll,DaysPresentforFixedIncome)
ELSE
InsertPayEmpDetails(Employee,PayEmpPayElement,Payroll,DaysPresentforVariableIncome);
UNTIL PayEmpPayElement.NEXT = 0;
After executing the function for the first time, it is coming out of the repeat until loop. I am inserting the values in the different Table when I call the marked function.
Thanks in advance for the help.0 -
Nope.
//IF PayEmpPayElement.FINDFIRST THEN
IF PayEmpPayElement.FIND('-') THEN
should become
//IF PayEmpPayElement.FINDFIRST THEN
IF PayEmpPayElement.FINDSET THEN0 -
As Maximus said, use FINDSET for better query.Microsoft Certified IT Professional for Microsoft Dynamics NAV
Just a happy frood who knows where his towel is0
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