12-18-2018 11:58 AM
Hello experts,
Here i have a table with single column which contains "views name". Based on the view name I tried to create a table.
Code:
loop itab into wa.
lv_vname = wa-view_name.
* Get a structure of view name
ro_struc_descr ?= cl_abap_typedescr=>describe_by_name( lv_vname ).
lt_comp = ro_struc_descr->get_components( ).
APPEND LINES OF lt_comp TO lt_tot_comp.
* Create new type from component table
lo_new_type = cl_abap_structdescr=>create( lt_tot_comp ).
* Create new table type
lo_table_type = cl_abap_tabledescr=>create( lo_new_type ).
* Create dynamic internal table and assign to Field Symbol
CREATE DATA w_tref TYPE HANDLE lo_table_type.
<---some logic---------->
endloop.
from the above code, "lv_vname" is a view name.
suppose if my table has a invalid view name means my program through the dump error.
error:
EXCEPTION CONDITION " Type_NOT_Found"
it won't process other values.
i want to capture that error and except that i want to process all the data to create dynamic table.
Any suggestions please...
Thanks in advance
12-18-2018 12:33 PM
Hi,
If the method has any exception, you can catch the exception by below format.
ro_struc_descr ?= cl_abap_typedescr=>describe_by_name( lv_vname ).
Replace above one with below one,
cl_abap_typedescr=>describe_by_name( exporting p_name = lv_vname
receiving p_descr_ref = ro_struc_descr
exceptions type_not_found = 1
others = 2 ).
if ( sy-subrc <> 0 ).
" process your exception
else.
" main logic when subrc eq 0
endif.
Thanks..
12-18-2018 12:33 PM
Hi,
If the method has any exception, you can catch the exception by below format.
ro_struc_descr ?= cl_abap_typedescr=>describe_by_name( lv_vname ).
Replace above one with below one,
cl_abap_typedescr=>describe_by_name( exporting p_name = lv_vname
receiving p_descr_ref = ro_struc_descr
exceptions type_not_found = 1
others = 2 ).
if ( sy-subrc <> 0 ).
" process your exception
else.
" main logic when subrc eq 0
endif.
Thanks..
12-18-2018 1:05 PM
What did you try, from try/catch/endtry wrapping the call to use of addition exceptions in the method call?