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: 

User-exits

Former Member
0 Kudos
457

Hi all,

I need to call a subroutine recursively inside a User-exit. The problem is that I am unable to write the body of the subroutine in the EXIT (i get an error when i try to activate it). So i wrote the body in another include, but now the problem is that I am unable to pass the data into this new include.

Please help me with this.

Thanks.

Moderator message: please use more descriptive subject lines for your posts.

Edited by: Thomas Zloch on Jun 29, 2011 11:08 PM

11 REPLIES 11

Former Member
0 Kudos
406

Export the data from User Exit and Import the data inside the include and clear the data at the end of include

Regards

Former Member
0 Kudos
406

Hi,

(i get an error when i try to activate it)

What was the error, which user exit are you trying to code?

Provide as much information as much as you can to get more helpful answers.

Regards,

Chen

0 Kudos
406

The error displayed is

" Incorrect Nesting: Before the statement "FORM", the structure introduced by "FUNCTION" must be concluded by "ENDFUNCTION".

0 Kudos
406

Hi,

As you still didn't post the name of the exit , looking at the error message, i guess you are trying to code a function exit.

In this exit, you are creating the Z Include and trying to code a subroutine within it, this is not allowed as you cannot have a subroutine definition within a Function module.

What you could do is code your logic directly, and if there are too many lines of code and you want to modularize them, then you could create your subroutines in another include/sub routine pool and call it as PERFORM F_TEST IN PROGRAM [sub routine pool program name] or create a Z FM with your code and call this Z FM.

Regards,

Chen

0 Kudos
406

hello aeterminator ,

you are getting the error message because you are trying to write a form in form i.e nesting of forms ant that is not possible.

So it is better if you write your code without any sub routine.

or

try to write your code in include rather than subroutine.


include z<name>.

doubleclick that include and write your code there.

NOTE You must not write subroutine in this include also (for this situation)

hope this is helpful,

kool.

0 Kudos
406

Thanks all for the reply..

But I want to have a recursive function call until a condition is not fulfilled, so I need to call the perform inside the perform.

Won't it be possible to achieve it inside the USER-EXIT ZXCO1U06.

0 Kudos
406

Hi,

As everyone mentioned, unfortunately yo cannot define a subroutine in the EXIT.

You will have to look for an alternative.

0 Kudos
406

Create an include for example zinclude and write the body of the subroutine zsub inside it.

Now inside the USER-EXIT include ZXCO1U06, try calling the subroutine inside the include like below,


"Use loop or while condition for recursive call
PERFORM zsub IN PROGRAM zinclude IF FOUND.

0 Kudos
406

as mentioned earlier,

What you could do is code your logic directly, and if there are too many lines of code and you want to modularize them, then you could create your subroutines in another include/sub routine pool and call it as PERFORM F_TEST IN PROGRAM sub routine pool program name or create a Z FM with your code and call this Z FM.

A ZFM sounds a better option in case you want to retain values of the variables involved during recursive calls.

Regards,

Chen

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Kudos
406

> But I want to have a recursive function call until a condition is not fulfilled, so I need to call the perform inside the perform.

> Won't it be possible to achieve it inside the USER-EXIT ZXCO1U06.

I don't understand why you need to program a PERFORM inside the (same) PERFORM to achieve the recursion!

You can use WHILE ... ENDWHILE or DO ... ENDDO to call the procedure(subroutine, function module etc.) & then exit the recursion when the condition is satisfied.

Br,

Suhas

Former Member
0 Kudos
406

Thank you all for all your replies....I have replaced the recursive call to the function with while and endwhile loop.