TransferFields to temp, modify and replace original!?

pettalpettal Member Posts: 20
Hi All,

This might be simple but my head is firmly wedged this morning! ](*,)

I basically have the Comment Line table and some of the data in it is duff and needs to be modified.

I think I need to:
Filter and duff records to a temp table
Modify duff records in temp table
Copy modified records back from temp table into Comment Line table

But for the life of me I can't get anything to work.

Pointers, examples...general life guidance appreciated! 8-[

Answers

  • TomasTomas Member Posts: 420
    Use a second (not Temporary) variable for comment line: "Temp Comment Line".

    Then you will be able to:
    - Filter records on your "Comment Line". Transferfields to "Temp Comment Line".
    - Modify "Temp Comment Line".
    - Use MODIFY function.
    - Go to next record on "Comment Line".
  • pettalpettal Member Posts: 20
    Thanks Tomas

    This what I got so far.... and it doesn't work!??!

    "Comment Line".SETFILTER("Comment Line"."Table Name",'97');
    TempTable.TRANSFERFIELDS("Comment Line");
    TempTable."Table Name" := TempTable."Table Name"::"Job";
    TempTable.Modify;

    It's sort of there...but is deffo missing something.... like maybe a brain cell!? :mrgreen:
  • TomasTomas Member Posts: 420
    I am not sure, why you have such data (97 in Table Name field in Comment Line table), however if I remember correctly, you cannot use MODIFY function on fields which are used in active keys.

    You could do something like this:

    "Comment Line".SETFILTER("Comment Line"."Table Name",'97');
    IF "Comment Line".FIND('-') THEN REPEAT
       TempTable.TRANSFERFIELDS("Comment Line"); 
       "Comment Line".DELETE(FALSE);
       TempTable."Table Name" := TempTable."Table Name"::Job; 
       TempTable.INSERT(FALSE);
    UNTIL "Comment Line".NEXT = 0;
    
  • pettalpettal Member Posts: 20
    Tomas you are a star! :D
  • TomasTomas Member Posts: 420
    I just wander, how did you manage to put 97 into Table Name field? :)
  • pettalpettal Member Posts: 20
    Hmmm I'm pretty sure it wasn't me.... I think :roll:

    Probably a coding "fudge" for something a long time ago and no one has noticed.... until now.

    Thanks once again!
Sign In or Register to comment.