Application Development 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: 

Error while creating a dynamic internal table refers to custom field

Former Member
0 Kudos

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..

1 ACCEPTED SOLUTION

Sandra_Rossi
Active Contributor
0 Kudos

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' ).

6 REPLIES 6

Sandra_Rossi
Active Contributor
0 Kudos

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' ).

0 Kudos

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.

0 Kudos

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.

0 Kudos

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??

0 Kudos

Yes it was a problem with the name..Thanks everyone..

alex_cook
Active Participant
0 Kudos

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