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

problem in using 'STOP' statement

Former Member
0 Likes
1,295

Hi all,

I am working on a BADI. On some condition im displaying message using 'POPUP_TO_CONFIRM' fm. If i click no, my control should be on same page, ie., the whole code after that should not execute.(Order should not be saved). But i am unable to use 'STOP' in OO context. Is there any alternative for this. I need to keep the control on the same page. Kindy help me soon..

Thanks,

Kumar

9 REPLIES 9
Read only

Former Member
0 Likes
1,005

Try EXIT.

Read only

0 Likes
1,005

EXIT doesnt work. It is for coming out of loops.

Can I create my own exception? If yes how can i?

Is there any alternative for STOP in OO context. Kindly reply me its urgent.. plz..

Kumar

Read only

0 Likes
1,005

Simplest code I can think of is

Execute your code only if POP_UP_TO_CONFIRM has answer = Yes

Read only

0 Likes
1,005

EXIT will also come out of other things besides loops, like PERFORM calls.



report zrich_0001.

perform test.

*---------------------------------------------------------------------*
*       FORM test                                                     *
*---------------------------------------------------------------------*
form test.

  write:/ 'Before'.

  exit.

  write:/ 'After'.


endform.

This may also work in a method, but I'm concerned that you are already past the "Point of no return". Simply exiting the method of the BADI, will not stop the transaction from processing the rest of the way.

Regards,

Rich Heilman

Read only

0 Likes
1,005

EXIT will also terminate processing blocks.

Read only

0 Likes
1,005

For example in the OO context, EXIT will exit a method.



report zrich_0001.

*---------------------------------------------------------------------*
*       CLASS lcl_main DEFINITION
*---------------------------------------------------------------------*
class lcl_main definition.
  public section.
    class-methods: test.

endclass.



call method lcl_main=>test.



*---------------------------------------------------------------------*
*       CLASS lcl_main  IMPLEMEMENTATI
*---------------------------------------------------------------------*
class lcl_main implementation.
  method test.

    write:/ 'Before'.
    exit.
    write:/ 'After'.
  endmethod.

endclass.

Regards,

Rich Heilman

Read only

0 Likes
1,005

Rich,

Absolutely.

Nice example.

Read only

0 Likes
1,005

See my flow is like this..

Before an order is saved many BADI'S will be executed. In my first BADI im using the 'POPUP_TO_CONFIRM' FM. If i click no, the rest of all BADI'S should not be executed. That is i just need to display a message and that's it. Nothing else.

Here 'STOP' i cannot execute.

One more option what m thinking is, by creating our own exceptions, and if clicked no we can raise that exception. Is that possible. How to achieve that..?

kumar

Read only

0 Likes
1,005

I would create a global variable like CONTINUE_PROCESSING in the class object.

If the popup is set to appear and the user presses NO, then set to the global var to "not continue" (in the first BADI)

Then check this global variable in all subsequent BADIs, if var is set to no continue, then EXIT the current block of code (current BADI).