Hi
Your code is correct, the place where it needs to go is in codeunit 80, search for "// Insert shipment header", just set a breakpoint here first to ensure that it is the correct spot before you make any modifications
Be aware that modifying posting codeunits can cause you years of problems if you don't know what you are doing, get a experienced NAV developer to help you if possible
Cheers
Nev