07-24-2010 5:53 PM
Hi all,
I am getting the exception TYPE_NOT_FOUND when I try to create a dynamic internal table using:-
DATA: gr_desc TYPE REF TO cl_abap_typedescr.
gr_desc = cl_abap_typedescr=>describe_by_name( p_field ).
The field p_field is a Z-field inside a DB table, (e.g. a user added field in MARA). The statement fails at that point and gives a runtime exception. Any suggestions to how I may solve this problem? Or any alternatives for the same? I guess we face this issue for all custom fields..has SAP released a note for this??
Thanks..
07-24-2010 9:08 PM
that's just the wrong method, you should use DESCRIBE_BY_DATA
gr_desc = cl_abap_typedescr=>describe_by_data( p_field ).
Note: DESCRIBE_BY_NAME is to be used for referencing a DDIC type by its name. Example:
gr_desc = cl_abap_typedescr=>describe_by_name( 'MARA-ZZFIELD' ).
07-24-2010 9:08 PM
that's just the wrong method, you should use DESCRIBE_BY_DATA
gr_desc = cl_abap_typedescr=>describe_by_data( p_field ).
Note: DESCRIBE_BY_NAME is to be used for referencing a DDIC type by its name. Example:
gr_desc = cl_abap_typedescr=>describe_by_name( 'MARA-ZZFIELD' ).
07-25-2010 3:51 AM
Hi Sandra,
Thanks for replying.
I'm passing the field name only in the method DESCRIBE_BY_NAME and it gives a dump for a custom field.
07-25-2010 10:58 PM
I don't understand why you have an error.
Did you check that your table is fully active (not partially), and did you check SAP notes?
How is defined your field?
If all is okay, then contact SAP support.
07-26-2010 2:43 AM
If I enter a custom added field name the code works for me, eg VBAK-ZREASON_CD..... but I do get this error if I enter a field name which does not exist....maybe you have mis-spelt the field name, or not included the 'mara-' or maybe p_field is too short to hold the whole field name??
07-26-2010 8:30 AM
07-26-2010 1:44 AM
Howdy,
If I set p_field to 'MARA-ZZFIELD' for example the method has a runtime error - however if I refer to the data element name then it works fine.
I suspect this is by design. Depending on what you are trying to retrieve you might be better using cl_abap_tabledescr to describe MARA and then retrieve the reference to the element that you're looking for.
Cheers
Alex