Alex Kiselev
Alex Kiselev

Reputation: 562

How to handle subsequent selection screens?

I'm trying to do the following thing: show user a selection screen with two buttons, each button, in turn, opens it own selection screen, which later initiates some processing and displays the results somehow.

My current code is something like the following:

REPORT ZREP.

TABLES sscrfields.

SELECTION-SCREEN:
    PUSHBUTTON 1(10) text-001 USER-COMMAND b1,
    PUSHBUTTON 15(10) text-001 USER-COMMAND b2.

SELECTION-SCREEN BEGIN OF SCREEN 1100.
    PARAMETERS p_param1 TYPE c.
SELECTION-SCREEN END OF SCREEN 1100.

SELECTION-SCREEN BEGIN OF SCREEN 1200.
    PARAMETERS p_param2 TYPE c.
SELECTION-SCREEN END OF SCREEN 1200.

AT SELECTION-SCREEN.

    CASE sscrfields.
        WHEN 'b1'.
            CALL SELECTION-SCREEN 1100.
        WHEN 'b2'.
            CALL SELECTION-SCREEN 1200.
    ENDCASE.

START-OF-SELECTION.

    " What do I do here?

The subsequent selection screens (1100 and 1200) open just fine when respective buttons are click. However, when I hit F8 on any of the screens, no processing takes place. Instead, the initial selection screem is opened, START-OF-SELECTION is not triggered.

Since I'm pretty new to ABAP, I assume that there's something wrong with my entire approach, so if anyone can point me to the right direction, that would be greatly appreciated.

Upvotes: 2

Views: 6914

Answers (2)

knut
knut

Reputation: 27875

As an alternative, you may define one selection screen with not displayed areas.

Via a pushbutton you could (de)activate the additional areas.

Code example (Maybe a bit too complex, but it was the fastest result I was able to build.):

REPORT  y_test.

PARAMETER:
  p_kunnr LIKE knmt-kunnr MODIF ID all, "maybe with option no-display ?
  p_vkorg LIKE mvke-vkorg,
  p_vtweg LIKE mvke-vtweg.

"Define a push button on selection screen
TABLES sscrfields.
SELECTION-SCREEN FUNCTION KEY 1.

INITIALIZATION.
  sscrfields-functxt_01 = 'Full selection'.

AT SELECTION-SCREEN. "PAI
  CASE sscrfields-ucomm. "pushbutton pressed
    WHEN 'FC01'.
      PERFORM selection_switch_all USING 'SET-SWITCH'.
  ENDCASE.
AT SELECTION-SCREEN OUTPUT.
  PERFORM selection_switch_all USING 'ALL'.


FORM selection_switch_all USING group.
  STATICS: flag_all.
  IF group = 'SET-SWITCH'.
    TRANSLATE flag_all USING ' XX '.
  ENDIF.
*
  IF flag_all = space.
    sscrfields-functxt_01 = 'Full selection'.
    LOOP AT SCREEN.
      IF screen-group1 = group.
        screen-invisible = 1.
        screen-input     = 0.
        MODIFY SCREEN.
      ENDIF.
    ENDLOOP.
  ELSE.
    sscrfields-functxt_01  = 'Restricted selection'.
    LOOP AT SCREEN.
      IF screen-group1 = group.
        screen-invisible = 0.
        screen-input     = 1.
        MODIFY SCREEN.
      ENDIF.
    ENDLOOP.
  ENDIF.
ENDFORM. "selection_switch_all.

When you start it you get:

enter image description here

After pushing Full Selection you get:

enter image description here


The selection screen options allow also the usage ob tabstrips.

This could be also a nice solution.

Upvotes: 4

vwegert
vwegert

Reputation: 18493

As the documentation for SELECTION-SCREEN PUSHBUTTON states,

pushbuttons on selection screens are intended primarily for use for dynamic modifications to the selection screen rather than to control the program

I would rather replace the pushbuttons with a set of radio buttons. This makes the handling much more familiar to the user, and it saves you a lot of trouble coding it:

REPORT zfoobar.

PARAMETERS p_b01 RADIOBUTTON GROUP cmd.
PARAMETERS p_b02 RADIOBUTTON GROUP cmd.

SELECTION-SCREEN BEGIN OF SCREEN 1100.
PARAMETERS p_einri TYPE einri OBLIGATORY.
SELECTION-SCREEN END OF SCREEN 1100.

SELECTION-SCREEN BEGIN OF SCREEN 1200.
PARAMETERS p_bukrs TYPE bukrs OBLIGATORY.
SELECTION-SCREEN END OF SCREEN 1200.

START-OF-SELECTION.
  IF p_b01 = abap_true.
    CALL SELECTION-SCREEN 1100.
    IF sy-subrc = 0.
      PERFORM processing_b01.
    ENDIF.
  ELSEIF p_b02 = abap_true.
    CALL SELECTION-SCREEN 1200.
    IF sy-subrc = 0.
      PERFORM processing_b02.
    ENDIF.
  ENDIF.

Upvotes: 2

Related Questions