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

Recursive Function Calls & Going Back to Previous Screen

Former Member
0 Likes
857

Hi,

I have defined a function with a screen.

To refresh the screen contents, I call the same function again, as shown below:

CALL function 'Z_SIMS_TEST'

exporting

ID_LIST = GID_LIST.

LEAVE PROGRAM.

What it does is exit the function, and the program that called it in the first place, is there away for it to just exit the function and go back to the program that called it? I still need the function to tidy itself up, and not cause any memory leaks.

Thanks

5 REPLIES 5
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
769

You might be able to use the STOP statement here. I think STOP, may stop the entire program all together.

You would have to "tidy up" before the execution of this statement.

You could use the EXIT statement if your check is in the main line of the function module.

Regards,

Rich Heilman

Read only

0 Likes
769

You also might be able to RAISE an exception.

Regards,

Rich Heilman

Read only

0 Likes
769

Here is what I mean...... Say you have this function module....




FUNCTION Z_TEST.
*"----------------------------------------------------------------------
*"*"Local interface:
*"  IMPORTING
*"     REFERENCE(SUBRC) TYPE  SY-SUBRC
*"  EXCEPTIONS
*"      AN_EXCEPTION
*"----------------------------------------------------------------------


Write:/ 'Im in the function module'.


if subrc  = 0.

Write:/
   'Im inside the check and need to come out of the function module'.

* You can use the exit statement here  to exit the 
* funciton module, if your check is in the mainline.
  exit.

* Or  you can raise an exception which will also make 
* the processing of the funcion module end.
Raise an_exception.

endif.


write:/ 'Im still in the function module after the check'.



ENDFUNCTION.


Here is the call to the example function module.


* Calling this way, will turn the check on and 
* make the function module end.
call function 'Z_TEST'
     exporting
          subrc        = '0'
     exceptions
          an_exception = 1
          others       = 2.


Regards,

Rich Heilman

Read only

0 Likes
769

I've also tested with the STOP statement, it is working also in the the mainline of the function module.

Regards,

Rich Heilman

Read only

0 Likes
769

Sims, did you solved it? Any answers helpful?

What did you do to solved your problem?

Regards,

Rich Heilman

Message was edited by: Rich Heilman