Application Development and Automation 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: 
Read only

Loop... Where clause is not working

Former Member
0 Likes
1,703

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

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

7 REPLIES 7
Read only

Former Member
0 Likes
1,068

Hi,

I think there is no relational operator in the condition.

Please check.


( opbel lv_opbel ) . " In both loop and IF

Thanks,

Sriram Ponna.

Read only

Former Member
0 Likes
1,068

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

Read only

0 Likes
1,068

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.

Read only

0 Likes
1,068

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

Read only

0 Likes
1,068

Hey bujji.

Say i do want to use a negative condition, Why is it working? It works for me in other loops.

Avi.

Read only

0 Likes
1,068

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

Read only

0 Likes
1,068

Hi madhu.

The "Where" clause is not a part of a "select" statement but still, it doesn't work.

Avi.