2008 Feb 13 8:34 AM
Hi
How can we make select single statement out of loop.
eg
LOOP AT WK.
SELECT SINGLE * FROM BKPF WHERE BUKRS = '4187' AND
BELNR = WK-BELNR AND
GJAHR = PROCYR.
...........
...........
.......
ENDLOOP.
To improve the performance we need to put the select single statement out of the loop. How can we do it.
Hi
How can we make select single statement out of loop.
eg
LOOP AT WK.
SELECT SINGLE * FROM BKPF WHERE BUKRS = '4187' AND
BELNR = WK-BELNR AND
GJAHR = PROCYR.
...........
...........
.......
ENDLOOP.
To improve the performance we need to put the select single statement out of the loop. How can we do it.
2008 Feb 13 8:40 AM
Change it to following -
SELECT * FROM BKPF into table it_bkpf WHERE BUKRS = '4187' .
LOOP AT WK.
Read table it_BKPF with key
BELNR = WK-BELNR.
GJAHR = PROCYR.
...........
...........
.......
ENDLOOP.
Regards,
Amit
2008 Feb 13 8:45 AM
Hi,
DATA : i_bkpf LIKE BKPF OCCURS 0 WITH
HEADER LINE.
SELECT * FROM BKPF
INTO TABLE i_BKPF
FOR ALL ENTRIES IN WK
WHERE BUKRS = '4187' AND
BELNR = WK-BELNR AND
GJAHR = PROCYR.
LOOP AT WK.
READ TABLE i_BKPF WITH KEY
BUKRS = '4187'
BELNR = WK-BELNR
GJAHR = PROCYR.
IF SY-SUBRC EQ 0.
.....................
ENDIF.
ENDLOOP.
Don't forget to reward if useful...
2008 Feb 13 9:09 AM
see i can do it by making select * but the thing is in select * it will return the best match value whereas in select single it returns the best first match values. So dont you think the requirement can change in making select * instead of select single.
2008 Feb 13 9:19 AM
Hi Anindita,
Select * will Fetch all the values for given BUKRS and reading within Loop will give the same entry when using select single.
2008 Feb 13 9:37 AM
But in where we are not giving full key . In this case multiple data will comefor same key.
I dont think select * is a gud option
2008 Feb 13 3:30 PM
You are giving it the full key, so FOR ALL ENTRIES is a good option.
Rob