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: 

statement

Former Member
0 Kudos

hi all,

i declared internal table like this:

data: itab like dbtab occurs 0 with header line.

i want to fetch the data from the dbtab. and i written

select * from dbtab into corresponding fields of table itab.

write: itab-fileds.

but in this way i am not getting records

this one i did differenrtly:

select * from dbtab into corresponding fields of itab.

write: itab-fileds.

endselect.

in this way i am fetching all the records

what is the problem in first select ststement.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

prS.

In your first statement

you are not looping the select statement.So internal table unable to print all records.

But in you select statement you are looping the select statement by SELECT ......ENDSELECT.

That is the reason second statement is giving output.

One more suggestion

when you have declared internal table with same structure like your dbase table why do you use into coreesponding in select statement .It give bad performance.

Don't forget to reward if useful....

9 REPLIES 9

Former Member
0 Kudos

Hi

Instead of select * from give the select (field names).

Mention the field names, hope it will work.

Reward if help.

Former Member
0 Kudos

Hi,

after selecting the data u write write: itab-fileds.in loop endloop.

Regards

Former Member
0 Kudos

prS.

In your first statement

you are not looping the select statement.So internal table unable to print all records.

But in you select statement you are looping the select statement by SELECT ......ENDSELECT.

That is the reason second statement is giving output.

One more suggestion

when you have declared internal table with same structure like your dbase table why do you use into coreesponding in select statement .It give bad performance.

Don't forget to reward if useful....

Former Member
0 Kudos

In debug mode you verify your internal table contents.

then try to use this:

loop at itab.

write:/ itab-fields.

endloop.

Former Member
0 Kudos

you know actually ur itab is populated in both cases.

problem is in your write statement.

in first case there is no loop .

so try this syntax with first case----

*select * from dbtab into corresponding fields of table itab.*

loop at itab.

write: itab-fields.

endloop.

it will work definitely

plz reward if useful

keep rockin

vivek

Former Member
0 Kudos

Hi,

Declare internal table like this.

types: begin of ty_mara,

matnr type mara-matnr,

matkl type matkl-matkl,

end of ty_mara.

data: it_mara type table of ty_mara, "internal table

wa_mara type ty_mara. " work-area.

select matnr matkl from mara

into table it_mara.

then loop the table it_mara for displaying the records.

loop at it_mara into wa_mara.

write: / wa_mara-matnr, wa_mara-matkl.

endloop.

don't use select endselect statment. it will cause performance issue.

regards,

Santosh Thorat

.

Former Member
0 Kudos

select *

from dbtable

into table itab.

loop at itab.

write:/ itab-field1,itab-field2....

endloop.

Former Member
0 Kudos

Hi,

In the first statement instead of using * use all the field names to be selected.

In the case of using * there must be end statement for that select. it perfomence is just like loop and endloop.

so that u can write the itab now.

regards,

vasavi.

Former Member
0 Kudos

select * from dbtab into corresponding fields of table itab.

case 1

whenever you use of table in a select statement in a select statement , it automatically loops for all record in dbtab in single line into itab.

case 2

but whenever you avoid of table you have to add a endselect statement , and now you can loop between these two codes any no of statement you want with count equal to number of records in dbtab.

DIFFERENCE

when you dont have any codes to loop that is you only have to populate the itab from dbtab always use case1 as performance wiser in case2 ENDSELECT statement has to be executed every time for each record transported from dbtab to itab

this increases load on presentation server and database server.

eg suppose for 1000 lines 1000 times endselect statement will be executed.