| Customizing
Error Service Behavior By
default, PFC displays the error message and stops
the application, irrespective of the user
response. For example, if you display Abort,
Ignore
buttons and the user clicks on the
"Ignore" button, the application still
stops instead of continuation. This is because,
PFC is not trapping the users response,
instead, its blindly halting the
application. You can see this code in the
pfc_n_cst_AppManagers 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 the code from
the ancestor into the descendants event.
Change the following line of code:
inv_error.of_message('pfc_systemerror',
ls_msgparm)
to trap the return code of the function, as
shown below:
li_rc
= inv_error.of_message('pfc_systemerror',
ls_msgparm)
Act depending on the function return code as
shown below. The function returns the number of
the button the user clicked. ( Starts from 1 from
left. )
If li_rc = 1 Then
this.event pfc_exit()
Else
Return
End If
The above code is just an example. Just by
knowing the clicked button number, you cant
act, because, you really dont 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 one of these buttons are used to the
message in the database? If you are using the
same icons for any error throughout the
application, then its easy to code. If your
application is using different icons depending on
the error, then you can call the of_Message()
function with all the parameters. This function
is overloaded and has many flavors. If you use
the following format, you know which icon the
user clicked exactly.
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 with the second
occurrence of %s,
and so on.
|