‎2008 Jul 01 12:18 PM
Hi experts,
How to move data from an internal table to a variable of type c or string?
‎2008 Jul 01 12:34 PM
DAta: begin of itab occurs 0,
str type string,
end of itab.
loop at it_data into wa.
conactenate wa-f1 wa-f2 wa-f3.. into itab-str.
append itab.
clear itab.
endloop.
This will append all the fields into a single field in each row in another internal table.
Thanks,
Keerthi.
‎2008 Jul 01 12:19 PM
do you means the whole data present in internal table to a single char variable?
‎2008 Jul 01 12:21 PM
Yeah.. say a table with length adding all the individual fields length comes out to be 500.
I have only one row in it.
i have to move that row to a variable of type c or string?
Can i do that ? if yes pls tell me how to do that?
‎2008 Jul 01 12:25 PM
after adding the rows u have it in a single row of internal table.
so use:
read table itab index 1.
move itab to variable.
i hope this works out.
Please check it.
‎2008 Jul 01 12:21 PM
hi,
You can move an entry/record of an internal table to a variable but not the entire table ....
data : v_char(1000).
read table itab index 1 to wa_itab.
if sy-subrc = 0.
move wa_itab to v_char.
endif.
‎2008 Jul 01 12:29 PM
data: gs_string type string.
read table itab into wa index 1.
if sy-subrc eq 0.
assign wa to gs_string casting type c.
endif.Regards
Kannaiah
‎2008 Jul 01 12:34 PM
DAta: begin of itab occurs 0,
str type string,
end of itab.
loop at it_data into wa.
conactenate wa-f1 wa-f2 wa-f3.. into itab-str.
append itab.
clear itab.
endloop.
This will append all the fields into a single field in each row in another internal table.
Thanks,
Keerthi.
‎2008 Jul 01 12:35 PM
Hi,
If the Type of your Internal table Is Not Character Type Field Then you can nto Move the Records from Internal table to a variable of Type C or String. Type Conflict Ocuur.
If the Type of Internal table is of type C then you can use
Data: w_target as type string.
Loop at itab into wa index 1.
w_target = wa.
Endloop.
Write : w_target.
Regards,
Sujit
‎2008 Jul 01 12:38 PM
Nope..
Internal table is not of type c...
It contains a structure...which has some fields.
‎2008 Jul 01 1:16 PM
Hi,
you can do this way-
Loop at itab into wa index 1.
Concatenate w_target wa-field1 wa-field2 ............into w_taget
separated by space.(If You want Space in between Two fields)
Write: w_target.
Endloop.
Regards,
Sujit
‎2008 Jul 01 12:43 PM
data: Char(100),
Merge(500).
Consider if Itab is the table with all data and WA is your workarea type/like ITAB.
Itab has three fields F1, F2, F3.
Loop at itab into Wa
clear char.
clear merge.
char = wa-F1.
Concatenate Char Merge into merge.
clear char.
char = wa-F2.
Concatenate Char Merge into merge.
clear char.
char = wa-F3.
Concatenate Char Merge into merge.
Append Merge to some table *******
Endloop.
Edited by: Vijay on Jul 1, 2008 1:43 PM