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: 

Select statement

Former Member
0 Kudos
69

Hi gurus,

I have a scenario where I need to copy everythng from one of my 'z_test' table(custom table) into my internal table it_tab and for this I have written thr following code, I just want to make sure whether I have written it right or not?

select * into table it_tab

from zbs_test.

Thanks

Rajeev gupta

3 REPLIES 3

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos
52

Of course you could have simply tested this, but yes that is the correct syntax as long as IT_TAB is defined as...

data: IT_TAB type table of zbs_test.

Regards,

Rich Heilman

Former Member
0 Kudos
52

Hi,

to make sure that you have wriiten well for the code , you can check it with sy-subrc

If sy-subrc = 0 , this means that you have copied successfilly .

you can define the code as below:

DATA : it_tab TYPE TABLE OF zbs_test.

Select * from zbs_test into table it_tab.

If sy-subrc EQ 0.

Write: ' Copied successfully '.

else.

write: 'fail to copy'.

endif.

Hope that it will be helpful for you

Former Member
0 Kudos
52

Looks like your code is good and i am not sure how are you declaring internal table.

Check the below code and here i am using one custom table (ZTEST99).

report ztest_ytt.

tables : ztest99.

  • internal table

data i_ztest type standard table of ztest99.

  • work area

data wa_ztest like line of i_ztest.

start-of-selection.

  • get the data from table

select * from ztest99 into table i_ztest.

if sy-subrc ne 0.

message e000(z01).

endif.

loop at i_ztest into wa_ztest.

write:/ wa_ztest. " use fields

clear : wa_ztest.

endloop.

use internal table with out header line for better performance and also use work area.

Thanks

Seshu