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: 

Create internal table dynamically for IDoc fields

Former Member
0 Kudos

Hi,

I need to create an internal table dynamically based on the segment field names that are returned in the table pt_fields when calling function 'IDOCTYPE_READ_COMPLETE'. I see many posts suggesting classes such as 'cl_wrf_dynamic_table=>create_dynamic_table', but it does not work for me. The problem I have with the classes is that it doesn't allow you to have the same column name more than once. But in the scenario I am testing, I have some column names that are duplicated, and I cannot remove the duplicates. Are there any functions or classes that I can use to create a dynamic internal table that will not check if a column name is used twice?

Thanks,

Carrie

1 ACCEPTED SOLUTION

uwe_schieferstein
Active Contributor
0 Kudos

Hello Carrie

My first thought was that RTTI might be able to do this but it does not (see the dump below). And it is obvious that RTTI behave likes this.

Error analysis
    An exception occurred which is explained in detail below.
    The exception, which is assigned to class 'CX_SY_STRUCT_COMP_NAME', was not
     caught and
    therefore caused a runtime error.
    The reason for the exception is:
    Multiple Specification of the Name 'CUSTOMER' as a Component Name (Component 7)

Just think about any way to define statically an itab or structure containing duplicated field names. You will always get a syntax error irrespective of whether you use a DDIC structure, a TYPE or a DATA variable.

If there is no way to define such a structure statically why should it be different when defining dynamically?

Regards

Uwe

2 REPLIES 2

uwe_schieferstein
Active Contributor
0 Kudos

Hello Carrie

My first thought was that RTTI might be able to do this but it does not (see the dump below). And it is obvious that RTTI behave likes this.

Error analysis
    An exception occurred which is explained in detail below.
    The exception, which is assigned to class 'CX_SY_STRUCT_COMP_NAME', was not
     caught and
    therefore caused a runtime error.
    The reason for the exception is:
    Multiple Specification of the Name 'CUSTOMER' as a Component Name (Component 7)

Just think about any way to define statically an itab or structure containing duplicated field names. You will always get a syntax error irrespective of whether you use a DDIC structure, a TYPE or a DATA variable.

If there is no way to define such a structure statically why should it be different when defining dynamically?

Regards

Uwe

Former Member
0 Kudos

Since this doesn't seem to be possible, I just added another character at the end of the field when adding it to it_fieldcat to make it unique.