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

RTTS example

Former Member
0 Likes
844

Hi Experts,

Am practing one RTTS example but am getting dump for the below example when we execute.

when i use describe_by_data( value ) am getiing output

when i use describe_by_name( value ) am getting runtime error.

Please explain what is the excat diff between describe_by_data( ) and describe_by_name( ) methods ?

data: value type i.

data: obj_ref type REF TO cl_abap_typedescr.

START-OF-SELECTION.

*obj_ref  = cl_abap_typedescr=>describe_by_data( value  ).
obj_ref = cl_abap_typedescr=>describe_by_name( value ).

  WRITE: / 'Typename:', obj_ref->absolute_name.
  WRITE: / 'Kind    :', obj_ref->type_kind.
  WRITE: / 'Length  :', obj_ref->length.
  WRITE: / 'Decimals:', obj_ref->decimals.

5 REPLIES 5
Read only

RaymondGiuseppi
Active Contributor
0 Likes
739

Just read documentation of the methods with its samples.

descr_ref = cl_abap_typedescr=>describe_by_name( 'MY_TYPE' ). " name of type/data

descr_ref = cl_abap_typedescr=>describe_by_data( my_data ). " type/data

Regards,

Raymond

Read only

0 Likes
739

Hi Raymond,

data: value type i.

obj_ref  = cl_abap_typedescr=>describe_by_data( value  ).

when we use above statement am getting correct output.(BELOW OUTPUT)

WRITE: / 'Typename:', obj_ref->absolute_name.   ---->\TYPE=I

  WRITE: / 'Kind    :', obj_ref->type_kind.            ------> I

  WRITE: / 'Length  :', obj_ref->length.                ------->4

  WRITE: / 'Decimals:', obj_ref->decimals.         -------->0

obj_ref  = cl_abap_typedescr=>describe_by_name ( value  ).

when i use above stmt am getting runtime dump.

obj_ref  = cl_abap_typedescr=>describe_by_name ( 'VALUE'  ).

when i use above stmt am not getting exact output.(BELOW OUTPUT).it is supposed to display interger type as per my guess

WRITE: / 'Typename:', obj_ref->absolute_name.   ---->\TYPE=C

  WRITE: / 'Kind    :', obj_ref->type_kind.            ------> C

  WRITE: / 'Length  :', obj_ref->length.                ------->32

  WRITE: / 'Decimals:', obj_ref->decimals.         -------->0

 

Please correct my code any one..i will reward

Moderator Message - Asking/offering points is against the forums' Rules of Engagement.

Message was edited by: Suhas Saha

Read only

0 Likes
739

Hi All,

data: value type i.

obj_ref  = cl_abap_typedescr=>describe_by_data( value  ).

when we use above statement am getting correct output.(BELOW OUTPUT)

WRITE: / 'Typename:', obj_ref->absolute_name.   ---->\TYPE=I

  WRITE: / 'Kind    :', obj_ref->type_kind.            ------> I

  WRITE: / 'Length  :', obj_ref->length.                ------->4

  WRITE: / 'Decimals:', obj_ref->decimals.         -------->0

obj_ref  = cl_abap_typedescr=>describe_by_name ( value  ).

when i use above stmt am getting runtime dump.

obj_ref  = cl_abap_typedescr=>describe_by_name ( 'VALUE'  ).

when i use above stmt am not getting exact output.(BELOW OUTPUT).it is supposed to display interger type as per my guess

WRITE: / 'Typename:', obj_ref->absolute_name.   ---->\TYPE=C

  WRITE: / 'Kind    :', obj_ref->type_kind.            ------> C

  WRITE: / 'Length  :', obj_ref->length.                ------->32

  WRITE: / 'Decimals:', obj_ref->decimals.         -------->0

I dont know the reason why it is displaying like that?

Read only

0 Likes
739

Run below statement and usage would be clear.

obj_ref  = cl_abap_typedescr=>describe_by_name( 'SFLIGHT'  ).

You have to pass a type name, either from dictionary or one defined in program using TYPES statement.

Read only

0 Likes
739

Hi Srinad,

this describe_by_name will describe types which are in the datadictionary (SE11). The data element 'VALUE'. So in your last example the data element VALUE will be described, instead of the instance variable 'value'.

Best,

Sander