Skip to Content
author's profile photo Former Member
Former Member

How to assign value from an internal table to a dynamic internal table ?

Hi all,

I have created a dynamic internal table, because I wanted to created my structure TYPE at runtime :

assign new_table->* to <dyn_table>.

* Create dynamic work area and assign to FS
  create data new_line like line of <dyn_table>.
  assign new_line->* to <dyn_wa>.

So now I have an dynamic internal table : <dyn_table>

and a dynamic workare or linetype : <dyn_wa>

This dynamic table has the same fields as my itab_normal, which has components :

itab_normal-week
itab_normal-begindate
itab_normal_enddate

How can I assign these values to my dynamic table <dyn_table> ?

This does not work :

<dyn_table>-week = itab_normal-week
<dyn_table>-begindate = itab_normal-begindate
<dyn_table>-enddate = itab_normal-enddate

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Sep 09, 2009 at 06:25 PM

    Hi

    If they have the same structure u can use a do cycle:

    LOOP AT  ITAB_NORMAL.
      
       DO.
         ASSIGN COMPONENT SY-INDEX OF STRUCTURE ITAB_NORMAL TO <VALUE_FROM>.
         IF SY-SUBRC NE 0. EXIT. ENDIF.    
         ASSIGN COMPONENT SY-INDEX OF STRUCTURE <DYN_WA> TO <VALUE_TO>.
        <VALUE_TO> = <VALUE_FROM>.
       ENDDO.
       APPEND <DYN_WA> TO <DYN_TABLE>.
    
    ENDLOOP.

    If the dynamic table has only certain fields of ITAB_NORMAL, I suppose u have an internal table with the fields of dynamic table (u should use it to generate the dynamic table) so u can loop it instead of DO/ENDO cycle

    LOOP AT  ITAB_NORMAL.
      
       LOOP AT ITAB_FIELD.
         ASSIGN COMPONENT ITAB_FIELD-FIELDNAME OF STRUCTURE ITAB_NORMAL TO <VALUE_FROM>.
         ASSIGN COMPONENT ITAB_FIELD-FIELDNAME OF STRUCTURE <DYN_WA> TO <VALUE_TO>.
        <VALUE_TO> = <VALUE_FROM>.
       ENDLOOP.
       APPEND <DYN_WA> TO <DYN_TABLE>.
    
    ENDLOOP.

    Anyway u can find out many solutions in SCN, there are many posts with your problem

    Max

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.