12-10-2007 4:21 PM
Hello Experts.
I have two entries in internal table , both of the entries are text of length 10chars.
Now i want to display that in the output with a single variable.
ie for example in itab i have like 1st field = Indian
2nd field = Heros
Now i want to display like Indian Heros with the help of a single variable. so please tell me how to populate this internal table data into that single variable and make it as one sentence.
Thanks for all the replies
12-10-2007 4:24 PM
Hi shiva,
1. Take a new variable.
eg.
Data : mystr(25) type c.
2. Loop at itab.
concatenate itab-field1 itab-field2 into mystr separated by space.
write 😕 mystr.
endloop.
regards,
amit m.
12-10-2007 4:25 PM
Try this:
DATA: variable TYPE string.
LOOP AT itab.
CONCATENATE variable itab INTO variable SEPARATED BY space.
ENDLOOP.
SHIFT variable LEFT DELETING LEADING SPACES.
WRITE: / variable.
Hope I've understood well.
Roby.
12-10-2007 4:57 PM
Hi Shiva,
Could also be like this:
data: begin of itab occurs 0 with header line,
f1,
f2,
end of itab.
data: w_field(20) type c.
start-of-selection.
itab-f1 = 'Indian'.
itab-f2 = 'Heroes'.
append itab.
loop at itab.
concatenate itab-f1 ifab-f2 into w_field seperated by space.
write: / w_field.
endloop.
Kind regards,
John.
12-10-2007 10:29 PM
Hi Shiva,
all the other experts above are right, but keep in mind that you might work with an internal table WITHOUT header line. Given this case you have to modify the example coding from above:
DATA struc TYPE structure_with_two_fields.
DATA itab TYPE TABLE OF structure_with_two_fields.
DATA text TYPE string.
LOOP AT itab INTO struc.
CONCATENATE struc-field1 struc-field2 INTO lv_text SEPARATED BY SPACE.
ENDLOOP.
WRITE test.
12-11-2007 4:33 AM
hi,
do this.
data : text1(25) type c,
text2(25) type c.
loop at itab.
if sy-tabix eq = 1.
text2 = itab-field.
else.
concatenate itab-field text2 into text1 separated by space.
text2 = text1.
clear text1.
endif.
endloop.
text2 contains all the records as concatenated into one string.