1

My requirement is to have two radio buttons in the selection screen. Upon execution , the report should be called based on Radio button.

Without execution when back button is clicked , it still opens report1. Pressing key F3 or back is not as expected.

SELECTION-SCREEN BEGIN OF SCREEN 100 TITLE title.

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-t01.
PARAMETER: ZREP_2 RADIOBUTTON GROUP rad  DEFAULT 'X' USER-COMMAND frad,
           ZREP_3 RADIOBUTTON GROUP rad .                            ##SEL_WRONG
SELECTION-SCREEN END OF BLOCK b1.

SELECTION-SCREEN END OF SCREEN 100.
 CALL SELECTION-SCREEN '100'.

AT SELECTION-SCREEN OUTPUT.

* Toggle the selection screens based on radio buttons
  LOOP AT SCREEN.
    IF zrep_2 = 'X' AND screen-group1 = 'SC2'.
      PERFORM modify_screen. "Calling subroutine
    ELSEIF zrep_3 = 'X' AND screen-group1 = 'SC1'.
      PERFORM modify_screen. "Calling subroutine
    ENDIF.
  ENDLOOP.

FORM modify_screen.
  screen-active = 0.
  MODIFY SCREEN.
ENDFORM.

START-OF-SELECTION.
  CASE 'X'.
    WHEN zrep_2.

      SUBMIT zpp_scrap_report AND RETURN.

      CALL SELECTION-SCREEN 100.
    WHEN  zrep_3.

      SUBMIT zpp_scrap_report_material_doc AND RETURN.
      CALL SELECTION-SCREEN 100.

  ENDCASE.
Suncatcher
  • 10,355
  • 10
  • 52
  • 90
Winona
  • 115
  • 1
  • 17
  • 3
    As you have a custom selection screen ("100"), and no default one ("1000"), your code directly starts at the `start-of-selection` event, first line is `call selection-screen '100'` (when a statement is outside event blocks, it's assigned implicitly to the `start-of-selection` event block). After that it executes the next line which is `case`. Many ways to solve, but I hope at least you understand the reason. Use the debugger to better understand what's going on. – Sandra Rossi Jan 28 '22 at 14:50

1 Answers1

0

There are several ways to fix this as Sandra said, you should thoroughly read help about selection screen events: what of them is PAI, what is PBO and what is difference between them.

In selscreen help you may find a concept about function codes, you need always check for function code when encapsulating some logic in the PAI selection screen events. In your case you gotta check for CRET as you have custom selscreen, for standard ones it is ONLI.

Practical-wise, you can return to screen explicitly via LEAVE TO

SELECTION-SCREEN BEGIN OF SCREEN 100 TITLE title.
...
SELECTION-SCREEN END OF SCREEN 100.

AT SELECTION-SCREEN.
  CHECK sy-ucomm = 'CRET'.
  CASE 'X'.
    WHEN zrep_2.
      SUBMIT zpp_scrap_report AND RETURN.
      LEAVE TO SCREEN 100.
    WHEN  zrep_3.
      SUBMIT zpp_scrap_report_material_doc AND RETURN.
      LEAVE TO SCREEN 100.
   ENDCASE.

FORM modify_screen.
 screen-active = 0.
 MODIFY SCREEN.
ENDFORM.   

AT SELECTION-SCREEN OUTPUT.
  LOOP AT SCREEN.
    IF zrep_2 = 'X' AND screen-group1 = 'SC2'.
      PERFORM modify_screen.
    ELSEIF zrep_3 = 'X' AND screen-group1 = 'SC1'.
      PERFORM modify_screen.
    ENDIF.
  ENDLOOP.

START-OF-SELECTION.
  CALL SELECTION-SCREEN '100'.

for making screen modifications like you do, it is more logical to use PBO event AT SELECTION-SCREEN OUTPUT

This way is straightforward, but more beautiful is to get rid of custom selection screen at all, in this case you don't need any LEAVE TO and don't need explicit START-OF-SELECTION either

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-t01.
...

AT SELECTION-SCREEN.
  CHECK sy-ucomm = 'ONLI'.
      CASE 'X'.
    WHEN zrep_2.
      SUBMIT zpp_scrap_report AND RETURN.
    WHEN  zrep_3.
      SUBMIT zpp_scrap_report_material_doc AND RETURN.
  ENDCASE.

AT SELECTION-SCREEN OUTPUT.
 LOOP AT SCREEN.
  ...
  ENDIF.
ENDLOOP.
Suncatcher
  • 10,355
  • 10
  • 52
  • 90