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

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?

7 REPLIES 7

Former Member
0 Kudos

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.

Former Member
0 Kudos

Checkout the workarea PAYR.

CHECK THE sy-subrc.

Please reward if useful.

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

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