‎2011 Sep 03 2:56 PM
Hi all,
i am converting all data type to CHAR statically as below.
tasktype* (raw)* to comp1(char)
time(tims) to comp2(char)
LOOP AT vmc INTO wa_vmctmp.
WRITE: wa_vmctmp-tasktype TO wa_zvmctmp-comp1,
wa_vmctmp-time TO wa_zvmctmp-comp2,
wa_vmctmp-entry_id TO wa_zvmctmp-comp3,
wa_vmctmp-counter TO wa_zvmctmp-comp4,
wa_vmctmp-mem_alloc_local TO wa_zvmctmp-comp5,
APPEND wa_zvmctmp TO zvmc1.
ENDLOOP.can anybody suggest me,how do i do it dynamically if i have the table data in a field symbol..
‎2011 Sep 05 9:16 AM
Check the [CASTING|http://help.sap.com/abapdocu_702/en/abapassign_casting.htm] addition of the ASSIGN statement.
‎2011 Sep 03 5:44 PM
Hello Sam
You can use this on same way as you have coded, instead of use work area, you can use Field-Symbol
LOOP AT vmc ASSIGNING <FS>.
WRITE: <fs>-tasktype TO wa_zvmctmp-comp1,
<fs>-time TO wa_zvmctmp-comp2,
<fs>-entry_id TO wa_zvmctmp-comp3,
<fs>-counter TO wa_zvmctmp-comp4,
<fs>-mem_alloc_local TO wa_zvmctmp-comp5,
APPEND wa_zvmctmp TO zvmc1.
ENDLOOP.However if you do not know exactly structure, you can use ASSIGN COMPONENT statement to refer unkown field
ASSIGN COMPONENT sy-index OF STRUCTURE <wa> TO <comp>.
Kind regards
Carlos Machado
‎2011 Sep 05 2:44 PM
thank you ......
since i am new ,i am asking this question
as i have huge data in internal tables ..and i have many internal tables also .........i cant hard code all the fields ....
can you suggest me any other way where i can do it dynamically..........
Regards
sam
‎2011 Sep 05 8:30 AM
Try something like
LOOP AT itab1 ASSIGNING <record>.
DO.
ASSIGN COMPONENT sy-index OF STRUCTURE <record> TO <source>.
IF sy-subrc NE 0. EXIT. ENDIF.
ASSIGN COMPONENT sy-index OF STRUCTURE record2 TO <target>.
IF sy-subrc NE 0. EXIT. ENDIF.
WRITE <source> TO <target>.
ENDDO.
APPEND record2 TO itab2.
ENDLOOP.Regards,
Raymond
‎2011 Sep 05 10:50 AM
Hi Raymond Giuseppi
thank you,the reply is some thing what i was expecting.....
As i have more number of internal tables,could you tell me what may be structure of itab2 in your code
and record2... is static or dynamic..
As i was mentioning i have data in field symbol then itab1 is static i guess ..if it is so what may be structure of itab1
Thanks and Regards
sam
‎2011 Sep 05 9:16 AM
Check the [CASTING|http://help.sap.com/abapdocu_702/en/abapassign_casting.htm] addition of the ASSIGN statement.