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

Stop a function module

Former Member
0 Likes
2,737

Hello,

I have a fuction module and I will export errors. When I export an error, the function module must stop. How can I stop the function module after the error message? Can I use exit?

9 REPLIES 9
Read only

Former Member
0 Likes
1,477

hi,

i think exit will work fine.

regards,

Sandeep.

Read only

Former Member
0 Likes
1,477

Put an export value check after execution of function module.

Read only

rajeshkumar_kaveti
Participant
0 Likes
1,477

hi,

1. If y r handling the exceptions, u can stop the FM using 'RAISE exception1' statement. This will return the sy-subrc with the value u assigned to 'exception1'. By checking the sy-subrc u can display the erroe message.

2. If y r not handling the exceptions:

if <condition>.

message i002(sy) with 'ERROR'.

exit.

endif.

Regards,

Rajesh

Read only

Former Member
0 Likes
1,477

I don't use exceptions. In my function module I have some subroutines. In this subroutines are the error messages. When I use exit it don't stop? What can I do?

For example:


FORM XY CHANGING MSGERROR TYPE BAPIRETURN.
...

IF NOT XX <> ''.

   error-type = 'W'.
   error-message = 'Error'(001).
   exit.

  ENDIF.
ENDFORM.

Read only

0 Likes
1,477

HI,

May be you are in LOOP...ENDLOOP statement.

If Yes, Just put a flag in the error scenario.

And after loop...

IF V_FLAG = 'X'.

EXIT.

ENDIF.

Thanks,

Ramakrishna

Read only

rajeshkumar_kaveti
Participant
0 Likes
1,477

I guess it is coming out of subroutine. If this is true again use exit by checking a condition in FM as the subsequent statement to subroutine call.

Read only

0 Likes
1,477

@Rajesh kumar kaveti: That was it, thank you! Now I want to click Solved Problem (10), so that you get 10 Points, but there is an error: Rewarding the message failed.

Sorry, so I don't rate you...

Read only

Former Member
0 Likes
1,477

Hi,

Use can use a RETURN statement once you check for the error and found any error in the routine.

Regards,

Uma.

Read only

0 Likes
1,477

Hi,

There so noway in ABAP where you can exit the program. If you use EXIT or RETURN this will only stop the current processing block. So if you say EXIT from a subroutine it only exits the subroutine not the Function Module. You can use LEAVE PROGRAM if you really want to comeout of the program. If you just want to come out of the FM its better use set some flag in the subroutine before exit and use that flat in FM to call EXIT again.

Best Regards,

Sesh