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: 

Exit the program ,when the condiiton fails

Former Member
0 Kudos

Hi Experts,

I want to leave leave the program it self ,

if the condition fails indise the nested if statement.

I have tried using exit statement in nested if condition, but it is exiting the current loop.

Thanks in Advance

Regards,

Irfan

8 REPLIES 8

Former Member
0 Kudos

Hi irfan,

1. ABEND message type.

2.

message a999(yhr) with 'Bye'.

regards,

amit m.

Former Member
0 Kudos

Hi Irfan,

Try using STOP.

Thanks,

Srinivas

Former Member
0 Kudos

Irfan,

EXIT with in the loop will only throw you out of the loop. somewhere, in the main program you will have to identify that a error has happened and then use EXIT statement. Probably you can set a flag in the loop and check it after the loop.

Regards,

Ravi

0 Kudos

Hi Irfan,

EXIT statement will take you out of the loop ... try using STOP statement to come out of the program .... you can view how it is working by keeping a break point at STOP ...

Regards,

Kalyani

PS: Reward Points if it is helpful ..

Former Member
0 Kudos

use STOP.

But this will get U to the end-of-selection.

U need to set a flag here.

If <condition>

flag = 'X'.

stop.

endif.

end-of-selection.

if flag <> 'X'.

write the coding for reporting.

endif.

former_member188685
Active Contributor
0 Kudos

Hi Irfan,

use STOP instead of exit.

REPORT  ZTEST_STOP .

parameters: p_matnr like mara-matnr.
data: x_mara type mara.
start-of-selection.

select single *
             from mara
             into x_mara
             where matnr = p_matnr.
if sy-subrc = 0.
stop.
endif.

end-of-selection.

if not x_mara-matnr = ' '.

endif.

Regards

Vijay

0 Kudos

Hi,

My problem is like this

***************************************

if cntry eq 'us'

if condition 1.

sy-subrc eq 0.

proceed.else terminate the program.

if condition 2.

sy-subrc eq 0

success

else

leave the program.

elseif cntry eq 'de'

same as above.

else.

if cntry ne 'de'.

same as above.

endif.

**************************

Please help me out.

Thanks in Advance

Irfan Hussain

0 Kudos

Hi...

see if this is what you want...

REPORT  yytest88 LINE-COUNT 20 NO STANDARD PAGE HEADING.

data : cntry(2) value '1US'.

if cntry eq 'US'.
 write 😕 'hai'.
else.

*** nothing will happen...
  leave program.
endif.