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

exiting from a function module.

Former Member
0 Likes
11,811

Hi,

I have a function module in which i am extracting output message from NAST based on vbeln.

I record is not found, then i am updating return table with error message using 'MESSAGE_TEXT_BUILD'.

Now i have to exit from the function module as my select statement is unsuccessful.

how do you do this?

can i use subroutines in a function module?

thanks,

Sandeep

4 REPLIES 4
Read only

Former Member
0 Likes
4,091

Hi Sandeep,

You can use EXIT statement to exit out of the FM.

Yes, you can use sub-routines in Function Module. If you are using EXIT inside a sub-routine, the program control will come out of sub-routine and not the FM> So if it is inside a sub-routine, return sy-subrc value as a parameter of the sub-routine. Outside the sub-routine, check the value and use EXIT statement accordingly.

Best Regards,

Ram.

Read only

Former Member
0 Likes
4,091

create an exception for ur FM.and after filling return tab.put RAISE exception.

it ll come out of FM.. with sy-subrc = the value for exception

Read only

Former Member
0 Likes
4,091

Hi,

Use EXIT statement to exit out of FM.

Read only

Former Member
0 Likes
4,091

Hi Sandeep,

You can use EXIT to come out of FM but make sure that you dont write EXIT inside a LOOP..

Better way would be to RAISE an exception... All you have to do is declare an exception in Exceptions tab.. and do a RAISE <exception_name>

You may have subroutines in FM.. the form can be declared in the MAIN program or any of the includes.