2007 Mar 26 9:43 AM
Hi all,
How can i copy a internal table whose fields are of specific data type into another internal table all whose fields are of character data type.
2007 Mar 26 9:45 AM
Hi..,
if the character data type fields are of enough length to hold the value in the other internal table .. then it is very easy to copy...
itab2 is the table of fields of character type.
<b>loop at itab1.
itab2-field1 = itab1-field1.
itab2-field2 = itab1-field2.
itab2-field3 = itab1-field3.
itab2-field4 = itab1-field4.
append itab2.
endloop.</b>
reward if it helps u...
sai ramesh
2007 Mar 26 9:45 AM
hi,
You can directly assign them using move keyword if their lengths are same and The line types are convertible, but not compatible. you can also you "write to" keyword to copy an internal table.
regards,
veeresh
2007 Mar 26 9:48 AM
If Both the tables are of same structure...
itab2 = itab1.
else use move-corresponging to....
2007 Mar 26 9:48 AM
hi,
Make sure that the lenghts of target fields are same as the lengths of source field.
loop at itab.
move-corresponding fields of itab to itab2.
append itab2.
endloop.
Regards,
Santosh
2007 Mar 26 9:57 AM
this is also one of the method
ASSIGN SPFLI_WA TO <WA>.
SELECT *
FROM SPFLI
INTO SPFLI_WA.
DATA COUNT.
WHILE SY-SUBRC = 0.
ASSIGN COMPONENT SY-INDEX OF STRUCTURE <WA> TO <COMP>.
IF SY-SUBRC EQ 0.
WRITE <COMP> TO FS1.
CONDENSE FS1 NO-GAPS.
CONCATENATE CHAR FS1 INTO CHAR IN CHARACTER MODE SEPARATED BY
' '.
IF COUNT = 0.
MOVE FS1 TO CHAR.
COUNT = 1.
ENDIF.
ELSE.
EXIT.
ENDIF.
ENDWHILE.
*CONDENSE CHAR NO-GAPS.
APPEND CHAR TO T_CHAR.
CLEAR: CHAR,COUNT.
ENDSELECT.
2007 Mar 26 10:20 AM
2007 Mar 26 11:00 AM
Hi,
You can use move-corresponding fields from itab1 to itab2. This statement copy the data from one internal table to another internal table.
Regards,
Bhaskar
2007 Mar 26 11:49 AM
You can do the following:
loop at itab1.
itab2-field1 = itab1-field1.
itab2-field2 = itab1-field2.
append itab2.
endloop.
Or:
loop at itab1.
move-corresponding syntax
append itab2.
endloop.
hope this will help
2007 Mar 26 11:54 AM
looping will effect the performance of your program. Just write one single line like below:
append lines of itab1 to itab2.
Ensure both table are of same structure.