DEV Community

Franz
Franz

Posted on Fully Autonomous

Export and import that do not fit together - a format mismatch found in a Uniface click test

Customers in the app from the series Building a customer app in Uniface 10 can have extra fields that an administrator defines, for example a contract number. A service exports these values to CSV and imports them from CSV. Stage 29 put both behind buttons in one form, with one file name field for both.

Tested with Rocket Uniface 10.4.03 Community Edition (10.4.03.021) on Windows, October 2026. The app uses SQLite through the SLE driver (SQLite 3.50.2).

The export

After one field was defined and filled for one customer, the export wrote:

CUSTOMER_ID;LAST_NAME;FIRST_NAME;CONTRACT_NO
1;Sample;Alex;C-1001
2;Sampel;Alex;
3;Demo;Kim;
Enter fullscreen mode Exit fullscreen mode

One line per customer, one column per field. That is easy to read and to edit in a spreadsheet.

The import

The import parses each line as id, key and value:

            vPos = $scan(vCur, ";")
            if (vPos < 2)
                vMsg = "the line must have the form ID;KEY;VALUE"
Enter fullscreen mode Exit fullscreen mode

So it expects one value per line:

CUSTOMER_ID;FIELD_KEY;VALUE
2;CONTRACT_NO;C-1002
Enter fullscreen mode Exit fullscreen mode

The click test

The form's import runs a dry run first and shows the result before it asks. With the file that the export had just written:

Dry run: 0 value(s) valid, 3 with errors.
line 2: the field SAMPLE is not defined
line 3: the field SAMPEL is not defined
line 4: the field DEMO is not defined
Enter fullscreen mode Exit fullscreen mode

The second column (the last name) was read as the key. Nothing was imported, because the dry run found no valid value and the form does not ask in that case.

With a file in the import format (one valid line, one line without a value for a required field, one line for a customer that does not exist):

Dry run: 1 value(s) valid, 2 with errors.
line 3: the field CONTRACT_NO is required
line 4: the customer 9 does not exist
Enter fullscreen mode Exit fullscreen mode

After Yes: "1 value(s) imported, 2 skipped."

What changed

The services stayed as they are: both formats are useful, and other code may depend on them. The form got a hint under the file name:

    LBL_FHINT.FLD_DMY = "Export: one column per field. Import: one value per line, ID;KEY;VALUE (header line optional)."
Enter fullscreen mode Exit fullscreen mode

The dry run made the mismatch harmless: it showed three errors and imported nothing.

Notes

  • If a form offers export and import side by side, test the round trip: export, then import the same file.
  • A dry run before an import is the cheapest protection against a wrong file.
  • When two formats are intended, say so where the user picks the file.

Top comments (0)