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

Logic for Exiting a Screen

Former Member
0 Likes
1,468

I have added a selection screen in the program and every time i hit the exit button the program just executes, I want to go back to the original screen when I hit the exit button.

is there logic for that?

1 ACCEPTED SOLUTION
Read only

MateuszAdamus
Active Contributor
1,384

Hello catienza11

Here's an example of how you can handle it.

TABLES:
  sscrfields.

PARAMETERS: p_test TYPE char1.

SELECTION-SCREEN BEGIN OF SCREEN 500 TITLE title AS WINDOW.
PARAMETERS: p_price  LIKE mbew-verpr OBLIGATORY DEFAULT '5000',
            p_capcur LIKE t001-waers OBLIGATORY DEFAULT 'USD'.
SELECTION-SCREEN: END OF SCREEN 500.

START-OF-SELECTION.
  WRITE 'Report executed'.

AT SELECTION-SCREEN.
  CASE sy-dynnr.
    WHEN '0500'.
      " do some specific actions
    WHEN '1000'.
      CASE sscrfields-ucomm.
        WHEN 'ONLI'.
          PERFORM show_subscreen.
          IF sy-subrc = 0.
            " do nothing, proceed with logic.
          ELSE.
            CLEAR sscrfields-ucomm.
          ENDIF.
      ENDCASE.
  ENDCASE.

FORM show_subscreen.
  title = 'Enter Local Price'.
  CALL SELECTION-SCREEN '0500' STARTING AT 10 10.
ENDFORM.

As always, I encourage to search and read the SAP Help documentation on the topic. It describes the meaning of SY-SUBRC:

  • 0 - The user selected the function Execute or Execute + Print on the selection screen.
  • 4 - User chose Back, Exit, or Cancel on the selection screen.

Kind regards,

Mateusz

I have added a selection screen in the program and every time i hit the exit button the program just executes, I want to go back to the original screen when I hit the exit button.

is there logic for that?

3 REPLIES 3
Read only

MateuszAdamus
Active Contributor
1,384

Hello catienza11

Please provide additional information.

How do you call the screen? How do you handle the buttons being pressed?

Kind regards,

Mateusz
Read only

Former Member
0 Likes
1,384

I called the screen when a specific radio button is pressed, I am calling it before the function of the radio button. I just created an additional selection screen and called it.

SELECTION-SCREEN BEGIN OF SCREEN 500 TITLE title AS WINDOW.
PARAMETERS: p_price LIKE mbew-verpr OBLIGATORY DEFAULT '5000',
p_capcur LIKE t001-waers OBLIGATORY DEFAULT 'USD'.

SELECTION-SCREEN: END OF SCREEN 500.

FORM 1920_mbew_data_pricing.
title = 'Enter Local Price'.

CALL SELECTION-SCREEN '0500' STARTING AT 10 10.

Read only

MateuszAdamus
Active Contributor
1,385

Hello catienza11

Here's an example of how you can handle it.

TABLES:
  sscrfields.

PARAMETERS: p_test TYPE char1.

SELECTION-SCREEN BEGIN OF SCREEN 500 TITLE title AS WINDOW.
PARAMETERS: p_price  LIKE mbew-verpr OBLIGATORY DEFAULT '5000',
            p_capcur LIKE t001-waers OBLIGATORY DEFAULT 'USD'.
SELECTION-SCREEN: END OF SCREEN 500.

START-OF-SELECTION.
  WRITE 'Report executed'.

AT SELECTION-SCREEN.
  CASE sy-dynnr.
    WHEN '0500'.
      " do some specific actions
    WHEN '1000'.
      CASE sscrfields-ucomm.
        WHEN 'ONLI'.
          PERFORM show_subscreen.
          IF sy-subrc = 0.
            " do nothing, proceed with logic.
          ELSE.
            CLEAR sscrfields-ucomm.
          ENDIF.
      ENDCASE.
  ENDCASE.

FORM show_subscreen.
  title = 'Enter Local Price'.
  CALL SELECTION-SCREEN '0500' STARTING AT 10 10.
ENDFORM.

As always, I encourage to search and read the SAP Help documentation on the topic. It describes the meaning of SY-SUBRC:

  • 0 - The user selected the function Execute or Execute + Print on the selection screen.
  • 4 - User chose Back, Exit, or Cancel on the selection screen.

Kind regards,

Mateusz