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

how to store internal table value in single variable

Former Member
0 Likes
5,015

hi gurus,

i have 3 value in int table , so want to store the value of int table into single variable of type string.

how it is possible

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,939

hmmm, your requirement is kinda weird and you could have given us a bit more info, but well lets start.

Why is your requirement weird?

Well an internal table kinda is a variable itself, or rather a set of variables which together make up for a line type of your table.

So you have a value you already have in a variable and now want to store it in anotherone? Seems weird.

What type is your internal table?

Do you have those three values in one record or in three records which only hold one value each?

Which of your values do you want to store in another variable?

Anyway, make a F1 on the "READ TABLE" statement, this should definiteley help you.

The "LOOP AT WHERE" statement could as well help if there should occur probrlem using READ TABLE.

/edit DAMn i was posting this while you gave us more info.

So still the question stays if you got your three values in one record or in three records.


DATA: lv_variabl_containing_all      type char100.

loop at itab into wa.
  concatenate lv_variabl_containing_all wa-value into lv_variabl_containing_all seperated by space.
endloop.

after the loop you now got all your values in lv_variabl_containing_all.

That is for the case you got three records.

other case would be


Read table itab into wa index 1.
concatenate wa-value1 wa-value2 wa-value3 into lv_variabl_containing_all.

Edited by: Florian Kemmer on Apr 16, 2010 12:59 PM

9 REPLIES 9
Read only

PedroGuarita
Active Contributor
0 Likes
2,939

Use CONCATENATE.

Read only

0 Likes
2,939

my int table has only one field, nd that field contain 3 values.

so i want that 3 values to be store in single variable

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
2,939

>

> i have 3 value in int table , so want to store the value of int table into single variable of type string.

Before answering , why do you want to do this ?

Read only

0 Likes
2,939

Use Move corresponding

Thanks and Regards

Sanjaya Kunar

Read only

Former Member
0 Likes
2,939

Hi,



data:
  w_string type string.

loop at t_tab into fs_tab.
concatenate fs_tab-field1 w_string into w_string seperated by space.
endloop.

Regards and Best wishes.

Read only

0 Likes
2,939

I get result in post1 field and in that field data i get that is a string

from that string i have take first 8 characters excluding dot

but getting multiple rows with different data in amdp

so how can i solve this?

Read only

Former Member
0 Likes
2,940

hmmm, your requirement is kinda weird and you could have given us a bit more info, but well lets start.

Why is your requirement weird?

Well an internal table kinda is a variable itself, or rather a set of variables which together make up for a line type of your table.

So you have a value you already have in a variable and now want to store it in anotherone? Seems weird.

What type is your internal table?

Do you have those three values in one record or in three records which only hold one value each?

Which of your values do you want to store in another variable?

Anyway, make a F1 on the "READ TABLE" statement, this should definiteley help you.

The "LOOP AT WHERE" statement could as well help if there should occur probrlem using READ TABLE.

/edit DAMn i was posting this while you gave us more info.

So still the question stays if you got your three values in one record or in three records.


DATA: lv_variabl_containing_all      type char100.

loop at itab into wa.
  concatenate lv_variabl_containing_all wa-value into lv_variabl_containing_all seperated by space.
endloop.

after the loop you now got all your values in lv_variabl_containing_all.

That is for the case you got three records.

other case would be


Read table itab into wa index 1.
concatenate wa-value1 wa-value2 wa-value3 into lv_variabl_containing_all.

Edited by: Florian Kemmer on Apr 16, 2010 12:59 PM

Read only

0 Likes
2,939

it is storing in value in reverse order

Read only

0 Likes
2,939

well so you need to sort your itab BEFORE looping at it the way you need it.

/edit typos corrected

Edited by: Florian Kemmer on Apr 16, 2010 1:12 PM