‎2007 Oct 19 2:10 PM
Hello,
I will describe a data element rtti.
With data type I mean:
A data element which i saved in the DDIC with data type DEC and a length of 15 with 4 decimal plases.
This means I will create a method with a importing parameter type "DATA" (or any) and a exporting parameter of type "dfies"
DFIES is the line type of DDFIELDS.
I have implemented already a method for describing a structure.
I have do tihs as following:
- create a method with incoming parameter type any and exporting parameter type ddfields
- call cl_abap_typedesc=>describe_by_data (my structure as imput)
- I receive a reference
- Cast the reference to type cl_abap_structdescr
-call cl_abap_structdescr->get_ddic_field_list
- I receive a list with all values for each attribiute of the structure! It works fine!
Now I want to do the same for only a simple data type:
I have also implemented the call cl_abap_typedesc=>describe_by_data.
But which is the correct casting type for data elements?
I receive also a type cl_abap_structdesc. But after casting I receive a dump because the structue has no fieldlists and so on.
If i use a other type for casting, for example cl_abap_elemdesc I receive the dump by the casting.
How can I get the describtion of a data element by RTTI?
I think the correct way must be by using type cl_abap_elemdesc, because there is a method which returns a structure of the type DFIES, but how must I cast this type?
Thanks for help
Regards
Christian
‎2007 Oct 19 2:59 PM
Hello Christian
Have a look at the sample report<b> ZUS_SDN_RTTI_ELEMENT</b>.
*&---------------------------------------------------------------------*
*& Report ZUS_SDN_RTTI_ELEMENT
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZUS_SDN_RTTI_ELEMENT.
TABLES: dfies.
DATA:
gs_dfies TYPE dfies,
go_typedescr TYPE REF TO cl_abap_typedescr,
go_elemdescr TYPE REF TO cl_abap_elemdescr.
START-OF-SELECTION.
go_typedescr = cl_abap_typedescr=>describe_by_data(
dfies-tabname ).
go_elemdescr ?= go_typedescr.
gs_dfies = go_elemdescr->get_ddic_field( ).
WRITE: / gs_dfies.
END-OF-SELECTION.Regards
Uwe
‎2007 Oct 19 2:59 PM
Hello Christian
Have a look at the sample report<b> ZUS_SDN_RTTI_ELEMENT</b>.
*&---------------------------------------------------------------------*
*& Report ZUS_SDN_RTTI_ELEMENT
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZUS_SDN_RTTI_ELEMENT.
TABLES: dfies.
DATA:
gs_dfies TYPE dfies,
go_typedescr TYPE REF TO cl_abap_typedescr,
go_elemdescr TYPE REF TO cl_abap_elemdescr.
START-OF-SELECTION.
go_typedescr = cl_abap_typedescr=>describe_by_data(
dfies-tabname ).
go_elemdescr ?= go_typedescr.
gs_dfies = go_elemdescr->get_ddic_field( ).
WRITE: / gs_dfies.
END-OF-SELECTION.Regards
Uwe
‎2007 Oct 23 9:52 AM
Thanks a lot for help.
I don't know exactly what I have make wrong but it works, now.