Quantcast
Channel: SCN : All Content - All Communities
Viewing all articles
Browse latest Browse all 3353

Check if variable is "numeric type"

$
0
0

Hello,

I need to check if dynamic variable is typed as "numeric".

Only solution I found so far is this:

lr_typedescr = cl_abap_typedescr=>describe_by_data( <lfs_comp>).

IF  lr_typedescr->type_kind = CL_ABAP_TYPEDESCR=>TYPEKIND_INT OR

     lr_typedescr->type_kind = CL_ABAP_TYPEDESCR=>TYPEKIND_INT1 OR

     lr_typedescr->type_kind = CL_ABAP_TYPEDESCR=>TYPEKIND_INT2 OR

     lr_typedescr->type_kind = CL_ABAP_TYPEDESCR=>TYPEKIND_NUM OR

     lr_typedescr->type_kind = CL_ABAP_TYPEDESCR=>TYPEKIND_PACKED OR

     lr_typedescr->type_kind = CL_ABAP_TYPEDESCR=>TYPEKIND_DECFLOAT OR

     etc... there are more constants for numeric types...

    

     "<lfs_comp> is numeric    


ENDIF.

Is there any better solution than checking for all these constants?

There is constant cl_abap_typedescr=>typekind_numeric but seems not working...

 

NOTE: I do not want check content of variable. String can contain number but string is not numeric type.


Viewing all articles
Browse latest Browse all 3353

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>