編集

次の方法で共有


DataTransfer.AddJoin(Integer, Integer) Method

Version: Available or changed with runtime version 10.0.

Adds a field pair to be used to create a join condition which determines which rows to transfer, optional for same table transfers.

Syntax

 DataTransfer.AddJoin(SourceField: Integer, DestinationField: Integer)

Parameters

DataTransfer
 Type: DataTransfer
An instance of the DataTransfer data type.

SourceField
 Type: Integer
The source table field.

DestinationField
 Type: Integer
The destination table field.

Remarks

The DataTransfer object can only be used in upgrade code and it will throw an runtime error if used outside of upgrade codeunits.

Use this method to create a join condition between tables when copying fields from one table to the other. For more information, see Transferring Data Bewteen Tables.

This method isn't needed when copying within the same table.

Example

In this example, you have two tables, Source and Destination. You're planning on obsoleting field S3 in the Source table. But before you do, you want to copy some values of S3 into the field D3 of the Destination table. Specifically, you only want to copy field S3 in rows where field S2 is equal to A.

local procedure CopyFields()
var
    dt: DataTransfer;
    dest: Record Destination;
    src: Record Source;
begin
    dt.SetTables(Database::Source, Database::Destination);
    dt.AddFieldValue(src.FieldNo("S3"), dest.FieldNo("D3"));
    dt.AddSourceFilter(src.FieldNo("S2"), '=%1', 'A');
    dt.AddJoin(src.FieldNo("PK"), dest.FieldNo("PK"));
    dt.CopyFields();
end;

DataTransfer Data Type
Getting Started with AL
Developing Extensions