Use
To create a log file that traces errors that occur when you use the IDoc Connector for XML component with your application, you use the ITrace object.
You can use this log file to communicate problems to SAP support regarding the use of the component.
You can also log errors that occur within your application into the same file.
Procedure
To log IDoc Connector for XML errors:
The TraceLevel property uses an enumerated type, with the following values:
Trace Level |
Constant |
Meaning |
0 |
NOMESG |
Nothing is traced |
1 |
ERRMESG |
Only errors are traced |
2 |
MESG |
Both errors and informational messages are traced |
Notice that using trace level 2 includes both messages and errors.
To log errors within your application to the same log file:
If you specify trace level… |
You can use… |
1 or 2 |
either WriteErrMsg (without a timestamp) or WriteErrMsgTime (with a timestamp) |
2 |
either WriteMsg or WriteMsgTime |
Notice that if you specify trace level 2, both errors and messages are traced, and therefore you can use both WriteErrMsg and WriteMsg to log both errors and messages. However, when you specify trace level 1, only errors are traced, so using WriteMsg or WriteMsgTime does not result in any log entry.
Example
The following example logs both errors and messages that occur when using the IDoc Connector for XML component:
Dim oTrace As New ITrace
oTrace.FileOpen("C:\temp\log1.txt")
oTrace.TraceLevel = 2
Set idoc.Trace = oTrace