Skip to Content
0
Jan 06, 2012 at 10:27 PM

Identify the TYPE using CL_ABAP_DATADESCR

2224 Views

we have a custom field ROLE with the Data element as ZDOA_ROLE in a table ZTABLE.

CODE SAMPLE 1

data gs_comp TYPE abap_componentdescr.

gs_comp-type ?= cl_abap_datadescr=>describe_by_data( 'ROLE' ).

gs_comp-name = gs_comp-type->get_relative_name( ).

when i write the above code, the name is blank.

CODE SAMPLE 2

do_type = cl_abap_datadescr=>describe_by_name( 'ROLE' ).

it dumps, stating ROLE type is not available

CODE SAMPLE 3

do_type = cl_abap_datadescr=>describe_by_name( 'ZDOA_ROLE' ).

it returns the type is ZDOA_ROLE.

"--NOT USEFUL because i cannot pass the Data element, I can only pass Field name

Priority is to find the type from the Field.

Can any body suggest me, a better way to get the Type of the Field and not by the Data element ?