Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Moving data from a internal table to a variable.

Former Member
0 Likes
9,412

Hi experts,

How to move data from an internal table to a variable of type c or string?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
3,670

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.

10 REPLIES 10
Read only

Former Member
0 Likes
3,670

do you means the whole data present in internal table to a single char variable?

Read only

0 Likes
3,670

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?

Read only

0 Likes
3,670

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.

Read only

Former Member
0 Likes
3,670

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.
 

Read only

Former Member
0 Likes
3,670
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

Read only

Former Member
0 Likes
3,671

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.

Read only

Former Member
0 Likes
3,670

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

Read only

0 Likes
3,670

Nope..

Internal table is not of type c...

It contains a structure...which has some fields.

Read only

0 Likes
3,670

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

Read only

Former Member
0 Likes
3,670

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