Duplicate vs. pointer

All,

I have an EDI DELFOR that I am mapping to multiple documents (of the same type). Basically what I do is create a “stub document” with all the common information, then, inside a loop, I copy that to a temporary document via mapping, populate the specific info, save it to a list of outgoing docs, and drop the temporary doc. However, whatever I do to the temporary document also is done to the original “stub.” So on the second time through the loop, whatever I do to the new temp is done to the stub AND to the document in the outgoing list. I know in Java if you say a = b; a becomes just a pointer to the b variable, and so changing one changes both, whereas a == b; would be a more explicit value match. Has anyone ever faced this issue, or know how to truly copy a document, and not create a pointer to it?

Thanks

Two items:

  • Map at the field level, not the record level. Primitive fields are copy by value. Records are copy by reference.

  • Drop the temp var near the end of the loop when you are done with it.

[Edit] The first bullet is a rule of thumb for string variables. For all other types of variables, IS copies by reference. Refer to the Developer User’s Guide for details, Chapter 8 “Mapping Data in a Flow Service” (v 6.5). That chapter provides information about copy by reference and copy by value, and mapping techniques to get the sort of copy behavior that you need for a given task.

Thanks reamon, mapping by field seems to do the trick. That’s a good piece of information to know about how values are copied!