Hi folks,
I use dataport to export data in the file. I have records to export and one of the field has a same value in a few records but I would like to export only one record according to that filed. How can I do this? How can I tell dataport to export only one record if value in fileds is the same.
Thanks.
Zac
0
Answers
I would hold the printed records in a temporary table. and compare the new record before printing to the temp table.
If there is a match then skip the record.
|To-Increase|
For example, if you want to export records from G/L Entry, but only one record per G/L Account number, you can do this (Yes, I know this is a bad example, but it will illustrate the technique).
OnBeforeExportRecord:
IF "G/L Entry"."G/L Account No." = LastAccountNo THEN
CurrDataport.SKIP
ELSE
LastAccountNo := "G/L Entry"."G/L Account No."
You can save whatever the comparison criteria you want to avoid duplicates.
One other thing - you have to "force" a key mismatch on the first record. So put something like this in the
OnPreDataItem trigger
The example assumes you want to export the FIRST record that you encounter. You can make the code more sophisticated if that's not what you want.
LastAccountNo := 'X0X0X0X0X0X0X0X'; // i.e. something that you know will not match any of your keys.
Thanks rsaritzky for your observation. I was also thinking to do that but I write in more files it the same time so if I skip dataport iteration then I will lose recordset to handle with it for others files.
There are always adaptations that have to be made, but even if you're looping through recordsets, you should be able to skip the export at the right time. I'm happy to look at your existing dataport if you want.