Collapsible controls in Selection Screen

Earlier in blog Collapsible Area Module Pool Screen I explained how to create collapsible area in module pool program. In this blog we will see how to create collapsible area in selection screen.

Controls are made to look collapsible by hiding them from screen on AT SELECTION SCREEN OUTPUT event. This event is triggered by a push button which is placed on the top of collapsible area using statement SELECTION-SCREEN: PUSHBUTTON 79(18) pb%exco USER-COMMAND expcol.

Collapsible controls Selection Screen SAP ABAP Report

When user press collapse button AT SELECTION-SCREEN OUTPUT event is triggered which hide controls and also change icon of push button. To user it appears that input controls are collapsed.

Collapsible controls Selection Screen SAP ABAP Report

REPORT  zpwscrcollapse.

DATA : full TYPE char01 .
INCLUDE <icon>.

TABLES : likp , vbap , vbak , kuagv , vbpa , vbuk .

SELECTION-SCREEN BEGIN OF BLOCK sel1od WITH FRAME TITLE text-002.
SELECT-OPTIONS: od_lfdat FOR likp-lfdat,
                od_vod   FOR likp-vbeln,
                od_lifex FOR likp-lifex.
SELECTION-SCREEN END OF BLOCK sel1od.

SELECTION-SCREEN: BEGIN OF BLOCK sel2od WITH FRAME TITLE text-001.
SELECTION-SCREEN: BEGIN OF LINE.
SELECTION-SCREEN: PUSHBUTTON 79(18) pb%exco USER-COMMAND expcol
                                   MODIF ID new.
SELECTION-SCREEN: END OF LINE.
SELECTION-SCREEN SKIP 1.
SELECT-OPTIONS: od_werks FOR vbap-werks MEMORY ID wrk MODIF ID new,
                od_audat FOR vbak-audat  MODIF ID old.
SELECT-OPTIONS :od_auart FOR vbak-auart  MODIF ID old,
                od_vso   FOR vbak-vbeln  MODIF ID old,
                od_vsc   FOR vbak-vbeln  MODIF ID old,
                od_kag   FOR kuagv-kunnr MODIF ID old,
                od_lifnr FOR vbpa-lifnr  MODIF ID old,
                od_vdatu FOR vbak-vdatu  MODIF ID old,
                od_fkstk FOR vbuk-fkstk  MODIF ID old,
                od_pdstk FOR vbuk-pdstk  MODIF ID old.
PARAMETERS: xd1 AS CHECKBOX MODIF ID old.
SELECTION-SCREEN: END OF BLOCK sel2od.

*--------------------------------------------------------------------*
* At Selection Screen
*--------------------------------------------------------------------*
AT SELECTION-SCREEN .
  CASE sy-ucomm .
    WHEN 'EXPCOL' .
  ENDCASE .

*--------------------------------------------------------------------*
* At Selection Screen Output
*--------------------------------------------------------------------*
AT SELECTION-SCREEN OUTPUT .
  PERFORM set_collapse CHANGING pb%exco .

*&---------------------------------------------------------------------*
*&      Form  set_collapse
*&---------------------------------------------------------------------*
FORM set_collapse CHANGING button TYPE c.

  IF full = 'X' .
    full = space .
  ELSE.
    full = 'X' .
  ENDIF.

  IF full = space.

    LOOP AT SCREEN.
      IF screen-group1 = 'OLD' .
        screen-active = '0'.
        MODIFY SCREEN.
      ENDIF.
    ENDLOOP.

    CALL FUNCTION 'ICON_CREATE'
      EXPORTING
        name   = icon_expand
        info   = 'Expand'
      IMPORTING
        RESULT = button.

  ELSE.

    CALL FUNCTION 'ICON_CREATE'
      EXPORTING
        name   = icon_collapse
        info   = 'Collapse'
      IMPORTING
        RESULT = button.

  ENDIF.

ENDFORM.                    "set_collapse

Leave a Reply