06-11-2008 1:07 PM
Hello experts.
There is program , which i want to add conditions to a loop command.
The constraints is considered only for this condition : blart = lv_blart , and doesn't consider for the second one opbel <> lv_opbel (meaning the loop continues even if this condition is FALSE ).
On the other hand , when i write with IF clause, the constraints is valid .
The program is :
data : lv_blart TYPE blart_kk,
lv_opbel TYPE opbel_kk,
it_blart TYPE TABLE OF dfkkop,
wa_dfkkop TYPE dfkkop.
.
.
.
.
/// Loop where ///
lv_blart = 'DI'.
LOOP AT it_blart INTO wa_dfkkop WHERE
( ( opbel <> lv_opbel ) AND ( blart = lv_blart ) ) .
*********************************
/// IF clause ///
lv_blart = 'DI'.
LOOP AT it_blart INTO wa_dfkkop.
IF ( wa_dfkkop-opbel <> lv_opbel )
AND ( wa_dfkkop-blart = lv_blart ).
***************************************
Thanks for help.
Avi.
Edited by: avi azulay on Jun 11, 2008 2:07 PM
06-11-2008 1:10 PM
Hi,
I think there is no relational operator in the condition.
Please check.
( opbel lv_opbel ) . " In both loop and IF
Thanks,
Sriram Ponna.
06-11-2008 1:14 PM
Hi,
Change your code in the below way...
LOOP AT it_blart INTO wa_dfkkop WHERE
opbel = lv_opbel AND (= is missing in your posted code, pls check)
blart = lv_blart.
Rgds,
Bujji
06-11-2008 1:18 PM
Thx for quick replies.
My honest mistake, it should be:
LOOP AT it_blart INTO wa_dfkkop
WHERE opbel NE lv_opbel
AND blart = lv_blart.
Avi.
06-11-2008 1:33 PM
Hi,
My sincere suggestion is don't use Negative conditions in where class. Instead you go ahead within the loop with IF conditions. It will reduce the performance of the program also.
Rgds,
Bujji
06-11-2008 1:36 PM
Hey bujji.
Say i do want to use a negative condition, Why is it working? It works for me in other loops.
Avi.
06-11-2008 1:45 PM
Hi,
If the WHERE clause in the LOOP has inequality condition( ie <>), then it should not give any performance problem.
"<>" condition in the WHERE clause of the SELECT statement may cause problems.
you can go ahead and use <> in LOOP.
regards,
madhu
06-11-2008 1:54 PM
Hi madhu.
The "Where" clause is not a part of a "select" statement but still, it doesn't work.
Avi.