‎2012 Sep 12 5:59 PM
Is there any way to get the length specified for an element.
say if i declare a variable in a global structure
data m type c length 3.
is there any way for me to prgramtically retrieve this length.
Moderator message: please search for information before posting.
Message was edited by: Thomas Zloch
‎2012 Sep 12 7:01 PM
You have to use RTTI.
ABAP gives you classes to handle it.
Try the following code:
=====================================
REPORT ZVUB_RTTI_02.
DATA: my_var TYPE c LENGTH 15.
DATA: lr_descr TYPE REF TO CL_ABAP_TYPEDESCR.
DATA: li_length TYPE I.
CALL METHOD cl_abap_typedescr=>describe_by_data
EXPORTING
p_data = my_var
receiving
p_descr_ref = lr_descr.
li_length = lr_descr->LENGTH.
WRITE: 'My Var length is ', li_length.
=====================================
This is it!
Faca na Caveira.