08-20-2007 10:48 AM
Hello ABAP-Experts,
I have a problem in understanding how to catch exceptions after calling method cl_gui_cfw=>flush.
Why calling "flush": Well, otherwise if there is no FLUSH after directory_create (for example) is called, the value of rc (methods internal return code) is checked prematurely.
Here my attempt:
"----
" Calling method directory_create
call method cl_gui_frontend_services=>directory_create
exporting
directory = tmpdir
changing
rc = returncode
exceptions
directory_create_failed = 1
cntl_error = 2
error_no_gui = 3
directory_access_denied = 4
directory_already_exists = 5
path_not_found = 6
unknown_error = 7
not_supported_by_gui = 8
wrong_parameter = 9
others = 10.
sy-subrc = my_sy_subrc " <=== ???!
"----
" Calling method flush
call method cl_gui_cfw=>flush
exceptions
cntl_system_error = 1
cntl_error = 2
others = 3.
"----
sy-subrc = my_sy_subrc2 " <=== ???!
Now my problem: How can I be sure to catch the execeptions of method cl_gui_frontend_services=>directory_create (1 to 10), since the flush method has its own exceptions (1 to 3)? After calling flush, I think they are overwritten by the flush exception -- checking them before the flush makes no sense, because the method is probably not executed (Automation queue).
(Background: I am writing test-programs for some frontend methods, and want to catch all possible exceptions and to write them in a internal table, so that I can see which method crashes.)
I hope my problem is clear and someone can clarify.
Thanks a lot in advance
Regards
Jasmin
08-21-2007 9:50 AM
Hi,
You can rely on the SUBRC after calling the directory_create because the flush is already present in it
Look at the code of the method :
> call method handle->call_method
> exporting
> method = 'CreateDirectory'
> p1 = directory
> p_count = 1
> queue_only = ' '
> importing
> result = rc
> exceptions
> others = 1.
>
> if sy-subrc <> 0.
> raise cntl_error.
> endif.
>
> call method cl_gui_cfw=>flush
> exceptions
> cntl_system_error = 1
> cntl_error = 2
> others = 3.
> if sy-subrc <> 0.
> raise cntl_error.
> endif.