02-28-2007 4:59 AM
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?
02-28-2007 5: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.
02-28-2007 5:03 AM
Checkout the workarea PAYR.
CHECK THE sy-subrc.
Please reward if useful.
02-28-2007 5: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
02-28-2007 5: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
02-28-2007 5: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
02-28-2007 5: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
02-28-2007 5: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