Skip to Content
author's profile photo Former Member
Former Member

statement

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.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

9 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jan 29, 2008 at 05:30 AM

    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....

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 29, 2008 at 05:31 AM

    In debug mode you verify your internal table contents.

    then try to use this:

    loop at itab.

    write:/ itab-fields.

    endloop.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 29, 2008 at 05:30 AM

    Hi

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

    Mention the field names, hope it will work.

    Reward if help.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 29, 2008 at 05:30 AM

    Hi,

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

    Regards

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 29, 2008 at 05:31 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 29, 2008 at 05:34 AM

    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

    .

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 29, 2008 at 05:36 AM

    select *

    from dbtable

    into table itab.

    loop at itab.

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

    endloop.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 29, 2008 at 05:38 AM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 29, 2008 at 05:51 AM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.