1. A method in a server comprising a memory interconnected with a processor, comprising: receiving a request to generate a code at the processor; automatically selecting one of a plurality of code generation rules from the memory based on an item identifier derived from the request, the selected rule including one or more lot code fragment definitions; retrieving data from at least one reference table stored in the memory, based on the code fragment definitions; generating the one or more code fragments according to the selected rule using the retrieved data and at least one subcomponent lot code; and concatenating the generated code fragments to generate the code.