| Home | Previous Lesson: Sourcing Error Messages Next Lesson: Error Service - e-Mail Notifications |
By default, PFC displays the error message and stops the application, irrespective of the users response. For example, if you display Abort, Ignore buttons and the user clicks on the "Ignore" button, the application still stops instead of continuing. This is because, PFC is not trapping the user�s response, instead, it�s blindly halting the application. You can see this code in the pfc_n_cst_AppManager�s pfc_SystemError event.
What we need to do is override this event in the n_cst_AppManager. If you want to use the existing code, just copy code from the ancestor into the descendant�s event. Change the following line of code:
inv_error.of_message('pfc_systemerror', ls_msgparm)
This traps the return code of the function, as shown below:
li_rc = inv_error.of_message('pfc_systemerror', ls_msgparm)
Act depending on the return code of the function, as shown below. The function returns the number of the button the user clicked (start 1 from left).
If li_rc = 1 Then
this.event pfc_exit()
Else
Return
End If
The above code is only an example. You can�t act just by knowing the clicked button number, because, you really don�t know the meaning of the button. For example, return code 2 would mean "No" in the "YesNoCancel" and "Retry" in the "AbortRetryIgnore". How do you know which button is being used? If you are using the same icons for all errors throughout the application, then it�s easy to code. If your application is using different icons depending on the error, then you can call of_Message() function with the parameters. This function is overloaded. If you use the following format, you know exactly which icon the user clicked.
li_rc = inv_Error.of_Message("Title", &
"Message", StopSign!, &
AbortRetryIgnore!, 1, 5, TRUE, TRUE)
The function of_message() at the pfc_n_cst_error object is overloaded. One flavor of that function takes a string array as the second parameter. For example, if you have defined an error message with three parameters, then you can declare an unbound string array and load the parameters into the array and send the array to the function:
ls_msgparm[1] = "Parameter 1"
ls_msgparm[2] = "Parameter 2"
ls_msgparm[3] = "Parameter 3"
li_rc = inv_error.of_message('pfc_systemerror', ls_msgparm)
PFC takes care of placing the parameters into correct positions in the error message, first parameter will replace the first occurrence of %s and the second parameter, the second occurrence of %s, and so on.
| Home | Previous Lesson: Sourcing Error Messages Next Lesson: Error Service - e-Mail Notifications |