Application Development 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: 

How to select from internal table

Former Member
0 Kudos

How to select from internal table.

e.g I would like to do

select from single * from itab1 into itab2 where fieldx = itab1-oldnumber.

4 REPLIES 4

Former Member
0 Kudos

Hi Tina,

You can not perform any kind of SELECT statement operations on Internal tables.

For your requirement, you can do using LOOP...ENDLOOP statements on internal table.

DATA WA_ITAB1 LINE OF ITAB1.

LOOP AT ITAB1 INTO WA_ITAB1.

READ TABLE ITAB1 WITH KEY FIELDX = WA_ITAB1-OLDNUMBER.

IF SY-SUBRC = 0.

APPEND WA_ITAB1 TO ITAB2.

EXIT.

ENDIF.

ENDLOOP.

READ TABLE ITAB1

Thanks,

Vinay

Former Member
0 Kudos

Hi,

We do not write the selects on Internal tables, we can write the READ statements on it.

LOOP AT ITAB1.
Read table ITAB2 with key FIELD1 = ITAB1-FIELD1.
 If sy-subrc = 0.
    write the code
 endif.

ENDLOOP

.

Regards

Sudheer

Former Member
0 Kudos

Try:


LOOP AT itab1 INTO itab2 WHERE (...)
  APPEND itab2.
ENDLOOP.

Rob

Former Member
0 Kudos

HI,

Your select query itself is wrong. What others have suggested is nothing but

itab2[] = itab1[].

Use:

select * from tablename into itab2

for all entries in itab1

where fieldx = itab1-oldnumber.

Regards

Subramanian