It seems like you are trying to iterate over the ordinal values of your custom enum, but you are not actually setting the value of myenum2 in the loop. Therefore, the if condition will never evaluate to true, and the loop will not break.
To iterate over the enum value of every record in the codeunit, you can use a RecordRef variable and the SETRANGE function to filter the records based on your custom enum value. Here’s an example of how you could modify your code:
local procedure CheckBalance(var GenJnlLine: Record “Gen. Journal Line edelb”) var GenJnlLineRef: RecordRef; myenum2: enum myEnum; begin GenJnlLineRef.OPEN(GenJnlLine); GenJnlLineRef.SETRANGE(“Custom Enum Field”, myenum2);
if GenJnlLineRef.ISEMPTY then // no records match the filter condition else begin repeat // do something with the filtered records here until GenJnlLineRef.NEXT = 0; end; end;
In this example, replace "Custom Enum Field" with the actual field name of your custom enum field.
By using a RecordRef and the SETRANGE function, you can filter the records based on your custom enum value and then loop through them to perform your custom operation.