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

Selection into table

Former Member
0 Likes
1,045

Hi experts,

I have the following selection below. It doesn't append the landx to i_mytable. If I use append i_mytable it appends to a new line not to i_mytable-landx. How can I solve the problem?

SELECT landx

into i_mytable-landx

FROM t005t

for ALL ENTRIES IN i_kna1

WHERE land1 = i_kna1-land1 AND

spras = 'EN'.

ENDSELECT.

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,028
SELECT landx into TABLE i_mytable     "<--  ADD the word TABLE here
         FROM t005t
                for ALL ENTRIES IN i_kna1
                WHERE land1 = i_kna1-land1 AND
                             spras = 'EN'.

* REMOVE the  "ENDSELECT"

I'm assuming that LANDX is the only field in I_MYTABLE, otherwise you may want to use INTO CORRESPONDING FIELDS OF TABLE

Regards,

RIch Heilman

10 REPLIES 10
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,029
SELECT landx into TABLE i_mytable     "<--  ADD the word TABLE here
         FROM t005t
                for ALL ENTRIES IN i_kna1
                WHERE land1 = i_kna1-land1 AND
                             spras = 'EN'.

* REMOVE the  "ENDSELECT"

I'm assuming that LANDX is the only field in I_MYTABLE, otherwise you may want to use INTO CORRESPONDING FIELDS OF TABLE

Regards,

RIch Heilman

Read only

0 Likes
1,028

Hello Rich,

in i_mytable there are several fields, I want to add landx to i_mytable-landx.

So in your version it inserts to the first column which is not good for me.

Have any idea?

Read only

Former Member
0 Likes
1,028

Hi,

Adding some more points .


if not i_kna1 is initial.
SELECT landx
into table i_mytable-landx
FROM t005t
for ALL ENTRIES IN i_kna1
WHERE land1 = i_kna1-land1 AND
spras = 'EN'.
endif.

Thanks,

Manjunath MS

Read only

0 Likes
1,028

Hello Manjunat,

it gives me an error that i_mytable is not an internal table. I've already tried this version:

SELECT landx

into i_mytable-landx

FROM t005t

for ALL ENTRIES IN i_kna1

WHERE land1 = i_kna1-land1 AND

spras = 'EN'.

endselect.

but when I'm trying to append to i_mytable it inserts landx to a wrong position into a new line of the table

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,028

You want to modify an existing line of the internal table, and only the LANDX field?

If so, you can't do it like that.

Regards

RIch Heilman

Read only

0 Likes
1,028

Yes, that is the case. So is it not possible to modify the line? Should I use instead of it an embedded selection and then when all the data is selected insert to the internal table?

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,028

Still a little confused how I_KNA1 is relevant in all this, but you must do something like this.



Loop at i_mytable.

SELECT landx into i_mytable-landx    
         FROM t005t
                WHERE land1 =i_mytable-land1 AND
                             spras = 'EN'.
modify i_mytable.
endloop.




Regards,

RIch Heilman

Read only

0 Likes
1,028

Previously I selected the LAND1 from kna1 into i_kna1 (it's my internal table) it stores the country key (LAND1). Then I'm trying to retrieve the text to the country key LAND1, and I want to put the text LANDX into an another internal table called i_mytable.

Read only

0 Likes
1,028

How are records getting into i_mytable? Are they coming from I_KNA1 at some point in time? IF so, i would suggest getting this text then. Please post the full code.

Regards

RIch Heilman

Read only

0 Likes
1,028

I think I have realized what's the solution. I have to move to all the data into the header of my internal table i_mytable and then i have to append to it.

Thanks for posting some help for me.