09-09-2009 6:11 PM
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
09-09-2009 7: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
09-09-2009 7: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