3 Replies Latest reply: Aug 23, 2007 11:38 AM by Chris Carmichael RSS

Help with "Data object has no structure" with dynamically created <FS>

Chris Carmichael
Currently Being Moderated

Hi,

 

I'm trying to update a dynamic created itab(<dyn_tab> from values from another itab(i_names). I use a dynamic created work area for reading i_names, however, when I read the i_names table using the dynamic <dyn_wa>-id, it's complaining about <dyn_wa> has no structure and therefore no component called ID, also there aren't any components called FNAME or LNAME either.

 

I've inserted my code below and would really appreciate some advice.

Thanks in advance,

C

 

DATA: dy_table TYPE REF TO data,

      dy_line  TYPE REF TO data,

      xfc TYPE lvc_s_fcat,

      ifc TYPE lvc_t_fcat.

 

FIELD-SYMBOLS: <dyn_tab> TYPE STANDARD TABLE,

               <dyn_wa>.

 

  • 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_tab>.

 

  • Create dynamic work area and assign to FS

  CREATE DATA dy_line LIKE LINE OF <dyn_tab>.

  ASSIGN dy_line->* TO <dyn_wa>.

   

  • Get data. 

  SELECT (lt_fieldlist)

    FROM DBTAB

     INTO CORRESPONDING FIELDS OF TABLE <dyn_tab>

      WHERE F1 = 'F1'

      AND   F2 = 'F2'.

     

  • Update <dyn_tab> table with names.

  LOOP AT <dyn_tab> INTO <dyn_wa>.

  • Read names table using ID.   

    READ TABLE i_names ASSIGNING <names>

     WITH TABLE KEY name_id = <dyn_wa>-id.

      IF sy-subrc = 0 AND <names> IS ASSIGNED.

        <dyn_wa>-fname = <names>-fname.

        <dyn_wa-lname = <names>-lname.

      ENDIF.

  ENDLOOP.

  • Re: Help with "Data object has no structure" with dynamically created <FS>
    Mahesh Kumar Raganmoni
    Currently Being Moderated

    DATA: dy_table TYPE REF TO data,

     

     

     

    dy_line TYPE REF TO data,

    xfc TYPE lvc_s_fcat,

    ifc TYPE lvc_t_fcat.

     

    <b>data : begin of wa ,

             id(4) type c,

             fname(10),

             lname(10),

            end of wa.</b>

     

    FIELD-SYMBOLS: <dyn_tab> TYPE STANDARD TABLE,

    <dyn_wa>.

     

    • 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_tab>.

     

    • Create dynamic work area and assign to FS

    CREATE DATA dy_line LIKE LINE OF <dyn_tab>.

    ASSIGN dy_line->* TO <dyn_wa>.

     

    • Get data.

    SELECT (lt_fieldlist)

    FROM DBTAB

    INTO CORRESPONDING FIELDS OF TABLE <dyn_tab>

    WHERE F1 = 'F1'

    AND F2 = 'F2'.

     

    • Update <dyn_tab> table with names.

    LOOP AT <dyn_tab> INTO <dyn_wa>.

    • Read names table using ID.

    <b>move corresponding <dyn_wa> to wa.

    READ TABLE i_names ASSIGNING <names>

    WITH TABLE KEY name_id = wa-id.</b>

    IF sy-subrc = 0 AND <names> IS ASSIGNED.

    wa-fname = <names>-fname.

    wa-lname = <names>-lname.

    move corresponding wa to <dyn_wa>.

    ENDIF.

    ENDLOOP.

  • Re: Help with "Data object has no structure" with dynamically created <FS>
    Rich Heilman
    Currently Being Moderated

    Try something like this.  When defining a dynamic internal table or structure, there is no structure at design time, so of course you can not reference them at design time, so you need to do it dynamically using the  ASSIGN COMPONENT statement.

     

     

    IF sy-subrc = 0 AND <names> IS ASSIGNED.
    field-symbols: <fs>.
    assign component 'FNAME' of structure <dyn_wa> to <fs>.
    if sy-subrc = 0.
    <fs> = <names>-fname.
    endif.
    assign component 'LNAME' of structure <dyn_wa> to <fs>.
    if sy-subrc = 0.
    <fs> = <names>-lname.
    endif.
    ENDIF.

     

    Regards,

    RIch Heilman

Actions