cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic internal table of generic table!

former_member2492
Active Participant
0 Kudos
DATA: lo_dynamic_table TYPE REF TO data.
FIELD-SYMBOLS: <lt_table_structure> TYPE table,
                <ls_table_structure> TYPE any.
CREATE DATA lo_dynamic_table TYPE TABLE OF (datatab).
ASSIGN lo_dynamic_table->* TO <lt_table_structure>.
// some code assigning the structure

I have a table DATATAB,type of which is generic!It can change depending from queries!

I have to create a dynamic internal table type datatab!

It throws a dump Short Text An exception has occurred that was not caught.

What happened? Exception 'CX_SY_STRUCT_ATTRIBUTES' was raised, but it was not caught anywhere along the call hierarchy.

Can sb help me?

Sandra_Rossi
Active Contributor
0 Kudos

That's weird to get a structure error during a table creation (TYPE TABLE OF). Are you sure it doesn't concern another ABAP line? (below, as I see you are talking about "some code assigning the structure")

former_member2492
Active Participant
former_member2492
Active Participant

Please in the question I have already specified that datatab is a generic type and the error is thrown at this line>>>CREATEDATA lo_dynamic_table TYPE TABLE OF(datatab).there's no change from my code!I am refering to the datatab of this exit EXIT_RSAQEXCE_001 try creating a dynamic table of this table.

Accepted Solutions (0)

Answers (6)

Answers (6)

Sandra_Rossi
Active Contributor
0 Kudos

Okay so I see in your attached short dump that datatab is a structured parameter, not a character variable containing the name of a type, so you can't use parentheses around datatab.

I guess that it's the syntax you need :

CREATE DATA lo_dynamic_table LIKE TABLE OF datatab. 

Note that you must also use LIKE instead of TYPE (and don't use parentheses around datatab)

franois_henrotte
Active Contributor
0 Kudos

I would do it the other way :

  FIELD-SYMBOLS: <fs_tab> TYPE table.

  ASSIGN LOCAL COPY OF datatab TO <fs_tab>.
  LOOP AT <fs_tab> ASSIGNING FIELD-SYMBOL(<fs_str>).
    "Do something with structure <fs_str>.
  ENDLOOP.

"or, to append a new record :
  APPEND INITIAL LINE TO <fs_tab> ASSIGNING <fs_str>.

former_member2492
Active Participant
0 Kudos

Type conflict with ASSIGN in program "SAPLXQUE".You attempted to assign a field to a typed field symbol, but the field does not have the required type.

0 Kudos

<lt_table_structure> TYPE table - Try TYPE ANY TABLE

former_member2492
Active Participant
0 Kudos

nope same error,see images above

former_member2492
Active Participant
0 Kudos

Please in the question I have already specified that datatab is a generic type and the error is thrown at this line>>>CREATEDATA lo_dynamic_table TYPE TABLE OF(datatab).there's no change from my code!I am refering to the datatab of this exit EXIT_RSAQEXCE_001 try creating a dynamic table of this table.

maheshpalavalli
Active Contributor
0 Kudos

Your code looks fine. Make sure what you are passing in datatab is a correct structure or database table name, else it might give you errors.

Like everyone mentioned, it would be better if you share your short dump analysis.

Best Regards,
Mahesh

former_member2492
Active Participant
0 Kudos
maheshpalavalli
Active Contributor
0 Kudos

Please check the below code, which is working in my system, let me know if there is any deviation in your case



DATA: lo_dynamic_table TYPE REF TO data,

      datatab          TYPE string VALUE 'MARA'.

FIELD-SYMBOLS: <lt_table_structure> TYPE table,

               <ls_table_structure> TYPE any.

CREATE DATA lo_dynamic_table TYPE TABLE OF (datatab).

ASSIGN lo_dynamic_table->* TO <lt_table_structure>.



SELECT *

  FROM mara

  INTO TABLE <lt_table_structure>

  UP TO 10 ROWS.



LOOP AT <lt_table_structure> ASSIGNING <ls_table_structure>.

  ASSIGN COMPONENT 'MATNR' OF STRUCTURE <ls_table_structure> TO FIELD-SYMBOL(<fs_value>).

  write <fs_value>.

ENDLOOP.

former_member2492
Active Participant
0 Kudos

Please in the question I have already specified that datatab is a generic type and the error is thrown at this line>>>CREATEDATA lo_dynamic_table TYPE TABLE OF(datatab).there's no change from my code!I am refering to the datatab of this exit EXIT_RSAQEXCE_001 try creating a dynamic table of this table.

0 Kudos

Can you attach the short dump for further analysis?

former_member2492
Active Participant
0 Kudos
former_member2492
Active Participant
0 Kudos

Please in the question I have already specified that datatab is a generic type and the error is thrown at this line>>>CREATEDATA lo_dynamic_table TYPE TABLE OF(datatab).I am refering to the datatab of this exit EXIT_RSAQEXCE_001 try creating a dynamic table of this table.

developerone
Contributor
0 Kudos

Please check if the datatab is getting filled in. Also, a good practice to check if lo_dynamic_table is assigned before the assign statement.

former_member2492
Active Participant
0 Kudos

Yes the datatab is already filled and no the lo_dynamic_table is not getting assigned