IF "Bin Mandatory" AND NOT xRec."Bin Mandatory" THEN BEGIN Window.OPEN(Text010); ItemLedgEntry.SETCURRENTKEY("Item No.",Open,"Variant Code",Positive,"Location Code"); IF ItemLedgEntry.FINDFIRST THEN REPEAT ItemLedgEntry.SETRANGE("Item No.",ItemLedgEntry."Item No."); ItemLedgEntry.SETRANGE(Open,TRUE); ItemLedgEntry.SETRANGE("Location Code",Code); IF ItemLedgEntry.FINDLAST THEN ERROR(Text009,FIELDCAPTION("Bin Mandatory")); ItemLedgEntry.SETRANGE(Open); ItemLedgEntry.SETRANGE("Location Code"); ItemLedgEntry.FINDLAST; ItemLedgEntry.SETRANGE("Item No."); UNTIL ItemLedgEntry.NEXT = 0; . . .
Comments
Probably they did it because there is no Key "Location Code", "Open" existing and they did not want to add it. Or they simply wanted to update the dialog with item no. but forgot to code it.
Anyway, using findfirst/last in combination with a loop is simply nonsense. In this piece of code you should at least use find-/+ and a second variable for ILE. The Key is still not good.
As this is piece of code is maybe triggered once in a lifetime just ignore it. Or simply change it to something like this:
FD Consulting