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

select query

hi all,

i have problem in my report i.e.,

BUKRS BELNR GJAHR BSCHL KOSTL LIFNR PRCTR

0010 100 2008 40 900 - 900

0010 100 2008 31 - 200 -

from bseg table

i need to get output as

BUKRS BELNR GJAHR KOSTL LIFNR PRCTR

0010 100 2008 900 200 900

PLEASE help me how to wite code for this.

select query i have written is

SELECT bukrs

belnr

gjahr

buzei

bschl

prctr

kostl

hkont

lifnr

zlsch

FROM bseg

into table gt-bseg

FOR ALL ENTRIES IN ls_bkpf

WHERE bukrs EQ ls_bkpf-bukrs

AND belnr EQ ls_bkpf-belnr

AND gjahr EQ ls_bkpf-gjahr.

thanks in advance

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Jun 19, 2008 at 10:38 AM

    Hi Kiran,

    try this,

    select BUKRS BELNR GJAHR KOSTL LIFNR PRCTR from bseg

    into table gt_bseg

    for all entries in ls_bkpf

    where belnr = ls_bkpf-belnr

    and gjahr = ls_bkpf-gjahr.

    Hope this will help you! rewards if useful.

    Regards,

    Mark

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 19, 2008 at 10:41 AM

    To use for all entries primarly ur using itab should have data.

    otherwise it will select all the data.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 19, 2008 at 10:43 AM

    Hi

    Use control break statements.

    sort internal table

    loop at internal table.

    at new bukrs.

    write bukrs.

    endat

    write BUKRS BELNR GJAHR KOSTL LIFNR PRCTR

    endloop.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 19, 2008 at 10:45 AM

    Hi kiran kumar

    It seems as per the naming convention u r using structure in select querry with for all entries clause. With for all entries u should use an internal table with entries. If ls_bkpf is structure then remove that for all entries. Only where clause is enough.

    SELECT bukrs

    belnr

    gjahr

    buzei

    bschl

    prctr

    kostl

    hkont

    lifnr

    zlsch

    FROM bseg

    into table gt-bseg

    WHERE bukrs EQ ls_bkpf-bukrs

    AND belnr EQ ls_bkpf-belnr

    AND gjahr EQ ls_bkpf-gjahr.

    Check changing as said.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 19, 2008 at 10:47 AM

    FOR ALL ENTRIES

    Beware when using FOR ALL ENTRIES in select statement. Although this addition to the select statement is an efficient way to fetch distinct records from a table, follow the below steps to ensure data consistency and efficiency.

    1. Sort the Internal table used in the 'FOR ALL ENTRIES IN' clause.

    2. Make sure they do not contain duplicates.

    3. Last and most importantly include a primary key field(Unique entry) in the select list. The reason, the system gets unique field records based on the where condition. It summarizes the data based on the Data type and field list in the target internal table.

    One should be sure the internal table, used in the FOR ALL ENTRIES clause is not empty. If the table is empty, ALL ENTRIES will be selected. (Actually, all WHERE clauses are neglected). Of course, you should also be sure you select on INDEX fields. Otherwise the use of FOR ALL ENTRIES increases the runtime instead of improving it.

    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.