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: 

Is there any way to leave the program directly

Former Member
0 Kudos

I am selecting some values using select statement

If the select fails i.e sy-subrc ne 0 i need to leave the program.

Is there any way

1 ACCEPTED SOLUTION

Mohamed_Mukhtar
Active Contributor
0 Kudos

Hi you can code like this

Select kunnr
          name1
          ort01
          land1 from kna1 into table it_kna1.

if it_kna1 is not inital.
loop at it_kna1.
ur code
endloop.
Else.
Message 'No data Available' type 'S'.
endif.

Regards

9 REPLIES 9

Mohamed_Mukhtar
Active Contributor
0 Kudos

Hi you can code like this

Select kunnr
          name1
          ort01
          land1 from kna1 into table it_kna1.

if it_kna1 is not inital.
loop at it_kna1.
ur code
endloop.
Else.
Message 'No data Available' type 'S'.
endif.

Regards

former_member181995
Active Contributor
0 Kudos

Leave list-processing?

Former Member
0 Kudos

after select statement just check the sy-subrc value.

if sy-sbbrc ne 0.

exit. (or) LEAVE LIST-PROCESSING

endif.

Regards,

Suresh

former_member188685
Active Contributor
0 Kudos

you can use

LEAVE PROGRAM

Former Member
0 Kudos

Hi,

Leave list-processing is the better way of leaving the program.

Former Member
0 Kudos

hi,

you can use the "LEAVE PROGRAM." statement.

Former Member
0 Kudos

Check sy-subrc value

if its 4.

leave progrom.

endif.

Former Member
0 Kudos

Hi,

if sy-subrc ne 0.

STOP.

endif.

or

if sy-subrc ne 0.

message i398(00) with 'No Data Found'.

STOP.

endif.

Thanks,

Durai.V

Former Member
0 Kudos

Hi,

simply use 'leave program'.

Regards,

venkat