Doubt on select statment

Question: Dear All,

I have the following statement in my code:

SELECT objek INTO objek_o FROM ausp WHERE atinn = atinn_o AND
adzhl = adzhl_o AND klart = '023' AND atwrt = <fs>-vbeln.



SELECT atflv INTO atflv FROM ausp WHERE objek = objek_o
AND atinn = atinn_i AND
adzhl = adzhl_i AND klart = '023'.
ENDSELECT.

ENDSELECT.


This select is taking too much time. I want to create an index in table ausp. For this specific statement which is the appropriate index (I mean, which fields should it have)?


Kind regards,

Nita.

Answer:
This is a better way to display your code... Use code blocks...

SELECT objek
INTO   objek_o
FROM   ausp
WHERE atinn = atinn_o
AND   adzhl = adzhl_o
AND   klart = '023'
AND   atwrt = <fs>-vbeln.

SELECT atflv
INTO   atflv
FROM   ausp
WHERE objek = objek_o
AND   atinn = atinn_i
AND   adzhl = adzhl_i
AND   klart = '023'.

ENDSELECT.

ENDSELECT.

That's a nested loop on the same table... Of course it's going to take its time...

What do you do in the middle of the select?
_________________
The Doc
Magna Grand Docot of the Tuly Idiot Order

2007 Basic Rules

Answer:
You have just broken one of "never" rules. Never do nested selects.
Also, as I can see you want to read some classification info. There are plenty of function modules for this. Search in SE37 by mask BAPI_OBJCL*.
_________________
Best regards, Sergey Korolev

Answer:
Hi,

My goal is:

I have an internal table itab with vbeln/posnr.

For each line of that internal table I want to check if there is any batch on a given storage (1080) allocated to that sales order/item (vbeln/posnr).


Thank you for all suggestions,

Nita.
Copyright ?2007 - 2008 www.jt77.com