2

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.

5
  • Is the processing logic the same for both sub-selection-screens or are these essentially two entirely different programs?
    – vwegert
    Jun 9, 2014 at 9:05
  • The processing logic is a bit different: 1100-screen shows some data, 1200 does some pre-processing and shows similat output as 1100. Jun 9, 2014 at 9:26
  • In that case, you might suggest making 3 separate transactions, using a shared FM. Have the buttons on the first selection screen use CALL TRANSACTION so you get "normal", one-depth selection screens. Jun 9, 2014 at 12:39
  • My two cents. stackoverflow.com/questions/15606863/… Jun 9, 2014 at 15:17
  • I already thought of creating several transactions, but for a number of resons I would like to avoid that. Thank you, anyway. Jun 9, 2014 at 15:43

2 Answers 2

4

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.

2
  • This sounds like a good idea. The only problem is that report parameters need to be obligatory. Will SAP allow submitting a selection screen if it has an empty hidden obligatory field? Jun 9, 2014 at 15:46
  • No, I don't think so. But you may programm the checks yourself (but that seems to be a bit overkill).
    – knut
    Jun 9, 2014 at 18:02
2

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.