Recently I needed to have a copy function for my theatre application.
The duplicate_record function works fine. Thanks for that, Archie. I
have only one little problem: it doesn't copy text fields.

This code doesn't work for text fields:

Move (Record_Buffer(Self)) to hRecBuffer

For iField From 1 to iNumFields
Get Value of hRecBuffer Item iField to sTemp
Set Array_Value of hFields Item iField to sTemp
Loop

Is there a simple way to solve this? (For me it only has to work in
VDF11). And is this way of copying records still the way to go???

Regards,

Peter van Mil





Archie Campbell schreef:
> Attached is a file cMyDataDictionary.pkg
> It has two methods in it:
> Duplicate_Record
> Clear_Retain_Parent
>
> This arose from a VDF posting I did a few weeks ago titled "How do I clear a
> DDO without clearing its parents". Thanks to Keren, Matthew, Steven and Will
> for their replies. This in turn was a followup to a 21Feb posting "Creating
> a copy of an existing record using DDO's". Thanks to Jim, Denys and Barry
> for their replies to that one.
>
> My original problem was that I wanted an easy way to create an offset
> invoice ( a copy of an existing invoice, but with negative amounts) using
> DDO's. Under procedural code you could use the "move 0 to invoice.recnum"
> trick. I was stuck trying to find an easy way to do it using DDO's.
>
> Duplicate_Record:
> . saves the field values in an array
> . clears the DDO
> . restores the field values from the array
>
> I ran into a problem when I noticed that the "clear" cleared the file plus
> its parents and restoring the attached fields got overwritten by the attach
> from the cleared parents. So I had to first save the parent record#'s, do
> the Duplicate_Record, then refind the parent records. This was a bit
> painful.
>
> Clear_Retain_Parents solved this. It:
> . builds a list of the servers (parents)
> . detaches the parents
> . does the clear, which, with no parents, just clears the main DDO
> . reattaches the parents.
>
> The end result is a simple to use method for duplicating a record. In
> addition to the original "invoice with one parent" example, I recently put
> it to use to duplicate a shipment segment record with 126 fields and 4
> parents. Seems to work OK.
>
> The code gives sample usage.
>
> Thanks again to all who helped with ideas on how to do it.
>
> Archie
>
>
>
>