How to customize the trace log file for errors and success messages

By | February 27, 2024

Trace files are extensively utilized in Sage X3 software, particularly during lengthy processes like Automatic Invoice Validation or Automatic Work Order Release. When a trace file is displayed, error lines appear in red text, allowing you to navigate through the errors.

To customize a trace file, follow the below steps:

Step 1: We need to open the trace file using the ‘OUVRE_TRACE’ function, as shown in the code below.

New Stuff: How to show comma-separated value for single or multiple fields in Sage X3 reports using crystal report

[Open_Trace_Log_File_Code]
[Open_Trace_Log_File_Code]

Step 2: After opening the log file, we can insert any messages as per our requirements.

Note: To customize a trace file, it’s essential to understand the color codes associated with different messages:

0: Used to display messages in black color.
1: Used to indicate error messages in red color.
-1: Used to present messages in green color.
-2: Used to showcase messages in blue color.

Step 3: Insert a message line using the ‘ECR_TRACE’ function. This function takes two parameters: the first parameter contains the message, and the second contains the color code, as shown in the code below.

[Inserting_Message_Trace_Log_File_Code]
[Inserting_Message_Trace_Log_File_Code]

Step 4: After inserting messages, we need to close this trace file using the ‘FERME_TRACE’ function.

[Close_Trace_Log_File_Code]
[Close_Trace_Log_File_Code]

Step 5: Now we can display our trace log file using the ‘LEC_TRACE’ function.

[Display_Trace_Log_File_Code]
[Display_Trace_Log_File_Code]

Step 6: If you want to delete this trace file, you can use the ‘SUPP_TRACE’ function.

[Delete_Trace_Log_File_Code]
[Delete_Trace_Log_File_Code]

After executing this script, you can view the log file as depicted in the screenshot below.

Note: If you added an error message using the code ‘1’ in the ‘ECR_TRACE’ function, you will receive a popup indicating the number of errors before the log file.

[Number_Of_Errors]
[Number_Of_Errors]
[Log_Reading_Screen]
[Log_Reading_Screen]

By following the above steps, we can customize the trace log file for errors and success messages.