Automatic Renumbering of Operation No in Routings

Hello everyone, I have a programming problem, which already have taken me a lot of time trying to solve it. So maybe one of the experts at this forum can help me. I should programm a codeunit, that can do an automatic renumbering of the Operation Numbers in the Routings. The customer wants a four digit number starting from 0010 and then proceed in 10ths, e.g. 0020,0030,0040. So, now there’s the problem, that he often removes or adds Routing lines, so the routings look like this: 0010,0015,0020,0040. My tool should bring them in appropriate order again. Below, I have attached the code that shows my efforts. However I always get an error message or the results are not right (i.e. no changes in the numbers). OBJECT Codeunit 60010 Nummerierung Test { OBJECT-PROPERTIES { Datum=13.09.04; Zeit=18:40:06; Ge„ndert=Ja; Versions Liste=MAFSTR 3.70; } PROPERTIES { OnRun=BEGIN Window.OPEN( ‘#1############################### ’ + Text000); Window.UPDATE(1,Text001); RoutingHeader.RESET; RoutingLine.RESET; OldRoutingNo := ‘’; intOpNo := 10; NoofAPL := 0; RoutingLine.SETFILTER(“Routing No.”,‘411005…411007’); IF RoutingLine.FIND(’-’) THEN BEGIN REPEAT Window.UPDATE(2,RoutingLine.“Routing No.”); Window.UPDATE(3,ROUND(NoofAPL / RoutingLine.COUNT * 10000,1)); RoutingHeader.SETFILTER(“No.”,’%1’,RoutingLine.“Routing No.”); IF RoutingHeader.FIND(’-’) THEN BEGIN IF RoutingLine.“Operation No.” <> ‘’ THEN BEGIN OldStatus := RoutingHeader.Status; RoutingHeader.Status := RoutingHeader.Status::“Under Development”; RoutingHeader.MODIFY(TRUE); RoutingLine.VALIDATE(“Operation No.”,’’); RoutingLine.VALIDATE(“Next Operation No.”,’’); RoutingLine.VALIDATE(“Previous Operation No.”,’’); IF RoutingLine.“Routing No.” <> OldRoutingNo THEN BEGIN RoutingLine.VALIDATE(“Operation No.”,‘0010’); OldRoutingNo := RoutingLine.“Routing No.”; END ELSE BEGIN OldRoutingNo := RoutingLine.“Routing No.”; intOpNo := intOpNo+10; RoutingLine.VALIDATE(“Operation No.”,‘00’ + FORMAT(intOpNo)); END; RoutingLine.MODIFY(TRUE); RoutingHeader.Status := OldStatus; RoutingHeader.MODIFY(TRUE); END; END; NoofAPL := NoofAPL+1; COMMIT; UNTIL RoutingLine.NEXT = 0; END; END; } CODE { VAR RoutingHeader@1000000002 : Record 99000763; RoutingLine@1000000000 : Record 99000764; ProdBOMHeader@1000000003 : Record 99000771; ProdBOMLine@1000000001 : Record 99000772; OldStatus@1000000004 : Option; Window@1000000005 : Dialog; Text000@1000000006 : TextConst ‘DEU=Arbeitsplannr.: #2############### @3@@@@@@@@@@\;ENU=Routing No.: #2############### @3@@@@@@@@@@\’; Text001@1000000007 : TextConst ‘DEU=Arbeitsgang-Nummerierung aktualisieren…;ENU=Update Routing description’; NoofAPL@1000000008 : Integer; OldRoutingNo@1000000009 : Code[20]; intOpNo@1000000010 : Integer; BEGIN END. } } Any hint is gladly appreciated. Cheers… Michael

Hi again, I found the (or better one possible) solution myself: Simply export all dataitems, delete the table and renumber it while importing again. Just in case anyone else comes across this topic. Regards, Michael

Operation No. is part of the primary key - you must use routingline.rename(“Routing No.”,“Version Code”, New Operation Number) instead of modify Martin

Try to use INCSTR function to create new code.