2022 Oct 11 2:03 PM
Hello Everybody,
I have a loop. i want to if the condition is met, back to first record and resume first line.
How can i do?
Hello Everybody,
I have a loop. i want to if the condition is met, back to first record and resume first line.
How can i do?
2022 Oct 11 3:01 PM
Here is pseudo code. I'd probably not code like that, but I don't know your exact logic.
DO.
repeat_loop = abap_false.
LOOP AT itab ... WHERE ...
IF ...
repeat_loop = abap_true.
EXIT. " leave LOOP AT to go back to first record and resume first line
ENDIF.
ENDLOOP.
IF repeat_loop = abap_false.
EXIT. " leave DO
ENDIF.
ENDDO.
2022 Oct 11 3:03 PM
sandra.rossi and what about replace LOOP with a READ... INDEX ... ?
2022 Oct 11 5:34 PM
sandra.rossi I said that "I'd probably not code like that" because "I don't know your exact logic", so any proposal could be valid. I hope that my comment will help the OP to elaborate the question.
2022 Oct 11 6:17 PM
Ok, i will make an simple example;
the following loop is on row 10 of the table and if statement is okay. I mark to lv_az_ok. now i have to go back for the first line. (my process is similar but of course there is a more complex calculation)
select * from sflight into table @data(t_sflight).<br>loop at t_sflight into data(_sflight).
IF _Sflight-carrid = 'AZ'.
DATA(lv_az_ok) = 'X'.
"leave LOOP AT to go back to first record and resume first line</em>
ENDIF.
endloop.
Also, the above code is a solution for me. However, i'am still curious about your choice. Maybe this could be the new syntax. And no suitable for me read table or index.
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |