Copying data from one table to another with RecordRef

LilithyanLilithyan Member Posts: 32
Hello,

I currently got a rather frustrating porblem, which doesn't want to get solved by me.
We are currently planing a datamigration for one of our customers. For this the first step ist to take all Data from the specified tables in the old Database an bring these without changes into the new database into the tables 99000-99999.
Step two is getting the data into there destined tables in the new database. for this there are some cases, where the Data can go without changes back into the same tables it had been in the old base.

My problem now is how to make this possible. There is a table in which the information - from which table the data came from, in which it is now and to which it has got to go - is stored.
A codeunit I am currently trying to programm takes this information and somehow has to get the data from A to B without specifying any record variables beforehand for the different tables since the customer wishes to do this all in one go.

The first thought was to use RecordRef for this, but as this is two different Tables we are speaking of, it doesn't seem to be possible. I have been stuck with this problem for three days and can't seem to find a working solution! ](*,)

Has anyone got any ideas how this problem can be solved? Any help would be greatly appreciated!

Ciao,

Lilithyan

Comments

  • mandykmandyk Member Posts: 57
    Hi Lilithyan,

    I am not quite sure if I am understand correctly your problems is, but talking about data migration in most situation can be helpfull using dataport to export and import into text files. You can control whether you want to retain the object number or you want to reassigned with new object number in new database.

    Btw, export and import normally works in all cases for master tables, documents and setups but not for ledgers tables.
    The ledgers tables has dependency with some internal tables to support system logic/controls/validation.

    The possible way to do data migration for ledgers normally is by cut off from old databse into new database by import opening balance journal and post them in new database. For example for inventory, you need to findout the final balance all the items stock on hands by the ends of May 2010 and prepare the item journals as opening balances in new database for June 2010. On 1st June 2010 you should inform users to do transaction in new database.
    I hope you get the idea.. and please try this out on test system before hands.. :wink:


    I hope above can help you though..
  • vaprogvaprog Member Posts: 1,139
    You need to copy the data field by field using FieldRefs and assigning like this
    toFieldRef.VALUE := fromFielRef.VALUE;
    
    You need to skip FlowFields and FlowFilters (use FieldRef.CLASS to determine) and you need to CALCULATE BLOBS (use FieldRef.TYPE to determine).
    You can even map fields and predetermine order of assignments in conjunction with VALIDATEing fields.
  • LilithyanLilithyan Member Posts: 32
    Many Thanks vaprog!

    I could hit myself of not thinking of this, but as I still have to finish the programming, I'll refrain from doing so.

    What has me bothered is the fact that my Version 4.03 doesn't want to determine the class of the field as I'm used to it.

    When I write the code
    IF fromfieldref.CLASS = fromfieldref.CLASS::Normal THEN
    

    it gives me back the Errormessage "Not an allowed Option". The same if I write FlowField or FlowFilter instead of Normal.

    Any ideas why?

    Ciao,

    Lilithyan
  • kapamaroukapamarou Member Posts: 1,152
    You could bypass this by using
        CASE FORMAT(fieldrefer.CLASS) OF
          'Normal': BEGIN
          END;
        END;
    
    


    Or by using the EVALUATE in combination with a new option variable that will hold the values normal,flowfield,flowfilter.
Sign In or Register to comment.