Application Development 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: 

looping issue

Former Member
0 Kudos

hi all,

I loop over a table. Within that loop I have a while loop that continues to call the following code as long as flg_end is blank.

FORM find_next_step CHANGING p_next_step.

DATA: lv_next_step TYPE stunr.

SELECT SINGLE stunr

INTO lv_next_step

FROM t683s

WHERE kvewe = c_a "Usage

AND kappl = c_ka "Application

AND kalsm = 'ZCBK01' "Procedure

AND ( ( stunb >= p_next_step )

AND ( stun2 <= p_next_step ) ).

IF sy-subrc = 0.

p_next_step = lv_next_step.

ELSE.

flg_end = 'X'.

ENDIF.

First pass and a step is successfully returned. Second pass the select fails...and I drop outside the while loop. This process repeats until I reach end of outer table.. Odd...if I remove the while loop and replace with a do loop...all additional reads fail. If I remove the inner loop and perform static calls to the program...all additional reads fail. What gives?

4 REPLIES 4

bbalci
Contributor
0 Kudos

Hello Mathew,

I see the veriable "p_next_step" in your where condition

and it is set by same select statement via variable lv_next_step.

This seems like it's caused by the value of this variable

on further loop steps.

Can you please post your code including loop and while commands?

Bulent

Former Member
0 Kudos

If you can post the complete code, that might help us understand better.

Also, if you are not appending your values, why are you repeatedly selecting from DB into a variable?

Regds,

Kiran

Former Member
0 Kudos

Hi,

according to my analsys, either ur while loop will execute infinetly or it will not be executed even a single time,

as ur condition is not getting changed with in the same loop at every pass and also u are not storing values.

Regards

Former Member
0 Kudos

Hi,

Can you please post the entire code? Please note that using a loop inside a loop (especially inside a loop at table )is not adviseable as it affects the performance.

Please post the entire code so that we can better analyse the issue.

Regards,

Shiny