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

End the program execution inside a User exit

Former Member
0 Likes
1,687

Hi Experts,

I am using a FM in a User exit. I want to give an error message if the FM gives a sy-subrc NE 0 and then the program should stop working.

I am using tcode COR1 to create a process order.Once the program reaches that FM .if sy-subrc <> 0

then it reaches that message but neither it gives an error message output nor ends the program execution.

Following FM is used inside the User exit.CANCELLED is the exception in that user exit.

WHILE sy-subrc <> 0 .

CALL FUNCTION 'ENQUEUE_EZ_0901_WM_0001'

EXPORTING

mode_z09_2_3_2_1__001 = 'E'

mandt = sy-mandt

nryear = l-nryear

z_nrmonth = l-nrmonth

x_nryear = ' '

x_z_nrmonth = ' '

_scope = '2'

_wait = 'X'

_collect = ' '

EXCEPTIONS

foreign_lock = 1

system_failure = 2

OTHERS = 3.

IF sy-index > 100 AND sy-subrc <> 0.

MESSAGE e398(00) WITH 'Please run this program again' RAISING cancelled.

EXIT.

ENDIF.

ENDWHILE.

Please guide me.

Regards,

Amit

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,277

Use LEAVE PROGRAM

6 REPLIES 6
Read only

Former Member
0 Likes
1,277

hi,

after the exit statement try " leave to screen 0" and check wether it helps u to pull ot from the transaction code .

Read only

Former Member
0 Likes
1,278

Use LEAVE PROGRAM

Read only

Former Member
0 Likes
1,277

Raise exception with error message, the program automatically stop

Regards

Sasi

Read only

Former Member
0 Likes
1,277

Hello Amit,

Please check that the condition that you have given for the message is true when you want to show the message.

i.e. sy-index should be greater than 100 also sy-subrc value should be '0' i.e. FM executed successfully, when both the condition are true then only you will be able to show the message that you want to show.

Try to display the message as Message 'Executed Successfully' type 'I'.

Hope it helps.

Regards,

Jayant.

Read only

jayanthi_jayaraman
Active Contributor
0 Likes
1,277

Hi,

Try removing the raising cancelled and run.

IF sy-index > 100 AND sy-subrc 0.

MESSAGE e398(00) WITH 'Please run this program again'.

Leave list-processing.

ENDIF.

Read only

Former Member
0 Likes
1,277

thanks a lot for your replies.

Regards,

Amit