Copyright 2021 - BV TallVision IT

More advanced selection screens can respond to the input on the selection screen and make alternative fields available for input. When a selection screen becomes cluttered with fields that rely on other fields, the link can be made appearant by hiding the fields that are not needed, and making these fields available instantly when they become relevant. Here's how: 

 

  1. First of all, compose your selection screen with all possible options you need. Radio buttons, checkboxes, whatever your report can handle. 
  2. The fields you want to respond to should be one of the following types: AS CHECKBOX, RADIOBUTTON GROUP or AS LISTBOX. For the cases you want the selection screen to respond to, add option USER-COMMAND dummy. 
  3. Note that we are not really responding to the used command "dummy", we are only using the PAI-PBO (process after input - process before output) mechanism that is triggered by assigning a user command to the parameter. 
  4. Add event AT SELECTION-SCREEN OUTPUT. to your coding, which is (like event AT SELECTION-SCREEN) processed as part of the classic PAI-PBO dynpro cycle 
  5. Perform changes to the visibility/availability of your parameter fields. If a checkbox is ticked, the parameters underneath it should he shown, if it is unticked they should be hidden. The routine will use modification ID's and use the LOOP AT SCREEN statement to apply changes. To hide a parameter, set SCREEN-ACTIVE and SCREEN-INPUT to 0. 

An example program:

TABLES: mara. "<= for selection screen definition purpose only
PARAMETERS: pa_CBOX1 as checkbox default 'X' USER-COMMAND dummy.
SELECT-OPTIONS: so_MATNR for mara-matnr modif id CB1,
                so_MTART for mara-mtart modif id CB1.
PARAMETERS: pa_CBOX2 as checkbox default ' ' USER-COMMAND dummy.
SELECT-OPTIONS: so_MATN2 for mara-matnr modif id CB2,
                so_MTAR2 for mara-mtart modif id CB2.

AT SELECTION-SCREEN OUTPUT.
* Selection parameter control: this routine will check the available
* values on the selection screen, and control which fields should
* be made available or hidden. Note the same concept can be applied
* in making fields display-only/ready for input.
  LOOP AT SCREEN.

    check SCREEN-NAME ns '-OPTI_PUSH'.
    case SCREEN-group1.
      when 'CB1'. "Fields with modification ID CB1
        if pa_CBOX1 = 'X'.
          SCREEN-ACTIVE = 1.
          SCREEN-INPUT = 1.
        else.
          SCREEN-ACTIVE = 0.
          SCREEN-INPUT = 0.
        endif.
      when 'CB2'.
        if pa_CBOX2 = 'X'.
          SCREEN-INPUT = 1.
        else.
          SCREEN-INPUT = 0.
        endif.
    endcase.

    MODIFY SCREEN.
  ENDLOOP.

So what is this "OPTI_PUSH" thing for ? If a select option parameter is populated with values, an icon will appear just to the left of the selection options field. This Icon field has a name ending with OPTIO_PUSH and changing field settings for this field is better not done. Try the effect if you leave the CHECK statement out.