A method and apparatus for dynamically generating code that generates a
mapping between territories and territorial assignees is provided. A code
generator uses the territory criteria to dynamically generate the code
for an assignee-to-territory-mapping-engine. The generated code uses the
territory criteria and the territorial assignees to produce an
assignee-to-territory-mapping. The assignee-to-territory-mapping can be
used to determine the sales representatives that are responsible for a
particular territorial assignee.