Previous Topic

Next Topic

EDIImport - MaxBasic Function

EDIImport(Definition: String, File: String[, Clear: Boolean, Backup: Boolean, Worksheet: Variant]): Variant

Imports an EDI file called File, using an EDI Definition file called Definition.

If the optional Clear parameter is True, the import will clear the successfully imported records from the File. If the second optional parameter Backup is also True, a backup of the import file will be made.

The backup copy has the original import file name with the extension ".BAK". Previous backups of the import files will be renamed to increment the backup number ".BAK" to ".BK1", ".BK1" to ".BK2", and so on through to ".BK8" to ".BK9"; the oldest backup previously ".BK9" will drop off.

If the import file is an Excel Workbook, you can specify a Sheet Name or Sheet Number. If not specified, the Worksheet specified from the EDI Import definition file will be used.

This function returns True when the Definition and File files are found, and creates an error if either of these files are not found. This does not reflect whether the file was imported successfully, as a file can be imported with some records importing successfully and others unsuccessfully. To set the return value of the EDIImport function, set the ImportFile.Result property in the EDI Import Definition using MaxBasic code. The ImportFile.Result property defaults to True. For example: ImportFile.Result = False. See also Import Invoices Example.

The ScriptArgs function can be used with this function.

EDIImport function syntax has these named arguments:

Parameter

Description

Definition

Required. The name of the DI definition file.

File

Required. The import file name.

Clear

Optional. When True, will clear successfully imported records from the File.

Backup

Optional. When True, will create a backup copy of the File.

Worksheet

Optional. When File is an Excel Workbook, the Sheet Name or Sheet Number for import can be specified.

Note: Do not use apostrophes (') in worksheet names, as this can cause problems.

To open the file in a new Script Editor window, place the cursor in the File Name and click Ctrl+Enter, or right click to open the Context Menu, then select Open Source.

This function accepts an infinite number of arguments after the required parameters, these may be accessed using the ScriptArgs function in the Import Definition.

See Also

Import/Export Functions

Book Contents

Book Index