INSERT

Hi,

I’ve got a problem with insert function.

Hereunder, you can read my code:

LIMCommentLine.RESET;
LIMCommentLine.SETFILTER(“Table Name”,FORMAT(LIMCommentLine.“Table Name”::Application));
LIMCommentLine.SETFILTER(“No.”,Application.“No.”);

IF LIMCommentLine.FIND(’-’) THEN
REPEAT
LIMCommentLine.VALIDATE(“Table Name”,LIMCommentLine.“Table Name”::Policy);
LIMCommentLine.VALIDATE(“No.”,NewPolicy.“No.”);
LIMCommentLine.INSERT;
UNTIL LIMCommentLine.NEXT = 0;

I have a bunch of lines like written below:

Type | App. No. | Line No. | Content |

Application | AP00001 | 10000 | monday |

Application | AP00002 | 20000 | thursday |

Application | AP00003 | 30000 | sunday |

And my code should insert new lines with new type and new app no. but keep the line no. and the content:

Type | App. No. | Line No. | Content |

Policy | PO00001 | 10000 | monday |

Policy | PO00002 | 20000 | thursday |

Policy | PO00003 | 30000 | sunday |

The first line is modified correctly but it stops at this point. When I manually changed the line, it inserts a new empty row … Then I suppose that the repeat loop breaks because of it.

How should I turn my code to avoid this additional blank line?

Thanks

Just copy the line to a variable of the same table and it should work:

IF LIMCommentLine.FIND(’-’) THEN REPEAT
LIMCommentLine2 := LIMCommentLine;
LIMCommentLine2.VALIDATE(“Table Name”,LIMCommentLine.“Table Name”::Policy);
LIMCommentLine2.VALIDATE(“No.”,NewPolicy.“No.”);
LIMCommentLine2.INSERT;
UNTIL LIMCommentLine.NEXT = 0;

BTW: Which version do you use? For performance reasons you could use FINDSET instead of FIND(’-’).

I used temporary variables to buffer data as you advised but unfortunately, it does not work … I am just wondering If I should not use RENAME function. Is that possible to do a multiple renaming of records?

It works Joerg, you were right. I had wrongly coded the buffer variables. Thanks

You’re welcome, good luck with your changes.