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

exit in itab.

Former Member
0 Likes
735

Hello everyone,

I like to know as to How we can exit from multiple loops using single exit inside the loop.

i pasted the code below. I just want to exit out of both the loops and i dont want to use onemore exit or stop there.

REPORT  zmadhu_temp.

TABLES: mara, makt.

DATA: BEGIN OF itab1 OCCURS 0.
        INCLUDE STRUCTURE mara.
DATA: END OF itab1.

DATA: BEGIN OF itab2 OCCURS 0.
        INCLUDE STRUCTURE makt.
DATA: END OF itab2.

SELECT * FROM mara INTO TABLE itab1 UP TO 10 ROWS.
SELECT * FROM makt INTO TABLE itab2 FOR ALL ENTRIES IN itab1 WHERE matnr = itab1-matnr.

LOOP AT itab1.
  LOOP AT itab2.
    EXIT.
  ENDLOOP.
ENDLOOP.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
696

Hi,

STOP will exit all your processing and take you to END-OF-SELECTION.

santhosh

Hello everyone,

I like to know as to How we can exit from multiple loops using single exit inside the loop.

i pasted the code below. I just want to exit out of both the loops and i dont want to use onemore exit or stop there.

REPORT  zmadhu_temp.

TABLES: mara, makt.

DATA: BEGIN OF itab1 OCCURS 0.
        INCLUDE STRUCTURE mara.
DATA: END OF itab1.

DATA: BEGIN OF itab2 OCCURS 0.
        INCLUDE STRUCTURE makt.
DATA: END OF itab2.

SELECT * FROM mara INTO TABLE itab1 UP TO 10 ROWS.
SELECT * FROM makt INTO TABLE itab2 FOR ALL ENTRIES IN itab1 WHERE matnr = itab1-matnr.

LOOP AT itab1.
  LOOP AT itab2.
    EXIT.
  ENDLOOP.
ENDLOOP.

5 REPLIES 5
Read only

Former Member
0 Likes
696

Hi,

I think we can't do like that.EXIT Statement is used for a Single Block Only.

Regards,

Padmam.

Read only

Former Member
0 Likes
696

hi,

with one exit you can not come out from 2 loops except the case the first loop is processing the last record.

sudheer.A

Message was edited by:

sudheer Addepalli

Read only

Former Member
0 Likes
697

Hi,

STOP will exit all your processing and take you to END-OF-SELECTION.

santhosh

Read only

jayanthi_jayaraman
Active Contributor
0 Likes
696

Hi,

Just try using return statement instead of exit.

RETURN.

Read only

0 Likes
696

Hello,

I am not sure about return. It does not return the control to statement which is below the nested loops.

Regards