Skip to Content
0
Nov 02, 2009 at 06:13 PM

Move-corresponding from Field symbol to workarea

2817 Views

I am using the following code for creating dynamic internal table.....


DATA: t_details TYPE abap_compdescr_tab,
        wa_details TYPE abap_compdescr,
        t_ref_tab TYPE REF TO cl_abap_structdescr.

* Get the structure of the table.

  t_ref_tab ?= cl_abap_typedescr=>describe_by_name( pv_tabname ).
  t_details[] = t_ref_tab->components[].


  LOOP AT t_details INTO wa_details.
    CLEAR wa_fc.
    wa_fc-fieldname  = wa_details-name .
    wa_fc-datatype   = wa_details-type_kind.
    wa_fc-inttype    = wa_details-type_kind.
    wa_fc-intlen     = wa_details-length.
    wa_fc-decimals   = wa_details-decimals.
    APPEND wa_fc TO it_fc.
  ENDLOOP.

* Create dynamic internal table and assign to FS
  CALL METHOD cl_alv_table_create=>create_dynamic_table
               EXPORTING
                  it_fieldcatalog = it_fc
               IMPORTING
                  ep_table        = it_dynamic.
  ASSIGN it_dynamic->* TO <fs_dyn>.

* Create dynamic work area and assign to FS
  CREATE DATA wa_dynamic LIKE LINE OF <fs_dyn>.
  ASSIGN wa_dynamic->* TO <fs_line>.

* Filling data into dynamic internal table.
  SELECT * FROM (gv_tabname) INTO TABLE <fs_dyn>.

  LOOP AT <fs_dyn> assigning <fs_line>.
  MOVE-CORRESPONDING <fs_line> TO wa_chandisc.  " --> Causing error
    APPEND wa_chandisc TO gt_chandisc.
  ENDLOOP.

Need some help in fixing this issue.