1

I'm trying to call a screen as a popup. The screen type is set to Modal dialog box and I'm able to call the screen, but unable to close it. Nothing happens when I click on the little cross. The next screen is set to 0.

The screen I'm calling as a popup, doesn't contain any buttons, not any hard coded ones anyway. Any ideas what I'm doing wrong?

I'd also like the screen it returns to, to be refreshed (so it loads the PBO again). How do I do that?

Here is the code:

MODULE werkende_knoppen_subscreen INPUT.
  CASE ok_code.
    WHEN 'X'.
      LEAVE TO SCREEN 0.
  ENDCASE.
ENDMODULE.
Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
  • Do you set a PF-Status at PBO? Do you handle the PF-Status at PAI of your popup? – knut Sep 04 '11 at 20:23
  • I don't think so, don't even know what PF-status is. Do you need it to get the `x` for closing the popup to work? –  Sep 04 '11 at 20:29
  • The PF-Status is set at PBO with `SET PF-STATUS xxxx`. xxxx (GUI status) must be defined with Menu Painter (SE41?). There you can define buttons and assign them to commands. At PAI you can react an this command in sy-ucomm. E.g. with `LEAVE TO SCREEN 0.` – knut Sep 04 '11 at 20:50
  • Ah right, I didn't know that, it's exactly what I was looking for. I created the gui status, and I added the code (see my post, it's updated) to my PAI, but once I click the button that I've added with function code x,instead of leaving the popup, it loads the screen in full size... Any idea what I'm doing wrong? –  Sep 04 '11 at 21:38
  • 1
    Check the 'Next Screen' field on your modal dialog box. It should be the screen you want to fall back to. If you want to leave the program entirely use 'exit program'. However I strongly suggest that you go through the ABAP dynpro help files if you have access too it. If you don't understand why you are doing certain things in dynpro you will have endless headaches with seemingly "random" bugs in future. – Esti Sep 06 '11 at 20:33

2 Answers2

2

You should be checking for the 'EXIT' (or, in your case for the custom close button, 'X') user command in the PAI part of your popup. For example:

MODULE user_command_0010 INPUT.
  ok = sy-ucomm.
  CLEAR sy-ucomm.
  CASE ok.
    WHEN 'EXIT' OR 'X'.
      LEAVE TO SCREEN 0.
  ENDCASE.
ENDMODULE.
René
  • 2,912
  • 1
  • 28
  • 46
1

This is a non-documented feature but in a modal dialog box (popup), the top-right button to close the popup is assigned the F12 key, so you must assign this key to a function code and process it as any other function code.

Step-by-step procedure:

1) Create the ABAP program (transaction code SE38 or SE80)

REPORT.

CALL SCREEN 100 STARTING AT 10 10 ENDING AT 60 20.

MODULE status_0100 OUTPUT. " <=== called "before output"
  SET PF-STATUS '0100'.    " <=== choose the GUI status
ENDMODULE.

MODULE user_command_0100 INPUT. " <=== called "after input" (after user action)
  IF sy-ucomm = 'CANCEL'.       " <=== the function code you chose in your GUI status
    SET SCREEN 0.               " <=== 0 is a special number which ends "CALL SCREEN"
  ENDIF.
ENDMODULE.

Note: SET SCREEN 0 is to close the dialog box (0 means "the current dynpro sequence is ended") ; if you have a complex screen you may also use LEAVE TO SCREEN (which is equivalent to the 2 statements SET SCREEN + LEAVE SCREEN).

2) Create the screen 0100 (transaction code SE51 or double-click 0100 behind CALL SCREEN)

Screen type: modal dialog box

Flow logic:

PROCESS BEFORE OUTPUT.
  MODULE status_0100.

PROCESS AFTER INPUT.
  MODULE user_command_0100.

3) Create the GUI status 0100 (transaction code SE41 or double-click 0100 behind SET PF-STATUS)

Status type: dialog box

Assign the F12 key to an arbitrary function code (I chose the name CANCEL), and activate this function code (button "Function Code"): enter image description here

4) Test

Run the program, you may now click the top-right button (or press F12 if you prefer) which closes the modal dialog box:

enter image description here

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48