|
Imports Supplier cards without user interface. |
|
|
VARIANT_BOOL Import ( BSTR bsDescFile, BSTR bsDataFile, LONG lImportFromItem, VARIANT_BOOL bInsert, VARIANT_BOOL bUpdate, VARIANT_BOOL bExclusive, VARIANT* pvImportedItems, VARIANT* pvErrorMessage ) |
|
|
Parameters | bsDescFile | [in] The full path of the descriptive file to use for the import. The descriptive file determines the logical structure of the data file and the fields which are to be imported. See the Venice help for a full explanation of the layout of this file. | bsDataFile | [in] The full path of the text file to be imported. This file contains the actual data to be imported and must match the logical structure defined in the descriptive file. | lImportFromItem | [in] It is possible to skip items in the data file and start actual importing from a specific item. An 'item' in this case is each individual entity (either 1 document or 1 card). Example: while importing sales documents, each customer card being imported is considered an item and so is each sales document. The separate entry or article lines of a document have no meaning on their own and are thus not considered to be 'items', they form part of the document item. This feature can be used to resume a previously interrupted import. Specify 0 or 1 to start importing from the start of the data file. | bInsert | [in] True if new records are to be inserted, false to ignore new records. | bUpdate | [in] True if existing records can be updated, false to ignore existing records. Documents can never be updated while importing, this parameter only applies to the customer or supplier cards preceding documents. | bExclusive | [in] Importing is a task that will usually require exclusive access to the files of the dossier or financial year. In other words: while importing, no other Venice modules or ClSdk objects can be active that could change or add to the same files in the same dossier or financial year. However it can be a nuisance if importing cannot continue because a user still has a module running or if a user cannot continue working because an import is currently running. Specify true to import in exclusive mode, false to import in concurrent mode, allowing other modules to continue while the import is running. Note that certain advanced features of importing documents (like ticking other documents) are only available when importing in exclusive mode. When importing in exclusive mode, all cards and documents are inserted and/or updated in transaction, they either all succeed or they don't. In concurrent mode, importing inserts and updates items as they are being processed and importing stops at the first error encountered. | pvImportedItems | [out] Returns a VARIANT, subtype LONG, containing the number of imported items. When importing in exclusive mode, returns either the total number of items in the data file or 0 if an error occured. When importing in concurrent mode, returns either the total number of items in the datafile or if an error occured, the number of items successfuly processed up to the offending item. After correcting the error in either the data file and/or the descriptive file, you can resume importing by using this return value + 1 as value for lImportFromItem. !! This parameter is only reliable if no exception was thrown during the import. !! | pvErrorMessage | [out] Returns a VARIANT, subtype BSTR, containing the error message concerning data that could not be validated. !! This parameter is only reliable if no exception was thrown during the import. !! | | Return value |
True if the complete data file was imported, in which case pvImportedItems is valid and contains the total number of items in the data file and pvErrorMessage is empty. False if only a part of the data file could be imported, in which case pvImportedItems is valid and contains the number of items that were actually imported before an error occured and pvErrorMessage contains the error message. | | Remarks |
| When returning from this method 2 situations can occur: |
|
|
The method returns (True or False) in a normal way. The data was tested successfully and the import of the data was started. It returns True if the complete data file is imported, in which case pvImportedItems is valid and contains the total number of items in the data file and pvErrorMessage is empty. It returns False if only a part of the data file could be imported, in which case pvImportedItems is valid and contains the number of items that were actually imported before an error occured and pvErrorMessage contains the error message. |
|
An exception is thrown. This means that an error occured while testing the data and that the actual import of that data was not started. In this situation, you cannot rely on the [out]-parameters pvImportedItems and pvErrorMessage because they do not contain a valid value! |
|
|
|
See Also |
|
|
|
Samples |
|
|
C++ |
|
// Import records without user interface
try
{
VARIANT vImported, vErrMsg;
if (pSuppl->Import ("C:\\Import\\Desc\\Suppl.cli", "C:\\Import\\Data\\Suppl.txt", 0, VARIANT_TRUE, VARIANT_TRUE, VARIANT_FALSE, &vImported, &vErrMsg))
{
// vImported contains the total number of imported items
// vErrMsg is empty
}
else
{
// vImported contains the number of imported items until an error occurred
// vErrMsg contains the error message that explains why the import was interrupted
// In this case importing can be restarted using parameter lImportFromItem, equal to vImported
}
}
catch (_com_error CE)
{
// Process exception
}
|
|
|
C# |
|
// Import records without user interface
try
{
object oImported, oErrMsg;
if (oSuppl.Import (@"C:\Import\Desc\Suppl.cli", @"C:\Import\Data\Suppl.txt", 0, true, true, false, out oImported, out oErrMsg))
{
// oImported contains the total number of imported items
// oErrMsg is empty
}
else
{
// oImported contains the number of imported items until an error occurred
// oErrMsg contains the error message that explains why the import was interrupted
// In this case importing can be restarted using parameter lImportFromItem, equal to oImported
}
}
catch (Exception ex)
{
// Process exception
}
|
|
|
VBS |
|
' Import records without user interface
Dim oImported, oErrMsg
On Error Resume Next
If oSuppl.Import("C:\Import\Desc\Suppl.cli", "C:\Import\Data\Suppl.txt", 0, True, True, False, oImported, oErrMsg) Then
' oImported contains the total number of imported items
' oErrMsg is empty
Else
' oImported contains the number of imported items until an error occurred
' oErrMsg contains the error message that explains why the import was interrupted
' In this case importing can be restarted using parameter lImportFromItem, equal to oImported
End If
If Err.Number <> 0 Then
' Process exception
End If
|
|
|
VB.NET |
|
' Import records without user interface
Try
Dim oImported, oErrMsg As Object
If oSuppl.Import("C:\Import\Desc\Suppl.cli", "C:\Import\Data\Suppl.txt", 0, True, True, False, oImported, oErrMsg) Then
' oImported contains the total number of imported items
' oErrMsg is empty
Else
' oImported contains the number of imported items until an error occurred
' oErrMsg contains the error message that explains why the import was interrupted
' In this case importing can be restarted using parameter lImportFromItem, equal to oImported
End If
Catch ex As Exception
' Process exception
End Try
|
|