Repeat Until Looping not working

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

Answers

  • namanupadhyay1namanupadhyay1 Member Posts: 3
    Done. the record variable was reset. :lol:
  • MaximusMaximus Member Posts: 105
    You should not use FINDFIRST with a REPEAT UNTIL loop but FINDSET. This will lead to more optimized queries to the SQL db.
  • Himanshu_NigamHimanshu_Nigam Member Posts: 23
    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.
  • MaximusMaximus Member Posts: 105
    Nope.

    //IF PayEmpPayElement.FINDFIRST THEN
    IF PayEmpPayElement.FIND('-') THEN

    should become

    //IF PayEmpPayElement.FINDFIRST THEN
    IF PayEmpPayElement.FINDSET THEN
  • dansdans Member Posts: 148
    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 is
Sign In or Register to comment.