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

select statement

hi all,

i came across a select statement like this.

SELECT * FROM PAYR WHERE

ZBUKR EQ I_ALL_PAY_COMP-ZBUKR AND

LIFNR IN S_LIFNR AND

ZALDT IN S_BUDAT AND

VOIDR EQ '00'.

here theres no destination after retreiving.how can this be useful?

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

7 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Feb 28, 2007 at 05:02 AM

    Hi Prashant,

    Sometimes if there is onlu a single row selection from the statement that you have provided , the row gets filled in the header line having the same line as that of the table and then this line or the fields in this line can be used in further code.

    Regards,

    Sunmit.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 28, 2007 at 05:03 AM

    Checkout the workarea PAYR.

    CHECK THE sy-subrc.

    Please reward if useful.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 28, 2007 at 05:06 AM

    HI,

    If PAYR has been declared in the TABLES, then theres no need for a specific workarea.

    Any tables that are declared in the TABLES stmt, it is treated as the workarea.

    Eg: TABLES: PAYR,

    BKPF.

    Regards

    Subramanian

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 28, 2007 at 05:11 AM

    Hi Prashanth,

    The PAYR must have been defined as follows:

    TABLES : PAYR.

    In this case the PAYR is defined as a table having a workarea attached to it. In this case you need not specify the destination in the select statement.

    SELECT * FROM PAYR WHERE

    ZBUKR EQ I_ALL_PAY_COMP-ZBUKR AND

    LIFNR IN S_LIFNR AND

    ZALDT IN S_BUDAT AND

    VOIDR EQ '00'.

    The above statement will fetch the data in the workarea PAYR which has been associated with table PAYR when it is defined as TABLES : PAYR.

    Hope it resolves ur query.

    Kindly award points if helpful.

    Thanks.

    Himanshu.

    Message was edited by:

    Himanshu Aggarwal

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 28, 2007 at 05:15 AM

    Prasanth,

    This is useful for below scenario.

    1.If we already know that for below select statement there will be only one record

    will exist for given condition.That time selected record will come into header

    area of "PAYR ".So need to deaclare any structure or internal table to store

    that data.

    Note : this data will get over write for each loop.

    2.If you want to check sy-subrc value .

    Pls. reward if useful

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 28, 2007 at 05:21 AM

    HI prasanth.....

    your code is ..

    SELECT * FROM PAYR WHERE

    ZBUKR EQ I_ALL_PAY_COMP-ZBUKR AND

    LIFNR IN S_LIFNR AND

    ZALDT IN S_BUDAT AND

    VOIDR EQ '00'.

    This will give u a Syntax error , if u doesn't declare PAYR under Tables.

    If u declare PAYR in Tables option it will create a Work area with PAYR Structure

    If the code is like this ......

    Tables:

    PAYR.

    SELECT * FROM PAYR WHERE

    ZBUKR EQ I_ALL_PAY_COMP-ZBUKR AND

    LIFNR IN S_LIFNR AND

    ZALDT IN S_BUDAT AND

    VOIDR EQ '00'.

    Here also you will get Syntax error,

    For this code you need to put Endselect

    like

    Tables:

    payr.

    SELECT * FROM PAYR WHERE

    ZBUKR EQ I_ALL_PAY_COMP-ZBUKR AND

    LIFNR IN S_LIFNR AND

    ZALDT IN S_BUDAT AND

    VOIDR EQ '00'.

    *some code

    endselect.

    other wise u can write like this also

    Tables:

    payr.

    SELECT single * FROM PAYR WHERE

    ZBUKR EQ I_ALL_PAY_COMP-ZBUKR AND

    LIFNR IN S_LIFNR AND

    ZALDT IN S_BUDAT AND

    VOIDR EQ '00'.

    here u will get only 1 record into PAYR work area

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 28, 2007 at 05:35 AM

    hi

    here you have to declare TABLES : PAYR which will create a table work area with the name PAYR so in your select * all the corresponding fields are populated by select query if you want to display them you have to use WRITE : / PAYR-LIFNR or like that. so it will take the data from that table work area and show the data.

    regards

    shiba dutta

    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.