sourceTable.OPEN(objectId, FALSE, fromCompany); sourceFieldFilter := sourceTable.FIELD(54); sourceFieldFilter.SETFILTER('FALSE'); IF sourceTable.FINDSET THEN BEGIN targetTable.OPEN(objectId, FALSE, toCompany); REPEAT targetTable.INIT; FOR intCounter := 1 TO sourceTable.FIELDCOUNT() DO BEGIN sourceField := sourceTable.FIELDINDEX(intCounter); targetField := targetTable.FIELD(sourceField.NUMBER); targetField.VALUE(sourceField.VALUE); IF FORMAT(sourceField.CLASS) <> 'FlowField' THEN BEGIN targetTable.MODIFY(FALSE); COMMIT; END; END; UNTIL sourceTable.NEXT = 0; END; targetTable.CLOSE(); sourceTable.CLOSE();
fromItem.INIT; fromItem.CHANGECOMPANY(companyName); fromItem.SETFILTER(fromItem.Blocked, 'FALSE'); IF fromItem.FINDSET THEN BEGIN REPEAT IF toItem.GET(fromItem."No.") THEN BEGIN toItem := fromItem toItem.MODIFY; END; COMMIT; UNTIL fromItem.NEXT = 0; END;
toItem.Fields1: = fromItem.Fields1; toItem.Fields2: = fromItem.Fields2; toItem.Fields3: = fromItem.Fields3; .... .... toItem.Fields200: = fromItem.Fields200; toItem.MODIFY;
toItem.TRANSFERFIELDS(fromItem, FALSE);instead of
toItem := fromItem;
Answers
Your "another" solution looks correct and should work.
Do you execute this code in the correct company?
Maybe, you have to add:
Thanks for the tip.
I am sure he execute in the correct company. System has a problem with MODIFY function, if the record already exists - as if it would also like to modify the key (??).
I get the following message:
If performance is still an issue (which it should'nt be with the transferfields approach) try committing the changes every 1000 records (assuming you sync that many).
/Wisa
Thanks, it works