Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

I need a mixture between XSEQUENCE and CSEQUENCE

rainer_hbenthal
Active Contributor
0 Likes
801

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?

2 REPLIES 2
Read only

Former Member
0 Likes
577

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.

Read only

0 Likes
577

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.