Import of a Composite Data Entity with a new (self created) key

I have a header / lines scenario for which I created a Composite Data Entity.
I will get the same information multiple times, and each time I want to insert this data into my header/lines tables.

I create a number sequence, which should fetch a value for the header data during import.
The lines should of course reference the header by using that number sequence value.

Where can/should I insert the number sequence value?
If I could add it to the headerStaging table, I could reference it in linesEntity.mapEntityToDataSource and fetch that value. But I do not see the entry point for adding values during the insert into the headerStaging table.

I I add the value to the header table in headerEntity.mapEntityToDataSource, how can I fetch that value in linesEntity.mapEntityToDataSource?

The last sentence should of course begin with “If I add the value…”.

I assume you have another field that you use to link header and lines in the composite entity and you can use this relation to find staging lines for a staging header. Therefore you can import staging header and lines, assign a number from number sequence and then write it to staging records.

It can be done in postGetStagingData() method. For example, look at postGetStagingData() in VendorInvoiceHeaderEntity and VendorInvoiceLineEntity.

Thanks, this works mostly as expected.

Some elaborations for those having the same problem: postGetStagingData is not included in the override methods, but can nevertheless be overwritten.

postGetStagingData() is executed after all staging tables are filled, so overwriting it on the parent entity of the composite was enough to update all staging data with the same number sequence value.

Transferring that value from staging into target took me some time to figure out:

Only those fields are transferred, that existed when the data import and its field mapping was created. So during creation, I added an empty journalId element to the xml, to include it in the field mapping.

Afterwards, the field does not have to exist on the imported xml files - the self generated sequence number value will be transferred…

Instead of adding a field to the xml-file, one can also change the field mapping of the import job, and add the the required field manually with the flag “auto-generated” set. Then the data will also be transferred from staging to target table.