In every application, such scenarios of retrieving dynamic runtime data through automation script is a common requirement. Usually any professional software testing services company, will handle such scenarios as utilities implemented in their automation frameworks by using parent-child locator concept.
Here also, we can use use the same parent-child locator concept using some unique element. In this case, unique element is "Code" and hence, correct xpath will be -
//dt//span[text() = 'Code']//..//dd//span
and then fetching the corresponding dynamic text using getText() default method of Selenium.
Additionally, below element will fetch you required dynamic code -
String codeToStore = driver.findElement(By.xpath("//dt//span[text() = 'Code']//..//dd//span")).getText();