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: 

Field symbols

Former Member
0 Kudos

Hi gentlemen,

I have fieldsymbols ,<dyn_table> and <dyn_wa> are declared in the following way ,

FIELD-SYMBOLS: <dyn_table> type standard table ,

<dyn_wa>.

Now at runtime ,field symbol <dyn_table> is gettin populated with some 10 records

Now i want to bring the data from the field symbol to internal table itab which has the same structure .How to go about this issue ?????

im gettin error when i use the following code .

loop at <dyn_table> into <dyn_wa> .

it_data-mandt = <dyn_wa>-mandt .

it_data-wl_no = <dyn_wa>-wl_no .

it_data-wc_no = <dyn_wa>-wc_no .

it_data-EFF_FROM_DT = <dyn_wa>-eff_from_dt .

it_data-EFF_TO_DT = <dyn_wa>-eff_to_dt .

it_data-CNTRY_CD = <dyn_wa>-cntry_cd .

it_data-PRI_GEO_LOC = <dyn_wa>-pri_geo_loc .

it_data-REG_ID = <dyn_wa>-reg_id .

append it_data to it_data .

endloop .

Many Thanks,

Hemanth .

3 REPLIES 3

Sm1tje
Active Contributor
0 Kudos

forget it, using the brackets just won't work in this editor. It is turned into some sort of link????

Edited by: Micky Oestreich on Apr 9, 2008 9:47 AM

Former Member
0 Kudos

Hi,

before loop u have to use

assign dy_line->* to <dyn_wa>.

dy_line will have a structure.

see the below example


type-pools : abap.
  field-symbols: <dyn_table> type standard table,
               <dyn_wa>,
               <dyn_field>.
  data: dy_table type ref to data,
      dy_line  type ref to data,
      xfc type lvc_s_fcat,
      ifc type lvc_t_fcat.
  selection-screen begin of block b1 with frame.
parameters: p_table(30) type c default 'T001'.
selection-screen end of block b1.
  start-of-selection.
    perform get_structure.
  perform create_dynamic_itab.
**********Creates a dyanamic internal table**********
  perform get_data.
  perform write_out.
  form get_structure.
  data : idetails type abap_compdescr_tab,
       xdetails type abap_compdescr.
  data : ref_table_des type ref to cl_abap_structdescr.
* Get the structure of the table.
  ref_table_des ?=
      cl_abap_typedescr=>describe_by_name( p_table ).
  idetails[] = ref_table_des->components[].
    loop at idetails into xdetails.
    clear xfc.
    xfc-fieldname = xdetails-name .
    xfc-datatype = xdetails-type_kind.
    xfc-inttype = xdetails-type_kind.
    xfc-intlen = xdetails-length.
    xfc-decimals = xdetails-decimals.
    append xfc to ifc.
  endloop.
  endform.
  form create_dynamic_itab.
* Create dynamic internal table and assign to FS
  call method cl_alv_table_create=>create_dynamic_table
               exporting
                  it_fieldcatalog = ifc
               importing
                  ep_table        = dy_table.
    assign dy_table->* to <dyn_table>.
* Create dynamic work area and assign to FS
  create data dy_line like line of <dyn_table>.
  assign dy_line->* to <dyn_wa>.
  endform.

  form get_data.
* Select Data from table.
  select * into table <dyn_table>
             from (p_table).
  endform.

FORM write_out .
*Write out data from table.
  loop at <dyn_table> into <dyn_wa>.
    do.
      assign component  sy-index
         of structure <dyn_wa> to <dyn_field>.
      if sy-subrc <> 0.
        exit.
      endif.
      if sy-index = 1.
        write:/ <dyn_field>.
      else.
        write: <dyn_field>.
      endif.
    enddo.
  endloop.
ENDFORM.                    " write_out

rgds,

bharat.

Former Member
0 Kudos

hi bharat ,

i added the code

assign itab[] to <dyn_table> .

create data dy_line like line of <dyn_table>.

assign dy_line to <dyn_wa>. before the loop .

Itab is declared as ,

DATA : it_data type standard TABLE OF zpra_pr_rrst1 WITH HEADER LINE.

Its giving me the same error ,

THE DATA OBJECT <DYN_WA> HAS NO STRUCTURE AND THEREFOR NO COMPONENT CALLED 'MANDT' .

whts the solution ???