‎2008 Nov 19 11:36 AM
Hi,
i would like to have a method which accepts XSEQUENCE or CSEQUENCE or to be more exact it should axxept XSTRING or STRING.
The only type i can see which covers that is ANY. But how to react if a structure or a table is delivered? I would like to raise an exception.
So, how can i check if the type is string or xstring?
‎2008 Nov 19 1:26 PM
Hi Rainer,
There might be some other simple way..... but one way is to use RTTI service...
example - an exception is triggered if passed data obj is not of elementary type.
DATA : gv_string TYPE string,
gv_xstring TYPE xstring,
gs_struc TYPE makt,
gt_table TYPE TABLE OF makt,
go_data_ref TYPE REF TO cl_abap_elemdescr.
TRY.
go_data_ref ?= cl_abap_typedescr=>describe_by_data( gv_string ). " safe
go_data_ref ?= cl_abap_typedescr=>describe_by_data( gv_xstring ). " safe
go_data_ref ?= cl_abap_typedescr=>describe_by_data( gs_struc ). " triggers exception
go_data_ref ?= cl_abap_typedescr=>describe_by_data( gt_table ). " triggers exception
CATCH cx_sy_move_cast_error.
BREAK-POINT. " it is a struc or table
ENDTRY.Cheers,
Jose.
‎2008 Nov 20 7:36 AM
Hi Jose,
the solution was rather simple
i'm now using data type simple which only allows flat data types plus string and xstring.
Inside the method i'm checking the type with old fashioned describe statement.