Framework EDI Reference. Methods and Properties
ediWarnings. OverrideErrorDescription

Override the default error description of an error code with a custom error code.

Syntax:

Parameters:

Returns:

Returns 1 if the override succeeds; otherwise 0 if it fails.

Remarks:

An error code generated may not have the same exact error description each time it is generated, but may differ depending on where, and what, may have caused the error.  However, an error description for an associated error code always follows a format containing input parameters that provide specific information about the error. For example, the error code 6016 may generate the following description:

No data in mandatory data element '92' in 'Data Segment' 'BEG'

which actually follows the format:

No data in mandatory data element '%1' in '%2' '%3'

where %1, %2, %3 are placeholders for specific information provided by the operation. Like the example, default error descriptions have the following properties:

  1. May or may not have input parameters.
  2. If input parameters exist, they are indicated by single quotes.
  3. Each input parameter in quotes are percent-labeled (%) in the order that they occur (example %1, %2, etc.).  In the example above, '92' is %1, 'Data Segment' is %2 and 'BEG' is %3.

NOTE: The error messages above are new to the version of this program that provide this method, or to Edidev_SEC.dll that is version 5.5.565.255 or later.

The input parameters may be placed in a different order when customizing the error description. For example, following the example above, the new error description can be specified as follows:

%2 %3 has no data in element %1.

Consequently, when the operation generates this error, it would be displayed as follows:

Data Segment BEG has no data in element 92.

Note that because no single quotes were provided in the new error description, no quotes are therefore displayed.  Single quotes are provided only in default error messages as an indication that input parameters exist.

 

Example

Dim oEdiDoc As Fredi.ediDocument
Dim oSchemas As Fredi.ediSchemas
Dim oSchema As Fredi.ediSchema
Dim oWarnings As Fredi.ediWarnings
Dim oWarning As Fredi.ediWarning
Dim i As Integer
Dim sErrorsStr As String

' Create instance of Framework EDI.
Set oEdiDoc = New Fredi.ediDocument

' Get the warnings object
Set oWarnings = oEdiDoc.GetWarnings

' This sample is expected to generate error 6016.
' The error message for 6016 is overridden as follows:
oWarnings.OverrideErrorDescription 6016, "%2 %3 has no data in mandatory element %1"


' Disable standard reference library.
Set oSchemas = oEdiDoc.GetSchemas
oSchemas.EnableStandardReference = False

' Load the schema that the EDI file will use.
Set oSchema = oEdiDoc.LoadSchema(App.Path & "\ASCX12_850.SEF", Schema_Standard_Exchange_Format)

' Process the EDI file.
oEdiDoc.LoadEdi App.Path & "\SampleEdi.X12"

If oWarnings.Count > 0 Then

For i = 1 To oWarnings.Count

Set oWarning = oWarnings.Warning(i)

sErrorsStr = sErrorsStr & oWarning.Description & vbCrLf

Next

MsgBox sErrorsStr, vbDefaultButton1, "Custom Error Message"

Else

MsgBox "No errors found."

End If