How to return to previous popup?

513 Views Asked by At

I am opening a Popup(1) - Screen_0300

CASE sy-ucomm.
  WHEN 'POPUP1'.
    CALL SCREEN 0300 STARTING AT 10 08 ENDING AT 70 15.
ENDCASE.

From within this Popup I am calling another screen Popup(2) - Screen_0400.

MODULE user_command_0300 INPUT.
  CASE sy-ucomm.
    WHEN 'POPUP2'.
      CALL SCREEN 0400 STARTING AT 10 08 ENDING AT 70 15.
  ENDCASE.
ENDMODULE.

Now when I close Popup(2) I want to return to Popup(1). Currently both Popups get closed simultaneously. I already tried to call Popup(1) in the PAI of Popup(2) with Leave to Screen or Set Screen. Is there any way to achieve this?

2

There are 2 best solutions below

2
Sandra Rossi On BEST ANSWER

To leave a screen displayed using CALL SCREEN, use SET SCREEN 0 during the execution of the PAI (MODULE ... INPUT), and the program will continue after the statement CALL SCREEN.

0 is a special value to leave the current "Screen Call Sequence".

0
SBECK1 On

I found the answer myself, posting it so others might find the answer faster. It seems to be the same issues as this.

Fixed it with the following:

data next_screen type sy-dynnr.
CASE sy-ucomm.
 WHEN 'POPUP1'.
  next_screen = '0300'.
  while next_screen is not INITIAL.
  CALL SCREEN next_screen STARTING AT 10 08 ENDING AT 70 15.
  endwhile.
ENDCASE.

And in the second popup:

MODULE user_command_0300 INPUT.
  CASE sy-ucomm.
    WHEN 'CANCEL' OR 'ENTER'
      CLEAR next_screen.
    WHEN 'POPUP2'.
      CALL SCREEN 0400 STARTING AT 10 08 ENDING AT 70 15.
  ENDCASE.
ENDMODULE.

This way whenever the first Popup is closed with the sy-ucomm CANCEL or EXIT next_screen is cleared and the main program is in focus again. Otherwise next_screen keeps being 300 and will be called all the time.