Application Development and Automation 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: 
Read only

Error in move-corresponding with create data

Former Member
0 Likes
589

Hi,

I am writing a program which creates tranparent table dynamically and populates data to it.

I have created the transparent table dynamically.

I am fetching data using native sql, so the columns to be fetched are determined at run time.

At compile time, I am getting warning for move-corresponding as

"LOS_DYN_TABLE" does not have a structured type.

When I run the program it gives a short dump.

With error

Error analysis

The MOVE-CORRESPONDING statement can only be used on operands with a

structured type.

In the case at hand, this condition is not fulfilled: Operand "LOS_DYN_TABLE" has the type "l".

In debug node, I have checked before loop, the structure types are compatible.

What are the possible solution to this problem.

FORM populate_data_into_dyn_table
  USING    uv_dyn_crtd_table_name TYPE tabname " table created dynamically
           uot_legacy_data        TYPE REF TO data .
  DATA:
        lot_dyn_table     TYPE REF TO data ,
        los_dyn_table     TYPE REF TO data .

  FIELD-SYMBOLS:
      <fst_legacy_data> TYPE STANDARD TABLE ,
      <fst_dyn_table>   TYPE STANDARD TABLE ,
      <fss_legacy_wa>   TYPE ANY ,
      <fsv_dyn_fld>     TYPE ANY .

  " Do error checking.
  CREATE DATA lot_dyn_table TYPE STANDARD TABLE OF (uv_dyn_crtd_table_name).
  CREATE DATA los_dyn_table TYPE (uv_dyn_crtd_table_name).
  ASSIGN uot_legacy_data->* TO <fst_legacy_data> .

  LOOP AT <fst_legacy_data> ASSIGNING <fss_legacy_wa>.
    MOVE-CORRESPONDING <fss_legacy_wa> TO los_dyn_table.
    append los_dyn_table to lot_dyn_table.	
  ENDLOOP.
endform.

Regards,

Vikas

2 REPLIES 2
Read only

former_member194669
Active Contributor
0 Likes
364

Try this way


    i_ref_descr ?= cl_abap_typedescr=>describe_by_data( <fss_legacy_wa> ).
    i_details[] = i_ref_descr->components[].

 LOOP AT <fst_legacy_data> ASSIGNING <fss_legacy_wa>.
   loop at i_details into wa_details.
     assign component sy-tabix of structure <fss_legacy_wa> to <fs1>.
     assign component sy-tabix of structure los_dyn_table to <fs2>.
     move <fs1> to <fs2>.
   endloop.
    append los_dyn_table to lot_dyn_table.	
  ENDLOOP.

a®

Read only

0 Likes
364

.