Modify a table with a field that is part of a Key

I wrote a function below to update a table. The data I’m trying to modify is a part of a key as shown in SETCURRENTKEY. I was expecting the function to start looping from the first record and modify each record’s line no by adding 100. However, the loop is not working. Am I missing something? Please look at it and suggest any possible fix.

XYZ.SETCURRENTKEY(“Job No.”, “Line No.”, “Report Name”);

XYZ.SETFILTER(“Job No.”, ‘ABC’);

IF XYZ.FINDSET(TRUE, TRUE) THEN BEGIN

REPEAT
XYZ.”Line No.” := XYZ.”Line No.” + 100;
XYZ.MODIFY;
UNTIL XYZ.NEXT <= 0;
END;

Where, XYZ is the table name; ABC is the Job no in XYZ table; Line No is a field in XYZ table, which is also part of a key.

You need to use the RENAME function instead of MODIFY. Renaming takes longer, though, so you may want to consider copying the original record, adding to the line number, and inserting it. Then you can delete the old one.

True, but if your record to rename have any relation, this relation has to be handled manually as well.

That is absolutely correct. RENAME is definitely the better, and easier, way to go. It just takes longer to run.